src/share/vm/prims/jniCheck.cpp

Mon, 03 Jun 2019 16:14:54 +0100

author
xliu
date
Mon, 03 Jun 2019 16:14:54 +0100
changeset 9689
89dcef434423
parent 8440
fde446cb8e19
child 8604
04d83ba48607
child 9998
d64fa7b92b5b
permissions
-rw-r--r--

8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
Summary: Includes compile_id addition from JDK-8054492
Reviewed-by: andrew

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

mercurial