Source Address: Basic syntax for JNI
Types of JNI
1. Basic Data type
The following is a comparison of the basic data types in Java and the basic data types in JNI, and the types of bytes.
2. Reference type
Different reference types in Java also have reference types in JNI, the following tree representation:
When used in the C language, all JNI reference types are defined as Jobject types. typedef jobject Jclass;
Jvalue type
The Jvalue type is a collection of basic data types and reference types, defined in the following way:
typedef Union JVALUE { Jboolean z; Jbyte B; Jchar C; Jshort S; Jint i; Jlong J; Jfloat F; Jdouble D; Jobject l;} jvalue;
Description of Class
(1). The descriptors for classes and interfaces are used in Java ".", such as: java.lang.String
In the case of JNI, "/" is used, such as: java/lang/string
(2). The reference type of the array type is denoted by "[". such as int[] (notation in Java)?---à[i ([uppercase I is the notation in JNI, [the number of the number representing the dimension of the array is [[I]
(3) The description of the domain, and the Java comparison table below:
Note: Fields of reference types start with L, and with ";" As the end. The array type is the same as the class description.
(4). Method description
Declaration rules for methods in JNI: write the parameter list first, then write the return type, here is an example.
Basic syntax for JNI