annotate src/share/vm/prims/jniCheck.cpp @ 470:ad8c8ca4ab0f

6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
author xdono
date Mon, 15 Dec 2008 16:55:11 -0800
parents dc16daa0329d
children 1760a1cbed36
rev   line source
duke@0 1 /*
xdono@470 2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 # include "incls/_precompiled.incl"
duke@0 26 # include "incls/_jniCheck.cpp.incl"
duke@0 27
duke@0 28
duke@0 29 // Heap objects are allowed to be directly referenced only in VM code,
duke@0 30 // not in native code.
duke@0 31
duke@0 32 #define ASSERT_OOPS_ALLOWED \
duke@0 33 assert(JavaThread::current()->thread_state() == _thread_in_vm, \
duke@0 34 "jniCheck examining oops in bad state.")
duke@0 35
duke@0 36
duke@0 37 // Execute the given block of source code with the thread in VM state.
duke@0 38 // To do this, transition from the NATIVE state to the VM state, execute
duke@0 39 // the code, and transtition back. The ThreadInVMfromNative constructor
duke@0 40 // performs the transition to VM state, its destructor restores the
duke@0 41 // NATIVE state.
duke@0 42
duke@0 43 #define IN_VM(source_code) { \
duke@0 44 { \
duke@0 45 ThreadInVMfromNative __tiv(thr); \
duke@0 46 source_code \
duke@0 47 } \
duke@0 48 }
duke@0 49
duke@0 50
duke@0 51 /*
duke@0 52 * DECLARATIONS
duke@0 53 */
duke@0 54
duke@0 55 static struct JNINativeInterface_ * unchecked_jni_NativeInterface;
duke@0 56
duke@0 57
duke@0 58 /*
duke@0 59 * MACRO DEFINITIONS
duke@0 60 */
duke@0 61
duke@0 62 // All JNI checked functions here use JNI_ENTRY_CHECKED() instead of the
duke@0 63 // QUICK_ENTRY or LEAF variants found in jni.cpp. This allows handles
duke@0 64 // to be created if a fatal error should occur.
duke@0 65
duke@0 66 // Check for thread not attached to VM; need to catch this before
duke@0 67 // assertions in the wrapper routines might fire
duke@0 68
duke@0 69 // Check for env being the one value appropriate for this thread.
duke@0 70
duke@0 71 #define JNI_ENTRY_CHECKED(result_type, header) \
duke@0 72 extern "C" { \
duke@0 73 result_type JNICALL header { \
duke@0 74 JavaThread* thr = (JavaThread*)ThreadLocalStorage::get_thread_slow();\
duke@0 75 if (thr == NULL || !thr->is_Java_thread()) { \
duke@0 76 tty->print_cr(fatal_using_jnienv_in_nonjava); \
duke@0 77 os::abort(true); \
duke@0 78 } \
duke@0 79 JNIEnv* xenv = thr->jni_environment(); \
duke@0 80 if (env != xenv) { \
duke@0 81 NativeReportJNIFatalError(thr, warn_wrong_jnienv); \
duke@0 82 } \
duke@0 83 __ENTRY(result_type, header, thr)
duke@0 84
duke@0 85
duke@0 86 #define UNCHECKED() (unchecked_jni_NativeInterface)
duke@0 87
duke@0 88 static const char * warn_wrong_jnienv = "Using JNIEnv in the wrong thread";
duke@0 89 static const char * warn_bad_class_descriptor = "JNI FindClass received a bad class descriptor \"%s\". A correct class descriptor " \
duke@0 90 "has no leading \"L\" or trailing \";\". Incorrect descriptors will not be accepted in future releases.";
duke@0 91 static const char * fatal_using_jnienv_in_nonjava = "FATAL ERROR in native method: Using JNIEnv in non-Java thread";
duke@0 92 static const char * warn_other_function_in_critical = "Warning: Calling other JNI functions in the scope of " \
duke@0 93 "Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical";
duke@0 94 static const char * fatal_bad_ref_to_jni = "Bad global or local ref passed to JNI";
duke@0 95 static const char * fatal_received_null_class = "JNI received a null class";
duke@0 96 static const char * fatal_class_not_a_class = "JNI received a class argument that is not a class";
duke@0 97 static const char * fatal_class_not_a_throwable_class = "JNI Throw or ThrowNew received a class argument that is not a Throwable or Throwable subclass";
duke@0 98 static const char * fatal_wrong_class_or_method = "Wrong object class or methodID passed to JNI call";
duke@0 99 static const char * fatal_unknown_array_object = "Unknown array object passed to JNI array operations";
duke@0 100 static const char * fatal_object_array_expected = "Object array expected but not received for JNI array operation";
duke@0 101 static const char * fatal_non_array = "Non-array passed to JNI array operations";
duke@0 102 static const char * fatal_element_type_mismatch = "Array element type mismatch in JNI";
duke@0 103 static const char * fatal_should_be_static = "Non-static field ID passed to JNI";
duke@0 104 static const char * fatal_wrong_static_field = "Wrong static field ID passed to JNI";
duke@0 105 static const char * fatal_static_field_not_found = "Static field not found in JNI get/set field operations";
duke@0 106 static const char * fatal_static_field_mismatch = "Field type (static) mismatch in JNI get/set field operations";
duke@0 107 static const char * fatal_should_be_nonstatic = "Static field ID passed to JNI";
duke@0 108 static const char * fatal_null_object = "Null object passed to JNI";
duke@0 109 static const char * fatal_wrong_field = "Wrong field ID passed to JNI";
duke@0 110 static const char * fatal_instance_field_not_found = "Instance field not found in JNI get/set field operations";
duke@0 111 static const char * fatal_instance_field_mismatch = "Field type (instance) mismatch in JNI get/set field operations";
duke@0 112 static const char * fatal_non_string = "JNI string operation received a non-string";
duke@0 113
duke@0 114
duke@0 115 // When in VM state:
duke@0 116 static void ReportJNIWarning(JavaThread* thr, const char *msg) {
duke@0 117 tty->print_cr("WARNING in native method: %s", msg);
duke@0 118 thr->print_stack();
duke@0 119 }
duke@0 120
duke@0 121 // When in NATIVE state:
duke@0 122 static void NativeReportJNIFatalError(JavaThread* thr, const char *msg) {
duke@0 123 IN_VM(
duke@0 124 ReportJNIFatalError(thr, msg);
duke@0 125 )
duke@0 126 }
duke@0 127
duke@0 128 static void NativeReportJNIWarning(JavaThread* thr, const char *msg) {
duke@0 129 IN_VM(
duke@0 130 ReportJNIWarning(thr, msg);
duke@0 131 )
duke@0 132 }
duke@0 133
duke@0 134
duke@0 135
duke@0 136
duke@0 137 /*
duke@0 138 * SUPPORT FUNCTIONS
duke@0 139 */
duke@0 140
duke@0 141 static inline void
duke@0 142 functionEnterCritical(JavaThread* thr)
duke@0 143 {
duke@0 144 if (thr->has_pending_exception()) {
duke@0 145 NativeReportJNIWarning(thr, "JNI call made with exception pending");
duke@0 146 }
duke@0 147 }
duke@0 148
duke@0 149 static inline void
duke@0 150 functionEnterCriticalExceptionAllowed(JavaThread* thr)
duke@0 151 {
duke@0 152 }
duke@0 153
duke@0 154 static inline void
duke@0 155 functionEnter(JavaThread* thr)
duke@0 156 {
duke@0 157 if (thr->in_critical()) {
duke@0 158 tty->print_cr(warn_other_function_in_critical);
duke@0 159 }
duke@0 160 if (thr->has_pending_exception()) {
duke@0 161 NativeReportJNIWarning(thr, "JNI call made with exception pending");
duke@0 162 }
duke@0 163 }
duke@0 164
duke@0 165 static inline void
duke@0 166 functionEnterExceptionAllowed(JavaThread* thr)
duke@0 167 {
duke@0 168 if (thr->in_critical()) {
duke@0 169 tty->print_cr(warn_other_function_in_critical);
duke@0 170 }
duke@0 171 }
duke@0 172
duke@0 173 static inline void
duke@0 174 functionExit(JNIEnv *env)
duke@0 175 {
duke@0 176 /* nothing to do at this time */
duke@0 177 }
duke@0 178
duke@0 179 static inline void
duke@0 180 checkStaticFieldID(JavaThread* thr, jfieldID fid, jclass cls, int ftype)
duke@0 181 {
duke@0 182 fieldDescriptor fd;
duke@0 183
duke@0 184 /* make sure it is a static field */
duke@0 185 if (!jfieldIDWorkaround::is_static_jfieldID(fid))
duke@0 186 ReportJNIFatalError(thr, fatal_should_be_static);
duke@0 187
duke@0 188 /* validate the class being passed */
duke@0 189 ASSERT_OOPS_ALLOWED;
duke@0 190 klassOop k_oop = jniCheck::validate_class(thr, cls, false);
duke@0 191
duke@0 192 /* check for proper subclass hierarchy */
duke@0 193 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fid);
duke@0 194 klassOop f_oop = id->holder();
duke@0 195 if (!instanceKlass::cast(k_oop)->is_subtype_of(f_oop))
duke@0 196 ReportJNIFatalError(thr, fatal_wrong_static_field);
duke@0 197
duke@0 198 /* check for proper field type */
duke@0 199 if (!instanceKlass::cast(f_oop)->find_local_field_from_offset(
duke@0 200 id->offset(), true, &fd))
duke@0 201 ReportJNIFatalError(thr, fatal_static_field_not_found);
duke@0 202 if ((fd.field_type() != ftype) &&
duke@0 203 !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
duke@0 204 ReportJNIFatalError(thr, fatal_static_field_mismatch);
duke@0 205 }
duke@0 206 }
duke@0 207
duke@0 208 static inline void
duke@0 209 checkInstanceFieldID(JavaThread* thr, jfieldID fid, jobject obj, int ftype)
duke@0 210 {
duke@0 211 fieldDescriptor fd;
duke@0 212
duke@0 213 /* make sure it is an instance field */
duke@0 214 if (jfieldIDWorkaround::is_static_jfieldID(fid))
duke@0 215 ReportJNIFatalError(thr, fatal_should_be_nonstatic);
duke@0 216
duke@0 217 /* validate the object being passed and then get its class */
duke@0 218 ASSERT_OOPS_ALLOWED;
duke@0 219 oop oopObj = jniCheck::validate_object(thr, obj);
duke@0 220 if (!oopObj) {
duke@0 221 ReportJNIFatalError(thr, fatal_null_object);
duke@0 222 }
duke@0 223 klassOop k_oop = oopObj->klass();
duke@0 224
duke@0 225 if (!jfieldIDWorkaround::is_valid_jfieldID(k_oop, fid)) {
duke@0 226 ReportJNIFatalError(thr, fatal_wrong_field);
duke@0 227 }
duke@0 228
duke@0 229 /* make sure the field exists */
duke@0 230 int offset = jfieldIDWorkaround::from_instance_jfieldID(k_oop, fid);
duke@0 231 if (!instanceKlass::cast(k_oop)->contains_field_offset(offset))
duke@0 232 ReportJNIFatalError(thr, fatal_wrong_field);
duke@0 233
duke@0 234 /* check for proper field type */
duke@0 235 if (!instanceKlass::cast(k_oop)->find_field_from_offset(offset,
duke@0 236 false, &fd))
duke@0 237 ReportJNIFatalError(thr, fatal_instance_field_not_found);
duke@0 238
duke@0 239 if ((fd.field_type() != ftype) &&
duke@0 240 !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
duke@0 241 ReportJNIFatalError(thr, fatal_instance_field_mismatch);
duke@0 242 }
duke@0 243 }
duke@0 244
duke@0 245 static inline void
duke@0 246 checkString(JavaThread* thr, jstring js)
duke@0 247 {
duke@0 248 ASSERT_OOPS_ALLOWED;
duke@0 249 oop s = jniCheck::validate_object(thr, js);
duke@0 250 if (!s || !java_lang_String::is_instance(s))
duke@0 251 ReportJNIFatalError(thr, fatal_non_string);
duke@0 252 }
duke@0 253
duke@0 254 static inline void
duke@0 255 checkArray(JavaThread* thr, jarray jArray, int elementType)
duke@0 256 {
duke@0 257 ASSERT_OOPS_ALLOWED;
duke@0 258 arrayOop aOop;
duke@0 259
duke@0 260 aOop = (arrayOop)jniCheck::validate_object(thr, jArray);
duke@0 261 if (aOop == NULL || !aOop->is_array())
duke@0 262 ReportJNIFatalError(thr, fatal_non_array);
duke@0 263
duke@0 264 if (elementType != -1) {
duke@0 265 if (aOop->is_typeArray()) {
duke@0 266 BasicType array_type = typeArrayKlass::cast(aOop->klass())->element_type();
duke@0 267 if (array_type != elementType)
duke@0 268 ReportJNIFatalError(thr, fatal_element_type_mismatch);
duke@0 269 } else if (aOop->is_objArray()) {
duke@0 270 if ( T_OBJECT != elementType)
duke@0 271 ReportJNIFatalError(thr, fatal_object_array_expected);
duke@0 272 } else {
duke@0 273 ReportJNIFatalError(thr, fatal_unknown_array_object);
duke@0 274 }
duke@0 275 }
duke@0 276 }
duke@0 277
duke@0 278
duke@0 279 oop jniCheck::validate_handle(JavaThread* thr, jobject obj) {
duke@0 280 if (JNIHandles::is_frame_handle(thr, obj) ||
duke@0 281 JNIHandles::is_local_handle(thr, obj) ||
duke@0 282 JNIHandles::is_global_handle(obj) ||
duke@0 283 JNIHandles::is_weak_global_handle(obj)) {
duke@0 284 ASSERT_OOPS_ALLOWED;
duke@0 285 return JNIHandles::resolve_external_guard(obj);
duke@0 286 }
duke@0 287 ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
duke@0 288 return NULL;
duke@0 289 }
duke@0 290
duke@0 291
duke@0 292 methodOop jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) {
duke@0 293 ASSERT_OOPS_ALLOWED;
duke@0 294 methodOop moop = JNIHandles::checked_resolve_jmethod_id(method_id);
duke@0 295 if (moop == NULL) {
duke@0 296 ReportJNIFatalError(thr, fatal_wrong_class_or_method);
duke@0 297 }
duke@0 298 return moop;
duke@0 299 }
duke@0 300
duke@0 301
duke@0 302 oop jniCheck::validate_object(JavaThread* thr, jobject obj) {
duke@0 303 if (!obj)
duke@0 304 return NULL;
duke@0 305 ASSERT_OOPS_ALLOWED;
duke@0 306 oop oopObj = jniCheck::validate_handle(thr, obj);
duke@0 307 if (!oopObj) {
duke@0 308 ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
duke@0 309 }
duke@0 310 return oopObj;
duke@0 311 }
duke@0 312
duke@0 313 // Warn if a class descriptor is in decorated form; class descriptors
duke@0 314 // passed to JNI findClass should not be decorated unless they are
duke@0 315 // array descriptors.
duke@0 316 void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) {
duke@0 317 if (name == NULL) return; // implementation accepts NULL so just return
duke@0 318
duke@0 319 size_t len = strlen(name);
duke@0 320
duke@0 321 if (len >= 2 &&
duke@0 322 name[0] == JVM_SIGNATURE_CLASS && // 'L'
duke@0 323 name[len-1] == JVM_SIGNATURE_ENDCLASS ) { // ';'
duke@0 324 char msg[JVM_MAXPATHLEN];
duke@0 325 jio_snprintf(msg, JVM_MAXPATHLEN, warn_bad_class_descriptor, name);
duke@0 326 ReportJNIWarning(thr, msg);
duke@0 327 }
duke@0 328 }
duke@0 329
duke@0 330 klassOop jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primitive) {
duke@0 331 ASSERT_OOPS_ALLOWED;
duke@0 332 oop mirror = jniCheck::validate_handle(thr, clazz);
duke@0 333 if (!mirror) {
duke@0 334 ReportJNIFatalError(thr, fatal_received_null_class);
duke@0 335 }
duke@0 336
duke@0 337 if (mirror->klass() != SystemDictionary::class_klass()) {
duke@0 338 ReportJNIFatalError(thr, fatal_class_not_a_class);
duke@0 339 }
duke@0 340
duke@0 341 klassOop k = java_lang_Class::as_klassOop(mirror);
duke@0 342 // Make allowances for primitive classes ...
duke@0 343 if (!(k != NULL || allow_primitive && java_lang_Class::is_primitive(mirror))) {
duke@0 344 ReportJNIFatalError(thr, fatal_class_not_a_class);
duke@0 345 }
duke@0 346 return k;
duke@0 347 }
duke@0 348
duke@0 349 void jniCheck::validate_throwable_klass(JavaThread* thr, klassOop klass) {
duke@0 350 ASSERT_OOPS_ALLOWED;
duke@0 351 assert(klass != NULL, "klass argument must have a value");
duke@0 352
duke@0 353 if (!Klass::cast(klass)->oop_is_instance() ||
duke@0 354 !instanceKlass::cast(klass)->is_subclass_of(SystemDictionary::throwable_klass())) {
duke@0 355 ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
duke@0 356 }
duke@0 357 }
duke@0 358
duke@0 359 void jniCheck::validate_call_object(JavaThread* thr, jobject obj, jmethodID method_id) {
duke@0 360 /* validate the object being passed */
duke@0 361 ASSERT_OOPS_ALLOWED;
duke@0 362 jniCheck::validate_jmethod_id(thr, method_id);
duke@0 363 jniCheck::validate_object(thr, obj);
duke@0 364 }
duke@0 365
duke@0 366 void jniCheck::validate_call_class(JavaThread* thr, jclass clazz, jmethodID method_id) {
duke@0 367 /* validate the class being passed */
duke@0 368 ASSERT_OOPS_ALLOWED;
duke@0 369 jniCheck::validate_jmethod_id(thr, method_id);
duke@0 370 jniCheck::validate_class(thr, clazz, false);
duke@0 371 }
duke@0 372
duke@0 373
duke@0 374 /*
duke@0 375 * IMPLEMENTATION OF FUNCTIONS IN CHECKED TABLE
duke@0 376 */
duke@0 377
duke@0 378 JNI_ENTRY_CHECKED(jclass,
duke@0 379 checked_jni_DefineClass(JNIEnv *env,
duke@0 380 const char *name,
duke@0 381 jobject loader,
duke@0 382 const jbyte *buf,
duke@0 383 jsize len))
duke@0 384 functionEnter(thr);
duke@0 385 IN_VM(
duke@0 386 jniCheck::validate_object(thr, loader);
duke@0 387 )
duke@0 388 jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len);
duke@0 389 functionExit(env);
duke@0 390 return result;
duke@0 391 JNI_END
duke@0 392
duke@0 393 JNI_ENTRY_CHECKED(jclass,
duke@0 394 checked_jni_FindClass(JNIEnv *env,
duke@0 395 const char *name))
duke@0 396 functionEnter(thr);
duke@0 397 IN_VM(
duke@0 398 jniCheck::validate_class_descriptor(thr, name);
duke@0 399 )
duke@0 400 jclass result = UNCHECKED()->FindClass(env, name);
duke@0 401 functionExit(env);
duke@0 402 return result;
duke@0 403 JNI_END
duke@0 404
duke@0 405 JNI_ENTRY_CHECKED(jmethodID,
duke@0 406 checked_jni_FromReflectedMethod(JNIEnv *env,
duke@0 407 jobject method))
duke@0 408 functionEnter(thr);
duke@0 409 IN_VM(
duke@0 410 jniCheck::validate_object(thr, method);
duke@0 411 )
duke@0 412 jmethodID result = UNCHECKED()->FromReflectedMethod(env, method);
duke@0 413 functionExit(env);
duke@0 414 return result;
duke@0 415 JNI_END
duke@0 416
duke@0 417 JNI_ENTRY_CHECKED(jfieldID,
duke@0 418 checked_jni_FromReflectedField(JNIEnv *env,
duke@0 419 jobject field))
duke@0 420 functionEnter(thr);
duke@0 421 IN_VM(
duke@0 422 jniCheck::validate_object(thr, field);
duke@0 423 )
duke@0 424 jfieldID result = UNCHECKED()->FromReflectedField(env, field);
duke@0 425 functionExit(env);
duke@0 426 return result;
duke@0 427 JNI_END
duke@0 428
duke@0 429 JNI_ENTRY_CHECKED(jobject,
duke@0 430 checked_jni_ToReflectedMethod(JNIEnv *env,
duke@0 431 jclass cls,
duke@0 432 jmethodID methodID,
duke@0 433 jboolean isStatic))
duke@0 434 functionEnter(thr);
duke@0 435 IN_VM(
duke@0 436 jniCheck::validate_class(thr, cls, false);
duke@0 437 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 438 )
duke@0 439 jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID,
duke@0 440 isStatic);
duke@0 441 functionExit(env);
duke@0 442 return result;
duke@0 443 JNI_END
duke@0 444
duke@0 445 JNI_ENTRY_CHECKED(jclass,
duke@0 446 checked_jni_GetSuperclass(JNIEnv *env,
duke@0 447 jclass sub))
duke@0 448 functionEnter(thr);
duke@0 449 IN_VM(
duke@0 450 jniCheck::validate_class(thr, sub, true);
duke@0 451 )
duke@0 452 jclass result = UNCHECKED()->GetSuperclass(env, sub);
duke@0 453 functionExit(env);
duke@0 454 return result;
duke@0 455 JNI_END
duke@0 456
duke@0 457 JNI_ENTRY_CHECKED(jboolean,
duke@0 458 checked_jni_IsAssignableFrom(JNIEnv *env,
duke@0 459 jclass sub,
duke@0 460 jclass sup))
duke@0 461 functionEnter(thr);
duke@0 462 IN_VM(
duke@0 463 jniCheck::validate_class(thr, sub, true);
duke@0 464 jniCheck::validate_class(thr, sup, true);
duke@0 465 )
duke@0 466 jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup);
duke@0 467 functionExit(env);
duke@0 468 return result;
duke@0 469 JNI_END
duke@0 470
duke@0 471 JNI_ENTRY_CHECKED(jobject,
duke@0 472 checked_jni_ToReflectedField(JNIEnv *env,
duke@0 473 jclass cls,
duke@0 474 jfieldID fieldID,
duke@0 475 jboolean isStatic))
duke@0 476 functionEnter(thr);
duke@0 477 IN_VM(
duke@0 478 jniCheck::validate_class(thr, cls, false);
duke@0 479 )
duke@0 480 jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID,
duke@0 481 isStatic);
duke@0 482 functionExit(env);
duke@0 483 return result;
duke@0 484 JNI_END
duke@0 485
duke@0 486 JNI_ENTRY_CHECKED(jint,
duke@0 487 checked_jni_Throw(JNIEnv *env,
duke@0 488 jthrowable obj))
duke@0 489 functionEnter(thr);
duke@0 490 IN_VM(
duke@0 491 oop oopObj = jniCheck::validate_object(thr, obj);
duke@0 492 if (oopObj == NULL) {
duke@0 493 // Unchecked Throw tolerates a NULL obj, so just warn
duke@0 494 ReportJNIWarning(thr, "JNI Throw called with NULL throwable");
duke@0 495 } else {
duke@0 496 jniCheck::validate_throwable_klass(thr, oopObj->klass());
duke@0 497 }
duke@0 498 )
duke@0 499 jint result = UNCHECKED()->Throw(env, obj);
duke@0 500 functionExit(env);
duke@0 501 return result;
duke@0 502 JNI_END
duke@0 503
duke@0 504 JNI_ENTRY_CHECKED(jint,
duke@0 505 checked_jni_ThrowNew(JNIEnv *env,
duke@0 506 jclass clazz,
duke@0 507 const char *msg))
duke@0 508 functionEnter(thr);
duke@0 509 IN_VM(
duke@0 510 klassOop k = jniCheck::validate_class(thr, clazz, false);
duke@0 511 assert(k != NULL, "validate_class shouldn't return NULL klassOop");
duke@0 512 jniCheck::validate_throwable_klass(thr, k);
duke@0 513 )
duke@0 514 jint result = UNCHECKED()->ThrowNew(env, clazz, msg);
duke@0 515 functionExit(env);
duke@0 516 return result;
duke@0 517 JNI_END
duke@0 518
duke@0 519 JNI_ENTRY_CHECKED(jthrowable,
duke@0 520 checked_jni_ExceptionOccurred(JNIEnv *env))
duke@0 521 functionEnterExceptionAllowed(thr);
duke@0 522 jthrowable result = UNCHECKED()->ExceptionOccurred(env);
duke@0 523 functionExit(env);
duke@0 524 return result;
duke@0 525 JNI_END
duke@0 526
duke@0 527 JNI_ENTRY_CHECKED(void,
duke@0 528 checked_jni_ExceptionDescribe(JNIEnv *env))
duke@0 529 functionEnterExceptionAllowed(thr);
duke@0 530 UNCHECKED()->ExceptionDescribe(env);
duke@0 531 functionExit(env);
duke@0 532 JNI_END
duke@0 533
duke@0 534 JNI_ENTRY_CHECKED(void,
duke@0 535 checked_jni_ExceptionClear(JNIEnv *env))
duke@0 536 functionEnterExceptionAllowed(thr);
duke@0 537 UNCHECKED()->ExceptionClear(env);
duke@0 538 functionExit(env);
duke@0 539 JNI_END
duke@0 540
duke@0 541 JNI_ENTRY_CHECKED(void,
duke@0 542 checked_jni_FatalError(JNIEnv *env,
duke@0 543 const char *msg))
duke@0 544 functionEnter(thr);
duke@0 545 UNCHECKED()->FatalError(env, msg);
duke@0 546 functionExit(env);
duke@0 547 JNI_END
duke@0 548
duke@0 549 JNI_ENTRY_CHECKED(jint,
duke@0 550 checked_jni_PushLocalFrame(JNIEnv *env,
duke@0 551 jint capacity))
duke@0 552 functionEnterExceptionAllowed(thr);
duke@0 553 if (capacity < 0)
duke@0 554 NativeReportJNIFatalError(thr, "negative capacity");
duke@0 555 jint result = UNCHECKED()->PushLocalFrame(env, capacity);
duke@0 556 functionExit(env);
duke@0 557 return result;
duke@0 558 JNI_END
duke@0 559
duke@0 560 JNI_ENTRY_CHECKED(jobject,
duke@0 561 checked_jni_PopLocalFrame(JNIEnv *env,
duke@0 562 jobject result))
duke@0 563 functionEnterExceptionAllowed(thr);
duke@0 564 jobject res = UNCHECKED()->PopLocalFrame(env, result);
duke@0 565 functionExit(env);
duke@0 566 return res;
duke@0 567 JNI_END
duke@0 568
duke@0 569 JNI_ENTRY_CHECKED(jobject,
duke@0 570 checked_jni_NewGlobalRef(JNIEnv *env,
duke@0 571 jobject lobj))
duke@0 572 functionEnter(thr);
duke@0 573 IN_VM(
duke@0 574 if (lobj != NULL) {
duke@0 575 jniCheck::validate_handle(thr, lobj);
duke@0 576 }
duke@0 577 )
duke@0 578 jobject result = UNCHECKED()->NewGlobalRef(env,lobj);
duke@0 579 functionExit(env);
duke@0 580 return result;
duke@0 581 JNI_END
duke@0 582
duke@0 583 JNI_ENTRY_CHECKED(void,
duke@0 584 checked_jni_DeleteGlobalRef(JNIEnv *env,
duke@0 585 jobject gref))
duke@0 586 functionEnterExceptionAllowed(thr);
duke@0 587 IN_VM(
duke@0 588 jniCheck::validate_object(thr, gref);
duke@0 589 if (gref && !JNIHandles::is_global_handle(gref)) {
duke@0 590 ReportJNIFatalError(thr,
duke@0 591 "Invalid global JNI handle passed to DeleteGlobalRef");
duke@0 592 }
duke@0 593 )
duke@0 594 UNCHECKED()->DeleteGlobalRef(env,gref);
duke@0 595 functionExit(env);
duke@0 596 JNI_END
duke@0 597
duke@0 598 JNI_ENTRY_CHECKED(void,
duke@0 599 checked_jni_DeleteLocalRef(JNIEnv *env,
duke@0 600 jobject obj))
duke@0 601 functionEnterExceptionAllowed(thr);
duke@0 602 IN_VM(
duke@0 603 jniCheck::validate_object(thr, obj);
duke@0 604 if (obj && !(JNIHandles::is_local_handle(thr, obj) ||
duke@0 605 JNIHandles::is_frame_handle(thr, obj)))
duke@0 606 ReportJNIFatalError(thr,
duke@0 607 "Invalid local JNI handle passed to DeleteLocalRef");
duke@0 608 )
duke@0 609 UNCHECKED()->DeleteLocalRef(env, obj);
duke@0 610 functionExit(env);
duke@0 611 JNI_END
duke@0 612
duke@0 613 JNI_ENTRY_CHECKED(jboolean,
duke@0 614 checked_jni_IsSameObject(JNIEnv *env,
duke@0 615 jobject obj1,
duke@0 616 jobject obj2))
duke@0 617 functionEnterExceptionAllowed(thr);
duke@0 618 IN_VM(
duke@0 619 /* This JNI function can be used to compare weak global references
duke@0 620 * to NULL objects. If the handles are valid, but contain NULL,
duke@0 621 * then don't attempt to validate the object.
duke@0 622 */
duke@0 623 if (obj1 != NULL && jniCheck::validate_handle(thr, obj1) != NULL) {
duke@0 624 jniCheck::validate_object(thr, obj1);
duke@0 625 }
duke@0 626 if (obj2 != NULL && jniCheck::validate_handle(thr, obj2) != NULL) {
duke@0 627 jniCheck::validate_object(thr, obj2);
duke@0 628 }
duke@0 629 )
duke@0 630 jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2);
duke@0 631 functionExit(env);
duke@0 632 return result;
duke@0 633 JNI_END
duke@0 634
duke@0 635 JNI_ENTRY_CHECKED(jobject,
duke@0 636 checked_jni_NewLocalRef(JNIEnv *env,
duke@0 637 jobject ref))
duke@0 638 functionEnter(thr);
duke@0 639 IN_VM(
duke@0 640 if (ref != NULL) {
duke@0 641 jniCheck::validate_handle(thr, ref);
duke@0 642 }
duke@0 643 )
duke@0 644 jobject result = UNCHECKED()->NewLocalRef(env, ref);
duke@0 645 functionExit(env);
duke@0 646 return result;
duke@0 647 JNI_END
duke@0 648
duke@0 649 JNI_ENTRY_CHECKED(jint,
duke@0 650 checked_jni_EnsureLocalCapacity(JNIEnv *env,
duke@0 651 jint capacity))
duke@0 652 functionEnter(thr);
duke@0 653 if (capacity < 0) {
duke@0 654 NativeReportJNIFatalError(thr, "negative capacity");
duke@0 655 }
duke@0 656 jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
duke@0 657 functionExit(env);
duke@0 658 return result;
duke@0 659 JNI_END
duke@0 660
duke@0 661 JNI_ENTRY_CHECKED(jobject,
duke@0 662 checked_jni_AllocObject(JNIEnv *env,
duke@0 663 jclass clazz))
duke@0 664 functionEnter(thr);
duke@0 665 IN_VM(
duke@0 666 jniCheck::validate_class(thr, clazz, false);
duke@0 667 )
duke@0 668 jobject result = UNCHECKED()->AllocObject(env,clazz);
duke@0 669 functionExit(env);
duke@0 670 return result;
duke@0 671 JNI_END
duke@0 672
duke@0 673 JNI_ENTRY_CHECKED(jobject,
duke@0 674 checked_jni_NewObject(JNIEnv *env,
duke@0 675 jclass clazz,
duke@0 676 jmethodID methodID,
duke@0 677 ...))
duke@0 678 functionEnter(thr);
duke@0 679 va_list args;
duke@0 680 IN_VM(
duke@0 681 jniCheck::validate_class(thr, clazz, false);
duke@0 682 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 683 )
duke@0 684 va_start(args, methodID);
duke@0 685 jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
duke@0 686 va_end(args);
duke@0 687 functionExit(env);
duke@0 688 return result;
duke@0 689 JNI_END
duke@0 690
duke@0 691 JNI_ENTRY_CHECKED(jobject,
duke@0 692 checked_jni_NewObjectV(JNIEnv *env,
duke@0 693 jclass clazz,
duke@0 694 jmethodID methodID,
duke@0 695 va_list args))
duke@0 696 functionEnter(thr);
duke@0 697 IN_VM(
duke@0 698 jniCheck::validate_class(thr, clazz, false);
duke@0 699 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 700 )
duke@0 701 jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
duke@0 702 functionExit(env);
duke@0 703 return result;
duke@0 704 JNI_END
duke@0 705
duke@0 706 JNI_ENTRY_CHECKED(jobject,
duke@0 707 checked_jni_NewObjectA(JNIEnv *env,
duke@0 708 jclass clazz,
duke@0 709 jmethodID methodID,
duke@0 710 const jvalue *args))
duke@0 711 functionEnter(thr);
duke@0 712 IN_VM(
duke@0 713 jniCheck::validate_class(thr, clazz, false);
duke@0 714 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 715 )
duke@0 716 jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args);
duke@0 717 functionExit(env);
duke@0 718 return result;
duke@0 719 JNI_END
duke@0 720
duke@0 721 JNI_ENTRY_CHECKED(jclass,
duke@0 722 checked_jni_GetObjectClass(JNIEnv *env,
duke@0 723 jobject obj))
duke@0 724 functionEnter(thr);
duke@0 725 IN_VM(
duke@0 726 jniCheck::validate_object(thr, obj);
duke@0 727 )
duke@0 728 jclass result = UNCHECKED()->GetObjectClass(env,obj);
duke@0 729 functionExit(env);
duke@0 730 return result;
duke@0 731 JNI_END
duke@0 732
duke@0 733 JNI_ENTRY_CHECKED(jboolean,
duke@0 734 checked_jni_IsInstanceOf(JNIEnv *env,
duke@0 735 jobject obj,
duke@0 736 jclass clazz))
duke@0 737 functionEnter(thr);
duke@0 738 IN_VM(
duke@0 739 jniCheck::validate_object(thr, obj);
duke@0 740 jniCheck::validate_class(thr, clazz, true);
duke@0 741 )
duke@0 742 jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz);
duke@0 743 functionExit(env);
duke@0 744 return result;
duke@0 745 JNI_END
duke@0 746
duke@0 747 JNI_ENTRY_CHECKED(jmethodID,
duke@0 748 checked_jni_GetMethodID(JNIEnv *env,
duke@0 749 jclass clazz,
duke@0 750 const char *name,
duke@0 751 const char *sig))
duke@0 752 functionEnter(thr);
duke@0 753 IN_VM(
duke@0 754 jniCheck::validate_class(thr, clazz, false);
duke@0 755 )
duke@0 756 jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig);
duke@0 757 functionExit(env);
duke@0 758 return result;
duke@0 759 JNI_END
duke@0 760
duke@0 761 #define WRAPPER_CallMethod(ResultType, Result) \
duke@0 762 JNI_ENTRY_CHECKED(ResultType, \
duke@0 763 checked_jni_Call##Result##Method(JNIEnv *env, \
duke@0 764 jobject obj, \
duke@0 765 jmethodID methodID, \
duke@0 766 ...)) \
duke@0 767 functionEnter(thr); \
duke@0 768 va_list args; \
duke@0 769 IN_VM( \
duke@0 770 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 771 ) \
duke@0 772 va_start(args,methodID); \
duke@0 773 ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \
duke@0 774 args); \
duke@0 775 va_end(args); \
duke@0 776 functionExit(env); \
duke@0 777 return result; \
duke@0 778 JNI_END \
duke@0 779 \
duke@0 780 JNI_ENTRY_CHECKED(ResultType, \
duke@0 781 checked_jni_Call##Result##MethodV(JNIEnv *env, \
duke@0 782 jobject obj, \
duke@0 783 jmethodID methodID, \
duke@0 784 va_list args)) \
duke@0 785 functionEnter(thr); \
duke@0 786 IN_VM(\
duke@0 787 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 788 ) \
duke@0 789 ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\
duke@0 790 args); \
duke@0 791 functionExit(env); \
duke@0 792 return result; \
duke@0 793 JNI_END \
duke@0 794 \
duke@0 795 JNI_ENTRY_CHECKED(ResultType, \
duke@0 796 checked_jni_Call##Result##MethodA(JNIEnv *env, \
duke@0 797 jobject obj, \
duke@0 798 jmethodID methodID, \
duke@0 799 const jvalue * args)) \
duke@0 800 functionEnter(thr); \
duke@0 801 IN_VM( \
duke@0 802 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 803 ) \
duke@0 804 ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\
duke@0 805 args); \
duke@0 806 functionExit(env); \
duke@0 807 return result; \
duke@0 808 JNI_END
duke@0 809
duke@0 810 WRAPPER_CallMethod(jobject,Object)
duke@0 811 WRAPPER_CallMethod(jboolean,Boolean)
duke@0 812 WRAPPER_CallMethod(jbyte,Byte)
duke@0 813 WRAPPER_CallMethod(jshort,Short)
duke@0 814 WRAPPER_CallMethod(jchar,Char)
duke@0 815 WRAPPER_CallMethod(jint,Int)
duke@0 816 WRAPPER_CallMethod(jlong,Long)
duke@0 817 WRAPPER_CallMethod(jfloat,Float)
duke@0 818 WRAPPER_CallMethod(jdouble,Double)
duke@0 819
duke@0 820 JNI_ENTRY_CHECKED(void,
duke@0 821 checked_jni_CallVoidMethod(JNIEnv *env, \
duke@0 822 jobject obj, \
duke@0 823 jmethodID methodID, \
duke@0 824 ...))
duke@0 825 functionEnter(thr);
duke@0 826 va_list args;
duke@0 827 IN_VM(
duke@0 828 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 829 )
duke@0 830 va_start(args,methodID);
duke@0 831 UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
duke@0 832 va_end(args);
duke@0 833 functionExit(env);
duke@0 834 JNI_END
duke@0 835
duke@0 836 JNI_ENTRY_CHECKED(void,
duke@0 837 checked_jni_CallVoidMethodV(JNIEnv *env,
duke@0 838 jobject obj,
duke@0 839 jmethodID methodID,
duke@0 840 va_list args))
duke@0 841 functionEnter(thr);
duke@0 842 IN_VM(
duke@0 843 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 844 )
duke@0 845 UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
duke@0 846 functionExit(env);
duke@0 847 JNI_END
duke@0 848
duke@0 849 JNI_ENTRY_CHECKED(void,
duke@0 850 checked_jni_CallVoidMethodA(JNIEnv *env,
duke@0 851 jobject obj,
duke@0 852 jmethodID methodID,
duke@0 853 const jvalue * args))
duke@0 854 functionEnter(thr);
duke@0 855 IN_VM(
duke@0 856 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 857 )
duke@0 858 UNCHECKED()->CallVoidMethodA(env,obj,methodID,args);
duke@0 859 functionExit(env);
duke@0 860 JNI_END
duke@0 861
duke@0 862 #define WRAPPER_CallNonvirtualMethod(ResultType, Result) \
duke@0 863 JNI_ENTRY_CHECKED(ResultType, \
duke@0 864 checked_jni_CallNonvirtual##Result##Method(JNIEnv *env, \
duke@0 865 jobject obj, \
duke@0 866 jclass clazz, \
duke@0 867 jmethodID methodID, \
duke@0 868 ...)) \
duke@0 869 functionEnter(thr); \
duke@0 870 va_list args; \
duke@0 871 IN_VM( \
duke@0 872 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 873 jniCheck::validate_call_class(thr, clazz, methodID); \
duke@0 874 ) \
duke@0 875 va_start(args,methodID); \
duke@0 876 ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
duke@0 877 obj, \
duke@0 878 clazz, \
duke@0 879 methodID,\
duke@0 880 args); \
duke@0 881 va_end(args); \
duke@0 882 functionExit(env); \
duke@0 883 return result; \
duke@0 884 JNI_END \
duke@0 885 \
duke@0 886 JNI_ENTRY_CHECKED(ResultType, \
duke@0 887 checked_jni_CallNonvirtual##Result##MethodV(JNIEnv *env, \
duke@0 888 jobject obj, \
duke@0 889 jclass clazz, \
duke@0 890 jmethodID methodID, \
duke@0 891 va_list args)) \
duke@0 892 functionEnter(thr); \
duke@0 893 IN_VM( \
duke@0 894 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 895 jniCheck::validate_call_class(thr, clazz, methodID); \
duke@0 896 ) \
duke@0 897 ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
duke@0 898 obj, \
duke@0 899 clazz, \
duke@0 900 methodID,\
duke@0 901 args); \
duke@0 902 functionExit(env); \
duke@0 903 return result; \
duke@0 904 JNI_END \
duke@0 905 \
duke@0 906 JNI_ENTRY_CHECKED(ResultType, \
duke@0 907 checked_jni_CallNonvirtual##Result##MethodA(JNIEnv *env, \
duke@0 908 jobject obj, \
duke@0 909 jclass clazz, \
duke@0 910 jmethodID methodID, \
duke@0 911 const jvalue * args)) \
duke@0 912 functionEnter(thr); \
duke@0 913 IN_VM( \
duke@0 914 jniCheck::validate_call_object(thr, obj, methodID); \
duke@0 915 jniCheck::validate_call_class(thr, clazz, methodID); \
duke@0 916 ) \
duke@0 917 ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodA(env, \
duke@0 918 obj, \
duke@0 919 clazz, \
duke@0 920 methodID,\
duke@0 921 args); \
duke@0 922 functionExit(env); \
duke@0 923 return result; \
duke@0 924 JNI_END
duke@0 925
duke@0 926 WRAPPER_CallNonvirtualMethod(jobject,Object)
duke@0 927 WRAPPER_CallNonvirtualMethod(jboolean,Boolean)
duke@0 928 WRAPPER_CallNonvirtualMethod(jbyte,Byte)
duke@0 929 WRAPPER_CallNonvirtualMethod(jshort,Short)
duke@0 930 WRAPPER_CallNonvirtualMethod(jchar,Char)
duke@0 931 WRAPPER_CallNonvirtualMethod(jint,Int)
duke@0 932 WRAPPER_CallNonvirtualMethod(jlong,Long)
duke@0 933 WRAPPER_CallNonvirtualMethod(jfloat,Float)
duke@0 934 WRAPPER_CallNonvirtualMethod(jdouble,Double)
duke@0 935
duke@0 936 JNI_ENTRY_CHECKED(void,
duke@0 937 checked_jni_CallNonvirtualVoidMethod(JNIEnv *env,
duke@0 938 jobject obj,
duke@0 939 jclass clazz,
duke@0 940 jmethodID methodID,
duke@0 941 ...))
duke@0 942 functionEnter(thr);
duke@0 943 va_list args;
duke@0 944 IN_VM(
duke@0 945 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 946 jniCheck::validate_call_class(thr, clazz, methodID);
duke@0 947 )
duke@0 948 va_start(args,methodID);
duke@0 949 UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
duke@0 950 va_end(args);
duke@0 951 functionExit(env);
duke@0 952 JNI_END
duke@0 953
duke@0 954 JNI_ENTRY_CHECKED(void,
duke@0 955 checked_jni_CallNonvirtualVoidMethodV(JNIEnv *env,
duke@0 956 jobject obj,
duke@0 957 jclass clazz,
duke@0 958 jmethodID methodID,
duke@0 959 va_list args))
duke@0 960 functionEnter(thr);
duke@0 961 IN_VM(
duke@0 962 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 963 jniCheck::validate_call_class(thr, clazz, methodID);
duke@0 964 )
duke@0 965 UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
duke@0 966 functionExit(env);
duke@0 967 JNI_END
duke@0 968
duke@0 969 JNI_ENTRY_CHECKED(void,
duke@0 970 checked_jni_CallNonvirtualVoidMethodA(JNIEnv *env,
duke@0 971 jobject obj,
duke@0 972 jclass clazz,
duke@0 973 jmethodID methodID,
duke@0 974 const jvalue * args))
duke@0 975 functionEnter(thr);
duke@0 976 IN_VM(
duke@0 977 jniCheck::validate_call_object(thr, obj, methodID);
duke@0 978 jniCheck::validate_call_class(thr, clazz, methodID);
duke@0 979 )
duke@0 980 UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args);
duke@0 981 functionExit(env);
duke@0 982 JNI_END
duke@0 983
duke@0 984 JNI_ENTRY_CHECKED(jfieldID,
duke@0 985 checked_jni_GetFieldID(JNIEnv *env,
duke@0 986 jclass clazz,
duke@0 987 const char *name,
duke@0 988 const char *sig))
duke@0 989 functionEnter(thr);
duke@0 990 IN_VM(
duke@0 991 jniCheck::validate_class(thr, clazz, false);
duke@0 992 )
duke@0 993 jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig);
duke@0 994 functionExit(env);
duke@0 995 return result;
duke@0 996 JNI_END
duke@0 997
duke@0 998 #define WRAPPER_GetField(ReturnType,Result,FieldType) \
duke@0 999 JNI_ENTRY_CHECKED(ReturnType, \
duke@0 1000 checked_jni_Get##Result##Field(JNIEnv *env, \
duke@0 1001 jobject obj, \
duke@0 1002 jfieldID fieldID)) \
duke@0 1003 functionEnter(thr); \
duke@0 1004 IN_VM( \
duke@0 1005 checkInstanceFieldID(thr, fieldID, obj, FieldType); \
duke@0 1006 ) \
duke@0 1007 ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \
duke@0 1008 functionExit(env); \
duke@0 1009 return result; \
duke@0 1010 JNI_END
duke@0 1011
duke@0 1012 WRAPPER_GetField(jobject, Object, T_OBJECT)
duke@0 1013 WRAPPER_GetField(jboolean, Boolean, T_BOOLEAN)
duke@0 1014 WRAPPER_GetField(jbyte, Byte, T_BYTE)
duke@0 1015 WRAPPER_GetField(jshort, Short, T_SHORT)
duke@0 1016 WRAPPER_GetField(jchar, Char, T_CHAR)
duke@0 1017 WRAPPER_GetField(jint, Int, T_INT)
duke@0 1018 WRAPPER_GetField(jlong, Long, T_LONG)
duke@0 1019 WRAPPER_GetField(jfloat, Float, T_FLOAT)
duke@0 1020 WRAPPER_GetField(jdouble, Double, T_DOUBLE)
duke@0 1021
duke@0 1022 #define WRAPPER_SetField(ValueType,Result,FieldType) \
duke@0 1023 JNI_ENTRY_CHECKED(void, \
duke@0 1024 checked_jni_Set##Result##Field(JNIEnv *env, \
duke@0 1025 jobject obj, \
duke@0 1026 jfieldID fieldID, \
duke@0 1027 ValueType val)) \
duke@0 1028 functionEnter(thr); \
duke@0 1029 IN_VM( \
duke@0 1030 checkInstanceFieldID(thr, fieldID, obj, FieldType); \
duke@0 1031 ) \
duke@0 1032 UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \
duke@0 1033 functionExit(env); \
duke@0 1034 JNI_END
duke@0 1035
duke@0 1036 WRAPPER_SetField(jobject, Object, T_OBJECT)
duke@0 1037 WRAPPER_SetField(jboolean, Boolean, T_BOOLEAN)
duke@0 1038 WRAPPER_SetField(jbyte, Byte, T_BYTE)
duke@0 1039 WRAPPER_SetField(jshort, Short, T_SHORT)
duke@0 1040 WRAPPER_SetField(jchar, Char, T_CHAR)
duke@0 1041 WRAPPER_SetField(jint, Int, T_INT)
duke@0 1042 WRAPPER_SetField(jlong, Long, T_LONG)
duke@0 1043 WRAPPER_SetField(jfloat, Float, T_FLOAT)
duke@0 1044 WRAPPER_SetField(jdouble, Double, T_DOUBLE)
duke@0 1045
duke@0 1046
duke@0 1047 JNI_ENTRY_CHECKED(jmethodID,
duke@0 1048 checked_jni_GetStaticMethodID(JNIEnv *env,
duke@0 1049 jclass clazz,
duke@0 1050 const char *name,
duke@0 1051 const char *sig))
duke@0 1052 functionEnter(thr);
duke@0 1053 IN_VM(
duke@0 1054 jniCheck::validate_class(thr, clazz, false);
duke@0 1055 )
duke@0 1056 jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig);
duke@0 1057 functionExit(env);
duke@0 1058 return result;
duke@0 1059 JNI_END
duke@0 1060
duke@0 1061 #define WRAPPER_CallStaticMethod(ReturnType,Result) \
duke@0 1062 JNI_ENTRY_CHECKED(ReturnType, \
duke@0 1063 checked_jni_CallStatic##Result##Method(JNIEnv *env, \
duke@0 1064 jclass clazz, \
duke@0 1065 jmethodID methodID, \
duke@0 1066 ...)) \
duke@0 1067 functionEnter(thr); \
duke@0 1068 va_list args; \
duke@0 1069 IN_VM( \
duke@0 1070 jniCheck::validate_jmethod_id(thr, methodID); \
duke@0 1071 jniCheck::validate_class(thr, clazz, false); \
duke@0 1072 ) \
duke@0 1073 va_start(args,methodID); \
duke@0 1074 ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
duke@0 1075 clazz, \
duke@0 1076 methodID, \
duke@0 1077 args); \
duke@0 1078 va_end(args); \
duke@0 1079 functionExit(env); \
duke@0 1080 return result; \
duke@0 1081 JNI_END \
duke@0 1082 \
duke@0 1083 JNI_ENTRY_CHECKED(ReturnType, \
duke@0 1084 checked_jni_CallStatic##Result##MethodV(JNIEnv *env, \
duke@0 1085 jclass clazz, \
duke@0 1086 jmethodID methodID,\
duke@0 1087 va_list args)) \
duke@0 1088 functionEnter(thr); \
duke@0 1089 IN_VM( \
duke@0 1090 jniCheck::validate_jmethod_id(thr, methodID); \
duke@0 1091 jniCheck::validate_class(thr, clazz, false); \
duke@0 1092 ) \
duke@0 1093 ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
duke@0 1094 clazz, \
duke@0 1095 methodID, \
duke@0 1096 args); \
duke@0 1097 functionExit(env); \
duke@0 1098 return result; \
duke@0 1099 JNI_END \
duke@0 1100 \
duke@0 1101 JNI_ENTRY_CHECKED(ReturnType, \
duke@0 1102 checked_jni_CallStatic##Result##MethodA(JNIEnv *env, \
duke@0 1103 jclass clazz, \
duke@0 1104 jmethodID methodID, \
duke@0 1105 const jvalue *args)) \
duke@0 1106 functionEnter(thr); \
duke@0 1107 IN_VM( \
duke@0 1108 jniCheck::validate_jmethod_id(thr, methodID); \
duke@0 1109 jniCheck::validate_class(thr, clazz, false); \
duke@0 1110 ) \
duke@0 1111 ReturnType result = UNCHECKED()->CallStatic##Result##MethodA(env, \
duke@0 1112 clazz, \
duke@0 1113 methodID, \
duke@0 1114 args); \
duke@0 1115 functionExit(env); \
duke@0 1116 return result; \
duke@0 1117 JNI_END
duke@0 1118
duke@0 1119 WRAPPER_CallStaticMethod(jobject,Object)
duke@0 1120 WRAPPER_CallStaticMethod(jboolean,Boolean)
duke@0 1121 WRAPPER_CallStaticMethod(jbyte,Byte)
duke@0 1122 WRAPPER_CallStaticMethod(jshort,Short)
duke@0 1123 WRAPPER_CallStaticMethod(jchar,Char)
duke@0 1124 WRAPPER_CallStaticMethod(jint,Int)
duke@0 1125 WRAPPER_CallStaticMethod(jlong,Long)
duke@0 1126 WRAPPER_CallStaticMethod(jfloat,Float)
duke@0 1127 WRAPPER_CallStaticMethod(jdouble,Double)
duke@0 1128
duke@0 1129 JNI_ENTRY_CHECKED(void,
duke@0 1130 checked_jni_CallStaticVoidMethod(JNIEnv *env,
duke@0 1131 jclass cls,
duke@0 1132 jmethodID methodID,
duke@0 1133 ...))
duke@0 1134 functionEnter(thr);
duke@0 1135 va_list args;
duke@0 1136 IN_VM(
duke@0 1137 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 1138 jniCheck::validate_class(thr, cls, false);
duke@0 1139 )
duke@0 1140 va_start(args,methodID);
duke@0 1141 UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
duke@0 1142 va_end(args);
duke@0 1143 functionExit(env);
duke@0 1144 JNI_END
duke@0 1145
duke@0 1146 JNI_ENTRY_CHECKED(void,
duke@0 1147 checked_jni_CallStaticVoidMethodV(JNIEnv *env,
duke@0 1148 jclass cls,
duke@0 1149 jmethodID methodID,
duke@0 1150 va_list args))
duke@0 1151 functionEnter(thr);
duke@0 1152 IN_VM(
duke@0 1153 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 1154 jniCheck::validate_class(thr, cls, false);
duke@0 1155 )
duke@0 1156 UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
duke@0 1157 functionExit(env);
duke@0 1158 JNI_END
duke@0 1159
duke@0 1160 JNI_ENTRY_CHECKED(void,
duke@0 1161 checked_jni_CallStaticVoidMethodA(JNIEnv *env,
duke@0 1162 jclass cls,
duke@0 1163 jmethodID methodID,
duke@0 1164 const jvalue * args))
duke@0 1165 functionEnter(thr);
duke@0 1166 IN_VM(
duke@0 1167 jniCheck::validate_jmethod_id(thr, methodID);
duke@0 1168 jniCheck::validate_class(thr, cls, false);
duke@0 1169 )
duke@0 1170 UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args);
duke@0 1171 functionExit(env);
duke@0 1172 JNI_END
duke@0 1173
duke@0 1174 JNI_ENTRY_CHECKED(jfieldID,
duke@0 1175 checked_jni_GetStaticFieldID(JNIEnv *env,
duke@0 1176 jclass clazz,
duke@0 1177 const char *name,
duke@0 1178 const char *sig))
duke@0 1179 functionEnter(thr);
duke@0 1180 IN_VM(
duke@0 1181 jniCheck::validate_class(thr, clazz, false);
duke@0 1182 )
duke@0 1183 jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig);
duke@0 1184 functionExit(env);
duke@0 1185 return result;
duke@0 1186 JNI_END
duke@0 1187
duke@0 1188 #define WRAPPER_GetStaticField(ReturnType,Result,FieldType) \
duke@0 1189 JNI_ENTRY_CHECKED(ReturnType, \
duke@0 1190 checked_jni_GetStatic##Result##Field(JNIEnv *env, \
duke@0 1191 jclass clazz, \
duke@0 1192 jfieldID fieldID)) \
duke@0 1193 functionEnter(thr); \
duke@0 1194 IN_VM( \
duke@0 1195 jniCheck::validate_class(thr, clazz, false); \
duke@0 1196 checkStaticFieldID(thr, fieldID, clazz, FieldType); \
duke@0 1197 ) \
duke@0 1198 ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \
duke@0 1199 clazz, \
duke@0 1200 fieldID); \
duke@0 1201 functionExit(env); \
duke@0 1202 return result; \
duke@0 1203 JNI_END
duke@0 1204
duke@0 1205 WRAPPER_GetStaticField(jobject, Object, T_OBJECT)
duke@0 1206 WRAPPER_GetStaticField(jboolean, Boolean, T_BOOLEAN)
duke@0 1207 WRAPPER_GetStaticField(jbyte, Byte, T_BYTE)
duke@0 1208 WRAPPER_GetStaticField(jshort, Short, T_SHORT)
duke@0 1209 WRAPPER_GetStaticField(jchar, Char, T_CHAR)
duke@0 1210 WRAPPER_GetStaticField(jint, Int, T_INT)
duke@0 1211 WRAPPER_GetStaticField(jlong, Long, T_LONG)
duke@0 1212 WRAPPER_GetStaticField(jfloat, Float, T_FLOAT)
duke@0 1213 WRAPPER_GetStaticField(jdouble, Double, T_DOUBLE)
duke@0 1214
duke@0 1215 #define WRAPPER_SetStaticField(ValueType,Result,FieldType) \
duke@0 1216 JNI_ENTRY_CHECKED(void, \
duke@0 1217 checked_jni_SetStatic##Result##Field(JNIEnv *env, \
duke@0 1218 jclass clazz, \
duke@0 1219 jfieldID fieldID, \
duke@0 1220 ValueType value)) \
duke@0 1221 functionEnter(thr); \
duke@0 1222 IN_VM( \
duke@0 1223 jniCheck::validate_class(thr, clazz, false); \
duke@0 1224 checkStaticFieldID(thr, fieldID, clazz, FieldType); \
duke@0 1225 ) \
duke@0 1226 UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \
duke@0 1227 functionExit(env); \
duke@0 1228 JNI_END
duke@0 1229
duke@0 1230 WRAPPER_SetStaticField(jobject, Object, T_OBJECT)
duke@0 1231 WRAPPER_SetStaticField(jboolean, Boolean, T_BOOLEAN)
duke@0 1232 WRAPPER_SetStaticField(jbyte, Byte, T_BYTE)
duke@0 1233 WRAPPER_SetStaticField(jshort, Short, T_SHORT)
duke@0 1234 WRAPPER_SetStaticField(jchar, Char, T_CHAR)
duke@0 1235 WRAPPER_SetStaticField(jint, Int, T_INT)
duke@0 1236 WRAPPER_SetStaticField(jlong, Long, T_LONG)
duke@0 1237 WRAPPER_SetStaticField(jfloat, Float, T_FLOAT)
duke@0 1238 WRAPPER_SetStaticField(jdouble, Double, T_DOUBLE)
duke@0 1239
duke@0 1240
duke@0 1241 JNI_ENTRY_CHECKED(jstring,
duke@0 1242 checked_jni_NewString(JNIEnv *env,
duke@0 1243 const jchar *unicode,
duke@0 1244 jsize len))
duke@0 1245 functionEnter(thr);
duke@0 1246 jstring result = UNCHECKED()->NewString(env,unicode,len);
duke@0 1247 functionExit(env);
duke@0 1248 return result;
duke@0 1249 JNI_END
duke@0 1250
duke@0 1251 JNI_ENTRY_CHECKED(jsize,
duke@0 1252 checked_jni_GetStringLength(JNIEnv *env,
duke@0 1253 jstring str))
duke@0 1254 functionEnter(thr);
duke@0 1255 IN_VM(
duke@0 1256 checkString(thr, str);
duke@0 1257 )
duke@0 1258 jsize result = UNCHECKED()->GetStringLength(env,str);
duke@0 1259 functionExit(env);
duke@0 1260 return result;
duke@0 1261 JNI_END
duke@0 1262
duke@0 1263 JNI_ENTRY_CHECKED(const jchar *,
duke@0 1264 checked_jni_GetStringChars(JNIEnv *env,
duke@0 1265 jstring str,
duke@0 1266 jboolean *isCopy))
duke@0 1267 functionEnter(thr);
duke@0 1268 IN_VM(
duke@0 1269 checkString(thr, str);
duke@0 1270 )
duke@0 1271 const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy);
duke@0 1272 functionExit(env);
duke@0 1273 return result;
duke@0 1274 JNI_END
duke@0 1275
duke@0 1276 JNI_ENTRY_CHECKED(void,
duke@0 1277 checked_jni_ReleaseStringChars(JNIEnv *env,
duke@0 1278 jstring str,
duke@0 1279 const jchar *chars))
duke@0 1280 functionEnterExceptionAllowed(thr);
duke@0 1281 IN_VM(
duke@0 1282 checkString(thr, str);
duke@0 1283 )
duke@0 1284 /* cannot check validity of copy, unless every request is logged by
duke@0 1285 * checking code. Implementation of this check is deferred until a
duke@0 1286 * subsequent release.
duke@0 1287 */
duke@0 1288 UNCHECKED()->ReleaseStringChars(env,str,chars);
duke@0 1289 functionExit(env);
duke@0 1290 JNI_END
duke@0 1291
duke@0 1292 JNI_ENTRY_CHECKED(jstring,
duke@0 1293 checked_jni_NewStringUTF(JNIEnv *env,
duke@0 1294 const char *utf))
duke@0 1295 functionEnter(thr);
duke@0 1296 jstring result = UNCHECKED()->NewStringUTF(env,utf);
duke@0 1297 functionExit(env);
duke@0 1298 return result;
duke@0 1299 JNI_END
duke@0 1300
duke@0 1301 JNI_ENTRY_CHECKED(jsize,
duke@0 1302 checked_jni_GetStringUTFLength(JNIEnv *env,
duke@0 1303 jstring str))
duke@0 1304 functionEnter(thr);
duke@0 1305 IN_VM(
duke@0 1306 checkString(thr, str);
duke@0 1307 )
duke@0 1308 jsize result = UNCHECKED()->GetStringUTFLength(env,str);
duke@0 1309 functionExit(env);
duke@0 1310 return result;
duke@0 1311 JNI_END
duke@0 1312
duke@0 1313 JNI_ENTRY_CHECKED(const char *,
duke@0 1314 checked_jni_GetStringUTFChars(JNIEnv *env,
duke@0 1315 jstring str,
duke@0 1316 jboolean *isCopy))
duke@0 1317 functionEnter(thr);
duke@0 1318 IN_VM(
duke@0 1319 checkString(thr, str);
duke@0 1320 )
duke@0 1321 const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy);
duke@0 1322 functionExit(env);
duke@0 1323 return result;
duke@0 1324 JNI_END
duke@0 1325
duke@0 1326 JNI_ENTRY_CHECKED(void,
duke@0 1327 checked_jni_ReleaseStringUTFChars(JNIEnv *env,
duke@0 1328 jstring str,
duke@0 1329 const char* chars))
duke@0 1330 functionEnterExceptionAllowed(thr);
duke@0 1331 IN_VM(
duke@0 1332 checkString(thr, str);
duke@0 1333 )
duke@0 1334 /* cannot check validity of copy, unless every request is logged by
duke@0 1335 * checking code. Implementation of this check is deferred until a
duke@0 1336 * subsequent release.
duke@0 1337 */
duke@0 1338 UNCHECKED()->ReleaseStringUTFChars(env,str,chars);
duke@0 1339 functionExit(env);
duke@0 1340 JNI_END
duke@0 1341
duke@0 1342 JNI_ENTRY_CHECKED(jsize,
duke@0 1343 checked_jni_GetArrayLength(JNIEnv *env,
duke@0 1344 jarray array))
duke@0 1345 functionEnter(thr);
duke@0 1346 IN_VM(
duke@0 1347 checkArray(thr, array, -1);
duke@0 1348 )
duke@0 1349 jsize result = UNCHECKED()->GetArrayLength(env,array);
duke@0 1350 functionExit(env);
duke@0 1351 return result;
duke@0 1352 JNI_END
duke@0 1353
duke@0 1354 JNI_ENTRY_CHECKED(jobjectArray,
duke@0 1355 checked_jni_NewObjectArray(JNIEnv *env,
duke@0 1356 jsize len,
duke@0 1357 jclass clazz,
duke@0 1358 jobject init))
duke@0 1359 functionEnter(thr);
duke@0 1360 jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init);
duke@0 1361 functionExit(env);
duke@0 1362 return result;
duke@0 1363 JNI_END
duke@0 1364
duke@0 1365 JNI_ENTRY_CHECKED(jobject,
duke@0 1366 checked_jni_GetObjectArrayElement(JNIEnv *env,
duke@0 1367 jobjectArray array,
duke@0 1368 jsize index))
duke@0 1369 functionEnter(thr);
duke@0 1370 IN_VM(
duke@0 1371 checkArray(thr, array, T_OBJECT);
duke@0 1372 )
duke@0 1373 jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
duke@0 1374 functionExit(env);
duke@0 1375 return result;
duke@0 1376 JNI_END
duke@0 1377
duke@0 1378 JNI_ENTRY_CHECKED(void,
duke@0 1379 checked_jni_SetObjectArrayElement(JNIEnv *env,
duke@0 1380 jobjectArray array,
duke@0 1381 jsize index,
duke@0 1382 jobject val))
duke@0 1383 functionEnter(thr);
duke@0 1384 IN_VM(
duke@0 1385 checkArray(thr, array, T_OBJECT);
duke@0 1386 )
duke@0 1387 UNCHECKED()->SetObjectArrayElement(env,array,index,val);
duke@0 1388 functionExit(env);
duke@0 1389 JNI_END
duke@0 1390
duke@0 1391 #define WRAPPER_NewScalarArray(Return, Result) \
duke@0 1392 JNI_ENTRY_CHECKED(Return, \
duke@0 1393 checked_jni_New##Result##Array(JNIEnv *env, \
duke@0 1394 jsize len)) \
duke@0 1395 functionEnter(thr); \
duke@0 1396 Return result = UNCHECKED()->New##Result##Array(env,len); \
duke@0 1397 functionExit(env); \
duke@0 1398 return (Return) result; \
duke@0 1399 JNI_END
duke@0 1400
duke@0 1401 WRAPPER_NewScalarArray(jbooleanArray, Boolean)
duke@0 1402 WRAPPER_NewScalarArray(jbyteArray, Byte)
duke@0 1403 WRAPPER_NewScalarArray(jshortArray, Short)
duke@0 1404 WRAPPER_NewScalarArray(jcharArray, Char)
duke@0 1405 WRAPPER_NewScalarArray(jintArray, Int)
duke@0 1406 WRAPPER_NewScalarArray(jlongArray, Long)
duke@0 1407 WRAPPER_NewScalarArray(jfloatArray, Float)
duke@0 1408 WRAPPER_NewScalarArray(jdoubleArray, Double)
duke@0 1409
duke@0 1410 #define WRAPPER_GetScalarArrayElements(ElementTag,ElementType,Result) \
duke@0 1411 JNI_ENTRY_CHECKED(ElementType *, \
duke@0 1412 checked_jni_Get##Result##ArrayElements(JNIEnv *env, \
duke@0 1413 ElementType##Array array, \
duke@0 1414 jboolean *isCopy)) \
duke@0 1415 functionEnter(thr); \
duke@0 1416 IN_VM( \
duke@0 1417 checkArray(thr, array, ElementTag); \
duke@0 1418 ) \
duke@0 1419 ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \
duke@0 1420 array, \
duke@0 1421 isCopy); \
duke@0 1422 functionExit(env); \
duke@0 1423 return result; \
duke@0 1424 JNI_END
duke@0 1425
duke@0 1426 WRAPPER_GetScalarArrayElements(T_BOOLEAN, jboolean, Boolean)
duke@0 1427 WRAPPER_GetScalarArrayElements(T_BYTE, jbyte, Byte)
duke@0 1428 WRAPPER_GetScalarArrayElements(T_SHORT, jshort, Short)
duke@0 1429 WRAPPER_GetScalarArrayElements(T_CHAR, jchar, Char)
duke@0 1430 WRAPPER_GetScalarArrayElements(T_INT, jint, Int)
duke@0 1431 WRAPPER_GetScalarArrayElements(T_LONG, jlong, Long)
duke@0 1432 WRAPPER_GetScalarArrayElements(T_FLOAT, jfloat, Float)
duke@0 1433 WRAPPER_GetScalarArrayElements(T_DOUBLE, jdouble, Double)
duke@0 1434
duke@0 1435 #define WRAPPER_ReleaseScalarArrayElements(ElementTag,ElementType,Result,Tag) \
duke@0 1436 JNI_ENTRY_CHECKED(void, \
duke@0 1437 checked_jni_Release##Result##ArrayElements(JNIEnv *env, \
duke@0 1438 ElementType##Array array, \
duke@0 1439 ElementType *elems, \
duke@0 1440 jint mode)) \
duke@0 1441 functionEnterExceptionAllowed(thr); \
duke@0 1442 IN_VM( \
duke@0 1443 checkArray(thr, array, ElementTag); \
duke@0 1444 ASSERT_OOPS_ALLOWED; \
duke@0 1445 typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
duke@0 1446 /* cannot check validity of copy, unless every request is logged by
duke@0 1447 * checking code. Implementation of this check is deferred until a
duke@0 1448 * subsequent release.
duke@0 1449 */ \
duke@0 1450 ) \
duke@0 1451 UNCHECKED()->Release##Result##ArrayElements(env,array,elems,mode); \
duke@0 1452 functionExit(env); \
duke@0 1453 JNI_END
duke@0 1454
duke@0 1455 WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool)
duke@0 1456 WRAPPER_ReleaseScalarArrayElements(T_BYTE, jbyte, Byte, byte)
duke@0 1457 WRAPPER_ReleaseScalarArrayElements(T_SHORT, jshort, Short, short)
duke@0 1458 WRAPPER_ReleaseScalarArrayElements(T_CHAR, jchar, Char, char)
duke@0 1459 WRAPPER_ReleaseScalarArrayElements(T_INT, jint, Int, int)
duke@0 1460 WRAPPER_ReleaseScalarArrayElements(T_LONG, jlong, Long, long)
duke@0 1461 WRAPPER_ReleaseScalarArrayElements(T_FLOAT, jfloat, Float, float)
duke@0 1462 WRAPPER_ReleaseScalarArrayElements(T_DOUBLE, jdouble, Double, double)
duke@0 1463
duke@0 1464 #define WRAPPER_GetScalarArrayRegion(ElementTag,ElementType,Result) \
duke@0 1465 JNI_ENTRY_CHECKED(void, \
duke@0 1466 checked_jni_Get##Result##ArrayRegion(JNIEnv *env, \
duke@0 1467 ElementType##Array array, \
duke@0 1468 jsize start, \
duke@0 1469 jsize len, \
duke@0 1470 ElementType *buf)) \
duke@0 1471 functionEnter(thr); \
duke@0 1472 IN_VM( \
duke@0 1473 checkArray(thr, array, ElementTag); \
duke@0 1474 ) \
duke@0 1475 UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
duke@0 1476 functionExit(env); \
duke@0 1477 JNI_END
duke@0 1478
duke@0 1479 WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
duke@0 1480 WRAPPER_GetScalarArrayRegion(T_BYTE, jbyte, Byte)
duke@0 1481 WRAPPER_GetScalarArrayRegion(T_SHORT, jshort, Short)
duke@0 1482 WRAPPER_GetScalarArrayRegion(T_CHAR, jchar, Char)
duke@0 1483 WRAPPER_GetScalarArrayRegion(T_INT, jint, Int)
duke@0 1484 WRAPPER_GetScalarArrayRegion(T_LONG, jlong, Long)
duke@0 1485 WRAPPER_GetScalarArrayRegion(T_FLOAT, jfloat, Float)
duke@0 1486 WRAPPER_GetScalarArrayRegion(T_DOUBLE, jdouble, Double)
duke@0 1487
duke@0 1488 #define WRAPPER_SetScalarArrayRegion(ElementTag,ElementType,Result) \
duke@0 1489 JNI_ENTRY_CHECKED(void, \
duke@0 1490 checked_jni_Set##Result##ArrayRegion(JNIEnv *env, \
duke@0 1491 ElementType##Array array, \
duke@0 1492 jsize start, \
duke@0 1493 jsize len, \
duke@0 1494 const ElementType *buf)) \
duke@0 1495 functionEnter(thr); \
duke@0 1496 IN_VM( \
duke@0 1497 checkArray(thr, array, ElementTag); \
duke@0 1498 ) \
duke@0 1499 UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
duke@0 1500 functionExit(env); \
duke@0 1501 JNI_END
duke@0 1502
duke@0 1503 WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
duke@0 1504 WRAPPER_SetScalarArrayRegion(T_BYTE, jbyte, Byte)
duke@0 1505 WRAPPER_SetScalarArrayRegion(T_SHORT, jshort, Short)
duke@0 1506 WRAPPER_SetScalarArrayRegion(T_CHAR, jchar, Char)
duke@0 1507 WRAPPER_SetScalarArrayRegion(T_INT, jint, Int)
duke@0 1508 WRAPPER_SetScalarArrayRegion(T_LONG, jlong, Long)
duke@0 1509 WRAPPER_SetScalarArrayRegion(T_FLOAT, jfloat, Float)
duke@0 1510 WRAPPER_SetScalarArrayRegion(T_DOUBLE, jdouble, Double)
duke@0 1511
duke@0 1512 JNI_ENTRY_CHECKED(jint,
duke@0 1513 checked_jni_RegisterNatives(JNIEnv *env,
duke@0 1514 jclass clazz,
duke@0 1515 const JNINativeMethod *methods,
duke@0 1516 jint nMethods))
duke@0 1517 functionEnter(thr);
duke@0 1518 jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods);
duke@0 1519 functionExit(env);
duke@0 1520 return result;
duke@0 1521 JNI_END
duke@0 1522
duke@0 1523 JNI_ENTRY_CHECKED(jint,
duke@0 1524 checked_jni_UnregisterNatives(JNIEnv *env,
duke@0 1525 jclass clazz))
duke@0 1526 functionEnter(thr);
duke@0 1527 jint result = UNCHECKED()->UnregisterNatives(env,clazz);
duke@0 1528 functionExit(env);
duke@0 1529 return result;
duke@0 1530 JNI_END
duke@0 1531
duke@0 1532 JNI_ENTRY_CHECKED(jint,
duke@0 1533 checked_jni_MonitorEnter(JNIEnv *env,
duke@0 1534 jobject obj))
duke@0 1535 functionEnter(thr);
duke@0 1536 IN_VM(
duke@0 1537 jniCheck::validate_object(thr, obj);
duke@0 1538 )
duke@0 1539 jint result = UNCHECKED()->MonitorEnter(env,obj);
duke@0 1540 functionExit(env);
duke@0 1541 return result;
duke@0 1542 JNI_END
duke@0 1543
duke@0 1544 JNI_ENTRY_CHECKED(jint,
duke@0 1545 checked_jni_MonitorExit(JNIEnv *env,
duke@0 1546 jobject obj))
duke@0 1547 functionEnterExceptionAllowed(thr);
duke@0 1548 IN_VM(
duke@0 1549 jniCheck::validate_object(thr, obj);
duke@0 1550 )
duke@0 1551 jint result = UNCHECKED()->MonitorExit(env,obj);
duke@0 1552 functionExit(env);
duke@0 1553 return result;
duke@0 1554 JNI_END
duke@0 1555
duke@0 1556 JNI_ENTRY_CHECKED(jint,
duke@0 1557 checked_jni_GetJavaVM(JNIEnv *env,
duke@0 1558 JavaVM **vm))
duke@0 1559 functionEnter(thr);
duke@0 1560 jint result = UNCHECKED()->GetJavaVM(env,vm);
duke@0 1561 functionExit(env);
duke@0 1562 return result;
duke@0 1563 JNI_END
duke@0 1564
duke@0 1565 JNI_ENTRY_CHECKED(void,
duke@0 1566 checked_jni_GetStringRegion(JNIEnv *env,
duke@0 1567 jstring str,
duke@0 1568 jsize start,
duke@0 1569 jsize len,
duke@0 1570 jchar *buf))
duke@0 1571 functionEnter(thr);
duke@0 1572 IN_VM(
duke@0 1573 checkString(thr, str);
duke@0 1574 )
duke@0 1575 UNCHECKED()->GetStringRegion(env, str, start, len, buf);
duke@0 1576 functionExit(env);
duke@0 1577 JNI_END
duke@0 1578
duke@0 1579 JNI_ENTRY_CHECKED(void,
duke@0 1580 checked_jni_GetStringUTFRegion(JNIEnv *env,
duke@0 1581 jstring str,
duke@0 1582 jsize start,
duke@0 1583 jsize len,
duke@0 1584 char *buf))
duke@0 1585 functionEnter(thr);
duke@0 1586 IN_VM(
duke@0 1587 checkString(thr, str);
duke@0 1588 )
duke@0 1589 UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
duke@0 1590 functionExit(env);
duke@0 1591 JNI_END
duke@0 1592
duke@0 1593 JNI_ENTRY_CHECKED(void *,
duke@0 1594 checked_jni_GetPrimitiveArrayCritical(JNIEnv *env,
duke@0 1595 jarray array,
duke@0 1596 jboolean *isCopy))
duke@0 1597 functionEnterCritical(thr);
duke@0 1598 IN_VM(
duke@0 1599 checkArray(thr, array, -1);
duke@0 1600 )
duke@0 1601 void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy);
duke@0 1602 functionExit(env);
duke@0 1603 return result;
duke@0 1604 JNI_END
duke@0 1605
duke@0 1606 JNI_ENTRY_CHECKED(void,
duke@0 1607 checked_jni_ReleasePrimitiveArrayCritical(JNIEnv *env,
duke@0 1608 jarray array,
duke@0 1609 void *carray,
duke@0 1610 jint mode))
duke@0 1611 functionEnterCriticalExceptionAllowed(thr);
duke@0 1612 IN_VM(
duke@0 1613 checkArray(thr, array, -1);
duke@0 1614 )
duke@0 1615 /* The Hotspot JNI code does not use the parameters, so just check the
duke@0 1616 * array parameter as a minor sanity check
duke@0 1617 */
duke@0 1618 UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, carray, mode);
duke@0 1619 functionExit(env);
duke@0 1620 JNI_END
duke@0 1621
duke@0 1622 JNI_ENTRY_CHECKED(const jchar*,
duke@0 1623 checked_jni_GetStringCritical(JNIEnv *env,
duke@0 1624 jstring string,
duke@0 1625 jboolean *isCopy))
duke@0 1626 functionEnterCritical(thr);
duke@0 1627 IN_VM(
duke@0 1628 checkString(thr, string);
duke@0 1629 )
duke@0 1630 const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy);
duke@0 1631 functionExit(env);
duke@0 1632 return result;
duke@0 1633 JNI_END
duke@0 1634
duke@0 1635 JNI_ENTRY_CHECKED(void,
duke@0 1636 checked_jni_ReleaseStringCritical(JNIEnv *env,
duke@0 1637 jstring str,
duke@0 1638 const jchar *chars))
duke@0 1639 functionEnterCriticalExceptionAllowed(thr);
duke@0 1640 IN_VM(
duke@0 1641 checkString(thr, str);
duke@0 1642 )
duke@0 1643 /* The Hotspot JNI code does not use the parameters, so just check the
duke@0 1644 * string parameter as a minor sanity check
duke@0 1645 */
duke@0 1646 UNCHECKED()->ReleaseStringCritical(env, str, chars);
duke@0 1647 functionExit(env);
duke@0 1648 JNI_END
duke@0 1649
duke@0 1650 JNI_ENTRY_CHECKED(jweak,
duke@0 1651 checked_jni_NewWeakGlobalRef(JNIEnv *env,
duke@0 1652 jobject obj))
duke@0 1653 functionEnter(thr);
duke@0 1654 IN_VM(
duke@0 1655 if (obj != NULL) {
duke@0 1656 jniCheck::validate_handle(thr, obj);
duke@0 1657 }
duke@0 1658 )
duke@0 1659 jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj);
duke@0 1660 functionExit(env);
duke@0 1661 return result;
duke@0 1662 JNI_END
duke@0 1663
duke@0 1664 JNI_ENTRY_CHECKED(void,
duke@0 1665 checked_jni_DeleteWeakGlobalRef(JNIEnv *env,
duke@0 1666 jweak ref))
duke@0 1667 functionEnterExceptionAllowed(thr);
duke@0 1668 UNCHECKED()->DeleteWeakGlobalRef(env, ref);
duke@0 1669 functionExit(env);
duke@0 1670 JNI_END
duke@0 1671
duke@0 1672 JNI_ENTRY_CHECKED(jboolean,
duke@0 1673 checked_jni_ExceptionCheck(JNIEnv *env))
duke@0 1674 functionEnterExceptionAllowed(thr);
duke@0 1675 jboolean result = UNCHECKED()->ExceptionCheck(env);
duke@0 1676 functionExit(env);
duke@0 1677 return result;
duke@0 1678 JNI_END
duke@0 1679
duke@0 1680 JNI_ENTRY_CHECKED(jobject,
duke@0 1681 checked_jni_NewDirectByteBuffer(JNIEnv *env,
duke@0 1682 void *address,
duke@0 1683 jlong capacity))
duke@0 1684 functionEnter(thr);
duke@0 1685 jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity);
duke@0 1686 functionExit(env);
duke@0 1687 return result;
duke@0 1688 JNI_END
duke@0 1689
duke@0 1690 JNI_ENTRY_CHECKED(void *,
duke@0 1691 checked_jni_GetDirectBufferAddress(JNIEnv *env,
duke@0 1692 jobject buf))
duke@0 1693 functionEnter(thr);
duke@0 1694 void* result = UNCHECKED()->GetDirectBufferAddress(env, buf);
duke@0 1695 functionExit(env);
duke@0 1696 return result;
duke@0 1697 JNI_END
duke@0 1698
duke@0 1699 JNI_ENTRY_CHECKED(jlong,
duke@0 1700 checked_jni_GetDirectBufferCapacity(JNIEnv *env,
duke@0 1701 jobject buf))
duke@0 1702 functionEnter(thr);
duke@0 1703 jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf);
duke@0 1704 functionExit(env);
duke@0 1705 return result;
duke@0 1706 JNI_END
duke@0 1707
duke@0 1708 JNI_ENTRY_CHECKED(jobjectRefType,
duke@0 1709 checked_jni_GetObjectRefType(JNIEnv *env,
duke@0 1710 jobject obj))
duke@0 1711 functionEnter(thr);
duke@0 1712 /* validate the object being passed */
duke@0 1713 IN_VM(
duke@0 1714 jniCheck::validate_object(thr, obj);
duke@0 1715 )
duke@0 1716 jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj);
duke@0 1717 functionExit(env);
duke@0 1718 return result;
duke@0 1719 JNI_END
duke@0 1720
duke@0 1721
duke@0 1722 JNI_ENTRY_CHECKED(jint,
duke@0 1723 checked_jni_GetVersion(JNIEnv *env))
duke@0 1724 functionEnter(thr);
duke@0 1725 jint result = UNCHECKED()->GetVersion(env);
duke@0 1726 functionExit(env);
duke@0 1727 return result;
duke@0 1728 JNI_END
duke@0 1729
duke@0 1730
duke@0 1731
duke@0 1732 /*
duke@0 1733 * Structure containing all checked jni functions
duke@0 1734 */
duke@0 1735 struct JNINativeInterface_ checked_jni_NativeInterface = {
duke@0 1736 NULL,
duke@0 1737 NULL,
duke@0 1738 NULL,
duke@0 1739
duke@0 1740 NULL,
duke@0 1741
duke@0 1742 checked_jni_GetVersion,
duke@0 1743
duke@0 1744 checked_jni_DefineClass,
duke@0 1745 checked_jni_FindClass,
duke@0 1746
duke@0 1747 checked_jni_FromReflectedMethod,
duke@0 1748 checked_jni_FromReflectedField,
duke@0 1749
duke@0 1750 checked_jni_ToReflectedMethod,
duke@0 1751
duke@0 1752 checked_jni_GetSuperclass,
duke@0 1753 checked_jni_IsAssignableFrom,
duke@0 1754
duke@0 1755 checked_jni_ToReflectedField,
duke@0 1756
duke@0 1757 checked_jni_Throw,
duke@0 1758 checked_jni_ThrowNew,
duke@0 1759 checked_jni_ExceptionOccurred,
duke@0 1760 checked_jni_ExceptionDescribe,
duke@0 1761 checked_jni_ExceptionClear,
duke@0 1762 checked_jni_FatalError,
duke@0 1763
duke@0 1764 checked_jni_PushLocalFrame,
duke@0 1765 checked_jni_PopLocalFrame,
duke@0 1766
duke@0 1767 checked_jni_NewGlobalRef,
duke@0 1768 checked_jni_DeleteGlobalRef,
duke@0 1769 checked_jni_DeleteLocalRef,
duke@0 1770 checked_jni_IsSameObject,
duke@0 1771
duke@0 1772 checked_jni_NewLocalRef,
duke@0 1773 checked_jni_EnsureLocalCapacity,
duke@0 1774
duke@0 1775 checked_jni_AllocObject,
duke@0 1776 checked_jni_NewObject,
duke@0 1777 checked_jni_NewObjectV,
duke@0 1778 checked_jni_NewObjectA,
duke@0 1779
duke@0 1780 checked_jni_GetObjectClass,
duke@0 1781 checked_jni_IsInstanceOf,
duke@0 1782
duke@0 1783 checked_jni_GetMethodID,
duke@0 1784
duke@0 1785 checked_jni_CallObjectMethod,
duke@0 1786 checked_jni_CallObjectMethodV,
duke@0 1787 checked_jni_CallObjectMethodA,
duke@0 1788 checked_jni_CallBooleanMethod,
duke@0 1789 checked_jni_CallBooleanMethodV,
duke@0 1790 checked_jni_CallBooleanMethodA,
duke@0 1791 checked_jni_CallByteMethod,
duke@0 1792 checked_jni_CallByteMethodV,
duke@0 1793 checked_jni_CallByteMethodA,
duke@0 1794 checked_jni_CallCharMethod,
duke@0 1795 checked_jni_CallCharMethodV,
duke@0 1796 checked_jni_CallCharMethodA,
duke@0 1797 checked_jni_CallShortMethod,
duke@0 1798 checked_jni_CallShortMethodV,
duke@0 1799 checked_jni_CallShortMethodA,
duke@0 1800 checked_jni_CallIntMethod,
duke@0 1801 checked_jni_CallIntMethodV,
duke@0 1802 checked_jni_CallIntMethodA,
duke@0 1803 checked_jni_CallLongMethod,
duke@0 1804 checked_jni_CallLongMethodV,
duke@0 1805 checked_jni_CallLongMethodA,
duke@0 1806 checked_jni_CallFloatMethod,
duke@0 1807 checked_jni_CallFloatMethodV,
duke@0 1808 checked_jni_CallFloatMethodA,
duke@0 1809 checked_jni_CallDoubleMethod,
duke@0 1810 checked_jni_CallDoubleMethodV,
duke@0 1811 checked_jni_CallDoubleMethodA,
duke@0 1812 checked_jni_CallVoidMethod,
duke@0 1813 checked_jni_CallVoidMethodV,
duke@0 1814 checked_jni_CallVoidMethodA,
duke@0 1815
duke@0 1816 checked_jni_CallNonvirtualObjectMethod,
duke@0 1817 checked_jni_CallNonvirtualObjectMethodV,
duke@0 1818 checked_jni_CallNonvirtualObjectMethodA,
duke@0 1819 checked_jni_CallNonvirtualBooleanMethod,
duke@0 1820 checked_jni_CallNonvirtualBooleanMethodV,
duke@0 1821 checked_jni_CallNonvirtualBooleanMethodA,
duke@0 1822 checked_jni_CallNonvirtualByteMethod,
duke@0 1823 checked_jni_CallNonvirtualByteMethodV,
duke@0 1824 checked_jni_CallNonvirtualByteMethodA,
duke@0 1825 checked_jni_CallNonvirtualCharMethod,
duke@0 1826 checked_jni_CallNonvirtualCharMethodV,
duke@0 1827 checked_jni_CallNonvirtualCharMethodA,
duke@0 1828 checked_jni_CallNonvirtualShortMethod,
duke@0 1829 checked_jni_CallNonvirtualShortMethodV,
duke@0 1830 checked_jni_CallNonvirtualShortMethodA,
duke@0 1831 checked_jni_CallNonvirtualIntMethod,
duke@0 1832 checked_jni_CallNonvirtualIntMethodV,
duke@0 1833 checked_jni_CallNonvirtualIntMethodA,
duke@0 1834 checked_jni_CallNonvirtualLongMethod,
duke@0 1835 checked_jni_CallNonvirtualLongMethodV,
duke@0 1836 checked_jni_CallNonvirtualLongMethodA,
duke@0 1837 checked_jni_CallNonvirtualFloatMethod,
duke@0 1838 checked_jni_CallNonvirtualFloatMethodV,
duke@0 1839 checked_jni_CallNonvirtualFloatMethodA,
duke@0 1840 checked_jni_CallNonvirtualDoubleMethod,
duke@0 1841 checked_jni_CallNonvirtualDoubleMethodV,
duke@0 1842 checked_jni_CallNonvirtualDoubleMethodA,
duke@0 1843 checked_jni_CallNonvirtualVoidMethod,
duke@0 1844 checked_jni_CallNonvirtualVoidMethodV,
duke@0 1845 checked_jni_CallNonvirtualVoidMethodA,
duke@0 1846
duke@0 1847 checked_jni_GetFieldID,
duke@0 1848
duke@0 1849 checked_jni_GetObjectField,
duke@0 1850 checked_jni_GetBooleanField,
duke@0 1851 checked_jni_GetByteField,
duke@0 1852 checked_jni_GetCharField,
duke@0 1853 checked_jni_GetShortField,
duke@0 1854 checked_jni_GetIntField,
duke@0 1855 checked_jni_GetLongField,
duke@0 1856 checked_jni_GetFloatField,
duke@0 1857 checked_jni_GetDoubleField,
duke@0 1858
duke@0 1859 checked_jni_SetObjectField,
duke@0 1860 checked_jni_SetBooleanField,
duke@0 1861 checked_jni_SetByteField,
duke@0 1862 checked_jni_SetCharField,
duke@0 1863 checked_jni_SetShortField,
duke@0 1864 checked_jni_SetIntField,
duke@0 1865 checked_jni_SetLongField,
duke@0 1866 checked_jni_SetFloatField,
duke@0 1867 checked_jni_SetDoubleField,
duke@0 1868
duke@0 1869 checked_jni_GetStaticMethodID,
duke@0 1870
duke@0 1871 checked_jni_CallStaticObjectMethod,
duke@0 1872 checked_jni_CallStaticObjectMethodV,
duke@0 1873 checked_jni_CallStaticObjectMethodA,
duke@0 1874 checked_jni_CallStaticBooleanMethod,
duke@0 1875 checked_jni_CallStaticBooleanMethodV,
duke@0 1876 checked_jni_CallStaticBooleanMethodA,
duke@0 1877 checked_jni_CallStaticByteMethod,
duke@0 1878 checked_jni_CallStaticByteMethodV,
duke@0 1879 checked_jni_CallStaticByteMethodA,
duke@0 1880 checked_jni_CallStaticCharMethod,
duke@0 1881 checked_jni_CallStaticCharMethodV,
duke@0 1882 checked_jni_CallStaticCharMethodA,
duke@0 1883 checked_jni_CallStaticShortMethod,
duke@0 1884 checked_jni_CallStaticShortMethodV,
duke@0 1885 checked_jni_CallStaticShortMethodA,
duke@0 1886 checked_jni_CallStaticIntMethod,
duke@0 1887 checked_jni_CallStaticIntMethodV,
duke@0 1888 checked_jni_CallStaticIntMethodA,
duke@0 1889 checked_jni_CallStaticLongMethod,
duke@0 1890 checked_jni_CallStaticLongMethodV,
duke@0 1891 checked_jni_CallStaticLongMethodA,
duke@0 1892 checked_jni_CallStaticFloatMethod,
duke@0 1893 checked_jni_CallStaticFloatMethodV,
duke@0 1894 checked_jni_CallStaticFloatMethodA,
duke@0 1895 checked_jni_CallStaticDoubleMethod,
duke@0 1896 checked_jni_CallStaticDoubleMethodV,
duke@0 1897 checked_jni_CallStaticDoubleMethodA,
duke@0 1898 checked_jni_CallStaticVoidMethod,
duke@0 1899 checked_jni_CallStaticVoidMethodV,
duke@0 1900 checked_jni_CallStaticVoidMethodA,
duke@0 1901
duke@0 1902 checked_jni_GetStaticFieldID,
duke@0 1903
duke@0 1904 checked_jni_GetStaticObjectField,
duke@0 1905 checked_jni_GetStaticBooleanField,
duke@0 1906 checked_jni_GetStaticByteField,
duke@0 1907 checked_jni_GetStaticCharField,
duke@0 1908 checked_jni_GetStaticShortField,
duke@0 1909 checked_jni_GetStaticIntField,
duke@0 1910 checked_jni_GetStaticLongField,
duke@0 1911 checked_jni_GetStaticFloatField,
duke@0 1912 checked_jni_GetStaticDoubleField,
duke@0 1913
duke@0 1914 checked_jni_SetStaticObjectField,
duke@0 1915 checked_jni_SetStaticBooleanField,
duke@0 1916 checked_jni_SetStaticByteField,
duke@0 1917 checked_jni_SetStaticCharField,
duke@0 1918 checked_jni_SetStaticShortField,
duke@0 1919 checked_jni_SetStaticIntField,
duke@0 1920 checked_jni_SetStaticLongField,
duke@0 1921 checked_jni_SetStaticFloatField,
duke@0 1922 checked_jni_SetStaticDoubleField,
duke@0 1923
duke@0 1924 checked_jni_NewString,
duke@0 1925 checked_jni_GetStringLength,
duke@0 1926 checked_jni_GetStringChars,
duke@0 1927 checked_jni_ReleaseStringChars,
duke@0 1928
duke@0 1929 checked_jni_NewStringUTF,
duke@0 1930 checked_jni_GetStringUTFLength,
duke@0 1931 checked_jni_GetStringUTFChars,
duke@0 1932 checked_jni_ReleaseStringUTFChars,
duke@0 1933
duke@0 1934 checked_jni_GetArrayLength,
duke@0 1935
duke@0 1936 checked_jni_NewObjectArray,
duke@0 1937 checked_jni_GetObjectArrayElement,
duke@0 1938 checked_jni_SetObjectArrayElement,
duke@0 1939
duke@0 1940 checked_jni_NewBooleanArray,
duke@0 1941 checked_jni_NewByteArray,
duke@0 1942 checked_jni_NewCharArray,
duke@0 1943 checked_jni_NewShortArray,
duke@0 1944 checked_jni_NewIntArray,
duke@0 1945 checked_jni_NewLongArray,
duke@0 1946 checked_jni_NewFloatArray,
duke@0 1947 checked_jni_NewDoubleArray,
duke@0 1948
duke@0 1949 checked_jni_GetBooleanArrayElements,
duke@0 1950 checked_jni_GetByteArrayElements,
duke@0 1951 checked_jni_GetCharArrayElements,
duke@0 1952 checked_jni_GetShortArrayElements,
duke@0 1953 checked_jni_GetIntArrayElements,
duke@0 1954 checked_jni_GetLongArrayElements,
duke@0 1955 checked_jni_GetFloatArrayElements,
duke@0 1956 checked_jni_GetDoubleArrayElements,
duke@0 1957
duke@0 1958 checked_jni_ReleaseBooleanArrayElements,
duke@0 1959 checked_jni_ReleaseByteArrayElements,
duke@0 1960 checked_jni_ReleaseCharArrayElements,
duke@0 1961 checked_jni_ReleaseShortArrayElements,
duke@0 1962 checked_jni_ReleaseIntArrayElements,
duke@0 1963 checked_jni_ReleaseLongArrayElements,
duke@0 1964 checked_jni_ReleaseFloatArrayElements,
duke@0 1965 checked_jni_ReleaseDoubleArrayElements,
duke@0 1966
duke@0 1967 checked_jni_GetBooleanArrayRegion,
duke@0 1968 checked_jni_GetByteArrayRegion,
duke@0 1969 checked_jni_GetCharArrayRegion,
duke@0 1970 checked_jni_GetShortArrayRegion,
duke@0 1971 checked_jni_GetIntArrayRegion,
duke@0 1972 checked_jni_GetLongArrayRegion,
duke@0 1973 checked_jni_GetFloatArrayRegion,
duke@0 1974 checked_jni_GetDoubleArrayRegion,
duke@0 1975
duke@0 1976 checked_jni_SetBooleanArrayRegion,
duke@0 1977 checked_jni_SetByteArrayRegion,
duke@0 1978 checked_jni_SetCharArrayRegion,
duke@0 1979 checked_jni_SetShortArrayRegion,
duke@0 1980 checked_jni_SetIntArrayRegion,
duke@0 1981 checked_jni_SetLongArrayRegion,
duke@0 1982 checked_jni_SetFloatArrayRegion,
duke@0 1983 checked_jni_SetDoubleArrayRegion,
duke@0 1984
duke@0 1985 checked_jni_RegisterNatives,
duke@0 1986 checked_jni_UnregisterNatives,
duke@0 1987
duke@0 1988 checked_jni_MonitorEnter,
duke@0 1989 checked_jni_MonitorExit,
duke@0 1990
duke@0 1991 checked_jni_GetJavaVM,
duke@0 1992
duke@0 1993 checked_jni_GetStringRegion,
duke@0 1994 checked_jni_GetStringUTFRegion,
duke@0 1995
duke@0 1996 checked_jni_GetPrimitiveArrayCritical,
duke@0 1997 checked_jni_ReleasePrimitiveArrayCritical,
duke@0 1998
duke@0 1999 checked_jni_GetStringCritical,
duke@0 2000 checked_jni_ReleaseStringCritical,
duke@0 2001
duke@0 2002 checked_jni_NewWeakGlobalRef,
duke@0 2003 checked_jni_DeleteWeakGlobalRef,
duke@0 2004
duke@0 2005 checked_jni_ExceptionCheck,
duke@0 2006
duke@0 2007 checked_jni_NewDirectByteBuffer,
duke@0 2008 checked_jni_GetDirectBufferAddress,
duke@0 2009 checked_jni_GetDirectBufferCapacity,
duke@0 2010
duke@0 2011 // New 1.6 Features
duke@0 2012
duke@0 2013 checked_jni_GetObjectRefType
duke@0 2014 };
duke@0 2015
duke@0 2016
duke@0 2017 // Returns the function structure
duke@0 2018 struct JNINativeInterface_* jni_functions_check() {
duke@0 2019
duke@0 2020 unchecked_jni_NativeInterface = jni_functions_nocheck();
duke@0 2021
duke@0 2022 // make sure the last pointer in the checked table is not null, indicating
duke@0 2023 // an addition to the JNINativeInterface_ structure without initializing
duke@0 2024 // it in the checked table.
duke@0 2025 debug_only(int *lastPtr = (int *)((char *)&checked_jni_NativeInterface + \
duke@0 2026 sizeof(*unchecked_jni_NativeInterface) - sizeof(char *));)
duke@0 2027 assert(*lastPtr != 0,
duke@0 2028 "Mismatched JNINativeInterface tables, check for new entries");
duke@0 2029
duke@0 2030 // with -verbose:jni this message will print
duke@0 2031 if (PrintJNIResolving) {
duke@0 2032 tty->print_cr("Checked JNI functions are being used to " \
duke@0 2033 "validate JNI usage");
duke@0 2034 }
duke@0 2035
duke@0 2036 return &checked_jni_NativeInterface;
duke@0 2037 }