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