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