Andoird uses a different traditional Java
JNI is used to define native functions. The important difference is that andorid uses a Java and C
The ing table array of the function, and describes the parameters and return values of the function. The type of this array is jninativemethod, which is defined as follows:
Typedef struct {
Const char * Name;
Const char * signature;
Void * fnptr;
} Jninativemethod;
The first variable name is the name of the function in Java.
The second variable signature describes the parameters and return values of the function using a string.
The third variable fnptr is the function pointer pointing to the C function.
The second parameter is hard to understand, for example
"() V"
"(Ii) V"
"(Ljava/lang/string;) V"
In fact, these characters correspond to the function parameter types one by one.
The character in "()" represents a parameter, and the subsequent character represents the return value. For example, "() V" indicates void func ();
"(Ii) V" indicates void func (INT, INT );
The relationship between each character is as follows:
Character Java type C
Type
V void
Z jboolean Boolean
I jint int
J jlong long
D jdouble double
F jfloat float
B jbyte byte
C jchar char
S jshort short
The array starts with "[" and is represented by two characters.
[I jintarray int []
[F jfloatarray float []
[B jbytearray byte []
[C jchararray char []
[S jshortarray short []
[D jdoublearray double []
[J jlongarray long []
[Z jbooleanarray Boolean []
The above are all basic types. If the Java function parameter is a class, it starts with "L" and ends with ";" and uses "/" in the middle "/"
The names of packages and classes. The parameter of the corresponding C function name is jobject. An exception is the string class, and its corresponding class is jstring.
Ljava/lang/string; string jstring
Ljava/NET/socket; socket jobject
If a Java function is located in an embedded class, $ is used as the delimiter between class names.
For example, "(ljava/lang/string; landroid/OS/fileutils $ filestatus;) z"