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