rev 1876 : 6539281 -Xcheck:jni should validate char* argument to ReleaseStringUTFChars

   1 /*
   2  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "oops/instanceKlass.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/symbolOop.hpp"
  31 #include "prims/jni.h"
  32 #include "prims/jniCheck.hpp"
  33 #include "prims/jvm_misc.hpp"
  34 #include "runtime/fieldDescriptor.hpp"
  35 #include "runtime/handles.hpp"
  36 #include "runtime/interfaceSupport.hpp"
  37 #include "runtime/jfieldIDWorkaround.hpp"
  38 #include "runtime/thread.hpp"
  39 #ifdef TARGET_ARCH_x86
  40 # include "jniTypes_x86.hpp"
  41 #endif
  42 #ifdef TARGET_ARCH_sparc
  43 # include "jniTypes_sparc.hpp"
  44 #endif
  45 #ifdef TARGET_ARCH_zero
  46 # include "jniTypes_zero.hpp"
  47 #endif
  48 
  49 
  50 // Heap objects are allowed to be directly referenced only in VM code,
  51 // not in native code.
  52 
  53 #define ASSERT_OOPS_ALLOWED                                          \
  54     assert(JavaThread::current()->thread_state() == _thread_in_vm,   \
  55            "jniCheck examining oops in bad state.")
  56 
  57 
  58 // Execute the given block of source code with the thread in VM state.
  59 // To do this, transition from the NATIVE state to the VM state, execute
  60 // the code, and transtition back.  The ThreadInVMfromNative constructor
  61 // performs the transition to VM state, its destructor restores the
  62 // NATIVE state.
  63 
  64 #define IN_VM(source_code)   {                                         \
  65     {                                                                  \
  66       ThreadInVMfromNative __tiv(thr);                                 \
  67       source_code                                                      \
  68     }                                                                  \
  69   }
  70 
  71 
  72 /*
  73  * DECLARATIONS
  74  */
  75 
  76 static struct JNINativeInterface_ * unchecked_jni_NativeInterface;
  77 
  78 
  79 /*
  80  * MACRO DEFINITIONS
  81  */
  82 
  83 // All JNI checked functions here use JNI_ENTRY_CHECKED() instead of the
  84 // QUICK_ENTRY or LEAF variants found in jni.cpp.  This allows handles
  85 // to be created if a fatal error should occur.
  86 
  87 // Check for thread not attached to VM;  need to catch this before
  88 // assertions in the wrapper routines might fire
  89 
  90 // Check for env being the one value appropriate for this thread.
  91 
  92 #define JNI_ENTRY_CHECKED(result_type, header)                           \
  93 extern "C" {                                                             \
  94   result_type JNICALL header {                                           \
  95     JavaThread* thr = (JavaThread*)ThreadLocalStorage::get_thread_slow();\
  96     if (thr == NULL || !thr->is_Java_thread()) {                         \
  97       tty->print_cr(fatal_using_jnienv_in_nonjava);                      \
  98       os::abort(true);                                                   \
  99     }                                                                    \
 100     JNIEnv* xenv = thr->jni_environment();                               \
 101     if (env != xenv) {                                                   \
 102       NativeReportJNIFatalError(thr, warn_wrong_jnienv);                 \
 103     }                                                                    \
 104     __ENTRY(result_type, header, thr)
 105 
 106 
 107 #define UNCHECKED() (unchecked_jni_NativeInterface)
 108 
 109 static const char * warn_wrong_jnienv = "Using JNIEnv in the wrong thread";
 110 static const char * warn_bad_class_descriptor = "JNI FindClass received a bad class descriptor \"%s\".  A correct class descriptor " \
 111   "has no leading \"L\" or trailing \";\".  Incorrect descriptors will not be accepted in future releases.";
 112 static const char * fatal_using_jnienv_in_nonjava = "FATAL ERROR in native method: Using JNIEnv in non-Java thread";
 113 static const char * warn_other_function_in_critical = "Warning: Calling other JNI functions in the scope of " \
 114   "Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical";
 115 static const char * fatal_bad_ref_to_jni = "Bad global or local ref passed to JNI";
 116 static const char * fatal_received_null_class = "JNI received a null class";
 117 static const char * fatal_class_not_a_class = "JNI received a class argument that is not a class";
 118 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";
 119 static const char * fatal_wrong_class_or_method = "Wrong object class or methodID passed to JNI call";
 120 static const char * fatal_non_weak_method = "non-weak methodID passed to JNI call";
 121 static const char * fatal_unknown_array_object = "Unknown array object passed to JNI array operations";
 122 static const char * fatal_object_array_expected = "Object array expected but not received for JNI array operation";
 123 static const char * fatal_non_array  = "Non-array passed to JNI array operations";
 124 static const char * fatal_element_type_mismatch = "Array element type mismatch in JNI";
 125 static const char * fatal_should_be_static = "Non-static field ID passed to JNI";
 126 static const char * fatal_wrong_static_field = "Wrong static field ID passed to JNI";
 127 static const char * fatal_static_field_not_found = "Static field not found in JNI get/set field operations";
 128 static const char * fatal_static_field_mismatch = "Field type (static) mismatch in JNI get/set field operations";
 129 static const char * fatal_should_be_nonstatic = "Static field ID passed to JNI";
 130 static const char * fatal_null_object = "Null object passed to JNI";
 131 static const char * fatal_wrong_field = "Wrong field ID passed to JNI";
 132 static const char * fatal_instance_field_not_found = "Instance field not found in JNI get/set field operations";
 133 static const char * fatal_instance_field_mismatch = "Field type (instance) mismatch in JNI get/set field operations";
 134 static const char * fatal_non_string = "JNI string operation received a non-string";
 135 
 136 
 137 // When in VM state:
 138 static void ReportJNIWarning(JavaThread* thr, const char *msg) {
 139   tty->print_cr("WARNING in native method: %s", msg);
 140   thr->print_stack();
 141 }
 142 
 143 // When in NATIVE state:
 144 static void NativeReportJNIFatalError(JavaThread* thr, const char *msg) {
 145   IN_VM(
 146     ReportJNIFatalError(thr, msg);
 147   )
 148 }
 149 
 150 static void NativeReportJNIWarning(JavaThread* thr, const char *msg) {
 151   IN_VM(
 152     ReportJNIWarning(thr, msg);
 153   )
 154 }
 155 
 156 
 157 
 158 
 159 /*
 160  * SUPPORT FUNCTIONS
 161  */
 162 
 163 static inline void
 164 functionEnterCritical(JavaThread* thr)
 165 {
 166   if (thr->has_pending_exception()) {
 167     NativeReportJNIWarning(thr, "JNI call made with exception pending");
 168   }
 169 }
 170 
 171 static inline void
 172 functionEnterCriticalExceptionAllowed(JavaThread* thr)
 173 {
 174 }
 175 
 176 static inline void
 177 functionEnter(JavaThread* thr)
 178 {
 179   if (thr->in_critical()) {
 180     tty->print_cr(warn_other_function_in_critical);
 181   }
 182   if (thr->has_pending_exception()) {
 183     NativeReportJNIWarning(thr, "JNI call made with exception pending");
 184   }
 185 }
 186 
 187 static inline void
 188 functionEnterExceptionAllowed(JavaThread* thr)
 189 {
 190   if (thr->in_critical()) {
 191     tty->print_cr(warn_other_function_in_critical);
 192   }
 193 }
 194 
 195 static inline void
 196 functionExit(JNIEnv *env)
 197 {
 198   /* nothing to do at this time */
 199 }
 200 
 201 static inline void
 202 checkStaticFieldID(JavaThread* thr, jfieldID fid, jclass cls, int ftype)
 203 {
 204   fieldDescriptor fd;
 205 
 206   /* make sure it is a static field */
 207   if (!jfieldIDWorkaround::is_static_jfieldID(fid))
 208     ReportJNIFatalError(thr, fatal_should_be_static);
 209 
 210   /* validate the class being passed */
 211   ASSERT_OOPS_ALLOWED;
 212   klassOop k_oop = jniCheck::validate_class(thr, cls, false);
 213 
 214   /* check for proper subclass hierarchy */
 215   JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fid);
 216   klassOop f_oop = id->holder();
 217   if (!instanceKlass::cast(k_oop)->is_subtype_of(f_oop))
 218     ReportJNIFatalError(thr, fatal_wrong_static_field);
 219 
 220   /* check for proper field type */
 221   if (!instanceKlass::cast(f_oop)->find_local_field_from_offset(
 222           id->offset(), true, &fd))
 223     ReportJNIFatalError(thr, fatal_static_field_not_found);
 224   if ((fd.field_type() != ftype) &&
 225       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
 226     ReportJNIFatalError(thr, fatal_static_field_mismatch);
 227   }
 228 }
 229 
 230 static inline void
 231 checkInstanceFieldID(JavaThread* thr, jfieldID fid, jobject obj, int ftype)
 232 {
 233   fieldDescriptor fd;
 234 
 235   /* make sure it is an instance field */
 236   if (jfieldIDWorkaround::is_static_jfieldID(fid))
 237     ReportJNIFatalError(thr, fatal_should_be_nonstatic);
 238 
 239   /* validate the object being passed and then get its class */
 240   ASSERT_OOPS_ALLOWED;
 241   oop oopObj = jniCheck::validate_object(thr, obj);
 242   if (!oopObj) {
 243     ReportJNIFatalError(thr, fatal_null_object);
 244   }
 245   klassOop k_oop = oopObj->klass();
 246 
 247   if (!jfieldIDWorkaround::is_valid_jfieldID(k_oop, fid)) {
 248     ReportJNIFatalError(thr, fatal_wrong_field);
 249   }
 250 
 251   /* make sure the field exists */
 252   int offset = jfieldIDWorkaround::from_instance_jfieldID(k_oop, fid);
 253   if (!instanceKlass::cast(k_oop)->contains_field_offset(offset))
 254     ReportJNIFatalError(thr, fatal_wrong_field);
 255 
 256   /* check for proper field type */
 257   if (!instanceKlass::cast(k_oop)->find_field_from_offset(offset,
 258                                                               false, &fd))
 259     ReportJNIFatalError(thr, fatal_instance_field_not_found);
 260 
 261   if ((fd.field_type() != ftype) &&
 262       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
 263     ReportJNIFatalError(thr, fatal_instance_field_mismatch);
 264   }
 265 }
 266 
 267 static inline void
 268 checkString(JavaThread* thr, jstring js)
 269 {
 270   ASSERT_OOPS_ALLOWED;
 271   oop s = jniCheck::validate_object(thr, js);
 272   if (!s || !java_lang_String::is_instance(s))
 273     ReportJNIFatalError(thr, fatal_non_string);
 274 }
 275 
 276 static inline void
 277 checkArray(JavaThread* thr, jarray jArray, int elementType)
 278 {
 279   ASSERT_OOPS_ALLOWED;
 280   arrayOop aOop;
 281 
 282   aOop = (arrayOop)jniCheck::validate_object(thr, jArray);
 283   if (aOop == NULL || !aOop->is_array())
 284     ReportJNIFatalError(thr, fatal_non_array);
 285 
 286   if (elementType != -1) {
 287     if (aOop->is_typeArray()) {
 288       BasicType array_type = typeArrayKlass::cast(aOop->klass())->element_type();
 289       if (array_type != elementType)
 290         ReportJNIFatalError(thr, fatal_element_type_mismatch);
 291       } else if (aOop->is_objArray()) {
 292         if ( T_OBJECT != elementType)
 293           ReportJNIFatalError(thr, fatal_object_array_expected);
 294       } else {
 295         ReportJNIFatalError(thr, fatal_unknown_array_object);
 296     }
 297   }
 298 }
 299 
 300 
 301 oop jniCheck::validate_handle(JavaThread* thr, jobject obj) {
 302   if (JNIHandles::is_frame_handle(thr, obj) ||
 303       JNIHandles::is_local_handle(thr, obj) ||
 304       JNIHandles::is_global_handle(obj) ||
 305       JNIHandles::is_weak_global_handle(obj)) {
 306     ASSERT_OOPS_ALLOWED;
 307     return JNIHandles::resolve_external_guard(obj);
 308   }
 309   ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
 310   return NULL;
 311 }
 312 
 313 
 314 methodOop jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) {
 315   ASSERT_OOPS_ALLOWED;
 316   // do the fast jmethodID check first
 317   methodOop moop = JNIHandles::checked_resolve_jmethod_id(method_id);
 318   if (moop == NULL) {
 319     ReportJNIFatalError(thr, fatal_wrong_class_or_method);
 320   }
 321   // jmethodIDs are supposed to be weak global handles, but that
 322   // can be expensive so check it last
 323   else if (!JNIHandles::is_weak_global_handle((jobject) method_id)) {
 324     ReportJNIFatalError(thr, fatal_non_weak_method);
 325   }
 326   return moop;
 327 }
 328 
 329 
 330 oop jniCheck::validate_object(JavaThread* thr, jobject obj) {
 331     if (!obj)
 332         return NULL;
 333     ASSERT_OOPS_ALLOWED;
 334     oop oopObj = jniCheck::validate_handle(thr, obj);
 335     if (!oopObj) {
 336       ReportJNIFatalError(thr, fatal_bad_ref_to_jni);
 337     }
 338     return oopObj;
 339 }
 340 
 341 // Warn if a class descriptor is in decorated form; class descriptors
 342 // passed to JNI findClass should not be decorated unless they are
 343 // array descriptors.
 344 void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) {
 345   if (name == NULL) return;  // implementation accepts NULL so just return
 346 
 347   size_t len = strlen(name);
 348 
 349   if (len >= 2 &&
 350       name[0] == JVM_SIGNATURE_CLASS &&            // 'L'
 351       name[len-1] == JVM_SIGNATURE_ENDCLASS ) {    // ';'
 352     char msg[JVM_MAXPATHLEN];
 353     jio_snprintf(msg, JVM_MAXPATHLEN, warn_bad_class_descriptor, name);
 354     ReportJNIWarning(thr, msg);
 355   }
 356 }
 357 
 358 klassOop jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primitive) {
 359   ASSERT_OOPS_ALLOWED;
 360   oop mirror = jniCheck::validate_handle(thr, clazz);
 361   if (!mirror) {
 362     ReportJNIFatalError(thr, fatal_received_null_class);
 363   }
 364 
 365   if (mirror->klass() != SystemDictionary::Class_klass()) {
 366     ReportJNIFatalError(thr, fatal_class_not_a_class);
 367   }
 368 
 369   klassOop k = java_lang_Class::as_klassOop(mirror);
 370   // Make allowances for primitive classes ...
 371   if (!(k != NULL || allow_primitive && java_lang_Class::is_primitive(mirror))) {
 372     ReportJNIFatalError(thr, fatal_class_not_a_class);
 373   }
 374   return k;
 375 }
 376 
 377 void jniCheck::validate_throwable_klass(JavaThread* thr, klassOop klass) {
 378   ASSERT_OOPS_ALLOWED;
 379   assert(klass != NULL, "klass argument must have a value");
 380 
 381   if (!Klass::cast(klass)->oop_is_instance() ||
 382       !instanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) {
 383     ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
 384   }
 385 }
 386 
 387 void jniCheck::validate_call_object(JavaThread* thr, jobject obj, jmethodID method_id) {
 388   /* validate the object being passed */
 389   ASSERT_OOPS_ALLOWED;
 390   jniCheck::validate_jmethod_id(thr, method_id);
 391   jniCheck::validate_object(thr, obj);
 392 }
 393 
 394 void jniCheck::validate_call_class(JavaThread* thr, jclass clazz, jmethodID method_id) {
 395   /* validate the class being passed */
 396   ASSERT_OOPS_ALLOWED;
 397   jniCheck::validate_jmethod_id(thr, method_id);
 398   jniCheck::validate_class(thr, clazz, false);
 399 }
 400 
 401 
 402 /*
 403  * IMPLEMENTATION OF FUNCTIONS IN CHECKED TABLE
 404  */
 405 
 406 JNI_ENTRY_CHECKED(jclass,
 407   checked_jni_DefineClass(JNIEnv *env,
 408                           const char *name,
 409                           jobject loader,
 410                           const jbyte *buf,
 411                           jsize len))
 412     functionEnter(thr);
 413     IN_VM(
 414       jniCheck::validate_object(thr, loader);
 415     )
 416     jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len);
 417     functionExit(env);
 418     return result;
 419 JNI_END
 420 
 421 JNI_ENTRY_CHECKED(jclass,
 422   checked_jni_FindClass(JNIEnv *env,
 423                         const char *name))
 424     functionEnter(thr);
 425     IN_VM(
 426       jniCheck::validate_class_descriptor(thr, name);
 427     )
 428     jclass result = UNCHECKED()->FindClass(env, name);
 429     functionExit(env);
 430     return result;
 431 JNI_END
 432 
 433 JNI_ENTRY_CHECKED(jmethodID,
 434   checked_jni_FromReflectedMethod(JNIEnv *env,
 435                                   jobject method))
 436     functionEnter(thr);
 437     IN_VM(
 438       jniCheck::validate_object(thr, method);
 439     )
 440     jmethodID result = UNCHECKED()->FromReflectedMethod(env, method);
 441     functionExit(env);
 442     return result;
 443 JNI_END
 444 
 445 JNI_ENTRY_CHECKED(jfieldID,
 446   checked_jni_FromReflectedField(JNIEnv *env,
 447                                  jobject field))
 448     functionEnter(thr);
 449     IN_VM(
 450       jniCheck::validate_object(thr, field);
 451     )
 452     jfieldID result = UNCHECKED()->FromReflectedField(env, field);
 453     functionExit(env);
 454     return result;
 455 JNI_END
 456 
 457 JNI_ENTRY_CHECKED(jobject,
 458   checked_jni_ToReflectedMethod(JNIEnv *env,
 459                                 jclass cls,
 460                                 jmethodID methodID,
 461                                 jboolean isStatic))
 462     functionEnter(thr);
 463     IN_VM(
 464       jniCheck::validate_class(thr, cls, false);
 465       jniCheck::validate_jmethod_id(thr, methodID);
 466     )
 467     jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID,
 468                                                     isStatic);
 469     functionExit(env);
 470     return result;
 471 JNI_END
 472 
 473 JNI_ENTRY_CHECKED(jclass,
 474   checked_jni_GetSuperclass(JNIEnv *env,
 475                             jclass sub))
 476     functionEnter(thr);
 477     IN_VM(
 478       jniCheck::validate_class(thr, sub, true);
 479     )
 480     jclass result = UNCHECKED()->GetSuperclass(env, sub);
 481     functionExit(env);
 482     return result;
 483 JNI_END
 484 
 485 JNI_ENTRY_CHECKED(jboolean,
 486   checked_jni_IsAssignableFrom(JNIEnv *env,
 487                                jclass sub,
 488                                jclass sup))
 489     functionEnter(thr);
 490     IN_VM(
 491       jniCheck::validate_class(thr, sub, true);
 492       jniCheck::validate_class(thr, sup, true);
 493     )
 494     jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup);
 495     functionExit(env);
 496     return result;
 497 JNI_END
 498 
 499 JNI_ENTRY_CHECKED(jobject,
 500   checked_jni_ToReflectedField(JNIEnv *env,
 501                                jclass cls,
 502                                jfieldID fieldID,
 503                                jboolean isStatic))
 504     functionEnter(thr);
 505     IN_VM(
 506       jniCheck::validate_class(thr, cls, false);
 507     )
 508     jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID,
 509                                                    isStatic);
 510     functionExit(env);
 511     return result;
 512 JNI_END
 513 
 514 JNI_ENTRY_CHECKED(jint,
 515   checked_jni_Throw(JNIEnv *env,
 516                     jthrowable obj))
 517     functionEnter(thr);
 518     IN_VM(
 519       oop oopObj = jniCheck::validate_object(thr, obj);
 520       if (oopObj == NULL) {
 521         // Unchecked Throw tolerates a NULL obj, so just warn
 522         ReportJNIWarning(thr, "JNI Throw called with NULL throwable");
 523       } else {
 524         jniCheck::validate_throwable_klass(thr, oopObj->klass());
 525       }
 526     )
 527     jint result = UNCHECKED()->Throw(env, obj);
 528     functionExit(env);
 529     return result;
 530 JNI_END
 531 
 532 JNI_ENTRY_CHECKED(jint,
 533   checked_jni_ThrowNew(JNIEnv *env,
 534                        jclass clazz,
 535                        const char *msg))
 536     functionEnter(thr);
 537     IN_VM(
 538       klassOop k = jniCheck::validate_class(thr, clazz, false);
 539       assert(k != NULL, "validate_class shouldn't return NULL klassOop");
 540       jniCheck::validate_throwable_klass(thr, k);
 541     )
 542     jint result = UNCHECKED()->ThrowNew(env, clazz, msg);
 543     functionExit(env);
 544     return result;
 545 JNI_END
 546 
 547 JNI_ENTRY_CHECKED(jthrowable,
 548   checked_jni_ExceptionOccurred(JNIEnv *env))
 549     functionEnterExceptionAllowed(thr);
 550     jthrowable result = UNCHECKED()->ExceptionOccurred(env);
 551     functionExit(env);
 552     return result;
 553 JNI_END
 554 
 555 JNI_ENTRY_CHECKED(void,
 556   checked_jni_ExceptionDescribe(JNIEnv *env))
 557     functionEnterExceptionAllowed(thr);
 558     UNCHECKED()->ExceptionDescribe(env);
 559     functionExit(env);
 560 JNI_END
 561 
 562 JNI_ENTRY_CHECKED(void,
 563   checked_jni_ExceptionClear(JNIEnv *env))
 564     functionEnterExceptionAllowed(thr);
 565     UNCHECKED()->ExceptionClear(env);
 566     functionExit(env);
 567 JNI_END
 568 
 569 JNI_ENTRY_CHECKED(void,
 570   checked_jni_FatalError(JNIEnv *env,
 571                          const char *msg))
 572     functionEnter(thr);
 573     UNCHECKED()->FatalError(env, msg);
 574     functionExit(env);
 575 JNI_END
 576 
 577 JNI_ENTRY_CHECKED(jint,
 578   checked_jni_PushLocalFrame(JNIEnv *env,
 579                              jint capacity))
 580     functionEnterExceptionAllowed(thr);
 581     if (capacity < 0)
 582       NativeReportJNIFatalError(thr, "negative capacity");
 583     jint result = UNCHECKED()->PushLocalFrame(env, capacity);
 584     functionExit(env);
 585     return result;
 586 JNI_END
 587 
 588 JNI_ENTRY_CHECKED(jobject,
 589   checked_jni_PopLocalFrame(JNIEnv *env,
 590                             jobject result))
 591     functionEnterExceptionAllowed(thr);
 592     jobject res = UNCHECKED()->PopLocalFrame(env, result);
 593     functionExit(env);
 594     return res;
 595 JNI_END
 596 
 597 JNI_ENTRY_CHECKED(jobject,
 598   checked_jni_NewGlobalRef(JNIEnv *env,
 599                            jobject lobj))
 600     functionEnter(thr);
 601     IN_VM(
 602       if (lobj != NULL) {
 603         jniCheck::validate_handle(thr, lobj);
 604       }
 605     )
 606     jobject result = UNCHECKED()->NewGlobalRef(env,lobj);
 607     functionExit(env);
 608     return result;
 609 JNI_END
 610 
 611 JNI_ENTRY_CHECKED(void,
 612   checked_jni_DeleteGlobalRef(JNIEnv *env,
 613                               jobject gref))
 614     functionEnterExceptionAllowed(thr);
 615     IN_VM(
 616       jniCheck::validate_object(thr, gref);
 617       if (gref && !JNIHandles::is_global_handle(gref)) {
 618         ReportJNIFatalError(thr,
 619             "Invalid global JNI handle passed to DeleteGlobalRef");
 620       }
 621     )
 622     UNCHECKED()->DeleteGlobalRef(env,gref);
 623     functionExit(env);
 624 JNI_END
 625 
 626 JNI_ENTRY_CHECKED(void,
 627   checked_jni_DeleteLocalRef(JNIEnv *env,
 628                              jobject obj))
 629     functionEnterExceptionAllowed(thr);
 630     IN_VM(
 631       jniCheck::validate_object(thr, obj);
 632       if (obj && !(JNIHandles::is_local_handle(thr, obj) ||
 633                    JNIHandles::is_frame_handle(thr, obj)))
 634         ReportJNIFatalError(thr,
 635             "Invalid local JNI handle passed to DeleteLocalRef");
 636     )
 637     UNCHECKED()->DeleteLocalRef(env, obj);
 638     functionExit(env);
 639 JNI_END
 640 
 641 JNI_ENTRY_CHECKED(jboolean,
 642   checked_jni_IsSameObject(JNIEnv *env,
 643                            jobject obj1,
 644                            jobject obj2))
 645     functionEnterExceptionAllowed(thr);
 646     IN_VM(
 647       /* This JNI function can be used to compare weak global references
 648        * to NULL objects. If the handles are valid, but contain NULL,
 649        * then don't attempt to validate the object.
 650        */
 651       if (obj1 != NULL && jniCheck::validate_handle(thr, obj1) != NULL) {
 652         jniCheck::validate_object(thr, obj1);
 653       }
 654       if (obj2 != NULL && jniCheck::validate_handle(thr, obj2) != NULL) {
 655         jniCheck::validate_object(thr, obj2);
 656       }
 657     )
 658     jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2);
 659     functionExit(env);
 660     return result;
 661 JNI_END
 662 
 663 JNI_ENTRY_CHECKED(jobject,
 664   checked_jni_NewLocalRef(JNIEnv *env,
 665                           jobject ref))
 666     functionEnter(thr);
 667     IN_VM(
 668       if (ref != NULL) {
 669         jniCheck::validate_handle(thr, ref);
 670       }
 671     )
 672     jobject result = UNCHECKED()->NewLocalRef(env, ref);
 673     functionExit(env);
 674     return result;
 675 JNI_END
 676 
 677 JNI_ENTRY_CHECKED(jint,
 678   checked_jni_EnsureLocalCapacity(JNIEnv *env,
 679                                   jint capacity))
 680     functionEnter(thr);
 681     if (capacity < 0) {
 682       NativeReportJNIFatalError(thr, "negative capacity");
 683     }
 684     jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
 685     functionExit(env);
 686     return result;
 687 JNI_END
 688 
 689 JNI_ENTRY_CHECKED(jobject,
 690   checked_jni_AllocObject(JNIEnv *env,
 691                           jclass clazz))
 692     functionEnter(thr);
 693     IN_VM(
 694       jniCheck::validate_class(thr, clazz, false);
 695     )
 696     jobject result = UNCHECKED()->AllocObject(env,clazz);
 697     functionExit(env);
 698     return result;
 699 JNI_END
 700 
 701 JNI_ENTRY_CHECKED(jobject,
 702   checked_jni_NewObject(JNIEnv *env,
 703                         jclass clazz,
 704                         jmethodID methodID,
 705                         ...))
 706     functionEnter(thr);
 707     va_list args;
 708     IN_VM(
 709       jniCheck::validate_class(thr, clazz, false);
 710       jniCheck::validate_jmethod_id(thr, methodID);
 711     )
 712     va_start(args, methodID);
 713     jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
 714     va_end(args);
 715     functionExit(env);
 716     return result;
 717 JNI_END
 718 
 719 JNI_ENTRY_CHECKED(jobject,
 720   checked_jni_NewObjectV(JNIEnv *env,
 721                          jclass clazz,
 722                          jmethodID methodID,
 723                          va_list args))
 724     functionEnter(thr);
 725     IN_VM(
 726       jniCheck::validate_class(thr, clazz, false);
 727       jniCheck::validate_jmethod_id(thr, methodID);
 728     )
 729     jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
 730     functionExit(env);
 731     return result;
 732 JNI_END
 733 
 734 JNI_ENTRY_CHECKED(jobject,
 735   checked_jni_NewObjectA(JNIEnv *env,
 736                          jclass clazz,
 737                          jmethodID methodID,
 738                          const jvalue *args))
 739     functionEnter(thr);
 740     IN_VM(
 741       jniCheck::validate_class(thr, clazz, false);
 742       jniCheck::validate_jmethod_id(thr, methodID);
 743     )
 744     jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args);
 745     functionExit(env);
 746     return result;
 747 JNI_END
 748 
 749 JNI_ENTRY_CHECKED(jclass,
 750   checked_jni_GetObjectClass(JNIEnv *env,
 751                              jobject obj))
 752     functionEnter(thr);
 753     IN_VM(
 754       jniCheck::validate_object(thr, obj);
 755     )
 756     jclass result = UNCHECKED()->GetObjectClass(env,obj);
 757     functionExit(env);
 758     return result;
 759 JNI_END
 760 
 761 JNI_ENTRY_CHECKED(jboolean,
 762   checked_jni_IsInstanceOf(JNIEnv *env,
 763                            jobject obj,
 764                            jclass clazz))
 765     functionEnter(thr);
 766     IN_VM(
 767       jniCheck::validate_object(thr, obj);
 768       jniCheck::validate_class(thr, clazz, true);
 769     )
 770     jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz);
 771     functionExit(env);
 772     return result;
 773 JNI_END
 774 
 775 JNI_ENTRY_CHECKED(jmethodID,
 776   checked_jni_GetMethodID(JNIEnv *env,
 777                           jclass clazz,
 778                           const char *name,
 779                           const char *sig))
 780     functionEnter(thr);
 781     IN_VM(
 782       jniCheck::validate_class(thr, clazz, false);
 783     )
 784     jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig);
 785     functionExit(env);
 786     return result;
 787 JNI_END
 788 
 789 #define WRAPPER_CallMethod(ResultType, Result) \
 790 JNI_ENTRY_CHECKED(ResultType,  \
 791   checked_jni_Call##Result##Method(JNIEnv *env, \
 792                                    jobject obj, \
 793                                    jmethodID methodID, \
 794                                    ...)) \
 795     functionEnter(thr); \
 796     va_list args; \
 797     IN_VM( \
 798       jniCheck::validate_call_object(thr, obj, methodID); \
 799     ) \
 800     va_start(args,methodID); \
 801     ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \
 802                                                           args); \
 803     va_end(args); \
 804     functionExit(env); \
 805     return result; \
 806 JNI_END \
 807 \
 808 JNI_ENTRY_CHECKED(ResultType,  \
 809   checked_jni_Call##Result##MethodV(JNIEnv *env, \
 810                                     jobject obj, \
 811                                     jmethodID methodID, \
 812                                     va_list args)) \
 813     functionEnter(thr); \
 814     IN_VM(\
 815       jniCheck::validate_call_object(thr, obj, methodID); \
 816     ) \
 817     ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\
 818                                                            args); \
 819     functionExit(env); \
 820     return result; \
 821 JNI_END \
 822 \
 823 JNI_ENTRY_CHECKED(ResultType,  \
 824   checked_jni_Call##Result##MethodA(JNIEnv *env, \
 825                                     jobject obj, \
 826                                     jmethodID methodID, \
 827                                     const jvalue * args)) \
 828     functionEnter(thr); \
 829     IN_VM( \
 830       jniCheck::validate_call_object(thr, obj, methodID); \
 831     ) \
 832     ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\
 833                                                            args); \
 834     functionExit(env); \
 835     return result; \
 836 JNI_END
 837 
 838 WRAPPER_CallMethod(jobject,Object)
 839 WRAPPER_CallMethod(jboolean,Boolean)
 840 WRAPPER_CallMethod(jbyte,Byte)
 841 WRAPPER_CallMethod(jshort,Short)
 842 WRAPPER_CallMethod(jchar,Char)
 843 WRAPPER_CallMethod(jint,Int)
 844 WRAPPER_CallMethod(jlong,Long)
 845 WRAPPER_CallMethod(jfloat,Float)
 846 WRAPPER_CallMethod(jdouble,Double)
 847 
 848 JNI_ENTRY_CHECKED(void,
 849   checked_jni_CallVoidMethod(JNIEnv *env, \
 850                              jobject obj, \
 851                              jmethodID methodID, \
 852                              ...))
 853     functionEnter(thr);
 854     va_list args;
 855     IN_VM(
 856       jniCheck::validate_call_object(thr, obj, methodID);
 857     )
 858     va_start(args,methodID);
 859     UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
 860     va_end(args);
 861     functionExit(env);
 862 JNI_END
 863 
 864 JNI_ENTRY_CHECKED(void,
 865   checked_jni_CallVoidMethodV(JNIEnv *env,
 866                               jobject obj,
 867                               jmethodID methodID,
 868                               va_list args))
 869     functionEnter(thr);
 870     IN_VM(
 871       jniCheck::validate_call_object(thr, obj, methodID);
 872     )
 873     UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
 874     functionExit(env);
 875 JNI_END
 876 
 877 JNI_ENTRY_CHECKED(void,
 878   checked_jni_CallVoidMethodA(JNIEnv *env,
 879                               jobject obj,
 880                               jmethodID methodID,
 881                               const jvalue * args))
 882     functionEnter(thr);
 883     IN_VM(
 884       jniCheck::validate_call_object(thr, obj, methodID);
 885     )
 886     UNCHECKED()->CallVoidMethodA(env,obj,methodID,args);
 887     functionExit(env);
 888 JNI_END
 889 
 890 #define WRAPPER_CallNonvirtualMethod(ResultType, Result) \
 891 JNI_ENTRY_CHECKED(ResultType,  \
 892   checked_jni_CallNonvirtual##Result##Method(JNIEnv *env, \
 893                                              jobject obj, \
 894                                              jclass clazz, \
 895                                              jmethodID methodID, \
 896                                              ...)) \
 897     functionEnter(thr); \
 898     va_list args; \
 899     IN_VM( \
 900       jniCheck::validate_call_object(thr, obj, methodID); \
 901       jniCheck::validate_call_class(thr, clazz, methodID); \
 902     ) \
 903     va_start(args,methodID); \
 904     ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
 905                                                                      obj, \
 906                                                                      clazz, \
 907                                                                      methodID,\
 908                                                                      args); \
 909     va_end(args); \
 910     functionExit(env); \
 911     return result; \
 912 JNI_END \
 913 \
 914 JNI_ENTRY_CHECKED(ResultType,  \
 915   checked_jni_CallNonvirtual##Result##MethodV(JNIEnv *env, \
 916                                               jobject obj, \
 917                                               jclass clazz, \
 918                                               jmethodID methodID, \
 919                                               va_list args)) \
 920     functionEnter(thr); \
 921     IN_VM( \
 922       jniCheck::validate_call_object(thr, obj, methodID); \
 923       jniCheck::validate_call_class(thr, clazz, methodID); \
 924     ) \
 925     ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
 926                                                                      obj, \
 927                                                                      clazz, \
 928                                                                      methodID,\
 929                                                                      args); \
 930     functionExit(env); \
 931     return result; \
 932 JNI_END \
 933 \
 934 JNI_ENTRY_CHECKED(ResultType,  \
 935   checked_jni_CallNonvirtual##Result##MethodA(JNIEnv *env, \
 936                                               jobject obj, \
 937                                               jclass clazz, \
 938                                               jmethodID methodID, \
 939                                               const jvalue * args)) \
 940     functionEnter(thr); \
 941     IN_VM( \
 942       jniCheck::validate_call_object(thr, obj, methodID); \
 943       jniCheck::validate_call_class(thr, clazz, methodID); \
 944     ) \
 945     ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodA(env, \
 946                                                                      obj, \
 947                                                                      clazz, \
 948                                                                      methodID,\
 949                                                                      args); \
 950     functionExit(env); \
 951     return result; \
 952 JNI_END
 953 
 954 WRAPPER_CallNonvirtualMethod(jobject,Object)
 955 WRAPPER_CallNonvirtualMethod(jboolean,Boolean)
 956 WRAPPER_CallNonvirtualMethod(jbyte,Byte)
 957 WRAPPER_CallNonvirtualMethod(jshort,Short)
 958 WRAPPER_CallNonvirtualMethod(jchar,Char)
 959 WRAPPER_CallNonvirtualMethod(jint,Int)
 960 WRAPPER_CallNonvirtualMethod(jlong,Long)
 961 WRAPPER_CallNonvirtualMethod(jfloat,Float)
 962 WRAPPER_CallNonvirtualMethod(jdouble,Double)
 963 
 964 JNI_ENTRY_CHECKED(void,
 965   checked_jni_CallNonvirtualVoidMethod(JNIEnv *env,
 966                                        jobject obj,
 967                                        jclass clazz,
 968                                        jmethodID methodID,
 969                                        ...))
 970     functionEnter(thr);
 971     va_list args;
 972     IN_VM(
 973       jniCheck::validate_call_object(thr, obj, methodID);
 974       jniCheck::validate_call_class(thr, clazz, methodID);
 975     )
 976     va_start(args,methodID);
 977     UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
 978     va_end(args);
 979     functionExit(env);
 980 JNI_END
 981 
 982 JNI_ENTRY_CHECKED(void,
 983   checked_jni_CallNonvirtualVoidMethodV(JNIEnv *env,
 984                                         jobject obj,
 985                                         jclass clazz,
 986                                         jmethodID methodID,
 987                                         va_list args))
 988     functionEnter(thr);
 989     IN_VM(
 990       jniCheck::validate_call_object(thr, obj, methodID);
 991       jniCheck::validate_call_class(thr, clazz, methodID);
 992     )
 993     UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
 994     functionExit(env);
 995 JNI_END
 996 
 997 JNI_ENTRY_CHECKED(void,
 998   checked_jni_CallNonvirtualVoidMethodA(JNIEnv *env,
 999                                         jobject obj,
1000                                         jclass clazz,
1001                                         jmethodID methodID,
1002                                         const jvalue * args))
1003     functionEnter(thr);
1004     IN_VM(
1005       jniCheck::validate_call_object(thr, obj, methodID);
1006       jniCheck::validate_call_class(thr, clazz, methodID);
1007     )
1008     UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args);
1009     functionExit(env);
1010 JNI_END
1011 
1012 JNI_ENTRY_CHECKED(jfieldID,
1013   checked_jni_GetFieldID(JNIEnv *env,
1014                          jclass clazz,
1015                          const char *name,
1016                          const char *sig))
1017     functionEnter(thr);
1018     IN_VM(
1019       jniCheck::validate_class(thr, clazz, false);
1020     )
1021     jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig);
1022     functionExit(env);
1023     return result;
1024 JNI_END
1025 
1026 #define WRAPPER_GetField(ReturnType,Result,FieldType) \
1027 JNI_ENTRY_CHECKED(ReturnType,  \
1028   checked_jni_Get##Result##Field(JNIEnv *env, \
1029                                  jobject obj, \
1030                                  jfieldID fieldID)) \
1031     functionEnter(thr); \
1032     IN_VM( \
1033       checkInstanceFieldID(thr, fieldID, obj, FieldType); \
1034     ) \
1035     ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \
1036     functionExit(env); \
1037     return result; \
1038 JNI_END
1039 
1040 WRAPPER_GetField(jobject,  Object,  T_OBJECT)
1041 WRAPPER_GetField(jboolean, Boolean, T_BOOLEAN)
1042 WRAPPER_GetField(jbyte,    Byte,    T_BYTE)
1043 WRAPPER_GetField(jshort,   Short,   T_SHORT)
1044 WRAPPER_GetField(jchar,    Char,    T_CHAR)
1045 WRAPPER_GetField(jint,     Int,     T_INT)
1046 WRAPPER_GetField(jlong,    Long,    T_LONG)
1047 WRAPPER_GetField(jfloat,   Float,   T_FLOAT)
1048 WRAPPER_GetField(jdouble,  Double,  T_DOUBLE)
1049 
1050 #define WRAPPER_SetField(ValueType,Result,FieldType) \
1051 JNI_ENTRY_CHECKED(void,  \
1052   checked_jni_Set##Result##Field(JNIEnv *env, \
1053                                  jobject obj, \
1054                                  jfieldID fieldID, \
1055                                  ValueType val)) \
1056     functionEnter(thr); \
1057     IN_VM( \
1058       checkInstanceFieldID(thr, fieldID, obj, FieldType); \
1059     ) \
1060     UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \
1061     functionExit(env); \
1062 JNI_END
1063 
1064 WRAPPER_SetField(jobject,  Object,  T_OBJECT)
1065 WRAPPER_SetField(jboolean, Boolean, T_BOOLEAN)
1066 WRAPPER_SetField(jbyte,    Byte,    T_BYTE)
1067 WRAPPER_SetField(jshort,   Short,   T_SHORT)
1068 WRAPPER_SetField(jchar,    Char,    T_CHAR)
1069 WRAPPER_SetField(jint,     Int,     T_INT)
1070 WRAPPER_SetField(jlong,    Long,    T_LONG)
1071 WRAPPER_SetField(jfloat,   Float,   T_FLOAT)
1072 WRAPPER_SetField(jdouble,  Double,  T_DOUBLE)
1073 
1074 
1075 JNI_ENTRY_CHECKED(jmethodID,
1076   checked_jni_GetStaticMethodID(JNIEnv *env,
1077                                 jclass clazz,
1078                                 const char *name,
1079                                 const char *sig))
1080     functionEnter(thr);
1081     IN_VM(
1082       jniCheck::validate_class(thr, clazz, false);
1083     )
1084     jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig);
1085     functionExit(env);
1086     return result;
1087 JNI_END
1088 
1089 #define WRAPPER_CallStaticMethod(ReturnType,Result) \
1090 JNI_ENTRY_CHECKED(ReturnType,  \
1091   checked_jni_CallStatic##Result##Method(JNIEnv *env, \
1092                                          jclass clazz, \
1093                                          jmethodID methodID, \
1094                                          ...)) \
1095     functionEnter(thr); \
1096     va_list args; \
1097     IN_VM( \
1098       jniCheck::validate_jmethod_id(thr, methodID); \
1099       jniCheck::validate_class(thr, clazz, false); \
1100     ) \
1101     va_start(args,methodID); \
1102     ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
1103                                                                  clazz, \
1104                                                                  methodID, \
1105                                                                  args); \
1106     va_end(args); \
1107     functionExit(env); \
1108     return result; \
1109 JNI_END \
1110 \
1111 JNI_ENTRY_CHECKED(ReturnType,  \
1112   checked_jni_CallStatic##Result##MethodV(JNIEnv *env, \
1113                                           jclass clazz, \
1114                                           jmethodID methodID,\
1115                                           va_list args)) \
1116     functionEnter(thr); \
1117     IN_VM( \
1118       jniCheck::validate_jmethod_id(thr, methodID); \
1119       jniCheck::validate_class(thr, clazz, false); \
1120     ) \
1121     ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
1122                                                                  clazz, \
1123                                                                  methodID, \
1124                                                                  args); \
1125     functionExit(env); \
1126     return result; \
1127 JNI_END \
1128 \
1129 JNI_ENTRY_CHECKED(ReturnType,  \
1130   checked_jni_CallStatic##Result##MethodA(JNIEnv *env, \
1131                                           jclass clazz, \
1132                                           jmethodID methodID, \
1133                                           const jvalue *args)) \
1134     functionEnter(thr); \
1135     IN_VM( \
1136       jniCheck::validate_jmethod_id(thr, methodID); \
1137       jniCheck::validate_class(thr, clazz, false); \
1138     ) \
1139     ReturnType result = UNCHECKED()->CallStatic##Result##MethodA(env, \
1140                                                                  clazz, \
1141                                                                  methodID, \
1142                                                                  args); \
1143     functionExit(env); \
1144     return result; \
1145 JNI_END
1146 
1147 WRAPPER_CallStaticMethod(jobject,Object)
1148 WRAPPER_CallStaticMethod(jboolean,Boolean)
1149 WRAPPER_CallStaticMethod(jbyte,Byte)
1150 WRAPPER_CallStaticMethod(jshort,Short)
1151 WRAPPER_CallStaticMethod(jchar,Char)
1152 WRAPPER_CallStaticMethod(jint,Int)
1153 WRAPPER_CallStaticMethod(jlong,Long)
1154 WRAPPER_CallStaticMethod(jfloat,Float)
1155 WRAPPER_CallStaticMethod(jdouble,Double)
1156 
1157 JNI_ENTRY_CHECKED(void,
1158   checked_jni_CallStaticVoidMethod(JNIEnv *env,
1159                                    jclass cls,
1160                                    jmethodID methodID,
1161                                    ...))
1162     functionEnter(thr);
1163     va_list args;
1164     IN_VM(
1165       jniCheck::validate_jmethod_id(thr, methodID);
1166       jniCheck::validate_class(thr, cls, false);
1167     )
1168     va_start(args,methodID);
1169     UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
1170     va_end(args);
1171     functionExit(env);
1172 JNI_END
1173 
1174 JNI_ENTRY_CHECKED(void,
1175   checked_jni_CallStaticVoidMethodV(JNIEnv *env,
1176                                     jclass cls,
1177                                     jmethodID methodID,
1178                                     va_list args))
1179     functionEnter(thr);
1180     IN_VM(
1181       jniCheck::validate_jmethod_id(thr, methodID);
1182       jniCheck::validate_class(thr, cls, false);
1183     )
1184     UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
1185     functionExit(env);
1186 JNI_END
1187 
1188 JNI_ENTRY_CHECKED(void,
1189   checked_jni_CallStaticVoidMethodA(JNIEnv *env,
1190                                     jclass cls,
1191                                     jmethodID methodID,
1192                                     const jvalue * args))
1193     functionEnter(thr);
1194     IN_VM(
1195       jniCheck::validate_jmethod_id(thr, methodID);
1196       jniCheck::validate_class(thr, cls, false);
1197     )
1198     UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args);
1199     functionExit(env);
1200 JNI_END
1201 
1202 JNI_ENTRY_CHECKED(jfieldID,
1203   checked_jni_GetStaticFieldID(JNIEnv *env,
1204                                jclass clazz,
1205                                const char *name,
1206                                const char *sig))
1207     functionEnter(thr);
1208     IN_VM(
1209       jniCheck::validate_class(thr, clazz, false);
1210     )
1211     jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig);
1212     functionExit(env);
1213     return result;
1214 JNI_END
1215 
1216 #define WRAPPER_GetStaticField(ReturnType,Result,FieldType) \
1217 JNI_ENTRY_CHECKED(ReturnType,  \
1218   checked_jni_GetStatic##Result##Field(JNIEnv *env, \
1219                                        jclass clazz, \
1220                                        jfieldID fieldID)) \
1221     functionEnter(thr); \
1222     IN_VM( \
1223       jniCheck::validate_class(thr, clazz, false); \
1224       checkStaticFieldID(thr, fieldID, clazz, FieldType); \
1225     ) \
1226     ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \
1227                                                               clazz, \
1228                                                               fieldID); \
1229     functionExit(env); \
1230     return result; \
1231 JNI_END
1232 
1233 WRAPPER_GetStaticField(jobject,  Object,  T_OBJECT)
1234 WRAPPER_GetStaticField(jboolean, Boolean, T_BOOLEAN)
1235 WRAPPER_GetStaticField(jbyte,    Byte,    T_BYTE)
1236 WRAPPER_GetStaticField(jshort,   Short,   T_SHORT)
1237 WRAPPER_GetStaticField(jchar,    Char,    T_CHAR)
1238 WRAPPER_GetStaticField(jint,     Int,     T_INT)
1239 WRAPPER_GetStaticField(jlong,    Long,    T_LONG)
1240 WRAPPER_GetStaticField(jfloat,   Float,   T_FLOAT)
1241 WRAPPER_GetStaticField(jdouble,  Double,  T_DOUBLE)
1242 
1243 #define WRAPPER_SetStaticField(ValueType,Result,FieldType) \
1244 JNI_ENTRY_CHECKED(void,  \
1245   checked_jni_SetStatic##Result##Field(JNIEnv *env, \
1246                                        jclass clazz, \
1247                                        jfieldID fieldID, \
1248                                        ValueType value)) \
1249     functionEnter(thr); \
1250     IN_VM( \
1251       jniCheck::validate_class(thr, clazz, false); \
1252       checkStaticFieldID(thr, fieldID, clazz, FieldType); \
1253     ) \
1254     UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \
1255     functionExit(env); \
1256 JNI_END
1257 
1258 WRAPPER_SetStaticField(jobject,  Object,  T_OBJECT)
1259 WRAPPER_SetStaticField(jboolean, Boolean, T_BOOLEAN)
1260 WRAPPER_SetStaticField(jbyte,    Byte,    T_BYTE)
1261 WRAPPER_SetStaticField(jshort,   Short,   T_SHORT)
1262 WRAPPER_SetStaticField(jchar,    Char,    T_CHAR)
1263 WRAPPER_SetStaticField(jint,     Int,     T_INT)
1264 WRAPPER_SetStaticField(jlong,    Long,    T_LONG)
1265 WRAPPER_SetStaticField(jfloat,   Float,   T_FLOAT)
1266 WRAPPER_SetStaticField(jdouble,  Double,  T_DOUBLE)
1267 
1268 
1269 JNI_ENTRY_CHECKED(jstring,
1270   checked_jni_NewString(JNIEnv *env,
1271                         const jchar *unicode,
1272                         jsize len))
1273     functionEnter(thr);
1274     jstring result = UNCHECKED()->NewString(env,unicode,len);
1275     functionExit(env);
1276     return result;
1277 JNI_END
1278 
1279 JNI_ENTRY_CHECKED(jsize,
1280   checked_jni_GetStringLength(JNIEnv *env,
1281                               jstring str))
1282     functionEnter(thr);
1283     IN_VM(
1284       checkString(thr, str);
1285     )
1286     jsize result = UNCHECKED()->GetStringLength(env,str);
1287     functionExit(env);
1288     return result;
1289 JNI_END
1290 



1291 JNI_ENTRY_CHECKED(const jchar *,
1292   checked_jni_GetStringChars(JNIEnv *env,
1293                              jstring str,
1294                              jboolean *isCopy))
1295     functionEnter(thr);
1296     IN_VM(
1297       checkString(thr, str);
1298     )
1299     const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy);









1300     functionExit(env);
1301     return result;
1302 JNI_END
1303 
1304 JNI_ENTRY_CHECKED(void,
1305   checked_jni_ReleaseStringChars(JNIEnv *env,
1306                                  jstring str,
1307                                  const jchar *chars))
1308     functionEnterExceptionAllowed(thr);
1309     IN_VM(
1310       checkString(thr, str);
1311     )
1312     /* cannot check validity of copy, unless every request is logged by
1313      * checking code.  Implementation of this check is deferred until a
1314      * subsequent release.
1315      */
1316     UNCHECKED()->ReleaseStringChars(env,str,chars);
1317     functionExit(env);
1318 JNI_END
1319 
1320 JNI_ENTRY_CHECKED(jstring,
1321   checked_jni_NewStringUTF(JNIEnv *env,
1322                            const char *utf))
1323     functionEnter(thr);
1324     jstring result = UNCHECKED()->NewStringUTF(env,utf);
1325     functionExit(env);
1326     return result;
1327 JNI_END
1328 
1329 JNI_ENTRY_CHECKED(jsize,
1330   checked_jni_GetStringUTFLength(JNIEnv *env,
1331                                  jstring str))
1332     functionEnter(thr);
1333     IN_VM(
1334       checkString(thr, str);
1335     )
1336     jsize result = UNCHECKED()->GetStringUTFLength(env,str);
1337     functionExit(env);
1338     return result;
1339 JNI_END
1340 



1341 JNI_ENTRY_CHECKED(const char *,
1342   checked_jni_GetStringUTFChars(JNIEnv *env,
1343                                 jstring str,
1344                                 jboolean *isCopy))
1345     functionEnter(thr);
1346     IN_VM(
1347       checkString(thr, str);
1348     )
1349     const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy);









1350     functionExit(env);
1351     return result;
1352 JNI_END
1353 
1354 JNI_ENTRY_CHECKED(void,
1355   checked_jni_ReleaseStringUTFChars(JNIEnv *env,
1356                                     jstring str,
1357                                     const char* chars))
1358     functionEnterExceptionAllowed(thr);
1359     IN_VM(
1360       checkString(thr, str);
1361     )
1362     /* cannot check validity of copy, unless every request is logged by
1363      * checking code.  Implementation of this check is deferred until a
1364      * subsequent release.
1365      */
1366     UNCHECKED()->ReleaseStringUTFChars(env,str,chars);
1367     functionExit(env);
1368 JNI_END
1369 
1370 JNI_ENTRY_CHECKED(jsize,
1371   checked_jni_GetArrayLength(JNIEnv *env,
1372                              jarray array))
1373     functionEnter(thr);
1374     IN_VM(
1375       checkArray(thr, array, -1);
1376     )
1377     jsize result = UNCHECKED()->GetArrayLength(env,array);
1378     functionExit(env);
1379     return result;
1380 JNI_END
1381 
1382 JNI_ENTRY_CHECKED(jobjectArray,
1383   checked_jni_NewObjectArray(JNIEnv *env,
1384                              jsize len,
1385                              jclass clazz,
1386                              jobject init))
1387     functionEnter(thr);
1388     jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init);
1389     functionExit(env);
1390     return result;
1391 JNI_END
1392 
1393 JNI_ENTRY_CHECKED(jobject,
1394   checked_jni_GetObjectArrayElement(JNIEnv *env,
1395                                     jobjectArray array,
1396                                     jsize index))
1397     functionEnter(thr);
1398     IN_VM(
1399       checkArray(thr, array, T_OBJECT);
1400     )
1401     jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
1402     functionExit(env);
1403     return result;
1404 JNI_END
1405 
1406 JNI_ENTRY_CHECKED(void,
1407   checked_jni_SetObjectArrayElement(JNIEnv *env,
1408                                     jobjectArray array,
1409                                     jsize index,
1410                                     jobject val))
1411     functionEnter(thr);
1412     IN_VM(
1413       checkArray(thr, array, T_OBJECT);
1414     )
1415     UNCHECKED()->SetObjectArrayElement(env,array,index,val);
1416     functionExit(env);
1417 JNI_END
1418 
1419 #define WRAPPER_NewScalarArray(Return, Result) \
1420 JNI_ENTRY_CHECKED(Return, \
1421   checked_jni_New##Result##Array(JNIEnv *env, \
1422                                  jsize len)) \
1423     functionEnter(thr); \
1424     Return result = UNCHECKED()->New##Result##Array(env,len); \
1425     functionExit(env); \
1426     return (Return) result; \
1427 JNI_END
1428 
1429 WRAPPER_NewScalarArray(jbooleanArray, Boolean)
1430 WRAPPER_NewScalarArray(jbyteArray, Byte)
1431 WRAPPER_NewScalarArray(jshortArray, Short)
1432 WRAPPER_NewScalarArray(jcharArray, Char)
1433 WRAPPER_NewScalarArray(jintArray, Int)
1434 WRAPPER_NewScalarArray(jlongArray, Long)
1435 WRAPPER_NewScalarArray(jfloatArray, Float)
1436 WRAPPER_NewScalarArray(jdoubleArray, Double)
1437 
1438 #define WRAPPER_GetScalarArrayElements(ElementTag,ElementType,Result) \
1439 JNI_ENTRY_CHECKED(ElementType *,  \
1440   checked_jni_Get##Result##ArrayElements(JNIEnv *env, \
1441                                          ElementType##Array array, \
1442                                          jboolean *isCopy)) \
1443     functionEnter(thr); \
1444     IN_VM( \
1445       checkArray(thr, array, ElementTag); \
1446     ) \
1447     ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \
1448                                                                   array, \
1449                                                                   isCopy); \
1450     functionExit(env); \
1451     return result; \
1452 JNI_END
1453 
1454 WRAPPER_GetScalarArrayElements(T_BOOLEAN, jboolean, Boolean)
1455 WRAPPER_GetScalarArrayElements(T_BYTE,    jbyte,    Byte)
1456 WRAPPER_GetScalarArrayElements(T_SHORT,   jshort,   Short)
1457 WRAPPER_GetScalarArrayElements(T_CHAR,    jchar,    Char)
1458 WRAPPER_GetScalarArrayElements(T_INT,     jint,     Int)
1459 WRAPPER_GetScalarArrayElements(T_LONG,    jlong,    Long)
1460 WRAPPER_GetScalarArrayElements(T_FLOAT,   jfloat,   Float)
1461 WRAPPER_GetScalarArrayElements(T_DOUBLE,  jdouble,  Double)
1462 
1463 #define WRAPPER_ReleaseScalarArrayElements(ElementTag,ElementType,Result,Tag) \
1464 JNI_ENTRY_CHECKED(void,  \
1465   checked_jni_Release##Result##ArrayElements(JNIEnv *env, \
1466                                              ElementType##Array array, \
1467                                              ElementType *elems, \
1468                                              jint mode)) \
1469     functionEnterExceptionAllowed(thr); \
1470     IN_VM( \
1471       checkArray(thr, array, ElementTag); \
1472       ASSERT_OOPS_ALLOWED; \
1473       typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
1474       /* cannot check validity of copy, unless every request is logged by
1475        * checking code.  Implementation of this check is deferred until a
1476        * subsequent release.
1477        */ \
1478     ) \
1479     UNCHECKED()->Release##Result##ArrayElements(env,array,elems,mode); \
1480     functionExit(env); \
1481 JNI_END
1482 
1483 WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool)
1484 WRAPPER_ReleaseScalarArrayElements(T_BYTE,   jbyte,    Byte,    byte)
1485 WRAPPER_ReleaseScalarArrayElements(T_SHORT,  jshort,   Short,   short)
1486 WRAPPER_ReleaseScalarArrayElements(T_CHAR,   jchar,    Char,    char)
1487 WRAPPER_ReleaseScalarArrayElements(T_INT,    jint,     Int,     int)
1488 WRAPPER_ReleaseScalarArrayElements(T_LONG,   jlong,    Long,    long)
1489 WRAPPER_ReleaseScalarArrayElements(T_FLOAT,  jfloat,   Float,   float)
1490 WRAPPER_ReleaseScalarArrayElements(T_DOUBLE, jdouble,  Double,  double)
1491 
1492 #define WRAPPER_GetScalarArrayRegion(ElementTag,ElementType,Result) \
1493 JNI_ENTRY_CHECKED(void,  \
1494   checked_jni_Get##Result##ArrayRegion(JNIEnv *env, \
1495                                        ElementType##Array array, \
1496                                        jsize start, \
1497                                        jsize len, \
1498                                        ElementType *buf)) \
1499     functionEnter(thr); \
1500     IN_VM( \
1501       checkArray(thr, array, ElementTag); \
1502     ) \
1503     UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
1504     functionExit(env); \
1505 JNI_END
1506 
1507 WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
1508 WRAPPER_GetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
1509 WRAPPER_GetScalarArrayRegion(T_SHORT,   jshort,   Short)
1510 WRAPPER_GetScalarArrayRegion(T_CHAR,    jchar,    Char)
1511 WRAPPER_GetScalarArrayRegion(T_INT,     jint,     Int)
1512 WRAPPER_GetScalarArrayRegion(T_LONG,    jlong,    Long)
1513 WRAPPER_GetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
1514 WRAPPER_GetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
1515 
1516 #define WRAPPER_SetScalarArrayRegion(ElementTag,ElementType,Result) \
1517 JNI_ENTRY_CHECKED(void,  \
1518   checked_jni_Set##Result##ArrayRegion(JNIEnv *env, \
1519                                        ElementType##Array array, \
1520                                        jsize start, \
1521                                        jsize len, \
1522                                        const ElementType *buf)) \
1523     functionEnter(thr); \
1524     IN_VM( \
1525       checkArray(thr, array, ElementTag); \
1526     ) \
1527     UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
1528     functionExit(env); \
1529 JNI_END
1530 
1531 WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
1532 WRAPPER_SetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
1533 WRAPPER_SetScalarArrayRegion(T_SHORT,   jshort,   Short)
1534 WRAPPER_SetScalarArrayRegion(T_CHAR,    jchar,    Char)
1535 WRAPPER_SetScalarArrayRegion(T_INT,     jint,     Int)
1536 WRAPPER_SetScalarArrayRegion(T_LONG,    jlong,    Long)
1537 WRAPPER_SetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
1538 WRAPPER_SetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
1539 
1540 JNI_ENTRY_CHECKED(jint,
1541   checked_jni_RegisterNatives(JNIEnv *env,
1542                               jclass clazz,
1543                               const JNINativeMethod *methods,
1544                               jint nMethods))
1545     functionEnter(thr);
1546     jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods);
1547     functionExit(env);
1548     return result;
1549 JNI_END
1550 
1551 JNI_ENTRY_CHECKED(jint,
1552   checked_jni_UnregisterNatives(JNIEnv *env,
1553                                 jclass clazz))
1554     functionEnter(thr);
1555     jint result = UNCHECKED()->UnregisterNatives(env,clazz);
1556     functionExit(env);
1557     return result;
1558 JNI_END
1559 
1560 JNI_ENTRY_CHECKED(jint,
1561   checked_jni_MonitorEnter(JNIEnv *env,
1562                            jobject obj))
1563     functionEnter(thr);
1564     IN_VM(
1565       jniCheck::validate_object(thr, obj);
1566     )
1567     jint result = UNCHECKED()->MonitorEnter(env,obj);
1568     functionExit(env);
1569     return result;
1570 JNI_END
1571 
1572 JNI_ENTRY_CHECKED(jint,
1573   checked_jni_MonitorExit(JNIEnv *env,
1574                           jobject obj))
1575     functionEnterExceptionAllowed(thr);
1576     IN_VM(
1577       jniCheck::validate_object(thr, obj);
1578     )
1579     jint result = UNCHECKED()->MonitorExit(env,obj);
1580     functionExit(env);
1581     return result;
1582 JNI_END
1583 
1584 JNI_ENTRY_CHECKED(jint,
1585   checked_jni_GetJavaVM(JNIEnv *env,
1586                         JavaVM **vm))
1587     functionEnter(thr);
1588     jint result = UNCHECKED()->GetJavaVM(env,vm);
1589     functionExit(env);
1590     return result;
1591 JNI_END
1592 
1593 JNI_ENTRY_CHECKED(void,
1594   checked_jni_GetStringRegion(JNIEnv *env,
1595                               jstring str,
1596                               jsize start,
1597                               jsize len,
1598                               jchar *buf))
1599     functionEnter(thr);
1600     IN_VM(
1601       checkString(thr, str);
1602     )
1603     UNCHECKED()->GetStringRegion(env, str, start, len, buf);
1604     functionExit(env);
1605 JNI_END
1606 
1607 JNI_ENTRY_CHECKED(void,
1608   checked_jni_GetStringUTFRegion(JNIEnv *env,
1609                                  jstring str,
1610                                  jsize start,
1611                                  jsize len,
1612                                  char *buf))
1613     functionEnter(thr);
1614     IN_VM(
1615       checkString(thr, str);
1616     )
1617     UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
1618     functionExit(env);
1619 JNI_END
1620 
1621 JNI_ENTRY_CHECKED(void *,
1622   checked_jni_GetPrimitiveArrayCritical(JNIEnv *env,
1623                                         jarray array,
1624                                         jboolean *isCopy))
1625     functionEnterCritical(thr);
1626     IN_VM(
1627       checkArray(thr, array, -1);
1628     )
1629     void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy);
1630     functionExit(env);
1631     return result;
1632 JNI_END
1633 
1634 JNI_ENTRY_CHECKED(void,
1635   checked_jni_ReleasePrimitiveArrayCritical(JNIEnv *env,
1636                                             jarray array,
1637                                             void *carray,
1638                                             jint mode))
1639     functionEnterCriticalExceptionAllowed(thr);
1640     IN_VM(
1641       checkArray(thr, array, -1);
1642     )
1643     /* The Hotspot JNI code does not use the parameters, so just check the
1644      * array parameter as a minor sanity check
1645      */
1646     UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, carray, mode);
1647     functionExit(env);
1648 JNI_END
1649 
1650 JNI_ENTRY_CHECKED(const jchar*,
1651   checked_jni_GetStringCritical(JNIEnv *env,
1652                                 jstring string,
1653                                 jboolean *isCopy))
1654     functionEnterCritical(thr);
1655     IN_VM(
1656       checkString(thr, string);
1657     )
1658     const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy);
1659     functionExit(env);
1660     return result;
1661 JNI_END
1662 
1663 JNI_ENTRY_CHECKED(void,
1664   checked_jni_ReleaseStringCritical(JNIEnv *env,
1665                                     jstring str,
1666                                     const jchar *chars))
1667     functionEnterCriticalExceptionAllowed(thr);
1668     IN_VM(
1669       checkString(thr, str);
1670     )
1671     /* The Hotspot JNI code does not use the parameters, so just check the
1672      * string parameter as a minor sanity check
1673      */
1674     UNCHECKED()->ReleaseStringCritical(env, str, chars);
1675     functionExit(env);
1676 JNI_END
1677 
1678 JNI_ENTRY_CHECKED(jweak,
1679   checked_jni_NewWeakGlobalRef(JNIEnv *env,
1680                                jobject obj))
1681     functionEnter(thr);
1682     IN_VM(
1683       if (obj != NULL) {
1684         jniCheck::validate_handle(thr, obj);
1685       }
1686     )
1687     jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj);
1688     functionExit(env);
1689     return result;
1690 JNI_END
1691 
1692 JNI_ENTRY_CHECKED(void,
1693   checked_jni_DeleteWeakGlobalRef(JNIEnv *env,
1694                                   jweak ref))
1695     functionEnterExceptionAllowed(thr);
1696     UNCHECKED()->DeleteWeakGlobalRef(env, ref);
1697     functionExit(env);
1698 JNI_END
1699 
1700 JNI_ENTRY_CHECKED(jboolean,
1701   checked_jni_ExceptionCheck(JNIEnv *env))
1702     functionEnterExceptionAllowed(thr);
1703     jboolean result = UNCHECKED()->ExceptionCheck(env);
1704     functionExit(env);
1705     return result;
1706 JNI_END
1707 
1708 JNI_ENTRY_CHECKED(jobject,
1709   checked_jni_NewDirectByteBuffer(JNIEnv *env,
1710                                   void *address,
1711                                   jlong capacity))
1712     functionEnter(thr);
1713     jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity);
1714     functionExit(env);
1715     return result;
1716 JNI_END
1717 
1718 JNI_ENTRY_CHECKED(void *,
1719   checked_jni_GetDirectBufferAddress(JNIEnv *env,
1720                                      jobject buf))
1721     functionEnter(thr);
1722     void* result = UNCHECKED()->GetDirectBufferAddress(env, buf);
1723     functionExit(env);
1724     return result;
1725 JNI_END
1726 
1727 JNI_ENTRY_CHECKED(jlong,
1728   checked_jni_GetDirectBufferCapacity(JNIEnv *env,
1729                                       jobject buf))
1730     functionEnter(thr);
1731     jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf);
1732     functionExit(env);
1733     return result;
1734 JNI_END
1735 
1736 JNI_ENTRY_CHECKED(jobjectRefType,
1737   checked_jni_GetObjectRefType(JNIEnv *env,
1738                                jobject obj))
1739     functionEnter(thr);
1740     /* validate the object being passed */
1741     IN_VM(
1742       jniCheck::validate_object(thr, obj);
1743     )
1744     jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj);
1745     functionExit(env);
1746     return result;
1747 JNI_END
1748 
1749 
1750 JNI_ENTRY_CHECKED(jint,
1751   checked_jni_GetVersion(JNIEnv *env))
1752     functionEnter(thr);
1753     jint result = UNCHECKED()->GetVersion(env);
1754     functionExit(env);
1755     return result;
1756 JNI_END
1757 
1758 
1759 
1760 /*
1761  * Structure containing all checked jni functions
1762  */
1763 struct JNINativeInterface_  checked_jni_NativeInterface = {
1764     NULL,
1765     NULL,
1766     NULL,
1767 
1768     NULL,
1769 
1770     checked_jni_GetVersion,
1771 
1772     checked_jni_DefineClass,
1773     checked_jni_FindClass,
1774 
1775     checked_jni_FromReflectedMethod,
1776     checked_jni_FromReflectedField,
1777 
1778     checked_jni_ToReflectedMethod,
1779 
1780     checked_jni_GetSuperclass,
1781     checked_jni_IsAssignableFrom,
1782 
1783     checked_jni_ToReflectedField,
1784 
1785     checked_jni_Throw,
1786     checked_jni_ThrowNew,
1787     checked_jni_ExceptionOccurred,
1788     checked_jni_ExceptionDescribe,
1789     checked_jni_ExceptionClear,
1790     checked_jni_FatalError,
1791 
1792     checked_jni_PushLocalFrame,
1793     checked_jni_PopLocalFrame,
1794 
1795     checked_jni_NewGlobalRef,
1796     checked_jni_DeleteGlobalRef,
1797     checked_jni_DeleteLocalRef,
1798     checked_jni_IsSameObject,
1799 
1800     checked_jni_NewLocalRef,
1801     checked_jni_EnsureLocalCapacity,
1802 
1803     checked_jni_AllocObject,
1804     checked_jni_NewObject,
1805     checked_jni_NewObjectV,
1806     checked_jni_NewObjectA,
1807 
1808     checked_jni_GetObjectClass,
1809     checked_jni_IsInstanceOf,
1810 
1811     checked_jni_GetMethodID,
1812 
1813     checked_jni_CallObjectMethod,
1814     checked_jni_CallObjectMethodV,
1815     checked_jni_CallObjectMethodA,
1816     checked_jni_CallBooleanMethod,
1817     checked_jni_CallBooleanMethodV,
1818     checked_jni_CallBooleanMethodA,
1819     checked_jni_CallByteMethod,
1820     checked_jni_CallByteMethodV,
1821     checked_jni_CallByteMethodA,
1822     checked_jni_CallCharMethod,
1823     checked_jni_CallCharMethodV,
1824     checked_jni_CallCharMethodA,
1825     checked_jni_CallShortMethod,
1826     checked_jni_CallShortMethodV,
1827     checked_jni_CallShortMethodA,
1828     checked_jni_CallIntMethod,
1829     checked_jni_CallIntMethodV,
1830     checked_jni_CallIntMethodA,
1831     checked_jni_CallLongMethod,
1832     checked_jni_CallLongMethodV,
1833     checked_jni_CallLongMethodA,
1834     checked_jni_CallFloatMethod,
1835     checked_jni_CallFloatMethodV,
1836     checked_jni_CallFloatMethodA,
1837     checked_jni_CallDoubleMethod,
1838     checked_jni_CallDoubleMethodV,
1839     checked_jni_CallDoubleMethodA,
1840     checked_jni_CallVoidMethod,
1841     checked_jni_CallVoidMethodV,
1842     checked_jni_CallVoidMethodA,
1843 
1844     checked_jni_CallNonvirtualObjectMethod,
1845     checked_jni_CallNonvirtualObjectMethodV,
1846     checked_jni_CallNonvirtualObjectMethodA,
1847     checked_jni_CallNonvirtualBooleanMethod,
1848     checked_jni_CallNonvirtualBooleanMethodV,
1849     checked_jni_CallNonvirtualBooleanMethodA,
1850     checked_jni_CallNonvirtualByteMethod,
1851     checked_jni_CallNonvirtualByteMethodV,
1852     checked_jni_CallNonvirtualByteMethodA,
1853     checked_jni_CallNonvirtualCharMethod,
1854     checked_jni_CallNonvirtualCharMethodV,
1855     checked_jni_CallNonvirtualCharMethodA,
1856     checked_jni_CallNonvirtualShortMethod,
1857     checked_jni_CallNonvirtualShortMethodV,
1858     checked_jni_CallNonvirtualShortMethodA,
1859     checked_jni_CallNonvirtualIntMethod,
1860     checked_jni_CallNonvirtualIntMethodV,
1861     checked_jni_CallNonvirtualIntMethodA,
1862     checked_jni_CallNonvirtualLongMethod,
1863     checked_jni_CallNonvirtualLongMethodV,
1864     checked_jni_CallNonvirtualLongMethodA,
1865     checked_jni_CallNonvirtualFloatMethod,
1866     checked_jni_CallNonvirtualFloatMethodV,
1867     checked_jni_CallNonvirtualFloatMethodA,
1868     checked_jni_CallNonvirtualDoubleMethod,
1869     checked_jni_CallNonvirtualDoubleMethodV,
1870     checked_jni_CallNonvirtualDoubleMethodA,
1871     checked_jni_CallNonvirtualVoidMethod,
1872     checked_jni_CallNonvirtualVoidMethodV,
1873     checked_jni_CallNonvirtualVoidMethodA,
1874 
1875     checked_jni_GetFieldID,
1876 
1877     checked_jni_GetObjectField,
1878     checked_jni_GetBooleanField,
1879     checked_jni_GetByteField,
1880     checked_jni_GetCharField,
1881     checked_jni_GetShortField,
1882     checked_jni_GetIntField,
1883     checked_jni_GetLongField,
1884     checked_jni_GetFloatField,
1885     checked_jni_GetDoubleField,
1886 
1887     checked_jni_SetObjectField,
1888     checked_jni_SetBooleanField,
1889     checked_jni_SetByteField,
1890     checked_jni_SetCharField,
1891     checked_jni_SetShortField,
1892     checked_jni_SetIntField,
1893     checked_jni_SetLongField,
1894     checked_jni_SetFloatField,
1895     checked_jni_SetDoubleField,
1896 
1897     checked_jni_GetStaticMethodID,
1898 
1899     checked_jni_CallStaticObjectMethod,
1900     checked_jni_CallStaticObjectMethodV,
1901     checked_jni_CallStaticObjectMethodA,
1902     checked_jni_CallStaticBooleanMethod,
1903     checked_jni_CallStaticBooleanMethodV,
1904     checked_jni_CallStaticBooleanMethodA,
1905     checked_jni_CallStaticByteMethod,
1906     checked_jni_CallStaticByteMethodV,
1907     checked_jni_CallStaticByteMethodA,
1908     checked_jni_CallStaticCharMethod,
1909     checked_jni_CallStaticCharMethodV,
1910     checked_jni_CallStaticCharMethodA,
1911     checked_jni_CallStaticShortMethod,
1912     checked_jni_CallStaticShortMethodV,
1913     checked_jni_CallStaticShortMethodA,
1914     checked_jni_CallStaticIntMethod,
1915     checked_jni_CallStaticIntMethodV,
1916     checked_jni_CallStaticIntMethodA,
1917     checked_jni_CallStaticLongMethod,
1918     checked_jni_CallStaticLongMethodV,
1919     checked_jni_CallStaticLongMethodA,
1920     checked_jni_CallStaticFloatMethod,
1921     checked_jni_CallStaticFloatMethodV,
1922     checked_jni_CallStaticFloatMethodA,
1923     checked_jni_CallStaticDoubleMethod,
1924     checked_jni_CallStaticDoubleMethodV,
1925     checked_jni_CallStaticDoubleMethodA,
1926     checked_jni_CallStaticVoidMethod,
1927     checked_jni_CallStaticVoidMethodV,
1928     checked_jni_CallStaticVoidMethodA,
1929 
1930     checked_jni_GetStaticFieldID,
1931 
1932     checked_jni_GetStaticObjectField,
1933     checked_jni_GetStaticBooleanField,
1934     checked_jni_GetStaticByteField,
1935     checked_jni_GetStaticCharField,
1936     checked_jni_GetStaticShortField,
1937     checked_jni_GetStaticIntField,
1938     checked_jni_GetStaticLongField,
1939     checked_jni_GetStaticFloatField,
1940     checked_jni_GetStaticDoubleField,
1941 
1942     checked_jni_SetStaticObjectField,
1943     checked_jni_SetStaticBooleanField,
1944     checked_jni_SetStaticByteField,
1945     checked_jni_SetStaticCharField,
1946     checked_jni_SetStaticShortField,
1947     checked_jni_SetStaticIntField,
1948     checked_jni_SetStaticLongField,
1949     checked_jni_SetStaticFloatField,
1950     checked_jni_SetStaticDoubleField,
1951 
1952     checked_jni_NewString,
1953     checked_jni_GetStringLength,
1954     checked_jni_GetStringChars,
1955     checked_jni_ReleaseStringChars,
1956 
1957     checked_jni_NewStringUTF,
1958     checked_jni_GetStringUTFLength,
1959     checked_jni_GetStringUTFChars,
1960     checked_jni_ReleaseStringUTFChars,
1961 
1962     checked_jni_GetArrayLength,
1963 
1964     checked_jni_NewObjectArray,
1965     checked_jni_GetObjectArrayElement,
1966     checked_jni_SetObjectArrayElement,
1967 
1968     checked_jni_NewBooleanArray,
1969     checked_jni_NewByteArray,
1970     checked_jni_NewCharArray,
1971     checked_jni_NewShortArray,
1972     checked_jni_NewIntArray,
1973     checked_jni_NewLongArray,
1974     checked_jni_NewFloatArray,
1975     checked_jni_NewDoubleArray,
1976 
1977     checked_jni_GetBooleanArrayElements,
1978     checked_jni_GetByteArrayElements,
1979     checked_jni_GetCharArrayElements,
1980     checked_jni_GetShortArrayElements,
1981     checked_jni_GetIntArrayElements,
1982     checked_jni_GetLongArrayElements,
1983     checked_jni_GetFloatArrayElements,
1984     checked_jni_GetDoubleArrayElements,
1985 
1986     checked_jni_ReleaseBooleanArrayElements,
1987     checked_jni_ReleaseByteArrayElements,
1988     checked_jni_ReleaseCharArrayElements,
1989     checked_jni_ReleaseShortArrayElements,
1990     checked_jni_ReleaseIntArrayElements,
1991     checked_jni_ReleaseLongArrayElements,
1992     checked_jni_ReleaseFloatArrayElements,
1993     checked_jni_ReleaseDoubleArrayElements,
1994 
1995     checked_jni_GetBooleanArrayRegion,
1996     checked_jni_GetByteArrayRegion,
1997     checked_jni_GetCharArrayRegion,
1998     checked_jni_GetShortArrayRegion,
1999     checked_jni_GetIntArrayRegion,
2000     checked_jni_GetLongArrayRegion,
2001     checked_jni_GetFloatArrayRegion,
2002     checked_jni_GetDoubleArrayRegion,
2003 
2004     checked_jni_SetBooleanArrayRegion,
2005     checked_jni_SetByteArrayRegion,
2006     checked_jni_SetCharArrayRegion,
2007     checked_jni_SetShortArrayRegion,
2008     checked_jni_SetIntArrayRegion,
2009     checked_jni_SetLongArrayRegion,
2010     checked_jni_SetFloatArrayRegion,
2011     checked_jni_SetDoubleArrayRegion,
2012 
2013     checked_jni_RegisterNatives,
2014     checked_jni_UnregisterNatives,
2015 
2016     checked_jni_MonitorEnter,
2017     checked_jni_MonitorExit,
2018 
2019     checked_jni_GetJavaVM,
2020 
2021     checked_jni_GetStringRegion,
2022     checked_jni_GetStringUTFRegion,
2023 
2024     checked_jni_GetPrimitiveArrayCritical,
2025     checked_jni_ReleasePrimitiveArrayCritical,
2026 
2027     checked_jni_GetStringCritical,
2028     checked_jni_ReleaseStringCritical,
2029 
2030     checked_jni_NewWeakGlobalRef,
2031     checked_jni_DeleteWeakGlobalRef,
2032 
2033     checked_jni_ExceptionCheck,
2034 
2035     checked_jni_NewDirectByteBuffer,
2036     checked_jni_GetDirectBufferAddress,
2037     checked_jni_GetDirectBufferCapacity,
2038 
2039     // New 1.6 Features
2040 
2041     checked_jni_GetObjectRefType
2042 };
2043 
2044 
2045 // Returns the function structure
2046 struct JNINativeInterface_* jni_functions_check() {
2047 
2048   unchecked_jni_NativeInterface = jni_functions_nocheck();
2049 
2050   // make sure the last pointer in the checked table is not null, indicating
2051   // an addition to the JNINativeInterface_ structure without initializing
2052   // it in the checked table.
2053   debug_only(int *lastPtr = (int *)((char *)&checked_jni_NativeInterface + \
2054              sizeof(*unchecked_jni_NativeInterface) - sizeof(char *));)
2055   assert(*lastPtr != 0,
2056          "Mismatched JNINativeInterface tables, check for new entries");
2057 
2058   // with -verbose:jni this message will print
2059   if (PrintJNIResolving) {
2060     tty->print_cr("Checked JNI functions are being used to " \
2061                   "validate JNI usage");
2062   }
2063 
2064   return &checked_jni_NativeInterface;
2065 }
--- EOF ---