Data types for the Android JNI

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.