• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * JNI specification, as defined by Sun:
19  * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html
20  *
21  * Everything here is expected to be VM-neutral.
22  */
23 
24 #ifndef JNI_H_
25 #define JNI_H_
26 
27 #include <stdarg.h>
28 #include <stdint.h>
29 
30 /* Primitive types that match up with Java equivalents. */
31 typedef uint8_t  jboolean; /* unsigned 8 bits */
32 typedef int8_t   jbyte;    /* signed 8 bits */
33 typedef uint16_t jchar;    /* unsigned 16 bits */
34 typedef int16_t  jshort;   /* signed 16 bits */
35 typedef int32_t  jint;     /* signed 32 bits */
36 typedef int64_t  jlong;    /* signed 64 bits */
37 typedef float    jfloat;   /* 32-bit IEEE 754 */
38 typedef double   jdouble;  /* 64-bit IEEE 754 */
39 
40 /* "cardinal indices and sizes" */
41 typedef jint     jsize;
42 
43 #ifdef __cplusplus
44 /*
45  * Reference types, in C++
46  */
47 class _jobject {};
48 class _jclass : public _jobject {};
49 class _jstring : public _jobject {};
50 class _jarray : public _jobject {};
51 class _jobjectArray : public _jarray {};
52 class _jbooleanArray : public _jarray {};
53 class _jbyteArray : public _jarray {};
54 class _jcharArray : public _jarray {};
55 class _jshortArray : public _jarray {};
56 class _jintArray : public _jarray {};
57 class _jlongArray : public _jarray {};
58 class _jfloatArray : public _jarray {};
59 class _jdoubleArray : public _jarray {};
60 class _jthrowable : public _jobject {};
61 
62 typedef _jobject*       jobject;
63 typedef _jclass*        jclass;
64 typedef _jstring*       jstring;
65 typedef _jarray*        jarray;
66 typedef _jobjectArray*  jobjectArray;
67 typedef _jbooleanArray* jbooleanArray;
68 typedef _jbyteArray*    jbyteArray;
69 typedef _jcharArray*    jcharArray;
70 typedef _jshortArray*   jshortArray;
71 typedef _jintArray*     jintArray;
72 typedef _jlongArray*    jlongArray;
73 typedef _jfloatArray*   jfloatArray;
74 typedef _jdoubleArray*  jdoubleArray;
75 typedef _jthrowable*    jthrowable;
76 typedef _jobject*       jweak;
77 
78 
79 #else /* not __cplusplus */
80 
81 /*
82  * Reference types, in C.
83  */
84 typedef void*           jobject;
85 typedef jobject         jclass;
86 typedef jobject         jstring;
87 typedef jobject         jarray;
88 typedef jarray          jobjectArray;
89 typedef jarray          jbooleanArray;
90 typedef jarray          jbyteArray;
91 typedef jarray          jcharArray;
92 typedef jarray          jshortArray;
93 typedef jarray          jintArray;
94 typedef jarray          jlongArray;
95 typedef jarray          jfloatArray;
96 typedef jarray          jdoubleArray;
97 typedef jobject         jthrowable;
98 typedef jobject         jweak;
99 
100 #endif /* not __cplusplus */
101 
102 struct _jfieldID;                       /* opaque structure */
103 typedef struct _jfieldID* jfieldID;     /* field IDs */
104 
105 struct _jmethodID;                      /* opaque structure */
106 typedef struct _jmethodID* jmethodID;   /* method IDs */
107 
108 struct JNIInvokeInterface;
109 
110 typedef union jvalue {
111     jboolean    z;
112     jbyte       b;
113     jchar       c;
114     jshort      s;
115     jint        i;
116     jlong       j;
117     jfloat      f;
118     jdouble     d;
119     jobject     l;
120 } jvalue;
121 
122 typedef enum jobjectRefType {
123     JNIInvalidRefType = 0,
124     JNILocalRefType = 1,
125     JNIGlobalRefType = 2,
126     JNIWeakGlobalRefType = 3
127 } jobjectRefType;
128 
129 typedef struct {
130     const char* name;
131     const char* signature;
132     void*       fnPtr;
133 } JNINativeMethod;
134 
135 struct _JNIEnv;
136 struct _JavaVM;
137 typedef const struct JNINativeInterface* C_JNIEnv;
138 
139 #if defined(__cplusplus)
140 typedef _JNIEnv JNIEnv;
141 typedef _JavaVM JavaVM;
142 #else
143 typedef const struct JNINativeInterface* JNIEnv;
144 typedef const struct JNIInvokeInterface* JavaVM;
145 #endif
146 
147 /*
148  * Table of interface function pointers.
149  */
150 struct JNINativeInterface {
151     void*       reserved0;
152     void*       reserved1;
153     void*       reserved2;
154     void*       reserved3;
155 
156     jint        (*GetVersion)(JNIEnv *);
157 
158     jclass      (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*,
159                         jsize);
160     jclass      (*FindClass)(JNIEnv*, const char*);
161 
162     jmethodID   (*FromReflectedMethod)(JNIEnv*, jobject);
163     jfieldID    (*FromReflectedField)(JNIEnv*, jobject);
164     /* spec doesn't show jboolean parameter */
165     jobject     (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean);
166 
167     jclass      (*GetSuperclass)(JNIEnv*, jclass);
168     jboolean    (*IsAssignableFrom)(JNIEnv*, jclass, jclass);
169 
170     /* spec doesn't show jboolean parameter */
171     jobject     (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean);
172 
173     jint        (*Throw)(JNIEnv*, jthrowable);
174     jint        (*ThrowNew)(JNIEnv *, jclass, const char *);
175     jthrowable  (*ExceptionOccurred)(JNIEnv*);
176     void        (*ExceptionDescribe)(JNIEnv*);
177     void        (*ExceptionClear)(JNIEnv*);
178     void        (*FatalError)(JNIEnv*, const char*);
179 
180     jint        (*PushLocalFrame)(JNIEnv*, jint);
181     jobject     (*PopLocalFrame)(JNIEnv*, jobject);
182 
183     jobject     (*NewGlobalRef)(JNIEnv*, jobject);
184     void        (*DeleteGlobalRef)(JNIEnv*, jobject);
185     void        (*DeleteLocalRef)(JNIEnv*, jobject);
186     jboolean    (*IsSameObject)(JNIEnv*, jobject, jobject);
187 
188     jobject     (*NewLocalRef)(JNIEnv*, jobject);
189     jint        (*EnsureLocalCapacity)(JNIEnv*, jint);
190 
191     jobject     (*AllocObject)(JNIEnv*, jclass);
192     jobject     (*NewObject)(JNIEnv*, jclass, jmethodID, ...);
193     jobject     (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list);
194     jobject     (*NewObjectA)(JNIEnv*, jclass, jmethodID, const jvalue*);
195 
196     jclass      (*GetObjectClass)(JNIEnv*, jobject);
197     jboolean    (*IsInstanceOf)(JNIEnv*, jobject, jclass);
198     jmethodID   (*GetMethodID)(JNIEnv*, jclass, const char*, const char*);
199 
200     jobject     (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...);
201     jobject     (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list);
202     jobject     (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
203     jboolean    (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...);
204     jboolean    (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list);
205     jboolean    (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
206     jbyte       (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...);
207     jbyte       (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list);
208     jbyte       (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
209     jchar       (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...);
210     jchar       (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list);
211     jchar       (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
212     jshort      (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...);
213     jshort      (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list);
214     jshort      (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
215     jint        (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...);
216     jint        (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list);
217     jint        (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
218     jlong       (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...);
219     jlong       (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list);
220     jlong       (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
221     jfloat      (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...);
222     jfloat      (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list);
223     jfloat      (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
224     jdouble     (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...);
225     jdouble     (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list);
226     jdouble     (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
227     void        (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...);
228     void        (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list);
229     void        (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
230 
231     jobject     (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass,
232                         jmethodID, ...);
233     jobject     (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass,
234                         jmethodID, va_list);
235     jobject     (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass,
236                         jmethodID, const jvalue*);
237     jboolean    (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass,
238                         jmethodID, ...);
239     jboolean    (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass,
240                          jmethodID, va_list);
241     jboolean    (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass,
242                          jmethodID, const jvalue*);
243     jbyte       (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass,
244                         jmethodID, ...);
245     jbyte       (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass,
246                         jmethodID, va_list);
247     jbyte       (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass,
248                         jmethodID, const jvalue*);
249     jchar       (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass,
250                         jmethodID, ...);
251     jchar       (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass,
252                         jmethodID, va_list);
253     jchar       (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass,
254                         jmethodID, const jvalue*);
255     jshort      (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass,
256                         jmethodID, ...);
257     jshort      (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass,
258                         jmethodID, va_list);
259     jshort      (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass,
260                         jmethodID, const jvalue*);
261     jint        (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass,
262                         jmethodID, ...);
263     jint        (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass,
264                         jmethodID, va_list);
265     jint        (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass,
266                         jmethodID, const jvalue*);
267     jlong       (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass,
268                         jmethodID, ...);
269     jlong       (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass,
270                         jmethodID, va_list);
271     jlong       (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass,
272                         jmethodID, const jvalue*);
273     jfloat      (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass,
274                         jmethodID, ...);
275     jfloat      (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass,
276                         jmethodID, va_list);
277     jfloat      (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass,
278                         jmethodID, const jvalue*);
279     jdouble     (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass,
280                         jmethodID, ...);
281     jdouble     (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass,
282                         jmethodID, va_list);
283     jdouble     (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass,
284                         jmethodID, const jvalue*);
285     void        (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass,
286                         jmethodID, ...);
287     void        (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass,
288                         jmethodID, va_list);
289     void        (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass,
290                         jmethodID, const jvalue*);
291 
292     jfieldID    (*GetFieldID)(JNIEnv*, jclass, const char*, const char*);
293 
294     jobject     (*GetObjectField)(JNIEnv*, jobject, jfieldID);
295     jboolean    (*GetBooleanField)(JNIEnv*, jobject, jfieldID);
296     jbyte       (*GetByteField)(JNIEnv*, jobject, jfieldID);
297     jchar       (*GetCharField)(JNIEnv*, jobject, jfieldID);
298     jshort      (*GetShortField)(JNIEnv*, jobject, jfieldID);
299     jint        (*GetIntField)(JNIEnv*, jobject, jfieldID);
300     jlong       (*GetLongField)(JNIEnv*, jobject, jfieldID);
301     jfloat      (*GetFloatField)(JNIEnv*, jobject, jfieldID);
302     jdouble     (*GetDoubleField)(JNIEnv*, jobject, jfieldID);
303 
304     void        (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject);
305     void        (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean);
306     void        (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte);
307     void        (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar);
308     void        (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort);
309     void        (*SetIntField)(JNIEnv*, jobject, jfieldID, jint);
310     void        (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong);
311     void        (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat);
312     void        (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble);
313 
314     jmethodID   (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*);
315 
316     jobject     (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...);
317     jobject     (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list);
318     jobject     (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
319     jboolean    (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...);
320     jboolean    (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID,
321                         va_list);
322     jboolean    (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
323     jbyte       (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...);
324     jbyte       (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list);
325     jbyte       (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
326     jchar       (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...);
327     jchar       (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list);
328     jchar       (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
329     jshort      (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...);
330     jshort      (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list);
331     jshort      (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
332     jint        (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...);
333     jint        (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list);
334     jint        (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
335     jlong       (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...);
336     jlong       (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list);
337     jlong       (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
338     jfloat      (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...);
339     jfloat      (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list);
340     jfloat      (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
341     jdouble     (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...);
342     jdouble     (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list);
343     jdouble     (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
344     void        (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...);
345     void        (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list);
346     void        (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
347 
348     jfieldID    (*GetStaticFieldID)(JNIEnv*, jclass, const char*,
349                         const char*);
350 
351     jobject     (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID);
352     jboolean    (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID);
353     jbyte       (*GetStaticByteField)(JNIEnv*, jclass, jfieldID);
354     jchar       (*GetStaticCharField)(JNIEnv*, jclass, jfieldID);
355     jshort      (*GetStaticShortField)(JNIEnv*, jclass, jfieldID);
356     jint        (*GetStaticIntField)(JNIEnv*, jclass, jfieldID);
357     jlong       (*GetStaticLongField)(JNIEnv*, jclass, jfieldID);
358     jfloat      (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID);
359     jdouble     (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID);
360 
361     void        (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject);
362     void        (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean);
363     void        (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte);
364     void        (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar);
365     void        (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort);
366     void        (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint);
367     void        (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong);
368     void        (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat);
369     void        (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble);
370 
371     jstring     (*NewString)(JNIEnv*, const jchar*, jsize);
372     jsize       (*GetStringLength)(JNIEnv*, jstring);
373     const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*);
374     void        (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*);
375     jstring     (*NewStringUTF)(JNIEnv*, const char*);
376     jsize       (*GetStringUTFLength)(JNIEnv*, jstring);
377     /* JNI spec says this returns const jbyte*, but that's inconsistent */
378     const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*);
379     void        (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*);
380     jsize       (*GetArrayLength)(JNIEnv*, jarray);
381     jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject);
382     jobject     (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize);
383     void        (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject);
384 
385     jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize);
386     jbyteArray    (*NewByteArray)(JNIEnv*, jsize);
387     jcharArray    (*NewCharArray)(JNIEnv*, jsize);
388     jshortArray   (*NewShortArray)(JNIEnv*, jsize);
389     jintArray     (*NewIntArray)(JNIEnv*, jsize);
390     jlongArray    (*NewLongArray)(JNIEnv*, jsize);
391     jfloatArray   (*NewFloatArray)(JNIEnv*, jsize);
392     jdoubleArray  (*NewDoubleArray)(JNIEnv*, jsize);
393 
394     jboolean*   (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*);
395     jbyte*      (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*);
396     jchar*      (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*);
397     jshort*     (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*);
398     jint*       (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*);
399     jlong*      (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*);
400     jfloat*     (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*);
401     jdouble*    (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*);
402 
403     void        (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray,
404                         jboolean*, jint);
405     void        (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray,
406                         jbyte*, jint);
407     void        (*ReleaseCharArrayElements)(JNIEnv*, jcharArray,
408                         jchar*, jint);
409     void        (*ReleaseShortArrayElements)(JNIEnv*, jshortArray,
410                         jshort*, jint);
411     void        (*ReleaseIntArrayElements)(JNIEnv*, jintArray,
412                         jint*, jint);
413     void        (*ReleaseLongArrayElements)(JNIEnv*, jlongArray,
414                         jlong*, jint);
415     void        (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray,
416                         jfloat*, jint);
417     void        (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray,
418                         jdouble*, jint);
419 
420     void        (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
421                         jsize, jsize, jboolean*);
422     void        (*GetByteArrayRegion)(JNIEnv*, jbyteArray,
423                         jsize, jsize, jbyte*);
424     void        (*GetCharArrayRegion)(JNIEnv*, jcharArray,
425                         jsize, jsize, jchar*);
426     void        (*GetShortArrayRegion)(JNIEnv*, jshortArray,
427                         jsize, jsize, jshort*);
428     void        (*GetIntArrayRegion)(JNIEnv*, jintArray,
429                         jsize, jsize, jint*);
430     void        (*GetLongArrayRegion)(JNIEnv*, jlongArray,
431                         jsize, jsize, jlong*);
432     void        (*GetFloatArrayRegion)(JNIEnv*, jfloatArray,
433                         jsize, jsize, jfloat*);
434     void        (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
435                         jsize, jsize, jdouble*);
436 
437     /* spec shows these without const; some jni.h do, some don't */
438     void        (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
439                         jsize, jsize, const jboolean*);
440     void        (*SetByteArrayRegion)(JNIEnv*, jbyteArray,
441                         jsize, jsize, const jbyte*);
442     void        (*SetCharArrayRegion)(JNIEnv*, jcharArray,
443                         jsize, jsize, const jchar*);
444     void        (*SetShortArrayRegion)(JNIEnv*, jshortArray,
445                         jsize, jsize, const jshort*);
446     void        (*SetIntArrayRegion)(JNIEnv*, jintArray,
447                         jsize, jsize, const jint*);
448     void        (*SetLongArrayRegion)(JNIEnv*, jlongArray,
449                         jsize, jsize, const jlong*);
450     void        (*SetFloatArrayRegion)(JNIEnv*, jfloatArray,
451                         jsize, jsize, const jfloat*);
452     void        (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
453                         jsize, jsize, const jdouble*);
454 
455     jint        (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*,
456                         jint);
457     jint        (*UnregisterNatives)(JNIEnv*, jclass);
458     jint        (*MonitorEnter)(JNIEnv*, jobject);
459     jint        (*MonitorExit)(JNIEnv*, jobject);
460     jint        (*GetJavaVM)(JNIEnv*, JavaVM**);
461 
462     void        (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*);
463     void        (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*);
464 
465     void*       (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*);
466     void        (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint);
467 
468     const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*);
469     void        (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*);
470 
471     jweak       (*NewWeakGlobalRef)(JNIEnv*, jobject);
472     void        (*DeleteWeakGlobalRef)(JNIEnv*, jweak);
473 
474     jboolean    (*ExceptionCheck)(JNIEnv*);
475 
476     jobject     (*NewDirectByteBuffer)(JNIEnv*, void*, jlong);
477     void*       (*GetDirectBufferAddress)(JNIEnv*, jobject);
478     jlong       (*GetDirectBufferCapacity)(JNIEnv*, jobject);
479 
480     /* added in JNI 1.6 */
481     jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject);
482 };
483 
484 /*
485  * C++ object wrapper.
486  *
487  * This is usually overlaid on a C struct whose first element is a
488  * JNINativeInterface*.  We rely somewhat on compiler behavior.
489  */
490 struct _JNIEnv {
491     /* do not rename this; it does not seem to be entirely opaque */
492     const struct JNINativeInterface* functions;
493 
494 #if defined(__cplusplus)
495 
GetVersion_JNIEnv496     jint GetVersion()
497     { return functions->GetVersion(this); }
498 
DefineClass_JNIEnv499     jclass DefineClass(const char *name, jobject loader, const jbyte* buf,
500         jsize bufLen)
501     { return functions->DefineClass(this, name, loader, buf, bufLen); }
502 
FindClass_JNIEnv503     jclass FindClass(const char* name)
504     { return functions->FindClass(this, name); }
505 
FromReflectedMethod_JNIEnv506     jmethodID FromReflectedMethod(jobject method)
507     { return functions->FromReflectedMethod(this, method); }
508 
FromReflectedField_JNIEnv509     jfieldID FromReflectedField(jobject field)
510     { return functions->FromReflectedField(this, field); }
511 
ToReflectedMethod_JNIEnv512     jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic)
513     { return functions->ToReflectedMethod(this, cls, methodID, isStatic); }
514 
GetSuperclass_JNIEnv515     jclass GetSuperclass(jclass clazz)
516     { return functions->GetSuperclass(this, clazz); }
517 
IsAssignableFrom_JNIEnv518     jboolean IsAssignableFrom(jclass clazz1, jclass clazz2)
519     { return functions->IsAssignableFrom(this, clazz1, clazz2); }
520 
ToReflectedField_JNIEnv521     jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic)
522     { return functions->ToReflectedField(this, cls, fieldID, isStatic); }
523 
Throw_JNIEnv524     jint Throw(jthrowable obj)
525     { return functions->Throw(this, obj); }
526 
ThrowNew_JNIEnv527     jint ThrowNew(jclass clazz, const char* message)
528     { return functions->ThrowNew(this, clazz, message); }
529 
ExceptionOccurred_JNIEnv530     jthrowable ExceptionOccurred()
531     { return functions->ExceptionOccurred(this); }
532 
ExceptionDescribe_JNIEnv533     void ExceptionDescribe()
534     { functions->ExceptionDescribe(this); }
535 
ExceptionClear_JNIEnv536     void ExceptionClear()
537     { functions->ExceptionClear(this); }
538 
FatalError_JNIEnv539     void FatalError(const char* msg)
540     { functions->FatalError(this, msg); }
541 
PushLocalFrame_JNIEnv542     jint PushLocalFrame(jint capacity)
543     { return functions->PushLocalFrame(this, capacity); }
544 
PopLocalFrame_JNIEnv545     jobject PopLocalFrame(jobject result)
546     { return functions->PopLocalFrame(this, result); }
547 
NewGlobalRef_JNIEnv548     jobject NewGlobalRef(jobject obj)
549     { return functions->NewGlobalRef(this, obj); }
550 
DeleteGlobalRef_JNIEnv551     void DeleteGlobalRef(jobject globalRef)
552     { functions->DeleteGlobalRef(this, globalRef); }
553 
DeleteLocalRef_JNIEnv554     void DeleteLocalRef(jobject localRef)
555     { functions->DeleteLocalRef(this, localRef); }
556 
IsSameObject_JNIEnv557     jboolean IsSameObject(jobject ref1, jobject ref2)
558     { return functions->IsSameObject(this, ref1, ref2); }
559 
NewLocalRef_JNIEnv560     jobject NewLocalRef(jobject ref)
561     { return functions->NewLocalRef(this, ref); }
562 
EnsureLocalCapacity_JNIEnv563     jint EnsureLocalCapacity(jint capacity)
564     { return functions->EnsureLocalCapacity(this, capacity); }
565 
AllocObject_JNIEnv566     jobject AllocObject(jclass clazz)
567     { return functions->AllocObject(this, clazz); }
568 
NewObject_JNIEnv569     jobject NewObject(jclass clazz, jmethodID methodID, ...)
570     {
571         va_list args;
572         va_start(args, methodID);
573         jobject result = functions->NewObjectV(this, clazz, methodID, args);
574         va_end(args);
575         return result;
576     }
577 
NewObjectV_JNIEnv578     jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args)
579     { return functions->NewObjectV(this, clazz, methodID, args); }
580 
NewObjectA_JNIEnv581     jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue* args)
582     { return functions->NewObjectA(this, clazz, methodID, args); }
583 
GetObjectClass_JNIEnv584     jclass GetObjectClass(jobject obj)
585     { return functions->GetObjectClass(this, obj); }
586 
IsInstanceOf_JNIEnv587     jboolean IsInstanceOf(jobject obj, jclass clazz)
588     { return functions->IsInstanceOf(this, obj, clazz); }
589 
GetMethodID_JNIEnv590     jmethodID GetMethodID(jclass clazz, const char* name, const char* sig)
591     { return functions->GetMethodID(this, clazz, name, sig); }
592 
593 #define CALL_TYPE_METHOD(_jtype, _jname)                                    \
594     _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...)       \
595     {                                                                       \
596         _jtype result;                                                      \
597         va_list args;                                                       \
598         va_start(args, methodID);                                           \
599         result = functions->Call##_jname##MethodV(this, obj, methodID,      \
600                     args);                                                  \
601         va_end(args);                                                       \
602         return result;                                                      \
603     }
604 #define CALL_TYPE_METHODV(_jtype, _jname)                                   \
605     _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID,           \
606         va_list args)                                                       \
607     { return functions->Call##_jname##MethodV(this, obj, methodID, args); }
608 #define CALL_TYPE_METHODA(_jtype, _jname)                                   \
609     _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID,           \
610                                  const jvalue* args)                        \
611     { return functions->Call##_jname##MethodA(this, obj, methodID, args); }
612 
613 #define CALL_TYPE(_jtype, _jname)                                           \
614     CALL_TYPE_METHOD(_jtype, _jname)                                        \
615     CALL_TYPE_METHODV(_jtype, _jname)                                       \
616     CALL_TYPE_METHODA(_jtype, _jname)
617 
CALL_TYPE_JNIEnv618     CALL_TYPE(jobject, Object)
619     CALL_TYPE(jboolean, Boolean)
620     CALL_TYPE(jbyte, Byte)
621     CALL_TYPE(jchar, Char)
622     CALL_TYPE(jshort, Short)
623     CALL_TYPE(jint, Int)
624     CALL_TYPE(jlong, Long)
625     CALL_TYPE(jfloat, Float)
626     CALL_TYPE(jdouble, Double)
627 
628     void CallVoidMethod(jobject obj, jmethodID methodID, ...)
629     {
630         va_list args;
631         va_start(args, methodID);
632         functions->CallVoidMethodV(this, obj, methodID, args);
633         va_end(args);
634     }
CallVoidMethodV_JNIEnv635     void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args)
636     { functions->CallVoidMethodV(this, obj, methodID, args); }
CallVoidMethodA_JNIEnv637     void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue* args)
638     { functions->CallVoidMethodA(this, obj, methodID, args); }
639 
640 #define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname)                            \
641     _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz,        \
642         jmethodID methodID, ...)                                            \
643     {                                                                       \
644         _jtype result;                                                      \
645         va_list args;                                                       \
646         va_start(args, methodID);                                           \
647         result = functions->CallNonvirtual##_jname##MethodV(this, obj,      \
648                     clazz, methodID, args);                                 \
649         va_end(args);                                                       \
650         return result;                                                      \
651     }
652 #define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname)                           \
653     _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz,       \
654         jmethodID methodID, va_list args)                                   \
655     { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz,   \
656         methodID, args); }
657 #define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)                           \
658     _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz,       \
659         jmethodID methodID, const jvalue* args)                             \
660     { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz,   \
661         methodID, args); }
662 
663 #define CALL_NONVIRT_TYPE(_jtype, _jname)                                   \
664     CALL_NONVIRT_TYPE_METHOD(_jtype, _jname)                                \
665     CALL_NONVIRT_TYPE_METHODV(_jtype, _jname)                               \
666     CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)
667 
CALL_NONVIRT_TYPE_JNIEnv668     CALL_NONVIRT_TYPE(jobject, Object)
669     CALL_NONVIRT_TYPE(jboolean, Boolean)
670     CALL_NONVIRT_TYPE(jbyte, Byte)
671     CALL_NONVIRT_TYPE(jchar, Char)
672     CALL_NONVIRT_TYPE(jshort, Short)
673     CALL_NONVIRT_TYPE(jint, Int)
674     CALL_NONVIRT_TYPE(jlong, Long)
675     CALL_NONVIRT_TYPE(jfloat, Float)
676     CALL_NONVIRT_TYPE(jdouble, Double)
677 
678     void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
679         jmethodID methodID, ...)
680     {
681         va_list args;
682         va_start(args, methodID);
683         functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args);
684         va_end(args);
685     }
CallNonvirtualVoidMethodV_JNIEnv686     void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
687         jmethodID methodID, va_list args)
688     { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); }
CallNonvirtualVoidMethodA_JNIEnv689     void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
690         jmethodID methodID, const jvalue* args)
691     { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); }
692 
GetFieldID_JNIEnv693     jfieldID GetFieldID(jclass clazz, const char* name, const char* sig)
694     { return functions->GetFieldID(this, clazz, name, sig); }
695 
GetObjectField_JNIEnv696     jobject GetObjectField(jobject obj, jfieldID fieldID)
697     { return functions->GetObjectField(this, obj, fieldID); }
GetBooleanField_JNIEnv698     jboolean GetBooleanField(jobject obj, jfieldID fieldID)
699     { return functions->GetBooleanField(this, obj, fieldID); }
GetByteField_JNIEnv700     jbyte GetByteField(jobject obj, jfieldID fieldID)
701     { return functions->GetByteField(this, obj, fieldID); }
GetCharField_JNIEnv702     jchar GetCharField(jobject obj, jfieldID fieldID)
703     { return functions->GetCharField(this, obj, fieldID); }
GetShortField_JNIEnv704     jshort GetShortField(jobject obj, jfieldID fieldID)
705     { return functions->GetShortField(this, obj, fieldID); }
GetIntField_JNIEnv706     jint GetIntField(jobject obj, jfieldID fieldID)
707     { return functions->GetIntField(this, obj, fieldID); }
GetLongField_JNIEnv708     jlong GetLongField(jobject obj, jfieldID fieldID)
709     { return functions->GetLongField(this, obj, fieldID); }
GetFloatField_JNIEnv710     jfloat GetFloatField(jobject obj, jfieldID fieldID)
711     { return functions->GetFloatField(this, obj, fieldID); }
GetDoubleField_JNIEnv712     jdouble GetDoubleField(jobject obj, jfieldID fieldID)
713     { return functions->GetDoubleField(this, obj, fieldID); }
714 
SetObjectField_JNIEnv715     void SetObjectField(jobject obj, jfieldID fieldID, jobject value)
716     { functions->SetObjectField(this, obj, fieldID, value); }
SetBooleanField_JNIEnv717     void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value)
718     { functions->SetBooleanField(this, obj, fieldID, value); }
SetByteField_JNIEnv719     void SetByteField(jobject obj, jfieldID fieldID, jbyte value)
720     { functions->SetByteField(this, obj, fieldID, value); }
SetCharField_JNIEnv721     void SetCharField(jobject obj, jfieldID fieldID, jchar value)
722     { functions->SetCharField(this, obj, fieldID, value); }
SetShortField_JNIEnv723     void SetShortField(jobject obj, jfieldID fieldID, jshort value)
724     { functions->SetShortField(this, obj, fieldID, value); }
SetIntField_JNIEnv725     void SetIntField(jobject obj, jfieldID fieldID, jint value)
726     { functions->SetIntField(this, obj, fieldID, value); }
SetLongField_JNIEnv727     void SetLongField(jobject obj, jfieldID fieldID, jlong value)
728     { functions->SetLongField(this, obj, fieldID, value); }
SetFloatField_JNIEnv729     void SetFloatField(jobject obj, jfieldID fieldID, jfloat value)
730     { functions->SetFloatField(this, obj, fieldID, value); }
SetDoubleField_JNIEnv731     void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value)
732     { functions->SetDoubleField(this, obj, fieldID, value); }
733 
GetStaticMethodID_JNIEnv734     jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig)
735     { return functions->GetStaticMethodID(this, clazz, name, sig); }
736 
737 #define CALL_STATIC_TYPE_METHOD(_jtype, _jname)                             \
738     _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID,     \
739         ...)                                                                \
740     {                                                                       \
741         _jtype result;                                                      \
742         va_list args;                                                       \
743         va_start(args, methodID);                                           \
744         result = functions->CallStatic##_jname##MethodV(this, clazz,        \
745                     methodID, args);                                        \
746         va_end(args);                                                       \
747         return result;                                                      \
748     }
749 #define CALL_STATIC_TYPE_METHODV(_jtype, _jname)                            \
750     _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID,    \
751         va_list args)                                                       \
752     { return functions->CallStatic##_jname##MethodV(this, clazz, methodID,  \
753         args); }
754 #define CALL_STATIC_TYPE_METHODA(_jtype, _jname)                            \
755     _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID,    \
756                                        const jvalue* args)                  \
757     { return functions->CallStatic##_jname##MethodA(this, clazz, methodID,  \
758         args); }
759 
760 #define CALL_STATIC_TYPE(_jtype, _jname)                                    \
761     CALL_STATIC_TYPE_METHOD(_jtype, _jname)                                 \
762     CALL_STATIC_TYPE_METHODV(_jtype, _jname)                                \
763     CALL_STATIC_TYPE_METHODA(_jtype, _jname)
764 
CALL_STATIC_TYPE_JNIEnv765     CALL_STATIC_TYPE(jobject, Object)
766     CALL_STATIC_TYPE(jboolean, Boolean)
767     CALL_STATIC_TYPE(jbyte, Byte)
768     CALL_STATIC_TYPE(jchar, Char)
769     CALL_STATIC_TYPE(jshort, Short)
770     CALL_STATIC_TYPE(jint, Int)
771     CALL_STATIC_TYPE(jlong, Long)
772     CALL_STATIC_TYPE(jfloat, Float)
773     CALL_STATIC_TYPE(jdouble, Double)
774 
775     void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...)
776     {
777         va_list args;
778         va_start(args, methodID);
779         functions->CallStaticVoidMethodV(this, clazz, methodID, args);
780         va_end(args);
781     }
CallStaticVoidMethodV_JNIEnv782     void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args)
783     { functions->CallStaticVoidMethodV(this, clazz, methodID, args); }
CallStaticVoidMethodA_JNIEnv784     void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue* args)
785     { functions->CallStaticVoidMethodA(this, clazz, methodID, args); }
786 
GetStaticFieldID_JNIEnv787     jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig)
788     { return functions->GetStaticFieldID(this, clazz, name, sig); }
789 
GetStaticObjectField_JNIEnv790     jobject GetStaticObjectField(jclass clazz, jfieldID fieldID)
791     { return functions->GetStaticObjectField(this, clazz, fieldID); }
GetStaticBooleanField_JNIEnv792     jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID)
793     { return functions->GetStaticBooleanField(this, clazz, fieldID); }
GetStaticByteField_JNIEnv794     jbyte GetStaticByteField(jclass clazz, jfieldID fieldID)
795     { return functions->GetStaticByteField(this, clazz, fieldID); }
GetStaticCharField_JNIEnv796     jchar GetStaticCharField(jclass clazz, jfieldID fieldID)
797     { return functions->GetStaticCharField(this, clazz, fieldID); }
GetStaticShortField_JNIEnv798     jshort GetStaticShortField(jclass clazz, jfieldID fieldID)
799     { return functions->GetStaticShortField(this, clazz, fieldID); }
GetStaticIntField_JNIEnv800     jint GetStaticIntField(jclass clazz, jfieldID fieldID)
801     { return functions->GetStaticIntField(this, clazz, fieldID); }
GetStaticLongField_JNIEnv802     jlong GetStaticLongField(jclass clazz, jfieldID fieldID)
803     { return functions->GetStaticLongField(this, clazz, fieldID); }
GetStaticFloatField_JNIEnv804     jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID)
805     { return functions->GetStaticFloatField(this, clazz, fieldID); }
GetStaticDoubleField_JNIEnv806     jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID)
807     { return functions->GetStaticDoubleField(this, clazz, fieldID); }
808 
SetStaticObjectField_JNIEnv809     void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value)
810     { functions->SetStaticObjectField(this, clazz, fieldID, value); }
SetStaticBooleanField_JNIEnv811     void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value)
812     { functions->SetStaticBooleanField(this, clazz, fieldID, value); }
SetStaticByteField_JNIEnv813     void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value)
814     { functions->SetStaticByteField(this, clazz, fieldID, value); }
SetStaticCharField_JNIEnv815     void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value)
816     { functions->SetStaticCharField(this, clazz, fieldID, value); }
SetStaticShortField_JNIEnv817     void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value)
818     { functions->SetStaticShortField(this, clazz, fieldID, value); }
SetStaticIntField_JNIEnv819     void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value)
820     { functions->SetStaticIntField(this, clazz, fieldID, value); }
SetStaticLongField_JNIEnv821     void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value)
822     { functions->SetStaticLongField(this, clazz, fieldID, value); }
SetStaticFloatField_JNIEnv823     void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value)
824     { functions->SetStaticFloatField(this, clazz, fieldID, value); }
SetStaticDoubleField_JNIEnv825     void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value)
826     { functions->SetStaticDoubleField(this, clazz, fieldID, value); }
827 
NewString_JNIEnv828     jstring NewString(const jchar* unicodeChars, jsize len)
829     { return functions->NewString(this, unicodeChars, len); }
830 
GetStringLength_JNIEnv831     jsize GetStringLength(jstring string)
832     { return functions->GetStringLength(this, string); }
833 
GetStringChars_JNIEnv834     const jchar* GetStringChars(jstring string, jboolean* isCopy)
835     { return functions->GetStringChars(this, string, isCopy); }
836 
ReleaseStringChars_JNIEnv837     void ReleaseStringChars(jstring string, const jchar* chars)
838     { functions->ReleaseStringChars(this, string, chars); }
839 
NewStringUTF_JNIEnv840     jstring NewStringUTF(const char* bytes)
841     { return functions->NewStringUTF(this, bytes); }
842 
GetStringUTFLength_JNIEnv843     jsize GetStringUTFLength(jstring string)
844     { return functions->GetStringUTFLength(this, string); }
845 
GetStringUTFChars_JNIEnv846     const char* GetStringUTFChars(jstring string, jboolean* isCopy)
847     { return functions->GetStringUTFChars(this, string, isCopy); }
848 
ReleaseStringUTFChars_JNIEnv849     void ReleaseStringUTFChars(jstring string, const char* utf)
850     { functions->ReleaseStringUTFChars(this, string, utf); }
851 
GetArrayLength_JNIEnv852     jsize GetArrayLength(jarray array)
853     { return functions->GetArrayLength(this, array); }
854 
NewObjectArray_JNIEnv855     jobjectArray NewObjectArray(jsize length, jclass elementClass,
856         jobject initialElement)
857     { return functions->NewObjectArray(this, length, elementClass,
858         initialElement); }
859 
GetObjectArrayElement_JNIEnv860     jobject GetObjectArrayElement(jobjectArray array, jsize index)
861     { return functions->GetObjectArrayElement(this, array, index); }
862 
SetObjectArrayElement_JNIEnv863     void SetObjectArrayElement(jobjectArray array, jsize index, jobject value)
864     { functions->SetObjectArrayElement(this, array, index, value); }
865 
NewBooleanArray_JNIEnv866     jbooleanArray NewBooleanArray(jsize length)
867     { return functions->NewBooleanArray(this, length); }
NewByteArray_JNIEnv868     jbyteArray NewByteArray(jsize length)
869     { return functions->NewByteArray(this, length); }
NewCharArray_JNIEnv870     jcharArray NewCharArray(jsize length)
871     { return functions->NewCharArray(this, length); }
NewShortArray_JNIEnv872     jshortArray NewShortArray(jsize length)
873     { return functions->NewShortArray(this, length); }
NewIntArray_JNIEnv874     jintArray NewIntArray(jsize length)
875     { return functions->NewIntArray(this, length); }
NewLongArray_JNIEnv876     jlongArray NewLongArray(jsize length)
877     { return functions->NewLongArray(this, length); }
NewFloatArray_JNIEnv878     jfloatArray NewFloatArray(jsize length)
879     { return functions->NewFloatArray(this, length); }
NewDoubleArray_JNIEnv880     jdoubleArray NewDoubleArray(jsize length)
881     { return functions->NewDoubleArray(this, length); }
882 
GetBooleanArrayElements_JNIEnv883     jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy)
884     { return functions->GetBooleanArrayElements(this, array, isCopy); }
GetByteArrayElements_JNIEnv885     jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy)
886     { return functions->GetByteArrayElements(this, array, isCopy); }
GetCharArrayElements_JNIEnv887     jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy)
888     { return functions->GetCharArrayElements(this, array, isCopy); }
GetShortArrayElements_JNIEnv889     jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy)
890     { return functions->GetShortArrayElements(this, array, isCopy); }
GetIntArrayElements_JNIEnv891     jint* GetIntArrayElements(jintArray array, jboolean* isCopy)
892     { return functions->GetIntArrayElements(this, array, isCopy); }
GetLongArrayElements_JNIEnv893     jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy)
894     { return functions->GetLongArrayElements(this, array, isCopy); }
GetFloatArrayElements_JNIEnv895     jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy)
896     { return functions->GetFloatArrayElements(this, array, isCopy); }
GetDoubleArrayElements_JNIEnv897     jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy)
898     { return functions->GetDoubleArrayElements(this, array, isCopy); }
899 
ReleaseBooleanArrayElements_JNIEnv900     void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems,
901         jint mode)
902     { functions->ReleaseBooleanArrayElements(this, array, elems, mode); }
ReleaseByteArrayElements_JNIEnv903     void ReleaseByteArrayElements(jbyteArray array, jbyte* elems,
904         jint mode)
905     { functions->ReleaseByteArrayElements(this, array, elems, mode); }
ReleaseCharArrayElements_JNIEnv906     void ReleaseCharArrayElements(jcharArray array, jchar* elems,
907         jint mode)
908     { functions->ReleaseCharArrayElements(this, array, elems, mode); }
ReleaseShortArrayElements_JNIEnv909     void ReleaseShortArrayElements(jshortArray array, jshort* elems,
910         jint mode)
911     { functions->ReleaseShortArrayElements(this, array, elems, mode); }
ReleaseIntArrayElements_JNIEnv912     void ReleaseIntArrayElements(jintArray array, jint* elems,
913         jint mode)
914     { functions->ReleaseIntArrayElements(this, array, elems, mode); }
ReleaseLongArrayElements_JNIEnv915     void ReleaseLongArrayElements(jlongArray array, jlong* elems,
916         jint mode)
917     { functions->ReleaseLongArrayElements(this, array, elems, mode); }
ReleaseFloatArrayElements_JNIEnv918     void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems,
919         jint mode)
920     { functions->ReleaseFloatArrayElements(this, array, elems, mode); }
ReleaseDoubleArrayElements_JNIEnv921     void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems,
922         jint mode)
923     { functions->ReleaseDoubleArrayElements(this, array, elems, mode); }
924 
GetBooleanArrayRegion_JNIEnv925     void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
926         jboolean* buf)
927     { functions->GetBooleanArrayRegion(this, array, start, len, buf); }
GetByteArrayRegion_JNIEnv928     void GetByteArrayRegion(jbyteArray array, jsize start, jsize len,
929         jbyte* buf)
930     { functions->GetByteArrayRegion(this, array, start, len, buf); }
GetCharArrayRegion_JNIEnv931     void GetCharArrayRegion(jcharArray array, jsize start, jsize len,
932         jchar* buf)
933     { functions->GetCharArrayRegion(this, array, start, len, buf); }
GetShortArrayRegion_JNIEnv934     void GetShortArrayRegion(jshortArray array, jsize start, jsize len,
935         jshort* buf)
936     { functions->GetShortArrayRegion(this, array, start, len, buf); }
GetIntArrayRegion_JNIEnv937     void GetIntArrayRegion(jintArray array, jsize start, jsize len,
938         jint* buf)
939     { functions->GetIntArrayRegion(this, array, start, len, buf); }
GetLongArrayRegion_JNIEnv940     void GetLongArrayRegion(jlongArray array, jsize start, jsize len,
941         jlong* buf)
942     { functions->GetLongArrayRegion(this, array, start, len, buf); }
GetFloatArrayRegion_JNIEnv943     void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
944         jfloat* buf)
945     { functions->GetFloatArrayRegion(this, array, start, len, buf); }
GetDoubleArrayRegion_JNIEnv946     void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
947         jdouble* buf)
948     { functions->GetDoubleArrayRegion(this, array, start, len, buf); }
949 
SetBooleanArrayRegion_JNIEnv950     void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
951         const jboolean* buf)
952     { functions->SetBooleanArrayRegion(this, array, start, len, buf); }
SetByteArrayRegion_JNIEnv953     void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
954         const jbyte* buf)
955     { functions->SetByteArrayRegion(this, array, start, len, buf); }
SetCharArrayRegion_JNIEnv956     void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
957         const jchar* buf)
958     { functions->SetCharArrayRegion(this, array, start, len, buf); }
SetShortArrayRegion_JNIEnv959     void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
960         const jshort* buf)
961     { functions->SetShortArrayRegion(this, array, start, len, buf); }
SetIntArrayRegion_JNIEnv962     void SetIntArrayRegion(jintArray array, jsize start, jsize len,
963         const jint* buf)
964     { functions->SetIntArrayRegion(this, array, start, len, buf); }
SetLongArrayRegion_JNIEnv965     void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
966         const jlong* buf)
967     { functions->SetLongArrayRegion(this, array, start, len, buf); }
SetFloatArrayRegion_JNIEnv968     void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
969         const jfloat* buf)
970     { functions->SetFloatArrayRegion(this, array, start, len, buf); }
SetDoubleArrayRegion_JNIEnv971     void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
972         const jdouble* buf)
973     { functions->SetDoubleArrayRegion(this, array, start, len, buf); }
974 
RegisterNatives_JNIEnv975     jint RegisterNatives(jclass clazz, const JNINativeMethod* methods,
976         jint nMethods)
977     { return functions->RegisterNatives(this, clazz, methods, nMethods); }
978 
UnregisterNatives_JNIEnv979     jint UnregisterNatives(jclass clazz)
980     { return functions->UnregisterNatives(this, clazz); }
981 
MonitorEnter_JNIEnv982     jint MonitorEnter(jobject obj)
983     { return functions->MonitorEnter(this, obj); }
984 
MonitorExit_JNIEnv985     jint MonitorExit(jobject obj)
986     { return functions->MonitorExit(this, obj); }
987 
GetJavaVM_JNIEnv988     jint GetJavaVM(JavaVM** vm)
989     { return functions->GetJavaVM(this, vm); }
990 
GetStringRegion_JNIEnv991     void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf)
992     { functions->GetStringRegion(this, str, start, len, buf); }
993 
GetStringUTFRegion_JNIEnv994     void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf)
995     { return functions->GetStringUTFRegion(this, str, start, len, buf); }
996 
GetPrimitiveArrayCritical_JNIEnv997     void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy)
998     { return functions->GetPrimitiveArrayCritical(this, array, isCopy); }
999 
ReleasePrimitiveArrayCritical_JNIEnv1000     void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode)
1001     { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); }
1002 
GetStringCritical_JNIEnv1003     const jchar* GetStringCritical(jstring string, jboolean* isCopy)
1004     { return functions->GetStringCritical(this, string, isCopy); }
1005 
ReleaseStringCritical_JNIEnv1006     void ReleaseStringCritical(jstring string, const jchar* carray)
1007     { functions->ReleaseStringCritical(this, string, carray); }
1008 
NewWeakGlobalRef_JNIEnv1009     jweak NewWeakGlobalRef(jobject obj)
1010     { return functions->NewWeakGlobalRef(this, obj); }
1011 
DeleteWeakGlobalRef_JNIEnv1012     void DeleteWeakGlobalRef(jweak obj)
1013     { functions->DeleteWeakGlobalRef(this, obj); }
1014 
ExceptionCheck_JNIEnv1015     jboolean ExceptionCheck()
1016     { return functions->ExceptionCheck(this); }
1017 
NewDirectByteBuffer_JNIEnv1018     jobject NewDirectByteBuffer(void* address, jlong capacity)
1019     { return functions->NewDirectByteBuffer(this, address, capacity); }
1020 
GetDirectBufferAddress_JNIEnv1021     void* GetDirectBufferAddress(jobject buf)
1022     { return functions->GetDirectBufferAddress(this, buf); }
1023 
GetDirectBufferCapacity_JNIEnv1024     jlong GetDirectBufferCapacity(jobject buf)
1025     { return functions->GetDirectBufferCapacity(this, buf); }
1026 
1027     /* added in JNI 1.6 */
GetObjectRefType_JNIEnv1028     jobjectRefType GetObjectRefType(jobject obj)
1029     { return functions->GetObjectRefType(this, obj); }
1030 #endif /*__cplusplus*/
1031 };
1032 
1033 
1034 /*
1035  * JNI invocation interface.
1036  */
1037 struct JNIInvokeInterface {
1038     void*       reserved0;
1039     void*       reserved1;
1040     void*       reserved2;
1041 
1042     jint        (*DestroyJavaVM)(JavaVM*);
1043     jint        (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*);
1044     jint        (*DetachCurrentThread)(JavaVM*);
1045     jint        (*GetEnv)(JavaVM*, void**, jint);
1046     jint        (*AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*);
1047 };
1048 
1049 /*
1050  * C++ version.
1051  */
1052 struct _JavaVM {
1053     const struct JNIInvokeInterface* functions;
1054 
1055 #if defined(__cplusplus)
DestroyJavaVM_JavaVM1056     jint DestroyJavaVM()
1057     { return functions->DestroyJavaVM(this); }
AttachCurrentThread_JavaVM1058     jint AttachCurrentThread(JNIEnv** p_env, void* thr_args)
1059     { return functions->AttachCurrentThread(this, p_env, thr_args); }
DetachCurrentThread_JavaVM1060     jint DetachCurrentThread()
1061     { return functions->DetachCurrentThread(this); }
GetEnv_JavaVM1062     jint GetEnv(void** env, jint version)
1063     { return functions->GetEnv(this, env, version); }
AttachCurrentThreadAsDaemon_JavaVM1064     jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args)
1065     { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); }
1066 #endif /*__cplusplus*/
1067 };
1068 
1069 struct JavaVMAttachArgs {
1070     jint        version;    /* must be >= JNI_VERSION_1_2 */
1071     const char* name;       /* NULL or name of thread as modified UTF-8 str */
1072     jobject     group;      /* global ref of a ThreadGroup object, or NULL */
1073 };
1074 typedef struct JavaVMAttachArgs JavaVMAttachArgs;
1075 
1076 /*
1077  * JNI 1.2+ initialization.  (As of 1.6, the pre-1.2 structures are no
1078  * longer supported.)
1079  */
1080 typedef struct JavaVMOption {
1081     const char* optionString;
1082     void*       extraInfo;
1083 } JavaVMOption;
1084 
1085 typedef struct JavaVMInitArgs {
1086     jint        version;    /* use JNI_VERSION_1_2 or later */
1087 
1088     jint        nOptions;
1089     JavaVMOption* options;
1090     jboolean    ignoreUnrecognized;
1091 } JavaVMInitArgs;
1092 
1093 #ifdef __cplusplus
1094 extern "C" {
1095 #endif
1096 /*
1097  * VM initialization functions.
1098  *
1099  * Note these are the only symbols exported for JNI by the VM.
1100  */
1101 jint JNI_GetDefaultJavaVMInitArgs(void*);
1102 jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
1103 jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
1104 
1105 #define JNIIMPORT
1106 #define JNIEXPORT  __attribute__ ((visibility ("default")))
1107 #define JNICALL
1108 
1109 /*
1110  * Prototypes for functions exported by loadable shared libs.  These are
1111  * called by JNI, not provided by JNI.
1112  */
1113 JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved);
1114 JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved);
1115 
1116 #ifdef __cplusplus
1117 }
1118 #endif
1119 
1120 
1121 /*
1122  * Manifest constants.
1123  */
1124 #define JNI_FALSE   0
1125 #define JNI_TRUE    1
1126 
1127 #define JNI_VERSION_1_1 0x00010001
1128 #define JNI_VERSION_1_2 0x00010002
1129 #define JNI_VERSION_1_4 0x00010004
1130 #define JNI_VERSION_1_6 0x00010006
1131 
1132 #define JNI_OK          (0)         /* no error */
1133 #define JNI_ERR         (-1)        /* generic error */
1134 #define JNI_EDETACHED   (-2)        /* thread detached from the VM */
1135 #define JNI_EVERSION    (-3)        /* JNI version error */
1136 #define JNI_ENOMEM      (-4)        /* Out of memory */
1137 #define JNI_EEXIST      (-5)        /* VM already created */
1138 #define JNI_EINVAL      (-6)        /* Invalid argument */
1139 
1140 #define JNI_COMMIT      1           /* copy content, do not free buffer */
1141 #define JNI_ABORT       2           /* free buffer w/o copying back */
1142 
1143 #endif  /* JNI_H_ */
1144