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