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