The meaning of data types in JNI is bridging the Java data type with the C data type.
Simple data types:
| Java Type |
Native Type |
Description |
| Boolean |
Jboolean |
Unsigned 8 bits |
| Byte |
Jbyte |
Signed 8 bits |
| Char |
Jchar |
Unsigned bits |
| Short |
Jshort |
Signed Bits |
| Int |
Jint |
Signed Bits |
| Long |
Jlong |
Signed Bits |
| Float |
Jfloat |
Bits |
| Double |
Jdouble |
+ Bits |
| void |
void |
N/A |
Reference type:
Feature Type (Signatures):
See signatures is not a bit familiar, in my Android jni static registration in the area of the Javah auto-generated header files, note that Javah not only completed the conversion of the method name, but also in the method comments marked the method signature , let's talk about this correspondence.
| Type Signature |
Java Type |
| Z |
Boolean |
| B |
Byte |
| C |
Char |
| S |
Short |
| I |
Int |
| J |
Long |
| F |
Float |
| D |
Double |
| L Fully-qualified-class; |
Fully-qualified-class |
| [Type |
Type[] |
| (arg-types) Ret-type |
Method type |
For example, for a Java method
long f (intint[] arr);
The corresponding characteristic value is (iljava/lang/string;[ I) J
PS: This eigenvalue is important when registering dynamically, which is related to whether the native method you declare in the Java class can correctly find the corresponding native method.
Data types for the Android JNI