Android jni系统变量、函数、接口定义汇总

时间:2023-03-09 02:01:33
Android jni系统变量、函数、接口定义汇总

在做Android jni开发时,jni为我们提供了哪些函数、接口、变量,有时候一头雾水,今天就把jni.h中定义的所有内容列出来,供自己查阅:

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