Basic syntax for JNI

Source: Internet
Author: User

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

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.