src/share/vm/prims/jniCheck.cpp

Tue, 17 Oct 2017 12:58:25 +0800

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

mercurial