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