<jni.h> 全面剖析
<jni.h> 全面剖析
文章連結:JNI 函式(一)版本資訊、類操作、異常
文章連結:JNI 函式(二)全域性及區域性引用
文章連結:JNI 函式(三)物件操作
文章連結:JNI 函式(四)字串操作
文章連結:JNI 函式(五)陣列操作
文章連結:JNI 函式(六)系統級別的操作
文章連結:JNI 函式(七)NIO 操作
文章連結:JNI 函式(八)反射支援、獲取虛擬機器
JNI的型別和資料結構
基本型別
基本型別和本地等效型別表:
Java型別 | 本地型別 | 說明 |
boolean | jboolean | 無符號,8位 |
byte | jbyte | 無符號,8位 |
char |
jchar | 無符號,16位 |
short | jshort | 有符號,16位 |
int | jint | 有符號,32位 |
long | jlong | 有符號,64位 |
float | jfloat | 32位 |
double | jdouble | 64位 |
void | jobject | N/A |
為了使用方便,特提供以下定義:
1 /*
2 * Manifest constants.
3 */
4 #define JNI_FALSE 0
5 #define JNI_TRUE 1
6
7 #define JNI_VERSION_1_1 0x00010001
8 #define JNI_VERSION_1_2 0x00010002
9 #define JNI_VERSION_1_4 0x00010004
10 #define JNI_VERSION_1_6 0x00010006
11
12 #define JNI_OK (0) /* no error */
13 #define JNI_ERR (-1) /* generic error */
14 #define JNI_EDETACHED (-2) /* thread detached from the VM */
15 #define JNI_EVERSION (-3) /* JNI version error */
16 #define JNI_ENOMEM (-4) /* Out of memory */
17 #define JNI_EEXIST (-5) /* VM already created */
18 #define JNI_EINVAL (-6) /* Invalid argument */
19
20 #define JNI_COMMIT 1 /* copy content, do not free buffer */
21 #define JNI_ABORT 2 /* free buffer w/o copying back */
22
23 #endif // LIBNATIVEHELPER_INCLUDE_JNI_JNI_H_
jsize 整數型別用於描述主要指數和大小:
1 /* "cardinal indices and sizes" */
2 typedef jint jsize;
引用型別
JNI 包含了很多對應於不同 Java 物件的引用型別。JNI 引用型別的組織層次如圖所示:
1 #ifdef __cplusplus
2 /*
3 * Reference types, in C++
4 */
5 class _jobject {};
6 class _jclass : public _jobject {};
7 class _jstring : public _jobject {};
8 class _jarray : public _jobject {};
9 class _jobjectArray : public _jarray {};
10 class _jbooleanArray : public _jarray {};
11 class _jbyteArray : public _jarray {};
12 class _jcharArray : public _jarray {};
13 class _jshortArray : public _jarray {};
14 class _jintArray : public _jarray {};
15 class _jlongArray : public _jarray {};
16 class _jfloatArray : public _jarray {};
17 class _jdoubleArray : public _jarray {};
18 class _jthrowable : public _jobject {};
19
20 typedef _jobject* jobject;
21 typedef _jclass* jclass;
22 typedef _jstring* jstring;
23 typedef _jarray* jarray;
24 typedef _jobjectArray* jobjectArray;
25 typedef _jbooleanArray* jbooleanArray;
26 typedef _jbyteArray* jbyteArray;
27 typedef _jcharArray* jcharArray;
28 typedef _jshortArray* jshortArray;
29 typedef _jintArray* jintArray;
30 typedef _jlongArray* jlongArray;
31 typedef _jfloatArray* jfloatArray;
32 typedef _jdoubleArray* jdoubleArray;
33 typedef _jthrowable* jthrowable;
34 typedef _jobject* jweak;
35
36
37 #else /* not __cplusplus */
38
39 /*
40 * Reference types, in C.
41 */
42 typedef void* jobject;
43 typedef jobject jclass;
44 typedef jobject jstring;
45 typedef jobject jarray;
46 typedef jarray jobjectArray;
47 typedef jarray jbooleanArray;
48 typedef jarray jbyteArray;
49 typedef jarray jcharArray;
50 typedef jarray jshortArray;
51 typedef jarray jintArray;
52 typedef jarray jlongArray;
53 typedef jarray jfloatArray;
54 typedef jarray jdoubleArray;
55 typedef jobject jthrowable;
56 typedef jobject jweak;
57
58 #endif /* not __cplusplus */
在 C 中,所有其它 JNI 引用型別都被定義為與 jobject 一樣。例如:
1 typedef jobject jclass;
在 C++ 中,JNI 引入了虛構類以加強子類關係。例如:
1 class _jobject {};
2 class _jclass : public _jobject {};
3 ...
4 typedef _jobject *jobject;
5 typedef _jclass *jclass;
域ID和方法ID
方法 ID 和域 ID 是常規的 C 指標型別:
1 struct _jfieldID; /* opaque structure */
2 typedef struct _jfieldID* jfieldID; /* field IDs */
3
4 struct _jmethodID; /* opaque structure */
5 typedef struct _jmethodID* jmethodID; /* method IDs */
值型別
jvalue 聯合型別在引數陣列中用作單元型別。其宣告方式如下:
1 typedef union jvalue {
2 jboolean z;
3 jbyte b;
4 jchar c;
5 jshort s;
6 jint i;
7 jlong j;
8 jfloat f;
9 jdouble d;
10 jobject l;
11 } jvalue;
型別簽名
型別簽名 | Java 型別 |
Z | boolean |
B | byte |
C | char |
S | short |
I | int |
L/J | long |
F | float |
D | double |
L fully-qualified-class ; | 全限定的類 |
[type | type[] |
( arg-types ) ret-type | 方法型別 |
例如,Java 方法:
1 long f (int n, String s, int[] arr);
具有以下型別簽名:
1 (ILjava/lang/String;[I)J
2 //網上我也有見人寫
3 (ILjava/lang/String;[I)L
4 //對於 long 型別寫 J/L 的大家在實際專案上可以根據報錯不報錯來使用,具體的差異我也沒有去詳細瞭解
UTF-8字串
JNI 用 UTF-8 字串來表示各種字串型別。UTF-8 字串和 Java 虛擬機器所使用的一樣。UTF-8 字串的編碼方式使得僅包含非空 ASCII 字元的字元序列能夠按每字元一個位元組表示,但是最多隻能表示 16 位的字元。所有在 \u0001 到 \u007F 範圍內的字元都用單位元組表示,如下所示:
1 |0|0-6位|
位元組中的七位資料確定了所表示字元的值。空字元 ( \u000 )和 \u0080 到 \u07FF 範圍內的字元用一對位元組表示, 即 x 和 y,如下所示:
1 x:|1|1|0|6-10位|
2 y:|1|0|0-5位|
值為 ((x & 0x1f)<<6) + (y & 0x3f)的字元需用兩個位元組表示。\u0800 到 \uFFFF 範圍內的字元用三個位元組表示,即 x,y 和 z:
1 x:|1|1|1|0|12-15位|
2 y:|1|0|6-11位|
3 z:|1|0|0-5位|
值為((x & 0xf) << 12) + (y & 0x3f) << 6) + (z & 0x3f) 的字元需用三個位元組表示。
此格式與“標準” UTF-8 格式之間有兩個區別。第一,空位元組 (byte) 0 使用雙位元組格式進行編碼,而不是單位元組格式。這意味著 Java 虛擬機器的 UTF-8 字串不可能有嵌入的空值。第二,只使用單位元組、雙位元組和三位元組格式。Java 虛擬機器不能識別更長的 UTF-8 格式。
JNI 函式
本篇為 JNI 函式提供參考資訊。其中列出了全部 JNI 函式,同時也給出了 JNI 函式表的準確佈局。注意:“必須”一詞用於約束 JNI 程式設計人員。例如,當說明某個 JNI 函式必須接收非空物件時,就應確保不要向該 JNI 函式傳遞 NULL。這時,JNI 實現將無需在該 JNI 函式中執行 NULL 指標檢查。本章的部分資料改編自 Netscape 的 JRI 文件。該參考資料按用法對函式進行組織。
介面函式表
每個函式均可通過 JNIEnv 引數以固定偏移量進行訪問。JNIEnv 的型別是一個指標,指向儲存全部 JNI 函式指標的結構。注意:前三項留作將來與 COM 相容。此外,我們在函式表開頭部分也留出來多個 NULL 項,從而可將將來與類有關的 JNI 操作新增到 FindClass 後面,而非函式表的末尾。注意,函式表可在所有 JNI 介面指標間共享。
C 語言:
1 /*
2 * Table of interface function pointers.
3 */
4 struct JNINativeInterface {
5 void* reserved0;
6 void* reserved1;
7 void* reserved2;
8 void* reserved3;
9
10 jint (*GetVersion)(JNIEnv *);
11
12 jclass (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*,
13 jsize);
14 jclass (*FindClass)(JNIEnv*, const char*);
15
16 jmethodID (*FromReflectedMethod)(JNIEnv*, jobject);
17 jfieldID (*FromReflectedField)(JNIEnv*, jobject);
18 /* spec doesn't show jboolean parameter */
19 jobject (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean);
20
21 jclass (*GetSuperclass)(JNIEnv*, jclass);
22 jboolean (*IsAssignableFrom)(JNIEnv*, jclass, jclass);
23
24 /* spec doesn't show jboolean parameter */
25 jobject (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean);
26
27 jint (*Throw)(JNIEnv*, jthrowable);
28 jint (*ThrowNew)(JNIEnv *, jclass, const char *);
29 jthrowable (*ExceptionOccurred)(JNIEnv*);
30 void (*ExceptionDescribe)(JNIEnv*);
31 void (*ExceptionClear)(JNIEnv*);
32 void (*FatalError)(JNIEnv*, const char*);
33
34 jint (*PushLocalFrame)(JNIEnv*, jint);
35 jobject (*PopLocalFrame)(JNIEnv*, jobject);
36
37 jobject (*NewGlobalRef)(JNIEnv*, jobject);
38 void (*DeleteGlobalRef)(JNIEnv*, jobject);
39 void (*DeleteLocalRef)(JNIEnv*, jobject);
40 jboolean (*IsSameObject)(JNIEnv*, jobject, jobject);
41
42 jobject (*NewLocalRef)(JNIEnv*, jobject);
43 jint (*EnsureLocalCapacity)(JNIEnv*, jint);
44
45 jobject (*AllocObject)(JNIEnv*, jclass);
46 jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...);
47 jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list);
48 jobject (*NewObjectA)(JNIEnv*, jclass, jmethodID, const jvalue*);
49
50 jclass (*GetObjectClass)(JNIEnv*, jobject);
51 jboolean (*IsInstanceOf)(JNIEnv*, jobject, jclass);
52 jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*);
53
54 jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...);
55 jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list);
56 jobject (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
57 jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...);
58 jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list);
59 jboolean (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
60 jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...);
61 jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list);
62 jbyte (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
63 jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...);
64 jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list);
65 jchar (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
66 jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...);
67 jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list);
68 jshort (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
69 jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...);
70 jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list);
71 jint (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
72 jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...);
73 jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list);
74 jlong (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
75 jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...);
76 jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list);
77 jfloat (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
78 jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...);
79 jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list);
80 jdouble (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
81 void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...);
82 void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list);
83 void (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
84
85 jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass,
86 jmethodID, ...);
87 jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass,
88 jmethodID, va_list);
89 jobject (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass,
90 jmethodID, const jvalue*);
91 jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass,
92 jmethodID, ...);
93 jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass,
94 jmethodID, va_list);
95 jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass,
96 jmethodID, const jvalue*);
97 jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass,
98 jmethodID, ...);
99 jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass,
100 jmethodID, va_list);
101 jbyte (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass,
102 jmethodID, const jvalue*);
103 jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass,
104 jmethodID, ...);
105 jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass,
106 jmethodID, va_list);
107 jchar (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass,
108 jmethodID, const jvalue*);
109 jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass,
110 jmethodID, ...);
111 jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass,
112 jmethodID, va_list);
113 jshort (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass,
114 jmethodID, const jvalue*);
115 jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass,
116 jmethodID, ...);
117 jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass,
118 jmethodID, va_list);
119 jint (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass,
120 jmethodID, const jvalue*);
121 jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass,
122 jmethodID, ...);
123 jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass,
124 jmethodID, va_list);
125 jlong (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass,
126 jmethodID, const jvalue*);
127 jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass,
128 jmethodID, ...);
129 jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass,
130 jmethodID, va_list);
131 jfloat (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass,
132 jmethodID, const jvalue*);
133 jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass,
134 jmethodID, ...);
135 jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass,
136 jmethodID, va_list);
137 jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass,
138 jmethodID, const jvalue*);
139 void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass,
140 jmethodID, ...);
141 void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass,
142 jmethodID, va_list);
143 void (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass,
144 jmethodID, const jvalue*);
145
146 jfieldID (*GetFieldID)(JNIEnv*, jclass, const char*, const char*);
147
148 jobject (*GetObjectField)(JNIEnv*, jobject, jfieldID);
149 jboolean (*GetBooleanField)(JNIEnv*, jobject, jfieldID);
150 jbyte (*GetByteField)(JNIEnv*, jobject, jfieldID);
151 jchar (*GetCharField)(JNIEnv*, jobject, jfieldID);
152 jshort (*GetShortField)(JNIEnv*, jobject, jfieldID);
153 jint (*GetIntField)(JNIEnv*, jobject, jfieldID);
154 jlong (*GetLongField)(JNIEnv*, jobject, jfieldID);
155 jfloat (*GetFloatField)(JNIEnv*, jobject, jfieldID);
156 jdouble (*GetDoubleField)(JNIEnv*, jobject, jfieldID);
157
158 void (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject);
159 void (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean);
160 void (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte);
161 void (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar);
162 void (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort);
163 void (*SetIntField)(JNIEnv*, jobject, jfieldID, jint);
164 void (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong);
165 void (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat);
166 void (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble);
167
168 jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*);
169
170 jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...);
171 jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list);
172 jobject (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
173 jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...);
174 jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID,
175 va_list);
176 jboolean (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
177 jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...);
178 jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list);
179 jbyte (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
180 jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...);
181 jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list);
182 jchar (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
183 jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...);
184 jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list);
185 jshort (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
186 jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...);
187 jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list);
188 jint (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
189 jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...);
190 jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list);
191 jlong (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
192 jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...);
193 jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list);
194 jfloat (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
195 jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...);
196 jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list);
197 jdouble (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
198 void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...);
199 void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list);
200 void (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
201
202 jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const char*,
203 const char*);
204
205 jobject (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID);
206 jboolean (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID);
207 jbyte (*GetStaticByteField)(JNIEnv*, jclass, jfieldID);
208 jchar (*GetStaticCharField)(JNIEnv*, jclass, jfieldID);
209 jshort (*GetStaticShortField)(JNIEnv*, jclass, jfieldID);
210 jint (*GetStaticIntField)(JNIEnv*, jclass, jfieldID);
211 jlong (*GetStaticLongField)(JNIEnv*, jclass, jfieldID);
212 jfloat (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID);
213 jdouble (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID);
214
215 void (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject);
216 void (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean);
217 void (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte);
218 void (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar);
219 void (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort);
220 void (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint);
221 void (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong);
222 void (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat);
223 void (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble);
224
225 jstring (*NewString)(JNIEnv*, const jchar*, jsize);
226 jsize (*GetStringLength)(JNIEnv*, jstring);
227 const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*);
228 void (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*);
229 jstring (*NewStringUTF)(JNIEnv*, const char*);
230 jsize (*GetStringUTFLength)(JNIEnv*, jstring);
231 /* JNI spec says this returns const jbyte*, but that's inconsistent */
232 const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*);
233 void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*);
234 jsize (*GetArrayLength)(JNIEnv*, jarray);
235 jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject);
236 jobject (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize);
237 void (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject);
238
239 jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize);
240 jbyteArray (*NewByteArray)(JNIEnv*, jsize);
241 jcharArray (*NewCharArray)(JNIEnv*, jsize);
242 jshortArray (*NewShortArray)(JNIEnv*, jsize);
243 jintArray (*NewIntArray)(JNIEnv*, jsize);
244 jlongArray (*NewLongArray)(JNIEnv*, jsize);
245 jfloatArray (*NewFloatArray)(JNIEnv*, jsize);
246 jdoubleArray (*NewDoubleArray)(JNIEnv*, jsize);
247
248 jboolean* (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*);
249 jbyte* (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*);
250 jchar* (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*);
251 jshort* (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*);
252 jint* (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*);
253 jlong* (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*);
254 jfloat* (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*);
255 jdouble* (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*);
256
257 void (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray,
258 jboolean*, jint);
259 void (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray,
260 jbyte*, jint);
261 void (*ReleaseCharArrayElements)(JNIEnv*, jcharArray,
262 jchar*, jint);
263 void (*ReleaseShortArrayElements)(JNIEnv*, jshortArray,
264 jshort*, jint);
265 void (*ReleaseIntArrayElements)(JNIEnv*, jintArray,
266 jint*, jint);
267 void (*ReleaseLongArrayElements)(JNIEnv*, jlongArray,
268 jlong*, jint);
269 void (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray,
270 jfloat*, jint);
271 void (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray,
272 jdouble*, jint);
273
274 void (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
275 jsize, jsize, jboolean*);
276 void (*GetByteArrayRegion)(JNIEnv*, jbyteArray,
277 jsize, jsize, jbyte*);
278 void (*GetCharArrayRegion)(JNIEnv*, jcharArray,
279 jsize, jsize, jchar*);
280 void (*GetShortArrayRegion)(JNIEnv*, jshortArray,
281 jsize, jsize, jshort*);
282 void (*GetIntArrayRegion)(JNIEnv*, jintArray,
283 jsize, jsize, jint*);
284 void (*GetLongArrayRegion)(JNIEnv*, jlongArray,
285 jsize, jsize, jlong*);
286 void (*GetFloatArrayRegion)(JNIEnv*, jfloatArray,
287 jsize, jsize, jfloat*);
288 void (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
289 jsize, jsize, jdouble*);
290
291 /* spec shows these without const; some jni.h do, some don't */
292 void (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
293 jsize, jsize, const jboolean*);
294 void (*SetByteArrayRegion)(JNIEnv*, jbyteArray,
295 jsize, jsize, const jbyte*);
296 void (*SetCharArrayRegion)(JNIEnv*, jcharArray,
297 jsize, jsize, const jchar*);
298 void (*SetShortArrayRegion)(JNIEnv*, jshortArray,
299 jsize, jsize, const jshort*);
300 void (*SetIntArrayRegion)(JNIEnv*, jintArray,
301 jsize, jsize, const jint*);
302 void (*SetLongArrayRegion)(JNIEnv*, jlongArray,
303 jsize, jsize, const jlong*);
304 void (*SetFloatArrayRegion)(JNIEnv*, jfloatArray,
305 jsize, jsize, const jfloat*);
306 void (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
307 jsize, jsize, const jdouble*);
308
309 jint (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*,
310 jint);
311 jint (*UnregisterNatives)(JNIEnv*, jclass);
312 jint (*MonitorEnter)(JNIEnv*, jobject);
313 jint (*MonitorExit)(JNIEnv*, jobject);
314 jint (*GetJavaVM)(JNIEnv*, JavaVM**);
315
316 void (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*);
317 void (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*);
318
319 void* (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*);
320 void (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint);
321
322 const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*);
323 void (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*);
324
325 jweak (*NewWeakGlobalRef)(JNIEnv*, jobject);
326 void (*DeleteWeakGlobalRef)(JNIEnv*, jweak);
327
328 jboolean (*ExceptionCheck)(JNIEnv*);
329
330 jobject (*NewDirectByteBuffer)(JNIEnv*, void*, jlong);
331 void* (*GetDirectBufferAddress)(JNIEnv*, jobject);
332 jlong (*GetDirectBufferCapacity)(JNIEnv*, jobject);
333
334 /* added in JNI 1.6 */
335 jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject);
336 };
C ++ 物件封裝器:
1 /*
2 * C++ object wrapper.
3 *
4 * This is usually overlaid on a C struct whose first element is a
5 * JNINativeInterface*. We rely somewhat on compiler behavior.
6 */
7 struct _JNIEnv {
8 /* do not rename this; it does not seem to be entirely opaque */
9 const struct JNINativeInterface* functions;
10
11 #if defined(__cplusplus)
12
13 jint GetVersion()
14 { return functions->GetVersion(this); }
15
16 jclass DefineClass(const char *name, jobject loader, const jbyte* buf,
17 jsize bufLen)
18 { return functions->DefineClass(this, name, loader, buf, bufLen); }
19
20 jclass FindClass(const char* name)
21 { return functions->FindClass(this, name); }
22
23 jmethodID FromReflectedMethod(jobject method)
24 { return functions->FromReflectedMethod(this, method); }
25
26 jfieldID FromReflectedField(jobject field)
27 { return functions->FromReflectedField(this, field); }
28
29 jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic)
30 { return functions->ToReflectedMethod(this, cls, methodID, isStatic); }
31
32 jclass GetSuperclass(jclass clazz)
33 { return functions->GetSuperclass(this, clazz); }
34
35 jboolean IsAssignableFrom(jclass clazz1, jclass clazz2)
36 { return functions->IsAssignableFrom(this, clazz1, clazz2); }
37
38 jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic)
39 { return functions->ToReflectedField(this, cls, fieldID, isStatic); }
40
41 jint Throw(jthrowable obj)
42 { return functions->Throw(this, obj); }
43
44 jint ThrowNew(jclass clazz, const char* message)
45 { return functions->ThrowNew(this, clazz, message); }
46
47 jthrowable ExceptionOccurred()
48 { return functions->ExceptionOccurred(this); }
49
50 void ExceptionDescribe()
51 { functions->ExceptionDescribe(this); }
52
53 void ExceptionClear()
54 { functions->ExceptionClear(this); }
55
56 void FatalError(const char* msg)
57 { functions->FatalError(this, msg); }
58
59 jint PushLocalFrame(jint capacity)
60 { return functions->PushLocalFrame(this, capacity); }
61
62 jobject PopLocalFrame(jobject result)
63 { return functions->PopLocalFrame(this, result); }
64
65 jobject NewGlobalRef(jobject obj)
66 { return functions->NewGlobalRef(this, obj); }
67
68 void DeleteGlobalRef(jobject globalRef)
69 { functions->DeleteGlobalRef(this, globalRef); }
70
71 void DeleteLocalRef(jobject localRef)
72 { functions->DeleteLocalRef(this, localRef); }
73
74 jboolean IsSameObject(jobject ref1, jobject ref2)
75 { return functions->IsSameObject(this, ref1, ref2); }
76
77 jobject NewLocalRef(jobject ref)
78 { return functions->NewLocalRef(this, ref); }
79
80 jint EnsureLocalCapacity(jint capacity)
81 { return functions->EnsureLocalCapacity(this, capacity); }
82
83 jobject AllocObject(jclass clazz)
84 { return functions->AllocObject(this, clazz); }
85
86 jobject NewObject(jclass clazz, jmethodID methodID, ...)
87 {
88 va_list args;
89 va_start(args, methodID);
90 jobject result = functions->NewObjectV(this, clazz, methodID, args);
91 va_end(args);
92 return result;
93 }
94
95 jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args)
96 { return functions->NewObjectV(this, clazz, methodID, args); }
97
98 jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue* args)
99 { return functions->NewObjectA(this, clazz, methodID, args); }
100
101 jclass GetObjectClass(jobject obj)
102 { return functions->GetObjectClass(this, obj); }
103
104 jboolean IsInstanceOf(jobject obj, jclass clazz)
105 { return functions->IsInstanceOf(this, obj, clazz); }
106
107 jmethodID GetMethodID(jclass clazz, const char* name, const char* sig)
108 { return functions->GetMethodID(this, clazz, name, sig); }
109
110 #define CALL_TYPE_METHOD(_jtype, _jname) \
111 _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \
112 { \
113 _jtype result; \
114 va_list args; \
115 va_start(args, methodID); \
116 result = functions->Call##_jname##MethodV(this, obj, methodID, \
117 args); \
118 va_end(args); \
119 return result; \
120 }
121 #define CALL_TYPE_METHODV(_jtype, _jname) \
122 _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \
123 va_list args) \
124 { return functions->Call##_jname##MethodV(this, obj, methodID, args); }
125 #define CALL_TYPE_METHODA(_jtype, _jname) \
126 _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \
127 const jvalue* args) \
128 { return functions->Call##_jname##MethodA(this, obj, methodID, args); }
129
130 #define CALL_TYPE(_jtype, _jname) \
131 CALL_TYPE_METHOD(_jtype, _jname) \
132 CALL_TYPE_METHODV(_jtype, _jname) \
133 CALL_TYPE_METHODA(_jtype, _jname)
134
135 CALL_TYPE(jobject, Object)
136 CALL_TYPE(jboolean, Boolean)
137 CALL_TYPE(jbyte, Byte)
138 CALL_TYPE(jchar, Char)
139 CALL_TYPE(jshort, Short)
140 CALL_TYPE(jint, Int)
141 CALL_TYPE(jlong, Long)
142 CALL_TYPE(jfloat, Float)
143 CALL_TYPE(jdouble, Double)
144
145 void CallVoidMethod(jobject obj, jmethodID methodID, ...)
146 {
147 va_list args;
148 va_start(args, methodID);
149 functions->CallVoidMethodV(this, obj, methodID, args);
150 va_end(args);
151 }
152 void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args)
153 { functions->CallVoidMethodV(this, obj, methodID, args); }
154 void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue* args)
155 { functions->CallVoidMethodA(this, obj, methodID, args); }
156
157 #define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \
158 _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \
159 jmethodID methodID, ...) \
160 { \
161 _jtype result; \
162 va_list args; \
163 va_start(args, methodID); \
164 result = functions->CallNonvirtual##_jname##MethodV(this, obj, \
165 clazz, methodID, args); \
166 va_end(args); \
167 return result; \
168 }
169 #define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \
170 _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \
171 jmethodID methodID, va_list args) \
172 { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \
173 methodID, args); }
174 #define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \
175 _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \
176 jmethodID methodID, const jvalue* args) \
177 { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \
178 methodID, args); }
179
180 #define CALL_NONVIRT_TYPE(_jtype, _jname) \
181 CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \
182 CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \
183 CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)
184
185 CALL_NONVIRT_TYPE(jobject, Object)
186 CALL_NONVIRT_TYPE(jboolean, Boolean)
187 CALL_NONVIRT_TYPE(jbyte, Byte)
188 CALL_NONVIRT_TYPE(jchar, Char)
189 CALL_NONVIRT_TYPE(jshort, Short)
190 CALL_NONVIRT_TYPE(jint, Int)
191 CALL_NONVIRT_TYPE(jlong, Long)
192 CALL_NONVIRT_TYPE(jfloat, Float)
193 CALL_NONVIRT_TYPE(jdouble, Double)
194
195 void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
196 jmethodID methodID, ...)
197 {
198 va_list args;
199 va_start(args, methodID);
200 functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args);
201 va_end(args);
202 }
203 void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
204 jmethodID methodID, va_list args)
205 { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); }
206 void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
207 jmethodID methodID, const jvalue* args)
208 { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); }
209
210 jfieldID GetFieldID(jclass clazz, const char* name, const char* sig)
211 { return functions->GetFieldID(this, clazz, name, sig); }
212
213 jobject GetObjectField(jobject obj, jfieldID fieldID)
214 { return functions->GetObjectField(this, obj, fieldID); }
215 jboolean GetBooleanField(jobject obj, jfieldID fieldID)
216 { return functions->GetBooleanField(this, obj, fieldID); }
217 jbyte GetByteField(jobject obj, jfieldID fieldID)
218 { return functions->GetByteField(this, obj, fieldID); }
219 jchar GetCharField(jobject obj, jfieldID fieldID)
220 { return functions->GetCharField(this, obj, fieldID); }
221 jshort GetShortField(jobject obj, jfieldID fieldID)
222 { return functions->GetShortField(this, obj, fieldID); }
223 jint GetIntField(jobject obj, jfieldID fieldID)
224 { return functions->GetIntField(this, obj, fieldID); }
225 jlong GetLongField(jobject obj, jfieldID fieldID)
226 { return functions->GetLongField(this, obj, fieldID); }
227 jfloat GetFloatField(jobject obj, jfieldID fieldID)
228 { return functions->GetFloatField(this, obj, fieldID); }
229 jdouble GetDoubleField(jobject obj, jfieldID fieldID)
230 { return functions->GetDoubleField(this, obj, fieldID); }
231
232 void SetObjectField(jobject obj, jfieldID fieldID, jobject value)
233 { functions->SetObjectField(this, obj, fieldID, value); }
234 void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value)
235 { functions->SetBooleanField(this, obj, fieldID, value); }
236 void SetByteField(jobject obj, jfieldID fieldID, jbyte value)
237 { functions->SetByteField(this, obj, fieldID, value); }
238 void SetCharField(jobject obj, jfieldID fieldID, jchar value)
239 { functions->SetCharField(this, obj, fieldID, value); }
240 void SetShortField(jobject obj, jfieldID fieldID, jshort value)
241 { functions->SetShortField(this, obj, fieldID, value); }
242 void SetIntField(jobject obj, jfieldID fieldID, jint value)
243 { functions->SetIntField(this, obj, fieldID, value); }
244 void SetLongField(jobject obj, jfieldID fieldID, jlong value)
245 { functions->SetLongField(this, obj, fieldID, value); }
246 void SetFloatField(jobject obj, jfieldID fieldID, jfloat value)
247 { functions->SetFloatField(this, obj, fieldID, value); }
248 void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value)
249 { functions->SetDoubleField(this, obj, fieldID, value); }
250
251 jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig)
252 { return functions->GetStaticMethodID(this, clazz, name, sig); }
253
254 #define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \
255 _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \
256 ...) \
257 { \
258 _jtype result; \
259 va_list args; \
260 va_start(args, methodID); \
261 result = functions->CallStatic##_jname##MethodV(this, clazz, \
262 methodID, args); \
263 va_end(args); \
264 return result; \
265 }
266 #define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \
267 _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \
268 va_list args) \
269 { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \
270 args); }
271 #define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \
272 _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \
273 const jvalue* args) \
274 { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \
275 args); }
276
277 #define CALL_STATIC_TYPE(_jtype, _jname) \
278 CALL_STATIC_TYPE_METHOD(_jtype, _jname) \
279 CALL_STATIC_TYPE_METHODV(_jtype, _jname) \
280 CALL_STATIC_TYPE_METHODA(_jtype, _jname)
281
282 CALL_STATIC_TYPE(jobject, Object)
283 CALL_STATIC_TYPE(jboolean, Boolean)
284 CALL_STATIC_TYPE(jbyte, Byte)
285 CALL_STATIC_TYPE(jchar, Char)
286 CALL_STATIC_TYPE(jshort, Short)
287 CALL_STATIC_TYPE(jint, Int)
288 CALL_STATIC_TYPE(jlong, Long)
289 CALL_STATIC_TYPE(jfloat, Float)
290 CALL_STATIC_TYPE(jdouble, Double)
291
292 void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...)
293 {
294 va_list args;
295 va_start(args, methodID);
296 functions->CallStaticVoidMethodV(this, clazz, methodID, args);
297 va_end(args);
298 }
299 void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args)
300 { functions->CallStaticVoidMethodV(this, clazz, methodID, args); }
301 void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue* args)
302 { functions->CallStaticVoidMethodA(this, clazz, methodID, args); }
303
304 jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig)
305 { return functions->GetStaticFieldID(this, clazz, name, sig); }
306
307 jobject GetStaticObjectField(jclass clazz, jfieldID fieldID)
308 { return functions->GetStaticObjectField(this, clazz, fieldID); }
309 jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID)
310 { return functions->GetStaticBooleanField(this, clazz, fieldID); }
311 jbyte GetStaticByteField(jclass clazz, jfieldID fieldID)
312 { return functions->GetStaticByteField(this, clazz, fieldID); }
313 jchar GetStaticCharField(jclass clazz, jfieldID fieldID)
314 { return functions->GetStaticCharField(this, clazz, fieldID); }
315 jshort GetStaticShortField(jclass clazz, jfieldID fieldID)
316 { return functions->GetStaticShortField(this, clazz, fieldID); }
317 jint GetStaticIntField(jclass clazz, jfieldID fieldID)
318 { return functions->GetStaticIntField(this, clazz, fieldID); }
319 jlong GetStaticLongField(jclass clazz, jfieldID fieldID)
320 { return functions->GetStaticLongField(this, clazz, fieldID); }
321 jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID)
322 { return functions->GetStaticFloatField(this, clazz, fieldID); }
323 jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID)
324 { return functions->GetStaticDoubleField(this, clazz, fieldID); }
325
326 void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value)
327 { functions->SetStaticObjectField(this, clazz, fieldID, value); }
328 void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value)
329 { functions->SetStaticBooleanField(this, clazz, fieldID, value); }
330 void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value)
331 { functions->SetStaticByteField(this, clazz, fieldID, value); }
332 void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value)
333 { functions->SetStaticCharField(this, clazz, fieldID, value); }
334 void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value)
335 { functions->SetStaticShortField(this, clazz, fieldID, value); }
336 void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value)
337 { functions->SetStaticIntField(this, clazz, fieldID, value); }
338 void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value)
339 { functions->SetStaticLongField(this, clazz, fieldID, value); }
340 void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value)
341 { functions->SetStaticFloatField(this, clazz, fieldID, value); }
342 void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value)
343 { functions->SetStaticDoubleField(this, clazz, fieldID, value); }
344
345 jstring NewString(const jchar* unicodeChars, jsize len)
346 { return functions->NewString(this, unicodeChars, len); }
347
348 jsize GetStringLength(jstring string)
349 { return functions->GetStringLength(this, string); }
350
351 const jchar* GetStringChars(jstring string, jboolean* isCopy)
352 { return functions->GetStringChars(this, string, isCopy); }
353
354 void ReleaseStringChars(jstring string, const jchar* chars)
355 { functions->ReleaseStringChars(this, string, chars); }
356
357 jstring NewStringUTF(const char* bytes)
358 { return functions->NewStringUTF(this, bytes); }
359
360 jsize GetStringUTFLength(jstring string)
361 { return functions->GetStringUTFLength(this, string); }
362
363 const char* GetStringUTFChars(jstring string, jboolean* isCopy)
364 { return functions->GetStringUTFChars(this, string, isCopy); }
365
366 void ReleaseStringUTFChars(jstring string, const char* utf)
367 { functions->ReleaseStringUTFChars(this, string, utf); }
368
369 jsize GetArrayLength(jarray array)
370 { return functions->GetArrayLength(this, array); }
371
372 jobjectArray NewObjectArray(jsize length, jclass elementClass,
373 jobject initialElement)
374 { return functions->NewObjectArray(this, length, elementClass,
375 initialElement); }
376
377 jobject GetObjectArrayElement(jobjectArray array, jsize index)
378 { return functions->GetObjectArrayElement(this, array, index); }
379
380 void SetObjectArrayElement(jobjectArray array, jsize index, jobject value)
381 { functions->SetObjectArrayElement(this, array, index, value); }
382
383 jbooleanArray NewBooleanArray(jsize length)
384 { return functions->NewBooleanArray(this, length); }
385 jbyteArray NewByteArray(jsize length)
386 { return functions->NewByteArray(this, length); }
387 jcharArray NewCharArray(jsize length)
388 { return functions->NewCharArray(this, length); }
389 jshortArray NewShortArray(jsize length)
390 { return functions->NewShortArray(this, length); }
391 jintArray NewIntArray(jsize length)
392 { return functions->NewIntArray(this, length); }
393 jlongArray NewLongArray(jsize length)
394 { return functions->NewLongArray(this, length); }
395 jfloatArray NewFloatArray(jsize length)
396 { return functions->NewFloatArray(this, length); }
397 jdoubleArray NewDoubleArray(jsize length)
398 { return functions->NewDoubleArray(this, length); }
399
400 jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy)
401 { return functions->GetBooleanArrayElements(this, array, isCopy); }
402 jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy)
403 { return functions->GetByteArrayElements(this, array, isCopy); }
404 jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy)
405 { return functions->GetCharArrayElements(this, array, isCopy); }
406 jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy)
407 { return functions->GetShortArrayElements(this, array, isCopy); }
408 jint* GetIntArrayElements(jintArray array, jboolean* isCopy)
409 { return functions->GetIntArrayElements(this, array, isCopy); }
410 jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy)
411 { return functions->GetLongArrayElements(this, array, isCopy); }
412 jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy)
413 { return functions->GetFloatArrayElements(this, array, isCopy); }
414 jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy)
415 { return functions->GetDoubleArrayElements(this, array, isCopy); }
416
417 void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems,
418 jint mode)
419 { functions->ReleaseBooleanArrayElements(this, array, elems, mode); }
420 void ReleaseByteArrayElements(jbyteArray array, jbyte* elems,
421 jint mode)
422 { functions->ReleaseByteArrayElements(this, array, elems, mode); }
423 void ReleaseCharArrayElements(jcharArray array, jchar* elems,
424 jint mode)
425 { functions->ReleaseCharArrayElements(this, array, elems, mode); }
426 void ReleaseShortArrayElements(jshortArray array, jshort* elems,
427 jint mode)
428 { functions->ReleaseShortArrayElements(this, array, elems, mode); }
429 void ReleaseIntArrayElements(jintArray array, jint* elems,
430 jint mode)
431 { functions->ReleaseIntArrayElements(this, array, elems, mode); }
432 void ReleaseLongArrayElements(jlongArray array, jlong* elems,
433 jint mode)
434 { functions->ReleaseLongArrayElements(this, array, elems, mode); }
435 void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems,
436 jint mode)
437 { functions->ReleaseFloatArrayElements(this, array, elems, mode); }
438 void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems,
439 jint mode)
440 { functions->ReleaseDoubleArrayElements(this, array, elems, mode); }
441
442 void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
443 jboolean* buf)
444 { functions->GetBooleanArrayRegion(this, array, start, len, buf); }
445 void GetByteArrayRegion(jbyteArray array, jsize start, jsize len,
446 jbyte* buf)
447 { functions->GetByteArrayRegion(this, array, start, len, buf); }
448 void GetCharArrayRegion(jcharArray array, jsize start, jsize len,
449 jchar* buf)
450 { functions->GetCharArrayRegion(this, array, start, len, buf); }
451 void GetShortArrayRegion(jshortArray array, jsize start, jsize len,
452 jshort* buf)
453 { functions->GetShortArrayRegion(this, array, start, len, buf); }
454 void GetIntArrayRegion(jintArray array, jsize start, jsize len,
455 jint* buf)
456 { functions->GetIntArrayRegion(this, array, start, len, buf); }
457 void GetLongArrayRegion(jlongArray array, jsize start, jsize len,
458 jlong* buf)
459 { functions->GetLongArrayRegion(this, array, start, len, buf); }
460 void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
461 jfloat* buf)
462 { functions->GetFloatArrayRegion(this, array, start, len, buf); }
463 void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
464 jdouble* buf)
465 { functions->GetDoubleArrayRegion(this, array, start, len, buf); }
466
467 void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
468 const jboolean* buf)
469 { functions->SetBooleanArrayRegion(this, array, start, len, buf); }
470 void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
471 const jbyte* buf)
472 { functions->SetByteArrayRegion(this, array, start, len, buf); }
473 void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
474 const jchar* buf)
475 { functions->SetCharArrayRegion(this, array, start, len, buf); }
476 void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
477 const jshort* buf)
478 { functions->SetShortArrayRegion(this, array, start, len, buf); }
479 void SetIntArrayRegion(jintArray array, jsize start, jsize len,
480 const jint* buf)
481 { functions->SetIntArrayRegion(this, array, start, len, buf); }
482 void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
483 const jlong* buf)
484 { functions->SetLongArrayRegion(this, array, start, len, buf); }
485 void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
486 const jfloat* buf)
487 { functions->SetFloatArrayRegion(this, array, start, len, buf); }
488 void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
489 const jdouble* buf)
490 { functions->SetDoubleArrayRegion(this, array, start, len, buf); }
491
492 jint RegisterNatives(jclass clazz, const JNINativeMethod* methods,
493 jint nMethods)
494 { return functions->RegisterNatives(this, clazz, methods, nMethods); }
495
496 jint UnregisterNatives(jclass clazz)
497 { return functions->UnregisterNatives(this, clazz); }
498
499 jint MonitorEnter(jobject obj)
500 { return functions->MonitorEnter(this, obj); }
501
502 jint MonitorExit(jobject obj)
503 { return functions->MonitorExit(this, obj); }
504
505 jint GetJavaVM(JavaVM** vm)
506 { return functions->GetJavaVM(this, vm); }
507
508 void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf)
509 { functions->GetStringRegion(this, str, start, len, buf); }
510
511 void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf)
512 { return functions->GetStringUTFRegion(this, str, start, len, buf); }
513
514 void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy)
515 { return functions->GetPrimitiveArrayCritical(this, array, isCopy); }
516
517 void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode)
518 { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); }
519
520 const jchar* GetStringCritical(jstring string, jboolean* isCopy)
521 { return functions->GetStringCritical(this, string, isCopy); }
522
523 void ReleaseStringCritical(jstring string, const jchar* carray)
524 { functions->ReleaseStringCritical(this, string, carray); }
525
526 jweak NewWeakGlobalRef(jobject obj)
527 { return functions->NewWeakGlobalRef(this, obj); }
528
529 void DeleteWeakGlobalRef(jweak obj)
530 { functions->DeleteWeakGlobalRef(this, obj); }
531
532 jboolean ExceptionCheck()
533 { return functions->ExceptionCheck(this); }
534
535 jobject NewDirectByteBuffer(void* address, jlong capacity)
536 { return functions->NewDirectByteBuffer(this, address, capacity); }
537
538 void* GetDirectBufferAddress(jobject buf)
539 { return functions->GetDirectBufferAddress(this, buf); }
540
541 jlong GetDirectBufferCapacity(jobject buf)
542 { return functions->GetDirectBufferCapacity(this, buf); }
543
544 /* added in JNI 1.6 */
545 jobjectRefType GetObjectRefType(jobject obj)
546 { return functions->GetObjectRefType(this, obj); }
547 #endif /*__cplusplus*/
548 };