Author: Zhu Jincan
Source: clever101's column
How does a JNI program pass common parameters and return values
Since the JNI program involves the interaction between the Java program and the C++ program, it is necessary to consider how to pass common parameters and return values.
Java data type and JNI type mapping
The basic types in Java include boolean, byte, char, short, int, long, float, double. If you use these types as parameters of the native method, when you generate the .h file through the javah tool, these basic types The corresponding types are jboolean, jbyte, jchar, jshort, jint, jlong, jfloat, jdouble. Therefore, the transfer of basic types can be transferred directly. The following is a detailed Java data type and jni type mapping table:
Java type | native type | describe |
---|---|---|
boolean | jboolean | C/C++ 8-bit integer |
byte | jbyte | C/C++ |