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