src/share/vm/prims/jniCheck.cpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 8604
04d83ba48607
child 10015
eb7ce841ccec
permissions
-rw-r--r--

Merge

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

mercurial