3
This chapter discusses how the JNI maps Java types to native C types.The following definition is provided for convenience:
#define JNI_FALSE 0 #define JNI_TRUE 1 |
The jsize unsigned integer type describes cardinal indices that may range over the entire address space (that is, the size of a pointer).
typedef ... jsize; |
typedef void* jref; |
The following types are used in function prototypes for clarity:
typedef jref jobject; /* Java objects */ typedef jref jclass; /* Java class objects */ typedef jref jstring; /* Java strings */ typedef jref jarray; /* Java arrays */ |
typedef void *jfieldID; /* field IDs */ typedef void *jmethodID; /* method IDs */ |
typedef union jvalue { jboolean z; jbyte b; jchar c; jshort s; jint i; jlong j; jfloat f; jdouble d; jref l; } jvalue; |
long f (int n, String s, int[] arr); |
has the following type signature:
(ILjava/lang/String;[I)J |
\u0001 to \u007F are represented by a single byte, as follows:
The seven bits of data in the byte give the value of the character that is represented. The null character (\u000) and characters in the range \u0080 to \u07FF are represented by a pair of bytes, x and y, as follows:
The bytes represent the character with the value ((x&0x1f)<<6)+(y&0x3f).
Characters in the range \u0800 to \uFFFF are represented by three bytes, x, y, and z:
The character with the value ((x&0xf)<<12)+(y&0x3f)<<6)+(z&0x3f) is represented by the three bytes.
There are two differences between this format and the "standard" UTF-8 format. First, the null byte (byte)0 is encoded using the two-byte format rather than the one-byte format. This means that Java VM UTF-8 strings never have embedded nulls. Second, only the one-byte, two-byte, and three-byte formats are used. The Java VM does not recognize the longer UTF-8 formats.
Java Native Method Interface Specification (HTML generated by wegis on December 06, 1996)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to sl@eng.sun.com