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