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.
- B=byte
- C=char
- D=double
- F=float
- I=int
- J=long
- S=short
- V=void
- Z=boolean
- Lfully-qualified-class=fully qualified class
- [type=array of type>
- (argument types)return type=method type. If no arguments, use empty argument types: (). If return type is void (or constructor) use (argument types)V.
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.