dev.kanngard.net make sure you visit my new blog at: johankanngard.net

JNI method and constructor signature cheat sheet

by Johan Känngård / [Java] / 2005-05-09 / #26


I just started learning LS2J, and the JNI signatures that are required when getting methods and constructors are a bit hard to understand. Here are my findings so far.

Examples

constructor: (String s)translates to:(Ljava/lang/String;)V

method: String toString()translates to:()Ljava/lang/String;

method: long myMethod(int n, String s, int[] arr)translates to:(ILjava/lang/String;[I)J

javap

Use javap -s classname to get the signatures of the class, for example: javap -s java.lang.String.

Also see Sun's somewhat short description of JNI signatures. Another short one at Real's How To.