Home | History | Annotate | Download | only in include
      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 
     29 /*
     30  * Primitive types that match up with Java equivalents.
     31  */
     32 #ifdef HAVE_INTTYPES_H
     33 # include <inttypes.h>      /* C99 */
     34 typedef uint8_t         jboolean;       /* unsigned 8 bits */
     35 typedef int8_t          jbyte;          /* signed 8 bits */
     36 typedef uint16_t        jchar;          /* unsigned 16 bits */
     37 typedef int16_t         jshort;         /* signed 16 bits */
     38 typedef int32_t         jint;           /* signed 32 bits */
     39 typedef int64_t         jlong;          /* signed 64 bits */
     40 typedef float           jfloat;         /* 32-bit IEEE 754 */
     41 typedef double          jdouble;        /* 64-bit IEEE 754 */
     42 #else
     43 typedef unsigned char   jboolean;       /* unsigned 8 bits */
     44 typedef signed char     jbyte;          /* signed 8 bits */
     45 typedef unsigned short  jchar;          /* unsigned 16 bits */
     46 typedef short           jshort;         /* signed 16 bits */
     47 typedef int             jint;           /* signed 32 bits */
     48 typedef long long       jlong;          /* signed 64 bits */
     49 typedef float           jfloat;         /* 32-bit IEEE 754 */
     50 typedef double          jdouble;        /* 64-bit IEEE 754 */
     51 #endif
     52 
     53 /* "cardinal indices and sizes" */
     54 typedef jint            jsize;
     55 
     56 #ifdef __cplusplus
     57 /*
     58  * Reference types, in C++
     59  */
     60 class _jobject {};
     61 class _jclass : public _jobject {};
     62 class _jstring : public _jobject {};
     63 class _jarray : public _jobject {};
     64 class _jobjectArray : public _jarray {};
     65 class _jbooleanArray : public _jarray {};
     66 class _jbyteArray : public _jarray {};
     67 class _jcharArray : public _jarray {};
     68 class _jshortArray : public _jarray {};
     69 class _jintArray : public _jarray {};
     70 class _jlongArray : public _jarray {};
     71 class _jfloatArray : public _jarray {};
     72 class _jdoubleArray : public _jarray {};
     73 class _jthrowable : public _jobject {};
     74 
     75 typedef _jobject*       jobject;
     76 typedef _jclass*        jclass;
     77 typedef _jstring*       jstring;
     78 typedef _jarray*        jarray;
     79 typedef _jobjectArray*  jobjectArray;
     80 typedef _jbooleanArray* jbooleanArray;
     81 typedef _jbyteArray*    jbyteArray;
     82 typedef _jcharArray*    jcharArray;
     83 typedef _jshortArray*   jshortArray;
     84 typedef _jintArray*     jintArray;
     85 typedef _jlongArray*    jlongArray;
     86 typedef _jfloatArray*   jfloatArray;
     87 typedef _jdoubleArray*  jdoubleArray;
     88 typedef _jthrowable*    jthrowable;
     89 typedef _jobject*       jweak;
     90 
     91 
     92 #else /* not __cplusplus */
     93 
     94 /*
     95  * Reference types, in C.
     96  */
     97 typedef void*           jobject;
     98 typedef jobject         jclass;
     99 typedef jobject         jstring;
    100 typedef jobject         jarray;
    101 typedef jarray          jobjectArray;
    102 typedef jarray          jbooleanArray;
    103 typedef jarray          jbyteArray;
    104 typedef jarray          jcharArray;
    105 typedef jarray          jshortArray;
    106 typedef jarray          jintArray;
    107 typedef jarray          jlongArray;
    108 typedef jarray          jfloatArray;
    109 typedef jarray          jdoubleArray;
    110 typedef jobject         jthrowable;
    111 typedef jobject         jweak;
    112 
    113 #endif /* not __cplusplus */
    114 
    115 struct _jfieldID;                       /* opaque structure */
    116 typedef struct _jfieldID* jfieldID;     /* field IDs */
    117 
    118 struct _jmethodID;                      /* opaque structure */
    119 typedef struct _jmethodID* jmethodID;   /* method IDs */
    120 
    121 struct JNIInvokeInterface;
    122 
    123 typedef union jvalue {
    124     jboolean    z;
    125     jbyte       b;
    126     jchar       c;
    127     jshort      s;
    128     jint        i;
    129     jlong       j;
    130     jfloat      f;
    131     jdouble     d;
    132     jobject     l;
    133 } jvalue;
    134 
    135 typedef enum jobjectRefType {
    136     JNIInvalidRefType = 0,
    137     JNILocalRefType = 1,
    138     JNIGlobalRefType = 2,
    139     JNIWeakGlobalRefType = 3
    140 } jobjectRefType;
    141 
    142 typedef struct {
    143     const char* name;
    144     const char* signature;
    145     void*       fnPtr;
    146 } JNINativeMethod;
    147 
    148 struct _JNIEnv;
    149 struct _JavaVM;
    150 typedef const struct JNINativeInterface* C_JNIEnv;
    151 
    152 #if defined(__cplusplus)
    153 typedef _JNIEnv JNIEnv;
    154 typedef _JavaVM JavaVM;
    155 #else
    156 typedef const struct JNINativeInterface* JNIEnv;
    157 typedef const struct JNIInvokeInterface* JavaVM;
    158 #endif
    159 
    160 /*
    161  * Table of interface function pointers.
    162  */
    163 struct JNINativeInterface {
    164     void*       reserved0;
    165     void*       reserved1;
    166     void*       reserved2;
    167     void*       reserved3;
    168 
    169     jint        (*GetVersion)(JNIEnv *);
    170 
    171     jclass      (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*,
    172                         jsize);
    173     jclass      (*FindClass)(JNIEnv*, const char*);
    174 
    175     jmethodID   (*FromReflectedMethod)(JNIEnv*, jobject);
    176     jfieldID    (*FromReflectedField)(JNIEnv*, jobject);
    177     /* spec doesn't show jboolean parameter */
    178     jobject     (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean);
    179 
    180     jclass      (*GetSuperclass)(JNIEnv*, jclass);
    181     jboolean    (*IsAssignableFrom)(JNIEnv*, jclass, jclass);
    182 
    183     /* spec doesn't show jboolean parameter */
    184     jobject     (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean);
    185 
    186     jint        (*Throw)(JNIEnv*, jthrowable);
    187     jint        (*ThrowNew)(JNIEnv *, jclass, const char *);
    188     jthrowable  (*ExceptionOccurred)(JNIEnv*);
    189     void        (*ExceptionDescribe)(JNIEnv*);
    190     void        (*ExceptionClear)(JNIEnv*);
    191     void        (*FatalError)(JNIEnv*, const char*);
    192 
    193     jint        (*PushLocalFrame)(JNIEnv*, jint);
    194     jobject     (*PopLocalFrame)(JNIEnv*, jobject);
    195 
    196     jobject     (*NewGlobalRef)(JNIEnv*, jobject);
    197     void        (*DeleteGlobalRef)(JNIEnv*, jobject);
    198     void        (*DeleteLocalRef)(JNIEnv*, jobject);
    199     jboolean    (*IsSameObject)(JNIEnv*, jobject, jobject);
    200 
    201     jobject     (*NewLocalRef)(JNIEnv*, jobject);
    202     jint        (*EnsureLocalCapacity)(JNIEnv*, jint);
    203 
    204     jobject     (*AllocObject)(JNIEnv*, jclass);
    205     jobject     (*NewObject)(JNIEnv*, jclass, jmethodID, ...);
    206     jobject     (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list);
    207     jobject     (*NewObjectA)(JNIEnv*, jclass, jmethodID, jvalue*);
    208 
    209     jclass      (*GetObjectClass)(JNIEnv*, jobject);
    210     jboolean    (*IsInstanceOf)(JNIEnv*, jobject, jclass);
    211     jmethodID   (*GetMethodID)(JNIEnv*, jclass, const char*, const char*);
    212 
    213     jobject     (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...);
    214     jobject     (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    215     jobject     (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    216     jboolean    (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...);
    217     jboolean    (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    218     jboolean    (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    219     jbyte       (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...);
    220     jbyte       (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    221     jbyte       (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    222     jchar       (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...);
    223     jchar       (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    224     jchar       (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    225     jshort      (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...);
    226     jshort      (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    227     jshort      (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    228     jint        (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...);
    229     jint        (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    230     jint        (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    231     jlong       (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...);
    232     jlong       (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    233     jlong       (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    234     jfloat      (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...);
    235     jfloat      (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    236     jfloat      (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    237     jdouble     (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...);
    238     jdouble     (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    239     jdouble     (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    240     void        (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...);
    241     void        (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list);
    242     void        (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, jvalue*);
    243 
    244     jobject     (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass,
    245                         jmethodID, ...);
    246     jobject     (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass,
    247                         jmethodID, va_list);
    248     jobject     (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass,
    249                         jmethodID, jvalue*);
    250     jboolean    (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass,
    251                         jmethodID, ...);
    252     jboolean    (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass,
    253                          jmethodID, va_list);
    254     jboolean    (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass,
    255                          jmethodID, jvalue*);
    256     jbyte       (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass,
    257                         jmethodID, ...);
    258     jbyte       (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass,
    259                         jmethodID, va_list);
    260     jbyte       (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass,
    261                         jmethodID, jvalue*);
    262     jchar       (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass,
    263                         jmethodID, ...);
    264     jchar       (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass,
    265                         jmethodID, va_list);
    266     jchar       (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass,
    267                         jmethodID, jvalue*);
    268     jshort      (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass,
    269                         jmethodID, ...);
    270     jshort      (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass,
    271                         jmethodID, va_list);
    272     jshort      (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass,
    273                         jmethodID, jvalue*);
    274     jint        (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass,
    275                         jmethodID, ...);
    276     jint        (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass,
    277                         jmethodID, va_list);
    278     jint        (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass,
    279                         jmethodID, jvalue*);
    280     jlong       (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass,
    281                         jmethodID, ...);
    282     jlong       (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass,
    283                         jmethodID, va_list);
    284     jlong       (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass,
    285                         jmethodID, jvalue*);
    286     jfloat      (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass,
    287                         jmethodID, ...);
    288     jfloat      (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass,
    289                         jmethodID, va_list);
    290     jfloat      (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass,
    291                         jmethodID, jvalue*);
    292     jdouble     (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass,
    293                         jmethodID, ...);
    294     jdouble     (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass,
    295                         jmethodID, va_list);
    296     jdouble     (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass,
    297                         jmethodID, jvalue*);
    298     void        (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass,
    299                         jmethodID, ...);
    300     void        (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass,
    301                         jmethodID, va_list);
    302     void        (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass,
    303                         jmethodID, jvalue*);
    304 
    305     jfieldID    (*GetFieldID)(JNIEnv*, jclass, const char*, const char*);
    306 
    307     jobject     (*GetObjectField)(JNIEnv*, jobject, jfieldID);
    308     jboolean    (*GetBooleanField)(JNIEnv*, jobject, jfieldID);
    309     jbyte       (*GetByteField)(JNIEnv*, jobject, jfieldID);
    310     jchar       (*GetCharField)(JNIEnv*, jobject, jfieldID);
    311     jshort      (*GetShortField)(JNIEnv*, jobject, jfieldID);
    312     jint        (*GetIntField)(JNIEnv*, jobject, jfieldID);
    313     jlong       (*GetLongField)(JNIEnv*, jobject, jfieldID);
    314     jfloat      (*GetFloatField)(JNIEnv*, jobject, jfieldID);
    315     jdouble     (*GetDoubleField)(JNIEnv*, jobject, jfieldID);
    316 
    317     void        (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject);
    318     void        (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean);
    319     void        (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte);
    320     void        (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar);
    321     void        (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort);
    322     void        (*SetIntField)(JNIEnv*, jobject, jfieldID, jint);
    323     void        (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong);
    324     void        (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat);
    325     void        (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble);
    326 
    327     jmethodID   (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*);
    328 
    329     jobject     (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...);
    330     jobject     (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    331     jobject     (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    332     jboolean    (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...);
    333     jboolean    (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID,
    334                         va_list);
    335     jboolean    (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID,
    336                         jvalue*);
    337     jbyte       (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...);
    338     jbyte       (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    339     jbyte       (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    340     jchar       (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...);
    341     jchar       (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    342     jchar       (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    343     jshort      (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...);
    344     jshort      (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    345     jshort      (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    346     jint        (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...);
    347     jint        (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    348     jint        (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    349     jlong       (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...);
    350     jlong       (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    351     jlong       (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    352     jfloat      (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...);
    353     jfloat      (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    354     jfloat      (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    355     jdouble     (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...);
    356     jdouble     (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    357     jdouble     (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    358     void        (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...);
    359     void        (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list);
    360     void        (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*);
    361 
    362     jfieldID    (*GetStaticFieldID)(JNIEnv*, jclass, const char*,
    363                         const char*);
    364 
    365     jobject     (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID);
    366     jboolean    (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID);
    367     jbyte       (*GetStaticByteField)(JNIEnv*, jclass, jfieldID);
    368     jchar       (*GetStaticCharField)(JNIEnv*, jclass, jfieldID);
    369     jshort      (*GetStaticShortField)(JNIEnv*, jclass, jfieldID);
    370     jint        (*GetStaticIntField)(JNIEnv*, jclass, jfieldID);
    371     jlong       (*GetStaticLongField)(JNIEnv*, jclass, jfieldID);
    372     jfloat      (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID);
    373     jdouble     (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID);
    374 
    375     void        (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject);
    376     void        (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean);
    377     void        (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte);
    378     void        (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar);
    379     void        (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort);
    380     void        (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint);
    381     void        (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong);
    382     void        (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat);
    383     void        (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble);
    384 
    385     jstring     (*NewString)(JNIEnv*, const jchar*, jsize);
    386     jsize       (*GetStringLength)(JNIEnv*, jstring);
    387     const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*);
    388     void        (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*);
    389     jstring     (*NewStringUTF)(JNIEnv*, const char*);
    390     jsize       (*GetStringUTFLength)(JNIEnv*, jstring);
    391     /* JNI spec says this returns const jbyte*, but that's inconsistent */
    392     const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*);
    393     void        (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*);
    394     jsize       (*GetArrayLength)(JNIEnv*, jarray);
    395     jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject);
    396     jobject     (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize);
    397     void        (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject);
    398 
    399     jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize);
    400     jbyteArray    (*NewByteArray)(JNIEnv*, jsize);
    401     jcharArray    (*NewCharArray)(JNIEnv*, jsize);
    402     jshortArray   (*NewShortArray)(JNIEnv*, jsize);
    403     jintArray     (*NewIntArray)(JNIEnv*, jsize);
    404     jlongArray    (*NewLongArray)(JNIEnv*, jsize);
    405     jfloatArray   (*NewFloatArray)(JNIEnv*, jsize);
    406     jdoubleArray  (*NewDoubleArray)(JNIEnv*, jsize);
    407 
    408     jboolean*   (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*);
    409     jbyte*      (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*);
    410     jchar*      (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*);
    411     jshort*     (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*);
    412     jint*       (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*);
    413     jlong*      (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*);
    414     jfloat*     (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*);
    415     jdouble*    (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*);
    416 
    417     void        (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray,
    418                         jboolean*, jint);
    419     void        (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray,
    420                         jbyte*, jint);
    421     void        (*ReleaseCharArrayElements)(JNIEnv*, jcharArray,
    422                         jchar*, jint);
    423     void        (*ReleaseShortArrayElements)(JNIEnv*, jshortArray,
    424                         jshort*, jint);
    425     void        (*ReleaseIntArrayElements)(JNIEnv*, jintArray,
    426                         jint*, jint);
    427     void        (*ReleaseLongArrayElements)(JNIEnv*, jlongArray,
    428                         jlong*, jint);
    429     void        (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray,
    430                         jfloat*, jint);
    431     void        (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray,
    432                         jdouble*, jint);
    433 
    434     void        (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
    435                         jsize, jsize, jboolean*);
    436     void        (*GetByteArrayRegion)(JNIEnv*, jbyteArray,
    437                         jsize, jsize, jbyte*);
    438     void        (*GetCharArrayRegion)(JNIEnv*, jcharArray,
    439                         jsize, jsize, jchar*);
    440     void        (*GetShortArrayRegion)(JNIEnv*, jshortArray,
    441                         jsize, jsize, jshort*);
    442     void        (*GetIntArrayRegion)(JNIEnv*, jintArray,
    443                         jsize, jsize, jint*);
    444     void        (*GetLongArrayRegion)(JNIEnv*, jlongArray,
    445                         jsize, jsize, jlong*);
    446     void        (*GetFloatArrayRegion)(JNIEnv*, jfloatArray,
    447                         jsize, jsize, jfloat*);
    448     void        (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
    449                         jsize, jsize, jdouble*);
    450 
    451     /* spec shows these without const; some jni.h do, some don't */
    452     void        (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
    453                         jsize, jsize, const jboolean*);
    454     void        (*SetByteArrayRegion)(JNIEnv*, jbyteArray,
    455                         jsize, jsize, const jbyte*);
    456     void        (*SetCharArrayRegion)(JNIEnv*, jcharArray,
    457                         jsize, jsize, const jchar*);
    458     void        (*SetShortArrayRegion)(JNIEnv*, jshortArray,
    459                         jsize, jsize, const jshort*);
    460     void        (*SetIntArrayRegion)(JNIEnv*, jintArray,
    461                         jsize, jsize, const jint*);
    462     void        (*SetLongArrayRegion)(JNIEnv*, jlongArray,
    463                         jsize, jsize, const jlong*);
    464     void        (*SetFloatArrayRegion)(JNIEnv*, jfloatArray,
    465                         jsize, jsize, const jfloat*);
    466     void        (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
    467                         jsize, jsize, const jdouble*);
    468 
    469     jint        (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*,
    470                         jint);
    471     jint        (*UnregisterNatives)(JNIEnv*, jclass);
    472     jint        (*MonitorEnter)(JNIEnv*, jobject);
    473     jint        (*MonitorExit)(JNIEnv*, jobject);
    474     jint        (*GetJavaVM)(JNIEnv*, JavaVM**);
    475 
    476     void        (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*);
    477     void        (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*);
    478 
    479     void*       (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*);
    480     void        (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint);
    481 
    482     const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*);
    483     void        (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*);
    484 
    485     jweak       (*NewWeakGlobalRef)(JNIEnv*, jobject);
    486     void        (*DeleteWeakGlobalRef)(JNIEnv*, jweak);
    487 
    488     jboolean    (*ExceptionCheck)(JNIEnv*);
    489 
    490     jobject     (*NewDirectByteBuffer)(JNIEnv*, void*, jlong);
    491     void*       (*GetDirectBufferAddress)(JNIEnv*, jobject);
    492     jlong       (*GetDirectBufferCapacity)(JNIEnv*, jobject);
    493 
    494     /* added in JNI 1.6 */
    495     jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject);
    496 };
    497 
    498 /*
    499  * C++ object wrapper.
    500  *
    501  * This is usually overlaid on a C struct whose first element is a
    502  * JNINativeInterface*.  We rely somewhat on compiler behavior.
    503  */
    504 struct _JNIEnv {
    505     /* do not rename this; it does not seem to be entirely opaque */
    506     const struct JNINativeInterface* functions;
    507 
    508 #if defined(__cplusplus)
    509 
    510     jint GetVersion()
    511     { return functions->GetVersion(this); }
    512 
    513     jclass DefineClass(const char *name, jobject loader, const jbyte* buf,
    514         jsize bufLen)
    515     { return functions->DefineClass(this, name, loader, buf, bufLen); }
    516 
    517     jclass FindClass(const char* name)
    518     { return functions->FindClass(this, name); }
    519 
    520     jmethodID FromReflectedMethod(jobject method)
    521     { return functions->FromReflectedMethod(this, method); }
    522 
    523     jfieldID FromReflectedField(jobject field)
    524     { return functions->FromReflectedField(this, field); }
    525 
    526     jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic)
    527     { return functions->ToReflectedMethod(this, cls, methodID, isStatic); }
    528 
    529     jclass GetSuperclass(jclass clazz)
    530     { return functions->GetSuperclass(this, clazz); }
    531 
    532     jboolean IsAssignableFrom(jclass clazz1, jclass clazz2)
    533     { return functions->IsAssignableFrom(this, clazz1, clazz2); }
    534 
    535     jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic)
    536     { return functions->ToReflectedField(this, cls, fieldID, isStatic); }
    537 
    538     jint Throw(jthrowable obj)
    539     { return functions->Throw(this, obj); }
    540 
    541     jint ThrowNew(jclass clazz, const char* message)
    542     { return functions->ThrowNew(this, clazz, message); }
    543 
    544     jthrowable ExceptionOccurred()
    545     { return functions->ExceptionOccurred(this); }
    546 
    547     void ExceptionDescribe()
    548     { functions->ExceptionDescribe(this); }
    549 
    550     void ExceptionClear()
    551     { functions->ExceptionClear(this); }
    552 
    553     void FatalError(const char* msg)
    554     { functions->FatalError(this, msg); }
    555 
    556     jint PushLocalFrame(jint capacity)
    557     { return functions->PushLocalFrame(this, capacity); }
    558 
    559     jobject PopLocalFrame(jobject result)
    560     { return functions->PopLocalFrame(this, result); }
    561 
    562     jobject NewGlobalRef(jobject obj)
    563     { return functions->NewGlobalRef(this, obj); }
    564 
    565     void DeleteGlobalRef(jobject globalRef)
    566     { functions->DeleteGlobalRef(this, globalRef); }
    567 
    568     void DeleteLocalRef(jobject localRef)
    569     { functions->DeleteLocalRef(this, localRef); }
    570 
    571     jboolean IsSameObject(jobject ref1, jobject ref2)
    572     { return functions->IsSameObject(this, ref1, ref2); }
    573 
    574     jobject NewLocalRef(jobject ref)
    575     { return functions->NewLocalRef(this, ref); }
    576 
    577     jint EnsureLocalCapacity(jint capacity)
    578     { return functions->EnsureLocalCapacity(this, capacity); }
    579 
    580     jobject AllocObject(jclass clazz)
    581     { return functions->AllocObject(this, clazz); }
    582 
    583     jobject NewObject(jclass clazz, jmethodID methodID, ...)
    584     {
    585         va_list args;
    586         va_start(args, methodID);
    587         jobject result = functions->NewObjectV(this, clazz, methodID, args);
    588         va_end(args);
    589         return result;
    590     }
    591 
    592     jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args)
    593     { return functions->NewObjectV(this, clazz, methodID, args); }
    594 
    595     jobject NewObjectA(jclass clazz, jmethodID methodID, jvalue* args)
    596     { return functions->NewObjectA(this, clazz, methodID, args); }
    597 
    598     jclass GetObjectClass(jobject obj)
    599     { return functions->GetObjectClass(this, obj); }
    600 
    601     jboolean IsInstanceOf(jobject obj, jclass clazz)
    602     { return functions->IsInstanceOf(this, obj, clazz); }
    603 
    604     jmethodID GetMethodID(jclass clazz, const char* name, const char* sig)
    605     { return functions->GetMethodID(this, clazz, name, sig); }
    606 
    607 #define CALL_TYPE_METHOD(_jtype, _jname)                                    \
    608     _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...)       \
    609     {                                                                       \
    610         _jtype result;                                                      \
    611         va_list args;                                                       \
    612         va_start(args, methodID);                                           \
    613         result = functions->Call##_jname##MethodV(this, obj, methodID,      \
    614                     args);                                                  \
    615         va_end(args);                                                       \
    616         return result;                                                      \
    617     }
    618 #define CALL_TYPE_METHODV(_jtype, _jname)                                   \
    619     _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID,           \
    620         va_list args)                                                       \
    621     { return functions->Call##_jname##MethodV(this, obj, methodID, args); }
    622 #define CALL_TYPE_METHODA(_jtype, _jname)                                   \
    623     _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID,           \
    624         jvalue* args)                                                       \
    625     { return functions->Call##_jname##MethodA(this, obj, methodID, args); }
    626 
    627 #define CALL_TYPE(_jtype, _jname)                                           \
    628     CALL_TYPE_METHOD(_jtype, _jname)                                        \
    629     CALL_TYPE_METHODV(_jtype, _jname)                                       \
    630     CALL_TYPE_METHODA(_jtype, _jname)
    631 
    632     CALL_TYPE(jobject, Object)
    633     CALL_TYPE(jboolean, Boolean)
    634     CALL_TYPE(jbyte, Byte)
    635     CALL_TYPE(jchar, Char)
    636     CALL_TYPE(jshort, Short)
    637     CALL_TYPE(jint, Int)
    638     CALL_TYPE(jlong, Long)
    639     CALL_TYPE(jfloat, Float)
    640     CALL_TYPE(jdouble, Double)
    641 
    642     void CallVoidMethod(jobject obj, jmethodID methodID, ...)
    643     {
    644         va_list args;
    645         va_start(args, methodID);
    646         functions->CallVoidMethodV(this, obj, methodID, args);
    647         va_end(args);
    648     }
    649     void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args)
    650     { functions->CallVoidMethodV(this, obj, methodID, args); }
    651     void CallVoidMethodA(jobject obj, jmethodID methodID, jvalue* args)
    652     { functions->CallVoidMethodA(this, obj, methodID, args); }
    653 
    654 #define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname)                            \
    655     _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz,        \
    656         jmethodID methodID, ...)                                            \
    657     {                                                                       \
    658         _jtype result;                                                      \
    659         va_list args;                                                       \
    660         va_start(args, methodID);                                           \
    661         result = functions->CallNonvirtual##_jname##MethodV(this, obj,      \
    662                     clazz, methodID, args);                                 \
    663         va_end(args);                                                       \
    664         return result;                                                      \
    665     }
    666 #define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname)                           \
    667     _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz,       \
    668         jmethodID methodID, va_list args)                                   \
    669     { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz,   \
    670         methodID, args); }
    671 #define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)                           \
    672     _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz,       \
    673         jmethodID methodID, jvalue* args)                                   \
    674     { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz,   \
    675         methodID, args); }
    676 
    677 #define CALL_NONVIRT_TYPE(_jtype, _jname)                                   \
    678     CALL_NONVIRT_TYPE_METHOD(_jtype, _jname)                                \
    679     CALL_NONVIRT_TYPE_METHODV(_jtype, _jname)                               \
    680     CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)
    681 
    682     CALL_NONVIRT_TYPE(jobject, Object)
    683     CALL_NONVIRT_TYPE(jboolean, Boolean)
    684     CALL_NONVIRT_TYPE(jbyte, Byte)
    685     CALL_NONVIRT_TYPE(jchar, Char)
    686     CALL_NONVIRT_TYPE(jshort, Short)
    687     CALL_NONVIRT_TYPE(jint, Int)
    688     CALL_NONVIRT_TYPE(jlong, Long)
    689     CALL_NONVIRT_TYPE(jfloat, Float)
    690     CALL_NONVIRT_TYPE(jdouble, Double)
    691 
    692     void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
    693         jmethodID methodID, ...)
    694     {
    695         va_list args;
    696         va_start(args, methodID);
    697         functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args);
    698         va_end(args);
    699     }
    700     void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
    701         jmethodID methodID, va_list args)
    702     { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); }
    703     void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
    704         jmethodID methodID, jvalue* args)
    705     { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); }
    706 
    707     jfieldID GetFieldID(jclass clazz, const char* name, const char* sig)
    708     { return functions->GetFieldID(this, clazz, name, sig); }
    709 
    710     jobject GetObjectField(jobject obj, jfieldID fieldID)
    711     { return functions->GetObjectField(this, obj, fieldID); }
    712     jboolean GetBooleanField(jobject obj, jfieldID fieldID)
    713     { return functions->GetBooleanField(this, obj, fieldID); }
    714     jbyte GetByteField(jobject obj, jfieldID fieldID)
    715     { return functions->GetByteField(this, obj, fieldID); }
    716     jchar GetCharField(jobject obj, jfieldID fieldID)
    717     { return functions->GetCharField(this, obj, fieldID); }
    718     jshort GetShortField(jobject obj, jfieldID fieldID)
    719     { return functions->GetShortField(this, obj, fieldID); }
    720     jint GetIntField(jobject obj, jfieldID fieldID)
    721     { return functions->GetIntField(this, obj, fieldID); }
    722     jlong GetLongField(jobject obj, jfieldID fieldID)
    723     { return functions->GetLongField(this, obj, fieldID); }
    724     jfloat GetFloatField(jobject obj, jfieldID fieldID)
    725     { return functions->GetFloatField(this, obj, fieldID); }
    726     jdouble GetDoubleField(jobject obj, jfieldID fieldID)
    727     { return functions->GetDoubleField(this, obj, fieldID); }
    728 
    729     void SetObjectField(jobject obj, jfieldID fieldID, jobject value)
    730     { functions->SetObjectField(this, obj, fieldID, value); }
    731     void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value)
    732     { functions->SetBooleanField(this, obj, fieldID, value); }
    733     void SetByteField(jobject obj, jfieldID fieldID, jbyte value)
    734     { functions->SetByteField(this, obj, fieldID, value); }
    735     void SetCharField(jobject obj, jfieldID fieldID, jchar value)
    736     { functions->SetCharField(this, obj, fieldID, value); }
    737     void SetShortField(jobject obj, jfieldID fieldID, jshort value)
    738     { functions->SetShortField(this, obj, fieldID, value); }
    739     void SetIntField(jobject obj, jfieldID fieldID, jint value)
    740     { functions->SetIntField(this, obj, fieldID, value); }
    741     void SetLongField(jobject obj, jfieldID fieldID, jlong value)
    742     { functions->SetLongField(this, obj, fieldID, value); }
    743     void SetFloatField(jobject obj, jfieldID fieldID, jfloat value)
    744     { functions->SetFloatField(this, obj, fieldID, value); }
    745     void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value)
    746     { functions->SetDoubleField(this, obj, fieldID, value); }
    747 
    748     jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig)
    749     { return functions->GetStaticMethodID(this, clazz, name, sig); }
    750 
    751 #define CALL_STATIC_TYPE_METHOD(_jtype, _jname)                             \
    752     _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID,     \
    753         ...)                                                                \
    754     {                                                                       \
    755         _jtype result;                                                      \
    756         va_list args;                                                       \
    757         va_start(args, methodID);                                           \
    758         result = functions->CallStatic##_jname##MethodV(this, clazz,        \
    759                     methodID, args);                                        \
    760         va_end(args);                                                       \
    761         return result;                                                      \
    762     }
    763 #define CALL_STATIC_TYPE_METHODV(_jtype, _jname)                            \
    764     _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID,    \
    765         va_list args)                                                       \
    766     { return functions->CallStatic##_jname##MethodV(this, clazz, methodID,  \
    767         args); }
    768 #define CALL_STATIC_TYPE_METHODA(_jtype, _jname)                            \
    769     _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID,    \
    770         jvalue* args)                                                       \
    771     { return functions->CallStatic##_jname##MethodA(this, clazz, methodID,  \
    772         args); }
    773 
    774 #define CALL_STATIC_TYPE(_jtype, _jname)                                    \
    775     CALL_STATIC_TYPE_METHOD(_jtype, _jname)                                 \
    776     CALL_STATIC_TYPE_METHODV(_jtype, _jname)                                \
    777     CALL_STATIC_TYPE_METHODA(_jtype, _jname)
    778 
    779     CALL_STATIC_TYPE(jobject, Object)
    780     CALL_STATIC_TYPE(jboolean, Boolean)
    781     CALL_STATIC_TYPE(jbyte, Byte)
    782     CALL_STATIC_TYPE(jchar, Char)
    783     CALL_STATIC_TYPE(jshort, Short)
    784     CALL_STATIC_TYPE(jint, Int)
    785     CALL_STATIC_TYPE(jlong, Long)
    786     CALL_STATIC_TYPE(jfloat, Float)
    787     CALL_STATIC_TYPE(jdouble, Double)
    788 
    789     void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...)
    790     {
    791         va_list args;
    792         va_start(args, methodID);
    793         functions->CallStaticVoidMethodV(this, clazz, methodID, args);
    794         va_end(args);
    795     }
    796     void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args)
    797     { functions->CallStaticVoidMethodV(this, clazz, methodID, args); }
    798     void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, jvalue* args)
    799     { functions->CallStaticVoidMethodA(this, clazz, methodID, args); }
    800 
    801     jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig)
    802     { return functions->GetStaticFieldID(this, clazz, name, sig); }
    803 
    804     jobject GetStaticObjectField(jclass clazz, jfieldID fieldID)
    805     { return functions->GetStaticObjectField(this, clazz, fieldID); }
    806     jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID)
    807     { return functions->GetStaticBooleanField(this, clazz, fieldID); }
    808     jbyte GetStaticByteField(jclass clazz, jfieldID fieldID)
    809     { return functions->GetStaticByteField(this, clazz, fieldID); }
    810     jchar GetStaticCharField(jclass clazz, jfieldID fieldID)
    811     { return functions->GetStaticCharField(this, clazz, fieldID); }
    812     jshort GetStaticShortField(jclass clazz, jfieldID fieldID)
    813     { return functions->GetStaticShortField(this, clazz, fieldID); }
    814     jint GetStaticIntField(jclass clazz, jfieldID fieldID)
    815     { return functions->GetStaticIntField(this, clazz, fieldID); }
    816     jlong GetStaticLongField(jclass clazz, jfieldID fieldID)
    817     { return functions->GetStaticLongField(this, clazz, fieldID); }
    818     jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID)
    819     { return functions->GetStaticFloatField(this, clazz, fieldID); }
    820     jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID)
    821     { return functions->GetStaticDoubleField(this, clazz, fieldID); }
    822 
    823     void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value)
    824     { functions->SetStaticObjectField(this, clazz, fieldID, value); }
    825     void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value)
    826     { functions->SetStaticBooleanField(this, clazz, fieldID, value); }
    827     void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value)
    828     { functions->SetStaticByteField(this, clazz, fieldID, value); }
    829     void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value)
    830     { functions->SetStaticCharField(this, clazz, fieldID, value); }
    831     void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value)
    832     { functions->SetStaticShortField(this, clazz, fieldID, value); }
    833     void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value)
    834     { functions->SetStaticIntField(this, clazz, fieldID, value); }
    835     void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value)
    836     { functions->SetStaticLongField(this, clazz, fieldID, value); }
    837     void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value)
    838     { functions->SetStaticFloatField(this, clazz, fieldID, value); }
    839     void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value)
    840     { functions->SetStaticDoubleField(this, clazz, fieldID, value); }
    841 
    842     jstring NewString(const jchar* unicodeChars, jsize len)
    843     { return functions->NewString(this, unicodeChars, len); }
    844 
    845     jsize GetStringLength(jstring string)
    846     { return functions->GetStringLength(this, string); }
    847 
    848     const jchar* GetStringChars(jstring string, jboolean* isCopy)
    849     { return functions->GetStringChars(this, string, isCopy); }
    850 
    851     void ReleaseStringChars(jstring string, const jchar* chars)
    852     { functions->ReleaseStringChars(this, string, chars); }
    853 
    854     jstring NewStringUTF(const char* bytes)
    855     { return functions->NewStringUTF(this, bytes); }
    856 
    857     jsize GetStringUTFLength(jstring string)
    858     { return functions->GetStringUTFLength(this, string); }
    859 
    860     const char* GetStringUTFChars(jstring string, jboolean* isCopy)
    861     { return functions->GetStringUTFChars(this, string, isCopy); }
    862 
    863     void ReleaseStringUTFChars(jstring string, const char* utf)
    864     { functions->ReleaseStringUTFChars(this, string, utf); }
    865 
    866     jsize GetArrayLength(jarray array)
    867     { return functions->GetArrayLength(this, array); }
    868 
    869     jobjectArray NewObjectArray(jsize length, jclass elementClass,
    870         jobject initialElement)
    871     { return functions->NewObjectArray(this, length, elementClass,
    872         initialElement); }
    873 
    874     jobject GetObjectArrayElement(jobjectArray array, jsize index)
    875     { return functions->GetObjectArrayElement(this, array, index); }
    876 
    877     void SetObjectArrayElement(jobjectArray array, jsize index, jobject value)
    878     { functions->SetObjectArrayElement(this, array, index, value); }
    879 
    880     jbooleanArray NewBooleanArray(jsize length)
    881     { return functions->NewBooleanArray(this, length); }
    882     jbyteArray NewByteArray(jsize length)
    883     { return functions->NewByteArray(this, length); }
    884     jcharArray NewCharArray(jsize length)
    885     { return functions->NewCharArray(this, length); }
    886     jshortArray NewShortArray(jsize length)
    887     { return functions->NewShortArray(this, length); }
    888     jintArray NewIntArray(jsize length)
    889     { return functions->NewIntArray(this, length); }
    890     jlongArray NewLongArray(jsize length)
    891     { return functions->NewLongArray(this, length); }
    892     jfloatArray NewFloatArray(jsize length)
    893     { return functions->NewFloatArray(this, length); }
    894     jdoubleArray NewDoubleArray(jsize length)
    895     { return functions->NewDoubleArray(this, length); }
    896 
    897     jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy)
    898     { return functions->GetBooleanArrayElements(this, array, isCopy); }
    899     jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy)
    900     { return functions->GetByteArrayElements(this, array, isCopy); }
    901     jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy)
    902     { return functions->GetCharArrayElements(this, array, isCopy); }
    903     jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy)
    904     { return functions->GetShortArrayElements(this, array, isCopy); }
    905     jint* GetIntArrayElements(jintArray array, jboolean* isCopy)
    906     { return functions->GetIntArrayElements(this, array, isCopy); }
    907     jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy)
    908     { return functions->GetLongArrayElements(this, array, isCopy); }
    909     jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy)
    910     { return functions->GetFloatArrayElements(this, array, isCopy); }
    911     jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy)
    912     { return functions->GetDoubleArrayElements(this, array, isCopy); }
    913 
    914     void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems,
    915         jint mode)
    916     { functions->ReleaseBooleanArrayElements(this, array, elems, mode); }
    917     void ReleaseByteArrayElements(jbyteArray array, jbyte* elems,
    918         jint mode)
    919     { functions->ReleaseByteArrayElements(this, array, elems, mode); }
    920     void ReleaseCharArrayElements(jcharArray array, jchar* elems,
    921         jint mode)
    922     { functions->ReleaseCharArrayElements(this, array, elems, mode); }
    923     void ReleaseShortArrayElements(jshortArray array, jshort* elems,
    924         jint mode)
    925     { functions->ReleaseShortArrayElements(this, array, elems, mode); }
    926     void ReleaseIntArrayElements(jintArray array, jint* elems,
    927         jint mode)
    928     { functions->ReleaseIntArrayElements(this, array, elems, mode); }
    929     void ReleaseLongArrayElements(jlongArray array, jlong* elems,
    930         jint mode)
    931     { functions->ReleaseLongArrayElements(this, array, elems, mode); }
    932     void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems,
    933         jint mode)
    934     { functions->ReleaseFloatArrayElements(this, array, elems, mode); }
    935     void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems,
    936         jint mode)
    937     { functions->ReleaseDoubleArrayElements(this, array, elems, mode); }
    938 
    939     void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
    940         jboolean* buf)
    941     { functions->GetBooleanArrayRegion(this, array, start, len, buf); }
    942     void GetByteArrayRegion(jbyteArray array, jsize start, jsize len,
    943         jbyte* buf)
    944     { functions->GetByteArrayRegion(this, array, start, len, buf); }
    945     void GetCharArrayRegion(jcharArray array, jsize start, jsize len,
    946         jchar* buf)
    947     { functions->GetCharArrayRegion(this, array, start, len, buf); }
    948     void GetShortArrayRegion(jshortArray array, jsize start, jsize len,
    949         jshort* buf)
    950     { functions->GetShortArrayRegion(this, array, start, len, buf); }
    951     void GetIntArrayRegion(jintArray array, jsize start, jsize len,
    952         jint* buf)
    953     { functions->GetIntArrayRegion(this, array, start, len, buf); }
    954     void GetLongArrayRegion(jlongArray array, jsize start, jsize len,
    955         jlong* buf)
    956     { functions->GetLongArrayRegion(this, array, start, len, buf); }
    957     void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
    958         jfloat* buf)
    959     { functions->GetFloatArrayRegion(this, array, start, len, buf); }
    960     void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
    961         jdouble* buf)
    962     { functions->GetDoubleArrayRegion(this, array, start, len, buf); }
    963 
    964     void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
    965         const jboolean* buf)
    966     { functions->SetBooleanArrayRegion(this, array, start, len, buf); }
    967     void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
    968         const jbyte* buf)
    969     { functions->SetByteArrayRegion(this, array, start, len, buf); }
    970     void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
    971         const jchar* buf)
    972     { functions->SetCharArrayRegion(this, array, start, len, buf); }
    973     void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
    974         const jshort* buf)
    975     { functions->SetShortArrayRegion(this, array, start, len, buf); }
    976     void SetIntArrayRegion(jintArray array, jsize start, jsize len,
    977         const jint* buf)
    978     { functions->SetIntArrayRegion(this, array, start, len, buf); }
    979     void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
    980         const jlong* buf)
    981     { functions->SetLongArrayRegion(this, array, start, len, buf); }
    982     void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
    983         const jfloat* buf)
    984     { functions->SetFloatArrayRegion(this, array, start, len, buf); }
    985     void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
    986         const jdouble* buf)
    987     { functions->SetDoubleArrayRegion(this, array, start, len, buf); }
    988 
    989     jint RegisterNatives(jclass clazz, const JNINativeMethod* methods,
    990         jint nMethods)
    991     { return functions->RegisterNatives(this, clazz, methods, nMethods); }
    992 
    993     jint UnregisterNatives(jclass clazz)
    994     { return functions->UnregisterNatives(this, clazz); }
    995 
    996     jint MonitorEnter(jobject obj)
    997     { return functions->MonitorEnter(this, obj); }
    998 
    999     jint MonitorExit(jobject obj)
   1000     { return functions->MonitorExit(this, obj); }
   1001 
   1002     jint GetJavaVM(JavaVM** vm)
   1003     { return functions->GetJavaVM(this, vm); }
   1004 
   1005     void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf)
   1006     { functions->GetStringRegion(this, str, start, len, buf); }
   1007 
   1008     void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf)
   1009     { return functions->GetStringUTFRegion(this, str, start, len, buf); }
   1010 
   1011     void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy)
   1012     { return functions->GetPrimitiveArrayCritical(this, array, isCopy); }
   1013 
   1014     void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode)
   1015     { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); }
   1016 
   1017     const jchar* GetStringCritical(jstring string, jboolean* isCopy)
   1018     { return functions->GetStringCritical(this, string, isCopy); }
   1019 
   1020     void ReleaseStringCritical(jstring string, const jchar* carray)
   1021     { functions->ReleaseStringCritical(this, string, carray); }
   1022 
   1023     jweak NewWeakGlobalRef(jobject obj)
   1024     { return functions->NewWeakGlobalRef(this, obj); }
   1025 
   1026     void DeleteWeakGlobalRef(jweak obj)
   1027     { functions->DeleteWeakGlobalRef(this, obj); }
   1028 
   1029     jboolean ExceptionCheck()
   1030     { return functions->ExceptionCheck(this); }
   1031 
   1032     jobject NewDirectByteBuffer(void* address, jlong capacity)
   1033     { return functions->NewDirectByteBuffer(this, address, capacity); }
   1034 
   1035     void* GetDirectBufferAddress(jobject buf)
   1036     { return functions->GetDirectBufferAddress(this, buf); }
   1037 
   1038     jlong GetDirectBufferCapacity(jobject buf)
   1039     { return functions->GetDirectBufferCapacity(this, buf); }
   1040 
   1041     /* added in JNI 1.6 */
   1042     jobjectRefType GetObjectRefType(jobject obj)
   1043     { return functions->GetObjectRefType(this, obj); }
   1044 #endif /*__cplusplus*/
   1045 };
   1046 
   1047 
   1048 /*
   1049  * JNI invocation interface.
   1050  */
   1051 struct JNIInvokeInterface {
   1052     void*       reserved0;
   1053     void*       reserved1;
   1054     void*       reserved2;
   1055 
   1056     jint        (*DestroyJavaVM)(JavaVM*);
   1057     jint        (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*);
   1058     jint        (*DetachCurrentThread)(JavaVM*);
   1059     jint        (*GetEnv)(JavaVM*, void**, jint);
   1060     jint        (*AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*);
   1061 };
   1062 
   1063 /*
   1064  * C++ version.
   1065  */
   1066 struct _JavaVM {
   1067     const struct JNIInvokeInterface* functions;
   1068 
   1069 #if defined(__cplusplus)
   1070     jint DestroyJavaVM()
   1071     { return functions->DestroyJavaVM(this); }
   1072     jint AttachCurrentThread(JNIEnv** p_env, void* thr_args)
   1073     { return functions->AttachCurrentThread(this, p_env, thr_args); }
   1074     jint DetachCurrentThread()
   1075     { return functions->DetachCurrentThread(this); }
   1076     jint GetEnv(void** env, jint version)
   1077     { return functions->GetEnv(this, env, version); }
   1078     jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args)
   1079     { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); }
   1080 #endif /*__cplusplus*/
   1081 };
   1082 
   1083 struct JavaVMAttachArgs {
   1084     jint        version;    /* must be >= JNI_VERSION_1_2 */
   1085     const char* name;       /* NULL or name of thread as modified UTF-8 str */
   1086     jobject     group;      /* global ref of a ThreadGroup object, or NULL */
   1087 };
   1088 typedef struct JavaVMAttachArgs JavaVMAttachArgs;
   1089 
   1090 /*
   1091  * JNI 1.2+ initialization.  (As of 1.6, the pre-1.2 structures are no
   1092  * longer supported.)
   1093  */
   1094 typedef struct JavaVMOption {
   1095     const char* optionString;
   1096     void*       extraInfo;
   1097 } JavaVMOption;
   1098 
   1099 typedef struct JavaVMInitArgs {
   1100     jint        version;    /* use JNI_VERSION_1_2 or later */
   1101 
   1102     jint        nOptions;
   1103     JavaVMOption* options;
   1104     jboolean    ignoreUnrecognized;
   1105 } JavaVMInitArgs;
   1106 
   1107 #ifdef __cplusplus
   1108 extern "C" {
   1109 #endif
   1110 /*
   1111  * VM initialization functions.
   1112  *
   1113  * Note these are the only symbols exported for JNI by the VM.
   1114  */
   1115 #if 0  /* In practice, these are not exported by the NDK so don't declare them */
   1116 jint JNI_GetDefaultJavaVMInitArgs(void*);
   1117 jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
   1118 jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
   1119 #endif
   1120 
   1121 #define JNIIMPORT
   1122 #define JNIEXPORT  __attribute__ ((visibility ("default")))
   1123 #define JNICALL
   1124 
   1125 /*
   1126  * Prototypes for functions exported by loadable shared libs.  These are
   1127  * called by JNI, not provided by JNI.
   1128  */
   1129 JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved);
   1130 JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved);
   1131 
   1132 #ifdef __cplusplus
   1133 }
   1134 #endif
   1135 
   1136 
   1137 /*
   1138  * Manifest constants.
   1139  */
   1140 #define JNI_FALSE   0
   1141 #define JNI_TRUE    1
   1142 
   1143 #define JNI_VERSION_1_1 0x00010001
   1144 #define JNI_VERSION_1_2 0x00010002
   1145 #define JNI_VERSION_1_4 0x00010004
   1146 #define JNI_VERSION_1_6 0x00010006
   1147 
   1148 #define JNI_OK          (0)         /* no error */
   1149 #define JNI_ERR         (-1)        /* generic error */
   1150 #define JNI_EDETACHED   (-2)        /* thread detached from the VM */
   1151 #define JNI_EVERSION    (-3)        /* JNI version error */
   1152 
   1153 #define JNI_COMMIT      1           /* copy content, do not free buffer */
   1154 #define JNI_ABORT       2           /* free buffer w/o copying back */
   1155 
   1156 #endif  /* JNI_H_ */
   1157