src/share/vm/prims/jniCheck.cpp

Wed, 11 Mar 2015 13:36:57 -0700

author
poonam
date
Wed, 11 Mar 2015 13:36:57 -0700
changeset 7627
d68158e12cea
parent 7033
29a5c2fd2d2e
child 7843
9904bb920313
permissions
-rw-r--r--

8043224: -Xcheck:jni improvements to exception checking and excessive local refs
Summary: Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity.
Reviewed-by: dsimms

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

mercurial