File: | jdk/src/hotspot/share/prims/jvm.cpp |
Warning: | line 2839, column 12 Value stored to 'count' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. |
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 | * |
19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 | * or visit www.oracle.com if you need additional information or have any |
21 | * questions. |
22 | * |
23 | */ |
24 | |
25 | #include "precompiled.hpp" |
26 | #include "jvm.h" |
27 | #include "cds/classListParser.hpp" |
28 | #include "cds/classListWriter.hpp" |
29 | #include "cds/dynamicArchive.hpp" |
30 | #include "cds/heapShared.hpp" |
31 | #include "cds/lambdaFormInvokers.hpp" |
32 | #include "classfile/classFileStream.hpp" |
33 | #include "classfile/classLoader.hpp" |
34 | #include "classfile/classLoaderData.hpp" |
35 | #include "classfile/classLoaderData.inline.hpp" |
36 | #include "classfile/classLoadInfo.hpp" |
37 | #include "classfile/javaAssertions.hpp" |
38 | #include "classfile/javaClasses.inline.hpp" |
39 | #include "classfile/moduleEntry.hpp" |
40 | #include "classfile/modules.hpp" |
41 | #include "classfile/packageEntry.hpp" |
42 | #include "classfile/stringTable.hpp" |
43 | #include "classfile/symbolTable.hpp" |
44 | #include "classfile/systemDictionary.hpp" |
45 | #include "classfile/vmClasses.hpp" |
46 | #include "classfile/vmSymbols.hpp" |
47 | #include "gc/shared/collectedHeap.inline.hpp" |
48 | #include "interpreter/bytecode.hpp" |
49 | #include "interpreter/bytecodeUtils.hpp" |
50 | #include "jfr/jfrEvents.hpp" |
51 | #include "logging/log.hpp" |
52 | #include "memory/oopFactory.hpp" |
53 | #include "memory/referenceType.hpp" |
54 | #include "memory/resourceArea.hpp" |
55 | #include "memory/universe.hpp" |
56 | #include "oops/access.inline.hpp" |
57 | #include "oops/constantPool.hpp" |
58 | #include "oops/fieldStreams.inline.hpp" |
59 | #include "oops/instanceKlass.hpp" |
60 | #include "oops/klass.inline.hpp" |
61 | #include "oops/method.hpp" |
62 | #include "oops/recordComponent.hpp" |
63 | #include "oops/objArrayKlass.hpp" |
64 | #include "oops/objArrayOop.inline.hpp" |
65 | #include "oops/oop.inline.hpp" |
66 | #include "prims/jvm_misc.hpp" |
67 | #include "prims/jvmtiExport.hpp" |
68 | #include "prims/jvmtiThreadState.hpp" |
69 | #include "prims/stackwalk.hpp" |
70 | #include "runtime/arguments.hpp" |
71 | #include "runtime/atomic.hpp" |
72 | #include "runtime/globals_extension.hpp" |
73 | #include "runtime/handles.inline.hpp" |
74 | #include "runtime/init.hpp" |
75 | #include "runtime/interfaceSupport.inline.hpp" |
76 | #include "runtime/deoptimization.hpp" |
77 | #include "runtime/handshake.hpp" |
78 | #include "runtime/java.hpp" |
79 | #include "runtime/javaCalls.hpp" |
80 | #include "runtime/jfieldIDWorkaround.hpp" |
81 | #include "runtime/jniHandles.inline.hpp" |
82 | #include "runtime/os.inline.hpp" |
83 | #include "runtime/osThread.hpp" |
84 | #include "runtime/perfData.hpp" |
85 | #include "runtime/reflection.hpp" |
86 | #include "runtime/synchronizer.hpp" |
87 | #include "runtime/thread.inline.hpp" |
88 | #include "runtime/threadSMR.hpp" |
89 | #include "runtime/vframe.inline.hpp" |
90 | #include "runtime/vmOperations.hpp" |
91 | #include "runtime/vm_version.hpp" |
92 | #include "services/attachListener.hpp" |
93 | #include "services/management.hpp" |
94 | #include "services/threadService.hpp" |
95 | #include "utilities/copy.hpp" |
96 | #include "utilities/defaultStream.hpp" |
97 | #include "utilities/dtrace.hpp" |
98 | #include "utilities/events.hpp" |
99 | #include "utilities/macros.hpp" |
100 | #include "utilities/utf8.hpp" |
101 | #if INCLUDE_CDS1 |
102 | #include "classfile/systemDictionaryShared.hpp" |
103 | #endif |
104 | #if INCLUDE_JFR1 |
105 | #include "jfr/jfr.hpp" |
106 | #endif |
107 | #if INCLUDE_MANAGEMENT1 |
108 | #include "services/finalizerService.hpp" |
109 | #endif |
110 | |
111 | #include <errno(*__errno_location ()).h> |
112 | |
113 | /* |
114 | NOTE about use of any ctor or function call that can trigger a safepoint/GC: |
115 | such ctors and calls MUST NOT come between an oop declaration/init and its |
116 | usage because if objects are move this may cause various memory stomps, bus |
117 | errors and segfaults. Here is a cookbook for causing so called "naked oop |
118 | failures": |
119 | |
120 | JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields<etc> { |
121 | // Object address to be held directly in mirror & not visible to GC |
122 | oop mirror = JNIHandles::resolve_non_null(ofClass); |
123 | |
124 | // If this ctor can hit a safepoint, moving objects around, then |
125 | ComplexConstructor foo; |
126 | |
127 | // Boom! mirror may point to JUNK instead of the intended object |
128 | (some dereference of mirror) |
129 | |
130 | // Here's another call that may block for GC, making mirror stale |
131 | MutexLocker ml(some_lock); |
132 | |
133 | // And here's an initializer that can result in a stale oop |
134 | // all in one step. |
135 | oop o = call_that_can_throw_exception(TRAPS); |
136 | |
137 | |
138 | The solution is to keep the oop declaration BELOW the ctor or function |
139 | call that might cause a GC, do another resolve to reassign the oop, or |
140 | consider use of a Handle instead of an oop so there is immunity from object |
141 | motion. But note that the "QUICK" entries below do not have a handlemark |
142 | and thus can only support use of handles passed in. |
143 | */ |
144 | |
145 | static void trace_class_resolution_impl(Klass* to_class, TRAPSJavaThread* __the_thread__) { |
146 | ResourceMark rm; |
147 | int line_number = -1; |
148 | const char * source_file = NULL__null; |
149 | const char * trace = "explicit"; |
150 | InstanceKlass* caller = NULL__null; |
151 | JavaThread* jthread = THREAD__the_thread__; |
152 | if (jthread->has_last_Java_frame()) { |
153 | vframeStream vfst(jthread); |
154 | |
155 | // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames |
156 | TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController"); |
157 | Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
158 | TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction"); |
159 | Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
160 | |
161 | Method* last_caller = NULL__null; |
162 | |
163 | while (!vfst.at_end()) { |
164 | Method* m = vfst.method(); |
165 | if (!vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass())&& |
166 | !vfst.method()->method_holder()->is_subclass_of(access_controller_klass) && |
167 | !vfst.method()->method_holder()->is_subclass_of(privileged_action_klass)) { |
168 | break; |
169 | } |
170 | last_caller = m; |
171 | vfst.next(); |
172 | } |
173 | // if this is called from Class.forName0 and that is called from Class.forName, |
174 | // then print the caller of Class.forName. If this is Class.loadClass, then print |
175 | // that caller, otherwise keep quiet since this should be picked up elsewhere. |
176 | bool found_it = false; |
177 | if (!vfst.at_end() && |
178 | vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
179 | vfst.method()->name() == vmSymbols::forName0_name()) { |
180 | vfst.next(); |
181 | if (!vfst.at_end() && |
182 | vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
183 | vfst.method()->name() == vmSymbols::forName_name()) { |
184 | vfst.next(); |
185 | found_it = true; |
186 | } |
187 | } else if (last_caller != NULL__null && |
188 | last_caller->method_holder()->name() == |
189 | vmSymbols::java_lang_ClassLoader() && |
190 | last_caller->name() == vmSymbols::loadClass_name()) { |
191 | found_it = true; |
192 | } else if (!vfst.at_end()) { |
193 | if (vfst.method()->is_native()) { |
194 | // JNI call |
195 | found_it = true; |
196 | } |
197 | } |
198 | if (found_it && !vfst.at_end()) { |
199 | // found the caller |
200 | caller = vfst.method()->method_holder(); |
201 | line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
202 | if (line_number == -1) { |
203 | // show method name if it's a native method |
204 | trace = vfst.method()->name_and_sig_as_C_string(); |
205 | } |
206 | Symbol* s = caller->source_file_name(); |
207 | if (s != NULL__null) { |
208 | source_file = s->as_C_string(); |
209 | } |
210 | } |
211 | } |
212 | if (caller != NULL__null) { |
213 | if (to_class != caller) { |
214 | const char * from = caller->external_name(); |
215 | const char * to = to_class->external_name(); |
216 | // print in a single call to reduce interleaving between threads |
217 | if (source_file != NULL__null) { |
218 | log_debug(class, resolve)(!(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag:: __NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG )>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_resolve), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Debug>("%s %s %s:%d (%s)", from, to, source_file, line_number, trace); |
219 | } else { |
220 | log_debug(class, resolve)(!(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag:: __NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG )>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_resolve), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Debug>("%s %s (%s)", from, to, trace); |
221 | } |
222 | } |
223 | } |
224 | } |
225 | |
226 | void trace_class_resolution(Klass* to_class) { |
227 | EXCEPTION_MARKExceptionMark __em; JavaThread* __the_thread__ = __em.thread( );; |
228 | trace_class_resolution_impl(to_class, THREAD__the_thread__); |
229 | if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) { |
230 | CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception( )); |
231 | } |
232 | } |
233 | |
234 | // java.lang.System ////////////////////////////////////////////////////////////////////// |
235 | |
236 | |
237 | JVM_LEAF(jlong, JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored))extern "C" { jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored ) { VM_Exit::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
238 | return os::javaTimeMillis(); |
239 | JVM_END} } |
240 | |
241 | JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored))extern "C" { jlong JVM_NanoTime(JNIEnv *env, jclass ignored) { VM_Exit::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
242 | return os::javaTimeNanos(); |
243 | JVM_END} } |
244 | |
245 | // The function below is actually exposed by jdk.internal.misc.VM and not |
246 | // java.lang.System, but we choose to keep it here so that it stays next |
247 | // to JVM_CurrentTimeMillis and JVM_NanoTime |
248 | |
249 | const jlong MAX_DIFF_SECS = CONST64(0x0100000000)(0x0100000000LL); // 2^32 |
250 | const jlong MIN_DIFF_SECS = -MAX_DIFF_SECS; // -2^32 |
251 | |
252 | JVM_LEAF(jlong, JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs))extern "C" { jlong JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs) { VM_Exit::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment(); |
253 | jlong seconds; |
254 | jlong nanos; |
255 | |
256 | os::javaTimeSystemUTC(seconds, nanos); |
257 | |
258 | // We're going to verify that the result can fit in a long. |
259 | // For that we need the difference in seconds between 'seconds' |
260 | // and 'offset_secs' to be such that: |
261 | // |seconds - offset_secs| < (2^63/10^9) |
262 | // We're going to approximate 10^9 ~< 2^30 (1000^3 ~< 1024^3) |
263 | // which makes |seconds - offset_secs| < 2^33 |
264 | // and we will prefer +/- 2^32 as the maximum acceptable diff |
265 | // as 2^32 has a more natural feel than 2^33... |
266 | // |
267 | // So if |seconds - offset_secs| >= 2^32 - we return a special |
268 | // sentinel value (-1) which the caller should take as an |
269 | // exception value indicating that the offset given to us is |
270 | // too far from range of the current time - leading to too big |
271 | // a nano adjustment. The caller is expected to recover by |
272 | // computing a more accurate offset and calling this method |
273 | // again. (For the record 2^32 secs is ~136 years, so that |
274 | // should rarely happen) |
275 | // |
276 | jlong diff = seconds - offset_secs; |
277 | if (diff >= MAX_DIFF_SECS || diff <= MIN_DIFF_SECS) { |
278 | return -1; // sentinel value: the offset is too far off the target |
279 | } |
280 | |
281 | // return the adjustment. If you compute a time by adding |
282 | // this number of nanoseconds along with the number of seconds |
283 | // in the offset you should get the current UTC time. |
284 | return (diff * (jlong)1000000000) + nanos; |
285 | JVM_END} } |
286 | |
287 | JVM_ENTRY(void, JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,extern "C" { void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
288 | jobject dst, jint dst_pos, jint length))extern "C" { void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
289 | // Check if we have null pointers |
290 | if (src == NULL__null || dst == NULL__null) { |
291 | THROW(vmSymbols::java_lang_NullPointerException()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 291, vmSymbols::java_lang_NullPointerException(), __null); return ; }; |
292 | } |
293 | arrayOop s = arrayOop(JNIHandles::resolve_non_null(src)); |
294 | arrayOop d = arrayOop(JNIHandles::resolve_non_null(dst)); |
295 | assert(oopDesc::is_oop(s), "JVM_ArrayCopy: src not an oop")do { if (!(oopDesc::is_oop(s))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 295, "assert(" "oopDesc::is_oop(s)" ") failed", "JVM_ArrayCopy: src not an oop" ); ::breakpoint(); } } while (0); |
296 | assert(oopDesc::is_oop(d), "JVM_ArrayCopy: dst not an oop")do { if (!(oopDesc::is_oop(d))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 296, "assert(" "oopDesc::is_oop(d)" ") failed", "JVM_ArrayCopy: dst not an oop" ); ::breakpoint(); } } while (0); |
297 | // Do copy |
298 | s->klass()->copy_array(s, src_pos, d, dst_pos, length, thread); |
299 | JVM_END} } |
300 | |
301 | |
302 | static void set_property(Handle props, const char* key, const char* value, TRAPSJavaThread* __the_thread__) { |
303 | JavaValue r(T_OBJECT); |
304 | // public synchronized Object put(Object key, Object value); |
305 | HandleMark hm(THREAD__the_thread__); |
306 | Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
307 | Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL__null ? value : ""), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
308 | JavaCalls::call_virtual(&r, |
309 | props, |
310 | vmClasses::Properties_klass(), |
311 | vmSymbols::put_name(), |
312 | vmSymbols::object_object_object_signature(), |
313 | key_str, |
314 | value_str, |
315 | THREAD__the_thread__); |
316 | } |
317 | |
318 | |
319 | #define PUTPROP(props, name, value)set_property((props), (name), (value), __the_thread__); if (( ((ThreadShadow*)__the_thread__)->has_pending_exception())) return properties; (void)(0); set_property((props), (name), (value), CHECK_(properties)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return properties; (void)(0); |
320 | |
321 | /* |
322 | * Return all of the system properties in a Java String array with alternating |
323 | * names and values from the jvm SystemProperty. |
324 | * Which includes some internal and all commandline -D defined properties. |
325 | */ |
326 | JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env))extern "C" { jobjectArray JVM_GetProperties(JNIEnv *env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
327 | ResourceMark rm(THREAD__the_thread__); |
328 | HandleMark hm(THREAD__the_thread__); |
329 | int ndx = 0; |
330 | int fixedCount = 2; |
331 | |
332 | SystemProperty* p = Arguments::system_properties(); |
333 | int count = Arguments::PropertyList_count(p); |
334 | |
335 | // Allocate result String array |
336 | InstanceKlass* ik = vmClasses::String_klass(); |
337 | objArrayOop r = oopFactory::new_objArray(ik, (count + fixedCount) * 2, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
338 | objArrayHandle result_h(THREAD__the_thread__, r); |
339 | |
340 | while (p != NULL__null) { |
341 | const char * key = p->key(); |
342 | if (strcmp(key, "sun.nio.MaxDirectMemorySize") != 0) { |
343 | const char * value = p->value(); |
344 | Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
345 | Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL__null ? value : ""), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
346 | result_h->obj_at_put(ndx * 2, key_str()); |
347 | result_h->obj_at_put(ndx * 2 + 1, value_str()); |
348 | ndx++; |
349 | } |
350 | p = p->next(); |
351 | } |
352 | |
353 | // Convert the -XX:MaxDirectMemorySize= command line flag |
354 | // to the sun.nio.MaxDirectMemorySize property. |
355 | // Do this after setting user properties to prevent people |
356 | // from setting the value with a -D option, as requested. |
357 | // Leave empty if not supplied |
358 | if (!FLAG_IS_DEFAULT(MaxDirectMemorySize)(JVMFlag::is_default(Flag_MaxDirectMemorySize_enum))) { |
359 | char as_chars[256]; |
360 | jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT"%" "l" "u", MaxDirectMemorySize); |
361 | Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.nio.MaxDirectMemorySize", CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
362 | Handle value_str = java_lang_String::create_from_platform_dependent_str(as_chars, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
363 | result_h->obj_at_put(ndx * 2, key_str()); |
364 | result_h->obj_at_put(ndx * 2 + 1, value_str()); |
365 | ndx++; |
366 | } |
367 | |
368 | // JVM monitoring and management support |
369 | // Add the sun.management.compiler property for the compiler's name |
370 | { |
371 | #undef CSIZE"64-Bit " |
372 | #if defined(_LP641) || defined(_WIN64) |
373 | #define CSIZE"64-Bit " "64-Bit " |
374 | #else |
375 | #define CSIZE"64-Bit " |
376 | #endif // 64bit |
377 | |
378 | #if COMPILER1_AND_COMPILER21 |
379 | const char* compiler_name = "HotSpot " CSIZE"64-Bit " "Tiered Compilers"; |
380 | #else |
381 | #if defined(COMPILER11) |
382 | const char* compiler_name = "HotSpot " CSIZE"64-Bit " "Client Compiler"; |
383 | #elif defined(COMPILER21) |
384 | const char* compiler_name = "HotSpot " CSIZE"64-Bit " "Server Compiler"; |
385 | #elif INCLUDE_JVMCI1 |
386 | #error "INCLUDE_JVMCI should imply COMPILER1_OR_COMPILER2" |
387 | #else |
388 | const char* compiler_name = ""; |
389 | #endif // compilers |
390 | #endif // COMPILER1_AND_COMPILER2 |
391 | |
392 | if (*compiler_name != '\0' && |
393 | (Arguments::mode() != Arguments::_int)) { |
394 | Handle key_str = java_lang_String::create_from_platform_dependent_str("sun.management.compiler", CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
395 | Handle value_str = java_lang_String::create_from_platform_dependent_str(compiler_name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
396 | result_h->obj_at_put(ndx * 2, key_str()); |
397 | result_h->obj_at_put(ndx * 2 + 1, value_str()); |
398 | ndx++; |
399 | } |
400 | } |
401 | |
402 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result_h()); |
403 | JVM_END} } |
404 | |
405 | |
406 | /* |
407 | * Return the temporary directory that the VM uses for the attach |
408 | * and perf data files. |
409 | * |
410 | * It is important that this directory is well-known and the |
411 | * same for all VM instances. It cannot be affected by configuration |
412 | * variables such as java.io.tmpdir. |
413 | */ |
414 | JVM_ENTRY(jstring, JVM_GetTemporaryDirectory(JNIEnv *env))extern "C" { jstring JVM_GetTemporaryDirectory(JNIEnv *env) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
415 | HandleMark hm(THREAD__the_thread__); |
416 | const char* temp_dir = os::get_temp_directory(); |
417 | Handle h = java_lang_String::create_from_platform_dependent_str(temp_dir, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
418 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, h()); |
419 | JVM_END} } |
420 | |
421 | |
422 | // java.lang.Runtime ///////////////////////////////////////////////////////////////////////// |
423 | |
424 | extern volatile jint vm_created; |
425 | |
426 | JVM_ENTRY_NO_ENV(void, JVM_BeforeHalt())extern "C" { void JVM_BeforeHalt() { JavaThread* thread = JavaThread ::current(); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
427 | #if INCLUDE_CDS1 |
428 | // Link all classes for dynamic CDS dumping before vm exit. |
429 | if (DynamicArchive::should_dump_at_vm_exit()) { |
430 | DynamicArchive::prepare_for_dump_at_exit(); |
431 | } |
432 | #endif |
433 | EventShutdown event; |
434 | if (event.should_commit()) { |
435 | event.set_reason("Shutdown requested from Java"); |
436 | event.commit(); |
437 | } |
438 | JVM_END} } |
439 | |
440 | |
441 | JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code))extern "C" { void JVM_Halt(jint code) { JavaThread* thread = JavaThread ::current(); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
442 | before_exit(thread); |
443 | vm_exit(code); |
444 | JVM_END} } |
445 | |
446 | |
447 | JVM_ENTRY_NO_ENV(void, JVM_GC(void))extern "C" { void JVM_GC(void) { JavaThread* thread = JavaThread ::current(); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
448 | if (!DisableExplicitGC) { |
449 | EventSystemGC event; |
450 | event.set_invokedConcurrent(ExplicitGCInvokesConcurrent); |
451 | Universe::heap()->collect(GCCause::_java_lang_system_gc); |
452 | event.commit(); |
453 | } |
454 | JVM_END} } |
455 | |
456 | |
457 | JVM_LEAF(jlong, JVM_MaxObjectInspectionAge(void))extern "C" { jlong JVM_MaxObjectInspectionAge(void) { VM_Exit ::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
458 | return Universe::heap()->millis_since_last_whole_heap_examined(); |
459 | JVM_END} } |
460 | |
461 | |
462 | static inline jlong convert_size_t_to_jlong(size_t val) { |
463 | // In the 64-bit vm, a size_t can overflow a jlong (which is signed). |
464 | NOT_LP64 (return (jlong)val;) |
465 | LP64_ONLY(return (jlong)MIN2(val, (size_t)max_jlong);)return (jlong)MIN2(val, (size_t)max_jlong); |
466 | } |
467 | |
468 | JVM_ENTRY_NO_ENV(jlong, JVM_TotalMemory(void))extern "C" { jlong JVM_TotalMemory(void) { JavaThread* thread = JavaThread::current(); ; ThreadInVMfromNative __tiv(thread ); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread) ; JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
469 | size_t n = Universe::heap()->capacity(); |
470 | return convert_size_t_to_jlong(n); |
471 | JVM_END} } |
472 | |
473 | |
474 | JVM_ENTRY_NO_ENV(jlong, JVM_FreeMemory(void))extern "C" { jlong JVM_FreeMemory(void) { JavaThread* thread = JavaThread::current(); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread * __the_thread__ = thread; os::verify_stack_alignment(); |
475 | size_t n = Universe::heap()->unused(); |
476 | return convert_size_t_to_jlong(n); |
477 | JVM_END} } |
478 | |
479 | |
480 | JVM_ENTRY_NO_ENV(jlong, JVM_MaxMemory(void))extern "C" { jlong JVM_MaxMemory(void) { JavaThread* thread = JavaThread::current(); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread * __the_thread__ = thread; os::verify_stack_alignment(); |
481 | size_t n = Universe::heap()->max_capacity(); |
482 | return convert_size_t_to_jlong(n); |
483 | JVM_END} } |
484 | |
485 | |
486 | JVM_ENTRY_NO_ENV(jint, JVM_ActiveProcessorCount(void))extern "C" { jint JVM_ActiveProcessorCount(void) { JavaThread * thread = JavaThread::current(); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
487 | return os::active_processor_count(); |
488 | JVM_END} } |
489 | |
490 | JVM_ENTRY_NO_ENV(jboolean, JVM_IsUseContainerSupport(void))extern "C" { jboolean JVM_IsUseContainerSupport(void) { JavaThread * thread = JavaThread::current(); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
491 | #ifdef LINUX1 |
492 | if (UseContainerSupport) { |
493 | return JNI_TRUE1; |
494 | } |
495 | #endif |
496 | return JNI_FALSE0; |
497 | JVM_END} } |
498 | |
499 | // java.lang.Throwable ////////////////////////////////////////////////////// |
500 | |
501 | JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver))extern "C" { void JVM_FillInStackTrace(JNIEnv *env, jobject receiver ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
502 | Handle exception(thread, JNIHandles::resolve_non_null(receiver)); |
503 | java_lang_Throwable::fill_in_stack_trace(exception); |
504 | JVM_END} } |
505 | |
506 | // java.lang.NullPointerException /////////////////////////////////////////// |
507 | |
508 | JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable))extern "C" { jstring JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
509 | if (!ShowCodeDetailsInExceptionMessages) return NULL__null; |
510 | |
511 | oop exc = JNIHandles::resolve_non_null(throwable); |
512 | |
513 | Method* method; |
514 | int bci; |
515 | if (!java_lang_Throwable::get_top_method_and_bci(exc, &method, &bci)) { |
516 | return NULL__null; |
517 | } |
518 | if (method->is_native()) { |
519 | return NULL__null; |
520 | } |
521 | |
522 | stringStream ss; |
523 | bool ok = BytecodeUtils::get_NPE_message_at(&ss, method, bci); |
524 | if (ok) { |
525 | oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
526 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, result); |
527 | } else { |
528 | return NULL__null; |
529 | } |
530 | JVM_END} } |
531 | |
532 | // java.lang.StackTraceElement ////////////////////////////////////////////// |
533 | |
534 | |
535 | JVM_ENTRY(void, JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable))extern "C" { void JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
536 | Handle exception(THREAD__the_thread__, JNIHandles::resolve(throwable)); |
537 | objArrayOop st = objArrayOop(JNIHandles::resolve(elements)); |
538 | objArrayHandle stack_trace(THREAD__the_thread__, st); |
539 | // Fill in the allocated stack trace |
540 | java_lang_Throwable::get_stack_trace_elements(exception, stack_trace, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
541 | JVM_END} } |
542 | |
543 | |
544 | JVM_ENTRY(void, JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo))extern "C" { void JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
545 | Handle stack_frame_info(THREAD__the_thread__, JNIHandles::resolve_non_null(stackFrameInfo)); |
546 | Handle stack_trace_element(THREAD__the_thread__, JNIHandles::resolve_non_null(element)); |
547 | java_lang_StackFrameInfo::to_stack_trace_element(stack_frame_info, stack_trace_element, THREAD__the_thread__); |
548 | JVM_END} } |
549 | |
550 | |
551 | // java.lang.StackWalker ////////////////////////////////////////////////////// |
552 | |
553 | |
554 | JVM_ENTRY(jobject, JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,extern "C" { jobject JVM_CallStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jint skip_frames, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
555 | jint skip_frames, jint frame_count, jint start_index,extern "C" { jobject JVM_CallStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jint skip_frames, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
556 | jobjectArray frames))extern "C" { jobject JVM_CallStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jint skip_frames, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
557 | if (!thread->has_last_Java_frame()) { |
558 | THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: no stack trace", NULL){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 558, vmSymbols::java_lang_InternalError(), "doStackWalk: no stack trace" ); return __null; }; |
559 | } |
560 | |
561 | Handle stackStream_h(THREAD__the_thread__, JNIHandles::resolve_non_null(stackStream)); |
562 | |
563 | // frames array is a Class<?>[] array when only getting caller reference, |
564 | // and a StackFrameInfo[] array (or derivative) otherwise. It should never |
565 | // be null. |
566 | objArrayOop fa = objArrayOop(JNIHandles::resolve_non_null(frames)); |
567 | objArrayHandle frames_array_h(THREAD__the_thread__, fa); |
568 | |
569 | int limit = start_index + frame_count; |
570 | if (frames_array_h->length() < limit) { |
571 | THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers", NULL){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 571, vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers" ); return __null; }; |
572 | } |
573 | |
574 | oop result = StackWalk::walk(stackStream_h, mode, skip_frames, frame_count, |
575 | start_index, frames_array_h, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
576 | return JNIHandles::make_local(THREAD__the_thread__, result); |
577 | JVM_END} } |
578 | |
579 | |
580 | JVM_ENTRY(jint, JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,extern "C" { jint JVM_MoreStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jlong anchor, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
581 | jint frame_count, jint start_index,extern "C" { jint JVM_MoreStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jlong anchor, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
582 | jobjectArray frames))extern "C" { jint JVM_MoreStackWalk(JNIEnv *env, jobject stackStream , jlong mode, jlong anchor, jint frame_count, jint start_index , jobjectArray frames) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
583 | // frames array is a Class<?>[] array when only getting caller reference, |
584 | // and a StackFrameInfo[] array (or derivative) otherwise. It should never |
585 | // be null. |
586 | objArrayOop fa = objArrayOop(JNIHandles::resolve_non_null(frames)); |
587 | objArrayHandle frames_array_h(THREAD__the_thread__, fa); |
588 | |
589 | int limit = start_index+frame_count; |
590 | if (frames_array_h->length() < limit) { |
591 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 591, vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers" ); return 0; }; |
592 | } |
593 | |
594 | Handle stackStream_h(THREAD__the_thread__, JNIHandles::resolve_non_null(stackStream)); |
595 | return StackWalk::fetchNextBatch(stackStream_h, mode, anchor, frame_count, |
596 | start_index, frames_array_h, THREAD__the_thread__); |
597 | JVM_END} } |
598 | |
599 | // java.lang.Object /////////////////////////////////////////////// |
600 | |
601 | |
602 | JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle))extern "C" { jint JVM_IHashCode(JNIEnv* env, jobject handle) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
603 | // as implemented in the classic virtual machine; return 0 if object is NULL |
604 | return handle == NULL__null ? 0 : ObjectSynchronizer::FastHashCode (THREAD__the_thread__, JNIHandles::resolve_non_null(handle)) ; |
605 | JVM_END} } |
606 | |
607 | |
608 | JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms))extern "C" { void JVM_MonitorWait(JNIEnv* env, jobject handle , jlong ms) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
609 | Handle obj(THREAD__the_thread__, JNIHandles::resolve_non_null(handle)); |
610 | JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
611 | if (JvmtiExport::should_post_monitor_wait()) { |
612 | JvmtiExport::post_monitor_wait(thread, obj(), ms); |
613 | |
614 | // The current thread already owns the monitor and it has not yet |
615 | // been added to the wait queue so the current thread cannot be |
616 | // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT |
617 | // event handler cannot accidentally consume an unpark() meant for |
618 | // the ParkEvent associated with this ObjectMonitor. |
619 | } |
620 | ObjectSynchronizer::wait(obj, ms, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
621 | JVM_END} } |
622 | |
623 | |
624 | JVM_ENTRY(void, JVM_MonitorNotify(JNIEnv* env, jobject handle))extern "C" { void JVM_MonitorNotify(JNIEnv* env, jobject handle ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
625 | Handle obj(THREAD__the_thread__, JNIHandles::resolve_non_null(handle)); |
626 | ObjectSynchronizer::notify(obj, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
627 | JVM_END} } |
628 | |
629 | |
630 | JVM_ENTRY(void, JVM_MonitorNotifyAll(JNIEnv* env, jobject handle))extern "C" { void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
631 | Handle obj(THREAD__the_thread__, JNIHandles::resolve_non_null(handle)); |
632 | ObjectSynchronizer::notifyall(obj, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
633 | JVM_END} } |
634 | |
635 | |
636 | JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle))extern "C" { jobject JVM_Clone(JNIEnv* env, jobject handle) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
637 | Handle obj(THREAD__the_thread__, JNIHandles::resolve_non_null(handle)); |
638 | Klass* klass = obj->klass(); |
639 | JvmtiVMObjectAllocEventCollector oam; |
640 | |
641 | #ifdef ASSERT1 |
642 | // Just checking that the cloneable flag is set correct |
643 | if (obj->is_array()) { |
644 | guarantee(klass->is_cloneable(), "all arrays are cloneable")do { if (!(klass->is_cloneable())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 644, "guarantee(" "klass->is_cloneable()" ") failed", "all arrays are cloneable" ); ::breakpoint(); } } while (0); |
645 | } else { |
646 | guarantee(obj->is_instance(), "should be instanceOop")do { if (!(obj->is_instance())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 646, "guarantee(" "obj->is_instance()" ") failed", "should be instanceOop" ); ::breakpoint(); } } while (0); |
647 | bool cloneable = klass->is_subtype_of(vmClasses::Cloneable_klass()); |
648 | guarantee(cloneable == klass->is_cloneable(), "incorrect cloneable flag")do { if (!(cloneable == klass->is_cloneable())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 648, "guarantee(" "cloneable == klass->is_cloneable()" ") failed" , "incorrect cloneable flag"); ::breakpoint(); } } while (0); |
649 | } |
650 | #endif |
651 | |
652 | // Check if class of obj supports the Cloneable interface. |
653 | // All arrays are considered to be cloneable (See JLS 20.1.5). |
654 | // All j.l.r.Reference classes are considered non-cloneable. |
655 | if (!klass->is_cloneable() || |
656 | (klass->is_instance_klass() && |
657 | InstanceKlass::cast(klass)->reference_type() != REF_NONE)) { |
658 | ResourceMark rm(THREAD__the_thread__); |
659 | THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 659, vmSymbols::java_lang_CloneNotSupportedException(), klass ->external_name()); return 0; }; |
660 | } |
661 | |
662 | // Make shallow object copy |
663 | const size_t size = obj->size(); |
664 | oop new_obj_oop = NULL__null; |
665 | if (obj->is_array()) { |
666 | const int length = ((arrayOop)obj())->length(); |
667 | new_obj_oop = Universe::heap()->array_allocate(klass, size, length, |
668 | /* do_zero */ true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
669 | } else { |
670 | new_obj_oop = Universe::heap()->obj_allocate(klass, size, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
671 | } |
672 | |
673 | HeapAccess<>::clone(obj(), new_obj_oop, size); |
674 | |
675 | Handle new_obj(THREAD__the_thread__, new_obj_oop); |
676 | // Caution: this involves a java upcall, so the clone should be |
677 | // "gc-robust" by this stage. |
678 | if (klass->has_finalizer()) { |
679 | assert(obj->is_instance(), "should be instanceOop")do { if (!(obj->is_instance())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 679, "assert(" "obj->is_instance()" ") failed", "should be instanceOop" ); ::breakpoint(); } } while (0); |
680 | new_obj_oop = InstanceKlass::register_finalizer(instanceOop(new_obj()), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
681 | new_obj = Handle(THREAD__the_thread__, new_obj_oop); |
682 | } |
683 | |
684 | return JNIHandles::make_local(THREAD__the_thread__, new_obj()); |
685 | JVM_END} } |
686 | |
687 | // java.lang.ref.Finalizer //////////////////////////////////////////////////// |
688 | |
689 | JVM_ENTRY(void, JVM_ReportFinalizationComplete(JNIEnv * env, jobject finalizee))extern "C" { void JVM_ReportFinalizationComplete(JNIEnv * env , jobject finalizee) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
690 | MANAGEMENT_ONLY(FinalizerService::on_complete(JNIHandles::resolve_non_null(finalizee), THREAD);)FinalizerService::on_complete(JNIHandles::resolve_non_null(finalizee ), __the_thread__); |
691 | JVM_END} } |
692 | |
693 | JVM_ENTRY(jboolean, JVM_IsFinalizationEnabled(JNIEnv * env))extern "C" { jboolean JVM_IsFinalizationEnabled(JNIEnv * env) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
694 | return InstanceKlass::is_finalization_enabled(); |
695 | JVM_END} } |
696 | |
697 | // java.io.File /////////////////////////////////////////////////////////////// |
698 | |
699 | JVM_LEAF(char*, JVM_NativePath(char* path))extern "C" { char* JVM_NativePath(char* path) { VM_Exit::block_if_vm_exited (); NoHandleMark __hm; ; os::verify_stack_alignment(); |
700 | return os::native_path(path); |
701 | JVM_END} } |
702 | |
703 | |
704 | // Misc. class handling /////////////////////////////////////////////////////////// |
705 | |
706 | |
707 | JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env))extern "C" { jclass JVM_GetCallerClass(JNIEnv* env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
708 | // Getting the class of the caller frame. |
709 | // |
710 | // The call stack at this point looks something like this: |
711 | // |
712 | // [0] [ @CallerSensitive public sun.reflect.Reflection.getCallerClass ] |
713 | // [1] [ @CallerSensitive API.method ] |
714 | // [.] [ (skipped intermediate frames) ] |
715 | // [n] [ caller ] |
716 | vframeStream vfst(thread); |
717 | // Cf. LibraryCallKit::inline_native_Reflection_getCallerClass |
718 | for (int n = 0; !vfst.at_end(); vfst.security_next(), n++) { |
719 | Method* m = vfst.method(); |
720 | assert(m != NULL, "sanity")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 720, "assert(" "m != __null" ") failed", "sanity"); ::breakpoint (); } } while (0); |
721 | switch (n) { |
722 | case 0: |
723 | // This must only be called from Reflection.getCallerClass |
724 | if (m->intrinsic_id() != vmIntrinsics::_getCallerClass) { |
725 | THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetCallerClass must only be called from Reflection.getCallerClass"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 725, vmSymbols::java_lang_InternalError(), "JVM_GetCallerClass must only be called from Reflection.getCallerClass" ); return __null; }; |
726 | } |
727 | // fall-through |
728 | case 1: |
729 | // Frame 0 and 1 must be caller sensitive. |
730 | if (!m->caller_sensitive()) { |
731 | THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), err_msg("CallerSensitive annotation expected at frame %d", n)){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 731, vmSymbols::java_lang_InternalError(), err_msg("CallerSensitive annotation expected at frame %d" , n)); return __null; }; |
732 | } |
733 | break; |
734 | default: |
735 | if (!m->is_ignored_by_security_stack_walk()) { |
736 | // We have reached the desired frame; return the holder class. |
737 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, m->method_holder()->java_mirror()); |
738 | } |
739 | break; |
740 | } |
741 | } |
742 | return NULL__null; |
743 | JVM_END} } |
744 | |
745 | |
746 | JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf))extern "C" { jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* utf) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
747 | oop mirror = NULL__null; |
748 | BasicType t = name2type(utf); |
749 | if (t != T_ILLEGAL && !is_reference_type(t)) { |
750 | mirror = Universe::java_mirror(t); |
751 | } |
752 | if (mirror == NULL__null) { |
753 | THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 753, vmSymbols::java_lang_ClassNotFoundException(), (char*) utf); return 0; }; |
754 | } else { |
755 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, mirror); |
756 | } |
757 | JVM_END} } |
758 | |
759 | |
760 | // Returns a class loaded by the bootstrap class loader; or null |
761 | // if not found. ClassNotFoundException is not thrown. |
762 | // FindClassFromBootLoader is exported to the launcher for windows. |
763 | JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,extern "C" { jclass JVM_FindClassFromBootLoader(JNIEnv* env, const char* name) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
764 | const char* name))extern "C" { jclass JVM_FindClassFromBootLoader(JNIEnv* env, const char* name) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
765 | // Java libraries should ensure that name is never null or illegal. |
766 | if (name == NULL__null || (int)strlen(name) > Symbol::max_length()) { |
767 | // It's impossible to create this class; the name cannot fit |
768 | // into the constant pool. |
769 | return NULL__null; |
770 | } |
771 | assert(UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false), "illegal UTF name")do { if (!(UTF8::is_legal_utf8((const unsigned char*)name, (int )strlen(name), false))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 771, "assert(" "UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false)" ") failed", "illegal UTF name"); ::breakpoint(); } } while ( 0); |
772 | |
773 | TempNewSymbol h_name = SymbolTable::new_symbol(name); |
774 | Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
775 | if (k == NULL__null) { |
776 | return NULL__null; |
777 | } |
778 | |
779 | if (log_is_enabled(Debug, class, resolve)(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug))) { |
780 | trace_class_resolution(k); |
781 | } |
782 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, k->java_mirror()); |
783 | JVM_END} } |
784 | |
785 | // Find a class with this name in this loader, using the caller's protection domain. |
786 | JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,extern "C" { jclass JVM_FindClassFromCaller(JNIEnv* env, const char* name, jboolean init, jobject loader, jclass caller) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
787 | jboolean init, jobject loader,extern "C" { jclass JVM_FindClassFromCaller(JNIEnv* env, const char* name, jboolean init, jobject loader, jclass caller) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
788 | jclass caller))extern "C" { jclass JVM_FindClassFromCaller(JNIEnv* env, const char* name, jboolean init, jobject loader, jclass caller) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
789 | TempNewSymbol h_name = |
790 | SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_ClassNotFoundException(), |
791 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
792 | |
793 | oop loader_oop = JNIHandles::resolve(loader); |
794 | oop from_class = JNIHandles::resolve(caller); |
795 | oop protection_domain = NULL__null; |
796 | // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get |
797 | // NPE. Put it in another way, the bootstrap class loader has all permission and |
798 | // thus no checkPackageAccess equivalence in the VM class loader. |
799 | // The caller is also passed as NULL by the java code if there is no security |
800 | // manager to avoid the performance cost of getting the calling class. |
801 | if (from_class != NULL__null && loader_oop != NULL__null) { |
802 | protection_domain = java_lang_Class::as_Klass(from_class)->protection_domain(); |
803 | } |
804 | |
805 | Handle h_loader(THREAD__the_thread__, loader_oop); |
806 | Handle h_prot(THREAD__the_thread__, protection_domain); |
807 | jclass result = find_class_from_class_loader(env, h_name, init, h_loader, |
808 | h_prot, false, THREAD__the_thread__); |
809 | |
810 | if (log_is_enabled(Debug, class, resolve)(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug)) && result != NULL__null) { |
811 | trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
812 | } |
813 | return result; |
814 | JVM_END} } |
815 | |
816 | // Currently only called from the old verifier. |
817 | JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,extern "C" { jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
818 | jboolean init, jclass from))extern "C" { jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
819 | TempNewSymbol h_name = |
820 | SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_ClassNotFoundException(), |
821 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
822 | oop from_class_oop = JNIHandles::resolve(from); |
823 | Klass* from_class = (from_class_oop == NULL__null) |
824 | ? (Klass*)NULL__null |
825 | : java_lang_Class::as_Klass(from_class_oop); |
826 | oop class_loader = NULL__null; |
827 | oop protection_domain = NULL__null; |
828 | if (from_class != NULL__null) { |
829 | class_loader = from_class->class_loader(); |
830 | protection_domain = from_class->protection_domain(); |
831 | } |
832 | Handle h_loader(THREAD__the_thread__, class_loader); |
833 | Handle h_prot (THREAD__the_thread__, protection_domain); |
834 | jclass result = find_class_from_class_loader(env, h_name, init, h_loader, |
835 | h_prot, true, thread); |
836 | |
837 | if (log_is_enabled(Debug, class, resolve)(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug)) && result != NULL__null) { |
838 | // this function is generally only used for class loading during verification. |
839 | ResourceMark rm; |
840 | oop from_mirror = JNIHandles::resolve_non_null(from); |
841 | Klass* from_class = java_lang_Class::as_Klass(from_mirror); |
842 | const char * from_name = from_class->external_name(); |
843 | |
844 | oop mirror = JNIHandles::resolve_non_null(result); |
845 | Klass* to_class = java_lang_Class::as_Klass(mirror); |
846 | const char * to = to_class->external_name(); |
847 | log_debug(class, resolve)(!(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag:: __NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG )>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_resolve), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Debug>("%s %s (verification)", from_name, to); |
848 | } |
849 | |
850 | return result; |
851 | JVM_END} } |
852 | |
853 | // common code for JVM_DefineClass() and JVM_DefineClassWithSource() |
854 | static jclass jvm_define_class_common(const char *name, |
855 | jobject loader, const jbyte *buf, |
856 | jsize len, jobject pd, const char *source, |
857 | TRAPSJavaThread* __the_thread__) { |
858 | if (source == NULL__null) source = "__JVM_DefineClass__"; |
859 | |
860 | JavaThread* jt = THREAD__the_thread__; |
861 | |
862 | PerfClassTraceTime vmtimer(ClassLoader::perf_define_appclass_time(), |
863 | ClassLoader::perf_define_appclass_selftime(), |
864 | ClassLoader::perf_define_appclasses(), |
865 | jt->get_thread_stat()->perf_recursion_counts_addr(), |
866 | jt->get_thread_stat()->perf_timers_addr(), |
867 | PerfClassTraceTime::DEFINE_CLASS); |
868 | |
869 | if (UsePerfData) { |
870 | ClassLoader::perf_app_classfile_bytes_read()->inc(len); |
871 | } |
872 | |
873 | // Class resolution will get the class name from the .class stream if the name is null. |
874 | TempNewSymbol class_name = name == NULL__null ? NULL__null : |
875 | SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_NoClassDefFoundError(), |
876 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
877 | |
878 | ResourceMark rm(THREAD__the_thread__); |
879 | ClassFileStream st((u1*)buf, len, source, ClassFileStream::verify); |
880 | Handle class_loader (THREAD__the_thread__, JNIHandles::resolve(loader)); |
881 | Handle protection_domain (THREAD__the_thread__, JNIHandles::resolve(pd)); |
882 | ClassLoadInfo cl_info(protection_domain); |
883 | Klass* k = SystemDictionary::resolve_from_stream(&st, class_name, |
884 | class_loader, |
885 | cl_info, |
886 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
887 | |
888 | if (log_is_enabled(Debug, class, resolve)(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug))) { |
889 | trace_class_resolution(k); |
890 | } |
891 | |
892 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, k->java_mirror()); |
893 | } |
894 | |
895 | enum { |
896 | NESTMATE = java_lang_invoke_MemberName::MN_NESTMATE_CLASS, |
897 | HIDDEN_CLASS = java_lang_invoke_MemberName::MN_HIDDEN_CLASS, |
898 | STRONG_LOADER_LINK = java_lang_invoke_MemberName::MN_STRONG_LOADER_LINK, |
899 | ACCESS_VM_ANNOTATIONS = java_lang_invoke_MemberName::MN_ACCESS_VM_ANNOTATIONS |
900 | }; |
901 | |
902 | /* |
903 | * Define a class with the specified flags that indicates if it's a nestmate, |
904 | * hidden, or strongly referenced from class loader. |
905 | */ |
906 | static jclass jvm_lookup_define_class(jclass lookup, const char *name, |
907 | const jbyte *buf, jsize len, jobject pd, |
908 | jboolean init, int flags, jobject classData, TRAPSJavaThread* __the_thread__) { |
909 | ResourceMark rm(THREAD__the_thread__); |
910 | |
911 | Klass* lookup_k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(lookup)); |
912 | // Lookup class must be a non-null instance |
913 | if (lookup_k == NULL__null) { |
914 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 914, vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null" ); return 0; }; |
915 | } |
916 | assert(lookup_k->is_instance_klass(), "Lookup class must be an instance klass")do { if (!(lookup_k->is_instance_klass())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 916, "assert(" "lookup_k->is_instance_klass()" ") failed" , "Lookup class must be an instance klass"); ::breakpoint(); } } while (0); |
917 | |
918 | Handle class_loader (THREAD__the_thread__, lookup_k->class_loader()); |
919 | |
920 | bool is_nestmate = (flags & NESTMATE) == NESTMATE; |
921 | bool is_hidden = (flags & HIDDEN_CLASS) == HIDDEN_CLASS; |
922 | bool is_strong = (flags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK; |
923 | bool vm_annotations = (flags & ACCESS_VM_ANNOTATIONS) == ACCESS_VM_ANNOTATIONS; |
924 | |
925 | InstanceKlass* host_class = NULL__null; |
926 | if (is_nestmate) { |
927 | host_class = InstanceKlass::cast(lookup_k)->nest_host(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
928 | } |
929 | |
930 | log_info(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Info))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Info>("LookupDefineClass: %s - %s%s, %s, %s, %s", |
931 | name, |
932 | is_nestmate ? "with dynamic nest-host " : "non-nestmate", |
933 | is_nestmate ? host_class->external_name() : "", |
934 | is_hidden ? "hidden" : "not hidden", |
935 | is_strong ? "strong" : "weak", |
936 | vm_annotations ? "with vm annotations" : "without vm annotation"); |
937 | |
938 | if (!is_hidden) { |
939 | // classData is only applicable for hidden classes |
940 | if (classData != NULL__null) { |
941 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "classData is only applicable for hidden classes"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 941, vmSymbols::java_lang_IllegalArgumentException(), "classData is only applicable for hidden classes" ); return 0; }; |
942 | } |
943 | if (is_nestmate) { |
944 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "dynamic nestmate is only applicable for hidden classes"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 944, vmSymbols::java_lang_IllegalArgumentException(), "dynamic nestmate is only applicable for hidden classes" ); return 0; }; |
945 | } |
946 | if (!is_strong) { |
947 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "an ordinary class must be strongly referenced by its defining loader"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 947, vmSymbols::java_lang_IllegalArgumentException(), "an ordinary class must be strongly referenced by its defining loader" ); return 0; }; |
948 | } |
949 | if (vm_annotations) { |
950 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "vm annotations only allowed for hidden classes"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 950, vmSymbols::java_lang_IllegalArgumentException(), "vm annotations only allowed for hidden classes" ); return 0; }; |
951 | } |
952 | if (flags != STRONG_LOADER_LINK) { |
953 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),{ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 954, vmSymbols::java_lang_IllegalArgumentException(), err_msg ("invalid flag 0x%x", flags)); return 0; } |
954 | err_msg("invalid flag 0x%x", flags)){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 954, vmSymbols::java_lang_IllegalArgumentException(), err_msg ("invalid flag 0x%x", flags)); return 0; }; |
955 | } |
956 | } |
957 | |
958 | // Class resolution will get the class name from the .class stream if the name is null. |
959 | TempNewSymbol class_name = name == NULL__null ? NULL__null : |
960 | SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_NoClassDefFoundError(), |
961 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
962 | |
963 | Handle protection_domain (THREAD__the_thread__, JNIHandles::resolve(pd)); |
964 | const char* source = is_nestmate ? host_class->external_name() : "__JVM_LookupDefineClass__"; |
965 | ClassFileStream st((u1*)buf, len, source, ClassFileStream::verify); |
966 | |
967 | InstanceKlass* ik = NULL__null; |
968 | if (!is_hidden) { |
969 | ClassLoadInfo cl_info(protection_domain); |
970 | ik = SystemDictionary::resolve_from_stream(&st, class_name, |
971 | class_loader, |
972 | cl_info, |
973 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
974 | |
975 | if (log_is_enabled(Debug, class, resolve)(LogImpl<(LogTag::_class), (LogTag::_resolve), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug))) { |
976 | trace_class_resolution(ik); |
977 | } |
978 | } else { // hidden |
979 | Handle classData_h(THREAD__the_thread__, JNIHandles::resolve(classData)); |
980 | ClassLoadInfo cl_info(protection_domain, |
981 | host_class, |
982 | classData_h, |
983 | is_hidden, |
984 | is_strong, |
985 | vm_annotations); |
986 | ik = SystemDictionary::resolve_from_stream(&st, class_name, |
987 | class_loader, |
988 | cl_info, |
989 | CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
990 | |
991 | // The hidden class loader data has been artificially been kept alive to |
992 | // this point. The mirror and any instances of this class have to keep |
993 | // it alive afterwards. |
994 | ik->class_loader_data()->dec_keep_alive(); |
995 | |
996 | if (is_nestmate && log_is_enabled(Debug, class, nestmates)(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag:: __NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG )>::is_level(LogLevel::Debug))) { |
997 | ModuleEntry* module = ik->module(); |
998 | const char * module_name = module->is_named() ? module->name()->as_C_string() : UNNAMED_MODULE"unnamed module"; |
999 | log_debug(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Debug))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Debug>("Dynamic nestmate: %s/%s, nest_host %s, %s", |
1000 | module_name, |
1001 | ik->external_name(), |
1002 | host_class->external_name(), |
1003 | ik->is_hidden() ? "is hidden" : "is not hidden"); |
1004 | } |
1005 | } |
1006 | assert(Reflection::is_same_class_package(lookup_k, ik),do { if (!(Reflection::is_same_class_package(lookup_k, ik))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1007, "assert(" "Reflection::is_same_class_package(lookup_k, ik)" ") failed", "lookup class and defined class are in different packages" ); ::breakpoint(); } } while (0) |
1007 | "lookup class and defined class are in different packages")do { if (!(Reflection::is_same_class_package(lookup_k, ik))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1007, "assert(" "Reflection::is_same_class_package(lookup_k, ik)" ") failed", "lookup class and defined class are in different packages" ); ::breakpoint(); } } while (0); |
1008 | |
1009 | if (init) { |
1010 | ik->initialize(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1011 | } else { |
1012 | ik->link_class(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1013 | } |
1014 | |
1015 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, ik->java_mirror()); |
1016 | } |
1017 | |
1018 | JVM_ENTRY(jclass, JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd))extern "C" { jclass JVM_DefineClass(JNIEnv *env, const char * name, jobject loader, const jbyte *buf, jsize len, jobject pd ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1019 | return jvm_define_class_common(name, loader, buf, len, pd, NULL__null, THREAD__the_thread__); |
1020 | JVM_END} } |
1021 | |
1022 | /* |
1023 | * Define a class with the specified lookup class. |
1024 | * lookup: Lookup class |
1025 | * name: the name of the class |
1026 | * buf: class bytes |
1027 | * len: length of class bytes |
1028 | * pd: protection domain |
1029 | * init: initialize the class |
1030 | * flags: properties of the class |
1031 | * classData: private static pre-initialized field |
1032 | */ |
1033 | JVM_ENTRY(jclass, JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf,extern "C" { jclass JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf, jsize len, jobject pd, jboolean initialize, int flags, jobject classData) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1034 | jsize len, jobject pd, jboolean initialize, int flags, jobject classData))extern "C" { jclass JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf, jsize len, jobject pd, jboolean initialize, int flags, jobject classData) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1035 | |
1036 | if (lookup == NULL__null) { |
1037 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1037, vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null" ); return 0; }; |
1038 | } |
1039 | |
1040 | assert(buf != NULL, "buf must not be NULL")do { if (!(buf != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1040, "assert(" "buf != __null" ") failed", "buf must not be NULL" ); ::breakpoint(); } } while (0); |
1041 | |
1042 | return jvm_lookup_define_class(lookup, name, buf, len, pd, initialize, flags, classData, THREAD__the_thread__); |
1043 | JVM_END} } |
1044 | |
1045 | JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source))extern "C" { jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1046 | |
1047 | return jvm_define_class_common(name, loader, buf, len, pd, source, THREAD__the_thread__); |
1048 | JVM_END} } |
1049 | |
1050 | JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name))extern "C" { jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader , jstring name) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1051 | ResourceMark rm(THREAD__the_thread__); |
1052 | |
1053 | Handle h_name (THREAD__the_thread__, JNIHandles::resolve_non_null(name)); |
1054 | char* str = java_lang_String::as_utf8_string(h_name()); |
1055 | |
1056 | // Sanity check, don't expect null |
1057 | if (str == NULL__null) return NULL__null; |
1058 | |
1059 | // Internalize the string, converting '.' to '/' in string. |
1060 | char* p = (char*)str; |
1061 | while (*p != '\0') { |
1062 | if (*p == '.') { |
1063 | *p = '/'; |
1064 | } |
1065 | p++; |
1066 | } |
1067 | |
1068 | const int str_len = (int)(p - str); |
1069 | if (str_len > Symbol::max_length()) { |
1070 | // It's impossible to create this class; the name cannot fit |
1071 | // into the constant pool. |
1072 | return NULL__null; |
1073 | } |
1074 | TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len); |
1075 | |
1076 | // Security Note: |
1077 | // The Java level wrapper will perform the necessary security check allowing |
1078 | // us to pass the NULL as the initiating class loader. |
1079 | Handle h_loader(THREAD__the_thread__, JNIHandles::resolve(loader)); |
1080 | Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name, |
1081 | h_loader, |
1082 | Handle()); |
1083 | #if INCLUDE_CDS1 |
1084 | if (k == NULL__null) { |
1085 | // If the class is not already loaded, try to see if it's in the shared |
1086 | // archive for the current classloader (h_loader). |
1087 | k = SystemDictionaryShared::find_or_load_shared_class(klass_name, h_loader, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1088 | } |
1089 | #endif |
1090 | return (k == NULL__null) ? NULL__null : |
1091 | (jclass) JNIHandles::make_local(THREAD__the_thread__, k->java_mirror()); |
1092 | JVM_END} } |
1093 | |
1094 | // Module support ////////////////////////////////////////////////////////////////////////////// |
1095 | |
1096 | JVM_ENTRY(void, JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,extern "C" { void JVM_DefineModule(JNIEnv *env, jobject module , jboolean is_open, jstring version, jstring location, jobjectArray packages) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1097 | jstring location, jobjectArray packages))extern "C" { void JVM_DefineModule(JNIEnv *env, jobject module , jboolean is_open, jstring version, jstring location, jobjectArray packages) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1098 | Handle h_module (THREAD__the_thread__, JNIHandles::resolve(module)); |
1099 | Modules::define_module(h_module, is_open, version, location, packages, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1100 | JVM_END} } |
1101 | |
1102 | JVM_ENTRY(void, JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module))extern "C" { void JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1103 | Handle h_module (THREAD__the_thread__, JNIHandles::resolve(module)); |
1104 | Modules::set_bootloader_unnamed_module(h_module, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1105 | JVM_END} } |
1106 | |
1107 | JVM_ENTRY(void, JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module))extern "C" { void JVM_AddModuleExports(JNIEnv *env, jobject from_module , jstring package, jobject to_module) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1108 | Handle h_from_module (THREAD__the_thread__, JNIHandles::resolve(from_module)); |
1109 | Handle h_to_module (THREAD__the_thread__, JNIHandles::resolve(to_module)); |
1110 | Modules::add_module_exports_qualified(h_from_module, package, h_to_module, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1111 | JVM_END} } |
1112 | |
1113 | JVM_ENTRY(void, JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, jstring package))extern "C" { void JVM_AddModuleExportsToAllUnnamed(JNIEnv *env , jobject from_module, jstring package) { JavaThread* thread= JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1114 | Handle h_from_module (THREAD__the_thread__, JNIHandles::resolve(from_module)); |
1115 | Modules::add_module_exports_to_all_unnamed(h_from_module, package, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1116 | JVM_END} } |
1117 | |
1118 | JVM_ENTRY(void, JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package))extern "C" { void JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1119 | Handle h_from_module (THREAD__the_thread__, JNIHandles::resolve(from_module)); |
1120 | Modules::add_module_exports(h_from_module, package, Handle(), CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1121 | JVM_END} } |
1122 | |
1123 | JVM_ENTRY (void, JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module))extern "C" { void JVM_AddReadsModule(JNIEnv *env, jobject from_module , jobject source_module) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1124 | Handle h_from_module (THREAD__the_thread__, JNIHandles::resolve(from_module)); |
1125 | Handle h_source_module (THREAD__the_thread__, JNIHandles::resolve(source_module)); |
1126 | Modules::add_reads_module(h_from_module, h_source_module, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1127 | JVM_END} } |
1128 | |
1129 | JVM_ENTRY(void, JVM_DefineArchivedModules(JNIEnv *env, jobject platform_loader, jobject system_loader))extern "C" { void JVM_DefineArchivedModules(JNIEnv *env, jobject platform_loader, jobject system_loader) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1130 | Handle h_platform_loader (THREAD__the_thread__, JNIHandles::resolve(platform_loader)); |
1131 | Handle h_system_loader (THREAD__the_thread__, JNIHandles::resolve(system_loader)); |
1132 | Modules::define_archived_modules(h_platform_loader, h_system_loader, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
1133 | JVM_END} } |
1134 | |
1135 | // Reflection support ////////////////////////////////////////////////////////////////////////////// |
1136 | |
1137 | JVM_ENTRY(jstring, JVM_InitClassName(JNIEnv *env, jclass cls))extern "C" { jstring JVM_InitClassName(JNIEnv *env, jclass cls ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1138 | assert (cls != NULL, "illegal class")do { if (!(cls != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1138, "assert(" "cls != __null" ") failed", "illegal class" ); ::breakpoint(); } } while (0); |
1139 | JvmtiVMObjectAllocEventCollector oam; |
1140 | ResourceMark rm(THREAD__the_thread__); |
1141 | HandleMark hm(THREAD__the_thread__); |
1142 | Handle java_class(THREAD__the_thread__, JNIHandles::resolve(cls)); |
1143 | oop result = java_lang_Class::name(java_class, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1144 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, result); |
1145 | JVM_END} } |
1146 | |
1147 | |
1148 | JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls))extern "C" { jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1149 | JvmtiVMObjectAllocEventCollector oam; |
1150 | oop mirror = JNIHandles::resolve_non_null(cls); |
1151 | |
1152 | // Special handling for primitive objects |
1153 | if (java_lang_Class::is_primitive(mirror)) { |
1154 | // Primitive objects does not have any interfaces |
1155 | objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1156 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, r); |
1157 | } |
1158 | |
1159 | Klass* klass = java_lang_Class::as_Klass(mirror); |
1160 | // Figure size of result array |
1161 | int size; |
1162 | if (klass->is_instance_klass()) { |
1163 | size = InstanceKlass::cast(klass)->local_interfaces()->length(); |
1164 | } else { |
1165 | assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass")do { if (!(klass->is_objArray_klass() || klass->is_typeArray_klass ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1165, "assert(" "klass->is_objArray_klass() || klass->is_typeArray_klass()" ") failed", "Illegal mirror klass"); ::breakpoint(); } } while (0); |
1166 | size = 2; |
1167 | } |
1168 | |
1169 | // Allocate result array |
1170 | objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), size, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1171 | objArrayHandle result (THREAD__the_thread__, r); |
1172 | // Fill in result |
1173 | if (klass->is_instance_klass()) { |
1174 | // Regular instance klass, fill in all local interfaces |
1175 | for (int index = 0; index < size; index++) { |
1176 | Klass* k = InstanceKlass::cast(klass)->local_interfaces()->at(index); |
1177 | result->obj_at_put(index, k->java_mirror()); |
1178 | } |
1179 | } else { |
1180 | // All arrays implement java.lang.Cloneable and java.io.Serializable |
1181 | result->obj_at_put(0, vmClasses::Cloneable_klass()->java_mirror()); |
1182 | result->obj_at_put(1, vmClasses::Serializable_klass()->java_mirror()); |
1183 | } |
1184 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result()); |
1185 | JVM_END} } |
1186 | |
1187 | |
1188 | JVM_ENTRY(jboolean, JVM_IsInterface(JNIEnv *env, jclass cls))extern "C" { jboolean JVM_IsInterface(JNIEnv *env, jclass cls ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1189 | oop mirror = JNIHandles::resolve_non_null(cls); |
1190 | if (java_lang_Class::is_primitive(mirror)) { |
1191 | return JNI_FALSE0; |
1192 | } |
1193 | Klass* k = java_lang_Class::as_Klass(mirror); |
1194 | jboolean result = k->is_interface(); |
1195 | assert(!result || k->is_instance_klass(),do { if (!(!result || k->is_instance_klass())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1196, "assert(" "!result || k->is_instance_klass()" ") failed" , "all interfaces are instance types"); ::breakpoint(); } } while (0) |
1196 | "all interfaces are instance types")do { if (!(!result || k->is_instance_klass())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1196, "assert(" "!result || k->is_instance_klass()" ") failed" , "all interfaces are instance types"); ::breakpoint(); } } while (0); |
1197 | // The compiler intrinsic for isInterface tests the |
1198 | // Klass::_access_flags bits in the same way. |
1199 | return result; |
1200 | JVM_END} } |
1201 | |
1202 | JVM_ENTRY(jboolean, JVM_IsHiddenClass(JNIEnv *env, jclass cls))extern "C" { jboolean JVM_IsHiddenClass(JNIEnv *env, jclass cls ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1203 | oop mirror = JNIHandles::resolve_non_null(cls); |
1204 | if (java_lang_Class::is_primitive(mirror)) { |
1205 | return JNI_FALSE0; |
1206 | } |
1207 | Klass* k = java_lang_Class::as_Klass(mirror); |
1208 | return k->is_hidden(); |
1209 | JVM_END} } |
1210 | |
1211 | JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls))extern "C" { jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1212 | JvmtiVMObjectAllocEventCollector oam; |
1213 | oop mirror = JNIHandles::resolve_non_null(cls); |
1214 | if (java_lang_Class::is_primitive(mirror)) { |
1215 | // There are no signers for primitive types |
1216 | return NULL__null; |
1217 | } |
1218 | |
1219 | objArrayHandle signers(THREAD__the_thread__, java_lang_Class::signers(mirror)); |
1220 | |
1221 | // If there are no signers set in the class, or if the class |
1222 | // is an array, return NULL. |
1223 | if (signers == NULL__null) return NULL__null; |
1224 | |
1225 | // copy of the signers array |
1226 | Klass* element = ObjArrayKlass::cast(signers->klass())->element_klass(); |
1227 | objArrayOop signers_copy = oopFactory::new_objArray(element, signers->length(), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1228 | for (int index = 0; index < signers->length(); index++) { |
1229 | signers_copy->obj_at_put(index, signers->obj_at(index)); |
1230 | } |
1231 | |
1232 | // return the copy |
1233 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, signers_copy); |
1234 | JVM_END} } |
1235 | |
1236 | |
1237 | JVM_ENTRY(void, JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers))extern "C" { void JVM_SetClassSigners(JNIEnv *env, jclass cls , jobjectArray signers) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1238 | oop mirror = JNIHandles::resolve_non_null(cls); |
1239 | if (!java_lang_Class::is_primitive(mirror)) { |
1240 | // This call is ignored for primitive types and arrays. |
1241 | // Signers are only set once, ClassLoader.java, and thus shouldn't |
1242 | // be called with an array. Only the bootstrap loader creates arrays. |
1243 | Klass* k = java_lang_Class::as_Klass(mirror); |
1244 | if (k->is_instance_klass()) { |
1245 | java_lang_Class::set_signers(k->java_mirror(), objArrayOop(JNIHandles::resolve(signers))); |
1246 | } |
1247 | } |
1248 | JVM_END} } |
1249 | |
1250 | |
1251 | JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls))extern "C" { jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1252 | oop mirror = JNIHandles::resolve_non_null(cls); |
1253 | if (mirror == NULL__null) { |
1254 | THROW_(vmSymbols::java_lang_NullPointerException(), NULL){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1254, vmSymbols::java_lang_NullPointerException(), __null); return __null; }; |
1255 | } |
1256 | |
1257 | if (java_lang_Class::is_primitive(mirror)) { |
1258 | // Primitive types does not have a protection domain. |
1259 | return NULL__null; |
1260 | } |
1261 | |
1262 | oop pd = java_lang_Class::protection_domain(mirror); |
1263 | return (jobject) JNIHandles::make_local(THREAD__the_thread__, pd); |
1264 | JVM_END} } |
1265 | |
1266 | |
1267 | // Returns the inherited_access_control_context field of the running thread. |
1268 | JVM_ENTRY(jobject, JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls))extern "C" { jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1269 | oop result = java_lang_Thread::inherited_access_control_context(thread->threadObj()); |
1270 | return JNIHandles::make_local(THREAD__the_thread__, result); |
1271 | JVM_END} } |
1272 | |
1273 | JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))extern "C" { jobject JVM_GetStackAccessControlContext(JNIEnv * env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1274 | if (!UsePrivilegedStack) return NULL__null; |
1275 | |
1276 | ResourceMark rm(THREAD__the_thread__); |
1277 | GrowableArray<Handle>* local_array = new GrowableArray<Handle>(12); |
1278 | JvmtiVMObjectAllocEventCollector oam; |
1279 | |
1280 | // count the protection domains on the execution stack. We collapse |
1281 | // duplicate consecutive protection domains into a single one, as |
1282 | // well as stopping when we hit a privileged frame. |
1283 | |
1284 | oop previous_protection_domain = NULL__null; |
1285 | Handle privileged_context(thread, NULL__null); |
1286 | bool is_privileged = false; |
1287 | oop protection_domain = NULL__null; |
1288 | |
1289 | // Iterate through Java frames |
1290 | vframeStream vfst(thread); |
1291 | for(; !vfst.at_end(); vfst.next()) { |
1292 | // get method of frame |
1293 | Method* method = vfst.method(); |
1294 | |
1295 | // stop at the first privileged frame |
1296 | if (method->method_holder() == vmClasses::AccessController_klass() && |
1297 | method->name() == vmSymbols::executePrivileged_name()) |
1298 | { |
1299 | // this frame is privileged |
1300 | is_privileged = true; |
1301 | |
1302 | javaVFrame *priv = vfst.asJavaVFrame(); // executePrivileged |
1303 | |
1304 | StackValueCollection* locals = priv->locals(); |
1305 | StackValue* ctx_sv = locals->at(1); // AccessControlContext context |
1306 | StackValue* clr_sv = locals->at(2); // Class<?> caller |
1307 | assert(!ctx_sv->obj_is_scalar_replaced(), "found scalar-replaced object")do { if (!(!ctx_sv->obj_is_scalar_replaced())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1307, "assert(" "!ctx_sv->obj_is_scalar_replaced()" ") failed" , "found scalar-replaced object"); ::breakpoint(); } } while ( 0); |
1308 | assert(!clr_sv->obj_is_scalar_replaced(), "found scalar-replaced object")do { if (!(!clr_sv->obj_is_scalar_replaced())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1308, "assert(" "!clr_sv->obj_is_scalar_replaced()" ") failed" , "found scalar-replaced object"); ::breakpoint(); } } while ( 0); |
1309 | privileged_context = ctx_sv->get_obj(); |
1310 | Handle caller = clr_sv->get_obj(); |
1311 | |
1312 | Klass *caller_klass = java_lang_Class::as_Klass(caller()); |
1313 | protection_domain = caller_klass->protection_domain(); |
1314 | } else { |
1315 | protection_domain = method->method_holder()->protection_domain(); |
1316 | } |
1317 | |
1318 | if ((previous_protection_domain != protection_domain) && (protection_domain != NULL__null)) { |
1319 | local_array->push(Handle(thread, protection_domain)); |
1320 | previous_protection_domain = protection_domain; |
1321 | } |
1322 | |
1323 | if (is_privileged) break; |
1324 | } |
1325 | |
1326 | |
1327 | // either all the domains on the stack were system domains, or |
1328 | // we had a privileged system domain |
1329 | if (local_array->is_empty()) { |
1330 | if (is_privileged && privileged_context.is_null()) return NULL__null; |
1331 | |
1332 | oop result = java_security_AccessControlContext::create(objArrayHandle(), is_privileged, privileged_context, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1333 | return JNIHandles::make_local(THREAD__the_thread__, result); |
1334 | } |
1335 | |
1336 | objArrayOop context = oopFactory::new_objArray(vmClasses::ProtectionDomain_klass(), |
1337 | local_array->length(), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1338 | objArrayHandle h_context(thread, context); |
1339 | for (int index = 0; index < local_array->length(); index++) { |
1340 | h_context->obj_at_put(index, local_array->at(index)()); |
1341 | } |
1342 | |
1343 | oop result = java_security_AccessControlContext::create(h_context, is_privileged, privileged_context, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1344 | |
1345 | return JNIHandles::make_local(THREAD__the_thread__, result); |
1346 | JVM_END} } |
1347 | |
1348 | |
1349 | JVM_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls))extern "C" { jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1350 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1351 | return (k != NULL__null) && k->is_array_klass() ? true : false; |
1352 | JVM_END} } |
1353 | |
1354 | |
1355 | JVM_ENTRY(jboolean, JVM_IsPrimitiveClass(JNIEnv *env, jclass cls))extern "C" { jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1356 | oop mirror = JNIHandles::resolve_non_null(cls); |
1357 | return (jboolean) java_lang_Class::is_primitive(mirror); |
1358 | JVM_END} } |
1359 | |
1360 | |
1361 | JVM_ENTRY(jint, JVM_GetClassModifiers(JNIEnv *env, jclass cls))extern "C" { jint JVM_GetClassModifiers(JNIEnv *env, jclass cls ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1362 | oop mirror = JNIHandles::resolve_non_null(cls); |
1363 | if (java_lang_Class::is_primitive(mirror)) { |
1364 | // Primitive type |
1365 | return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1366 | } |
1367 | |
1368 | Klass* k = java_lang_Class::as_Klass(mirror); |
1369 | debug_only(int computed_modifiers = k->compute_modifier_flags())int computed_modifiers = k->compute_modifier_flags(); |
1370 | assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK")do { if (!(k->modifier_flags() == computed_modifiers)) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1370, "assert(" "k->modifier_flags() == computed_modifiers" ") failed", "modifiers cache is OK"); ::breakpoint(); } } while (0); |
1371 | return k->modifier_flags(); |
1372 | JVM_END} } |
1373 | |
1374 | |
1375 | // Inner class reflection /////////////////////////////////////////////////////////////////////////////// |
1376 | |
1377 | JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass))extern "C" { jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1378 | JvmtiVMObjectAllocEventCollector oam; |
1379 | // ofClass is a reference to a java_lang_Class object. The mirror object |
1380 | // of an InstanceKlass |
1381 | oop ofMirror = JNIHandles::resolve_non_null(ofClass); |
1382 | if (java_lang_Class::is_primitive(ofMirror) || |
1383 | ! java_lang_Class::as_Klass(ofMirror)->is_instance_klass()) { |
1384 | oop result = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1385 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result); |
1386 | } |
1387 | |
1388 | InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(ofMirror)); |
1389 | InnerClassesIterator iter(k); |
1390 | |
1391 | if (iter.length() == 0) { |
1392 | // Neither an inner nor outer class |
1393 | oop result = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1394 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result); |
1395 | } |
1396 | |
1397 | // find inner class info |
1398 | constantPoolHandle cp(thread, k->constants()); |
1399 | int length = iter.length(); |
1400 | |
1401 | // Allocate temp. result array |
1402 | objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), length/4, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1403 | objArrayHandle result (THREAD__the_thread__, r); |
1404 | int members = 0; |
1405 | |
1406 | for (; !iter.done(); iter.next()) { |
1407 | int ioff = iter.inner_class_info_index(); |
1408 | int ooff = iter.outer_class_info_index(); |
1409 | |
1410 | if (ioff != 0 && ooff != 0) { |
1411 | // Check to see if the name matches the class we're looking for |
1412 | // before attempting to find the class. |
1413 | if (cp->klass_name_at_matches(k, ooff)) { |
1414 | Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1415 | if (outer_klass == k) { |
1416 | Klass* ik = cp->klass_at(ioff, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1417 | InstanceKlass* inner_klass = InstanceKlass::cast(ik); |
1418 | |
1419 | // Throws an exception if outer klass has not declared k as |
1420 | // an inner klass |
1421 | Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1422 | |
1423 | result->obj_at_put(members, inner_klass->java_mirror()); |
1424 | members++; |
1425 | } |
1426 | } |
1427 | } |
1428 | } |
1429 | |
1430 | if (members != length) { |
1431 | // Return array of right length |
1432 | objArrayOop res = oopFactory::new_objArray(vmClasses::Class_klass(), members, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1433 | for(int i = 0; i < members; i++) { |
1434 | res->obj_at_put(i, result->obj_at(i)); |
1435 | } |
1436 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, res); |
1437 | } |
1438 | |
1439 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result()); |
1440 | JVM_END} } |
1441 | |
1442 | |
1443 | JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass))extern "C" { jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1444 | { |
1445 | // ofClass is a reference to a java_lang_Class object. |
1446 | oop ofMirror = JNIHandles::resolve_non_null(ofClass); |
1447 | if (java_lang_Class::is_primitive(ofMirror)) { |
1448 | return NULL__null; |
1449 | } |
1450 | Klass* klass = java_lang_Class::as_Klass(ofMirror); |
1451 | if (!klass->is_instance_klass()) { |
1452 | return NULL__null; |
1453 | } |
1454 | |
1455 | bool inner_is_member = false; |
1456 | Klass* outer_klass |
1457 | = InstanceKlass::cast(klass)->compute_enclosing_class(&inner_is_member, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1458 | if (outer_klass == NULL__null) return NULL__null; // already a top-level class |
1459 | if (!inner_is_member) return NULL__null; // a hidden class (inside a method) |
1460 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, outer_klass->java_mirror()); |
1461 | } |
1462 | JVM_END} } |
1463 | |
1464 | JVM_ENTRY(jstring, JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls))extern "C" { jstring JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1465 | { |
1466 | oop mirror = JNIHandles::resolve_non_null(cls); |
1467 | if (java_lang_Class::is_primitive(mirror)) { |
1468 | return NULL__null; |
1469 | } |
1470 | Klass* klass = java_lang_Class::as_Klass(mirror); |
1471 | if (!klass->is_instance_klass()) { |
1472 | return NULL__null; |
1473 | } |
1474 | InstanceKlass* k = InstanceKlass::cast(klass); |
1475 | int ooff = 0, noff = 0; |
1476 | if (k->find_inner_classes_attr(&ooff, &noff, THREAD__the_thread__)) { |
1477 | if (noff != 0) { |
1478 | constantPoolHandle i_cp(thread, k->constants()); |
1479 | Symbol* name = i_cp->symbol_at(noff); |
1480 | Handle str = java_lang_String::create_from_symbol(name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1481 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, str()); |
1482 | } |
1483 | } |
1484 | return NULL__null; |
1485 | } |
1486 | JVM_END} } |
1487 | |
1488 | JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls))extern "C" { jstring JVM_GetClassSignature(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1489 | assert (cls != NULL, "illegal class")do { if (!(cls != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1489, "assert(" "cls != __null" ") failed", "illegal class" ); ::breakpoint(); } } while (0); |
1490 | JvmtiVMObjectAllocEventCollector oam; |
1491 | ResourceMark rm(THREAD__the_thread__); |
1492 | oop mirror = JNIHandles::resolve_non_null(cls); |
1493 | // Return null for arrays and primatives |
1494 | if (!java_lang_Class::is_primitive(mirror)) { |
1495 | Klass* k = java_lang_Class::as_Klass(mirror); |
1496 | if (k->is_instance_klass()) { |
1497 | Symbol* sym = InstanceKlass::cast(k)->generic_signature(); |
1498 | if (sym == NULL__null) return NULL__null; |
1499 | Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1500 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, str()); |
1501 | } |
1502 | } |
1503 | return NULL__null; |
1504 | JVM_END} } |
1505 | |
1506 | |
1507 | JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls))extern "C" { jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1508 | assert (cls != NULL, "illegal class")do { if (!(cls != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1508, "assert(" "cls != __null" ") failed", "illegal class" ); ::breakpoint(); } } while (0); |
1509 | oop mirror = JNIHandles::resolve_non_null(cls); |
1510 | // Return null for arrays and primitives |
1511 | if (!java_lang_Class::is_primitive(mirror)) { |
1512 | Klass* k = java_lang_Class::as_Klass(mirror); |
1513 | if (k->is_instance_klass()) { |
1514 | typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->class_annotations(), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1515 | return (jbyteArray) JNIHandles::make_local(THREAD__the_thread__, a); |
1516 | } |
1517 | } |
1518 | return NULL__null; |
1519 | JVM_END} } |
1520 | |
1521 | |
1522 | static bool jvm_get_field_common(jobject field, fieldDescriptor& fd) { |
1523 | // some of this code was adapted from from jni_FromReflectedField |
1524 | |
1525 | oop reflected = JNIHandles::resolve_non_null(field); |
1526 | oop mirror = java_lang_reflect_Field::clazz(reflected); |
1527 | Klass* k = java_lang_Class::as_Klass(mirror); |
1528 | int slot = java_lang_reflect_Field::slot(reflected); |
1529 | int modifiers = java_lang_reflect_Field::modifiers(reflected); |
1530 | |
1531 | InstanceKlass* ik = InstanceKlass::cast(k); |
1532 | intptr_t offset = ik->field_offset(slot); |
1533 | |
1534 | if (modifiers & JVM_ACC_STATIC) { |
1535 | // for static fields we only look in the current class |
1536 | if (!ik->find_local_field_from_offset(offset, true, &fd)) { |
1537 | assert(false, "cannot find static field")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1537, "assert(" "false" ") failed", "cannot find static field" ); ::breakpoint(); } } while (0); |
1538 | return false; |
1539 | } |
1540 | } else { |
1541 | // for instance fields we start with the current class and work |
1542 | // our way up through the superclass chain |
1543 | if (!ik->find_field_from_offset(offset, false, &fd)) { |
1544 | assert(false, "cannot find instance field")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1544, "assert(" "false" ") failed", "cannot find instance field" ); ::breakpoint(); } } while (0); |
1545 | return false; |
1546 | } |
1547 | } |
1548 | return true; |
1549 | } |
1550 | |
1551 | static Method* jvm_get_method_common(jobject method) { |
1552 | // some of this code was adapted from from jni_FromReflectedMethod |
1553 | |
1554 | oop reflected = JNIHandles::resolve_non_null(method); |
1555 | oop mirror = NULL__null; |
1556 | int slot = 0; |
1557 | |
1558 | if (reflected->klass() == vmClasses::reflect_Constructor_klass()) { |
1559 | mirror = java_lang_reflect_Constructor::clazz(reflected); |
1560 | slot = java_lang_reflect_Constructor::slot(reflected); |
1561 | } else { |
1562 | assert(reflected->klass() == vmClasses::reflect_Method_klass(),do { if (!(reflected->klass() == vmClasses::reflect_Method_klass ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1563, "assert(" "reflected->klass() == vmClasses::reflect_Method_klass()" ") failed", "wrong type"); ::breakpoint(); } } while (0) |
1563 | "wrong type")do { if (!(reflected->klass() == vmClasses::reflect_Method_klass ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1563, "assert(" "reflected->klass() == vmClasses::reflect_Method_klass()" ") failed", "wrong type"); ::breakpoint(); } } while (0); |
1564 | mirror = java_lang_reflect_Method::clazz(reflected); |
1565 | slot = java_lang_reflect_Method::slot(reflected); |
1566 | } |
1567 | Klass* k = java_lang_Class::as_Klass(mirror); |
1568 | |
1569 | Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); |
1570 | assert(m != NULL, "cannot find method")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1570, "assert(" "m != __null" ") failed", "cannot find method" ); ::breakpoint(); } } while (0); |
1571 | return m; // caller has to deal with NULL in product mode |
1572 | } |
1573 | |
1574 | /* Type use annotations support (JDK 1.8) */ |
1575 | |
1576 | JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls))extern "C" { jbyteArray JVM_GetClassTypeAnnotations(JNIEnv *env , jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1577 | assert (cls != NULL, "illegal class")do { if (!(cls != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1577, "assert(" "cls != __null" ") failed", "illegal class" ); ::breakpoint(); } } while (0); |
1578 | ResourceMark rm(THREAD__the_thread__); |
1579 | // Return null for arrays and primitives |
1580 | if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1581 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
1582 | if (k->is_instance_klass()) { |
1583 | AnnotationArray* type_annotations = InstanceKlass::cast(k)->class_type_annotations(); |
1584 | if (type_annotations != NULL__null) { |
1585 | typeArrayOop a = Annotations::make_java_array(type_annotations, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1586 | return (jbyteArray) JNIHandles::make_local(THREAD__the_thread__, a); |
1587 | } |
1588 | } |
1589 | } |
1590 | return NULL__null; |
1591 | JVM_END} } |
1592 | |
1593 | JVM_ENTRY(jbyteArray, JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method))extern "C" { jbyteArray JVM_GetMethodTypeAnnotations(JNIEnv * env, jobject method) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1594 | assert (method != NULL, "illegal method")do { if (!(method != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1594, "assert(" "method != __null" ") failed", "illegal method" ); ::breakpoint(); } } while (0); |
1595 | // method is a handle to a java.lang.reflect.Method object |
1596 | Method* m = jvm_get_method_common(method); |
1597 | if (m == NULL__null) { |
1598 | return NULL__null; |
1599 | } |
1600 | |
1601 | AnnotationArray* type_annotations = m->type_annotations(); |
1602 | if (type_annotations != NULL__null) { |
1603 | typeArrayOop a = Annotations::make_java_array(type_annotations, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1604 | return (jbyteArray) JNIHandles::make_local(THREAD__the_thread__, a); |
1605 | } |
1606 | |
1607 | return NULL__null; |
1608 | JVM_END} } |
1609 | |
1610 | JVM_ENTRY(jbyteArray, JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field))extern "C" { jbyteArray JVM_GetFieldTypeAnnotations(JNIEnv *env , jobject field) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1611 | assert (field != NULL, "illegal field")do { if (!(field != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1611, "assert(" "field != __null" ") failed", "illegal field" ); ::breakpoint(); } } while (0); |
1612 | fieldDescriptor fd; |
1613 | bool gotFd = jvm_get_field_common(field, fd); |
1614 | if (!gotFd) { |
1615 | return NULL__null; |
1616 | } |
1617 | |
1618 | return (jbyteArray) JNIHandles::make_local(THREAD__the_thread__, Annotations::make_java_array(fd.type_annotations(), THREAD__the_thread__)); |
1619 | JVM_END} } |
1620 | |
1621 | static void bounds_check(const constantPoolHandle& cp, jint index, TRAPSJavaThread* __the_thread__) { |
1622 | if (!cp->is_within_bounds(index)) { |
1623 | THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1623, vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds" ); return; }; |
1624 | } |
1625 | } |
1626 | |
1627 | JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))extern "C" { jobjectArray JVM_GetMethodParameters(JNIEnv *env , jobject method) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1628 | { |
1629 | // method is a handle to a java.lang.reflect.Method object |
1630 | Method* method_ptr = jvm_get_method_common(method); |
1631 | methodHandle mh (THREAD__the_thread__, method_ptr); |
1632 | Handle reflected_method (THREAD__the_thread__, JNIHandles::resolve_non_null(method)); |
1633 | const int num_params = mh->method_parameters_length(); |
1634 | |
1635 | if (num_params < 0) { |
1636 | // A -1 return value from method_parameters_length means there is no |
1637 | // parameter data. Return null to indicate this to the reflection |
1638 | // API. |
1639 | assert(num_params == -1, "num_params should be -1 if it is less than zero")do { if (!(num_params == -1)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1639, "assert(" "num_params == -1" ") failed", "num_params should be -1 if it is less than zero" ); ::breakpoint(); } } while (0); |
1640 | return (jobjectArray)NULL__null; |
1641 | } else { |
1642 | // Otherwise, we return something up to reflection, even if it is |
1643 | // a zero-length array. Why? Because in some cases this can |
1644 | // trigger a MalformedParametersException. |
1645 | |
1646 | // make sure all the symbols are properly formatted |
1647 | for (int i = 0; i < num_params; i++) { |
1648 | MethodParametersElement* params = mh->method_parameters_start(); |
1649 | int index = params[i].name_cp_index; |
1650 | constantPoolHandle cp(THREAD__the_thread__, mh->constants()); |
1651 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1652 | |
1653 | if (0 != index && !mh->constants()->tag_at(index).is_utf8()) { |
1654 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),{ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1655, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; } |
1655 | "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1655, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
1656 | } |
1657 | |
1658 | } |
1659 | |
1660 | objArrayOop result_oop = oopFactory::new_objArray(vmClasses::reflect_Parameter_klass(), num_params, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1661 | objArrayHandle result (THREAD__the_thread__, result_oop); |
1662 | |
1663 | for (int i = 0; i < num_params; i++) { |
1664 | MethodParametersElement* params = mh->method_parameters_start(); |
1665 | // For a 0 index, give a NULL symbol |
1666 | Symbol* sym = 0 != params[i].name_cp_index ? |
1667 | mh->constants()->symbol_at(params[i].name_cp_index) : NULL__null; |
1668 | int flags = params[i].flags; |
1669 | oop param = Reflection::new_parameter(reflected_method, i, sym, |
1670 | flags, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1671 | result->obj_at_put(i, param); |
1672 | } |
1673 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result()); |
1674 | } |
1675 | } |
1676 | JVM_END} } |
1677 | |
1678 | // New (JDK 1.4) reflection implementation ///////////////////////////////////// |
1679 | |
1680 | JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly))extern "C" { jobjectArray JVM_GetClassDeclaredFields(JNIEnv * env, jclass ofClass, jboolean publicOnly) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1681 | { |
1682 | JvmtiVMObjectAllocEventCollector oam; |
1683 | |
1684 | oop ofMirror = JNIHandles::resolve_non_null(ofClass); |
1685 | // Exclude primitive types and array types |
1686 | if (java_lang_Class::is_primitive(ofMirror) || |
1687 | java_lang_Class::as_Klass(ofMirror)->is_array_klass()) { |
1688 | // Return empty array |
1689 | oop res = oopFactory::new_objArray(vmClasses::reflect_Field_klass(), 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1690 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, res); |
1691 | } |
1692 | |
1693 | InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(ofMirror)); |
1694 | constantPoolHandle cp(THREAD__the_thread__, k->constants()); |
1695 | |
1696 | // Ensure class is linked |
1697 | k->link_class(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1698 | |
1699 | // Allocate result |
1700 | int num_fields; |
1701 | |
1702 | if (publicOnly) { |
1703 | num_fields = 0; |
1704 | for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
1705 | if (fs.access_flags().is_public()) ++num_fields; |
1706 | } |
1707 | } else { |
1708 | num_fields = k->java_fields_count(); |
1709 | } |
1710 | |
1711 | objArrayOop r = oopFactory::new_objArray(vmClasses::reflect_Field_klass(), num_fields, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1712 | objArrayHandle result (THREAD__the_thread__, r); |
1713 | |
1714 | int out_idx = 0; |
1715 | fieldDescriptor fd; |
1716 | for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
1717 | if (!publicOnly || fs.access_flags().is_public()) { |
1718 | fd.reinitialize(k, fs.index()); |
1719 | oop field = Reflection::new_field(&fd, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1720 | result->obj_at_put(out_idx, field); |
1721 | ++out_idx; |
1722 | } |
1723 | } |
1724 | assert(out_idx == num_fields, "just checking")do { if (!(out_idx == num_fields)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1724, "assert(" "out_idx == num_fields" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
1725 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result()); |
1726 | } |
1727 | JVM_END} } |
1728 | |
1729 | // A class is a record if and only if it is final and a direct subclass of |
1730 | // java.lang.Record and has a Record attribute; otherwise, it is not a record. |
1731 | JVM_ENTRY(jboolean, JVM_IsRecord(JNIEnv *env, jclass cls))extern "C" { jboolean JVM_IsRecord(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1732 | { |
1733 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1734 | if (k != NULL__null && k->is_instance_klass()) { |
1735 | InstanceKlass* ik = InstanceKlass::cast(k); |
1736 | return ik->is_record(); |
1737 | } else { |
1738 | return false; |
1739 | } |
1740 | } |
1741 | JVM_END} } |
1742 | |
1743 | // Returns an array containing the components of the Record attribute, |
1744 | // or NULL if the attribute is not present. |
1745 | // |
1746 | // Note that this function returns the components of the Record attribute |
1747 | // even if the class is not a record. |
1748 | JVM_ENTRY(jobjectArray, JVM_GetRecordComponents(JNIEnv* env, jclass ofClass))extern "C" { jobjectArray JVM_GetRecordComponents(JNIEnv* env , jclass ofClass) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1749 | { |
1750 | Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)); |
1751 | assert(c->is_instance_klass(), "must be")do { if (!(c->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1751, "assert(" "c->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1752 | InstanceKlass* ik = InstanceKlass::cast(c); |
1753 | |
1754 | Array<RecordComponent*>* components = ik->record_components(); |
1755 | if (components != NULL__null) { |
1756 | JvmtiVMObjectAllocEventCollector oam; |
1757 | constantPoolHandle cp(THREAD__the_thread__, ik->constants()); |
1758 | int length = components->length(); |
1759 | assert(length >= 0, "unexpected record_components length")do { if (!(length >= 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1759, "assert(" "length >= 0" ") failed", "unexpected record_components length" ); ::breakpoint(); } } while (0); |
1760 | objArrayOop record_components = |
1761 | oopFactory::new_objArray(vmClasses::RecordComponent_klass(), length, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1762 | objArrayHandle components_h (THREAD__the_thread__, record_components); |
1763 | |
1764 | for (int x = 0; x < length; x++) { |
1765 | RecordComponent* component = components->at(x); |
1766 | assert(component != NULL, "unexpected NULL record component")do { if (!(component != __null)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1766, "assert(" "component != __null" ") failed", "unexpected NULL record component" ); ::breakpoint(); } } while (0); |
1767 | oop component_oop = java_lang_reflect_RecordComponent::create(ik, component, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1768 | components_h->obj_at_put(x, component_oop); |
1769 | } |
1770 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, components_h()); |
1771 | } |
1772 | |
1773 | return NULL__null; |
1774 | } |
1775 | JVM_END} } |
1776 | |
1777 | static bool select_method(const methodHandle& method, bool want_constructor) { |
1778 | if (want_constructor) { |
1779 | return (method->is_initializer() && !method->is_static()); |
1780 | } else { |
1781 | return (!method->is_initializer() && !method->is_overpass()); |
1782 | } |
1783 | } |
1784 | |
1785 | static jobjectArray get_class_declared_methods_helper( |
1786 | JNIEnv *env, |
1787 | jclass ofClass, jboolean publicOnly, |
1788 | bool want_constructor, |
1789 | Klass* klass, TRAPSJavaThread* __the_thread__) { |
1790 | |
1791 | JvmtiVMObjectAllocEventCollector oam; |
1792 | |
1793 | oop ofMirror = JNIHandles::resolve_non_null(ofClass); |
1794 | // Exclude primitive types and array types |
1795 | if (java_lang_Class::is_primitive(ofMirror) |
1796 | || java_lang_Class::as_Klass(ofMirror)->is_array_klass()) { |
1797 | // Return empty array |
1798 | oop res = oopFactory::new_objArray(klass, 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1799 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, res); |
1800 | } |
1801 | |
1802 | InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(ofMirror)); |
1803 | |
1804 | // Ensure class is linked |
1805 | k->link_class(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1806 | |
1807 | Array<Method*>* methods = k->methods(); |
1808 | int methods_length = methods->length(); |
1809 | |
1810 | // Save original method_idnum in case of redefinition, which can change |
1811 | // the idnum of obsolete methods. The new method will have the same idnum |
1812 | // but if we refresh the methods array, the counts will be wrong. |
1813 | ResourceMark rm(THREAD__the_thread__); |
1814 | GrowableArray<int>* idnums = new GrowableArray<int>(methods_length); |
1815 | int num_methods = 0; |
1816 | |
1817 | for (int i = 0; i < methods_length; i++) { |
1818 | methodHandle method(THREAD__the_thread__, methods->at(i)); |
1819 | if (select_method(method, want_constructor)) { |
1820 | if (!publicOnly || method->is_public()) { |
1821 | idnums->push(method->method_idnum()); |
1822 | ++num_methods; |
1823 | } |
1824 | } |
1825 | } |
1826 | |
1827 | // Allocate result |
1828 | objArrayOop r = oopFactory::new_objArray(klass, num_methods, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1829 | objArrayHandle result (THREAD__the_thread__, r); |
1830 | |
1831 | // Now just put the methods that we selected above, but go by their idnum |
1832 | // in case of redefinition. The methods can be redefined at any safepoint, |
1833 | // so above when allocating the oop array and below when creating reflect |
1834 | // objects. |
1835 | for (int i = 0; i < num_methods; i++) { |
1836 | methodHandle method(THREAD__the_thread__, k->method_with_idnum(idnums->at(i))); |
1837 | if (method.is_null()) { |
1838 | // Method may have been deleted and seems this API can handle null |
1839 | // Otherwise should probably put a method that throws NSME |
1840 | result->obj_at_put(i, NULL__null); |
1841 | } else { |
1842 | oop m; |
1843 | if (want_constructor) { |
1844 | m = Reflection::new_constructor(method, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1845 | } else { |
1846 | m = Reflection::new_method(method, false, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1847 | } |
1848 | result->obj_at_put(i, m); |
1849 | } |
1850 | } |
1851 | |
1852 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result()); |
1853 | } |
1854 | |
1855 | JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly))extern "C" { jobjectArray JVM_GetClassDeclaredMethods(JNIEnv * env, jclass ofClass, jboolean publicOnly) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1856 | { |
1857 | return get_class_declared_methods_helper(env, ofClass, publicOnly, |
1858 | /*want_constructor*/ false, |
1859 | vmClasses::reflect_Method_klass(), THREAD__the_thread__); |
1860 | } |
1861 | JVM_END} } |
1862 | |
1863 | JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly))extern "C" { jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
1864 | { |
1865 | return get_class_declared_methods_helper(env, ofClass, publicOnly, |
1866 | /*want_constructor*/ true, |
1867 | vmClasses::reflect_Constructor_klass(), THREAD__the_thread__); |
1868 | } |
1869 | JVM_END} } |
1870 | |
1871 | JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls))extern "C" { jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1872 | { |
1873 | oop mirror = JNIHandles::resolve_non_null(cls); |
1874 | if (java_lang_Class::is_primitive(mirror)) { |
1875 | // Primitive type |
1876 | return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1877 | } |
1878 | |
1879 | Klass* k = java_lang_Class::as_Klass(mirror); |
1880 | return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1881 | } |
1882 | JVM_END} } |
1883 | |
1884 | JVM_ENTRY(jboolean, JVM_AreNestMates(JNIEnv *env, jclass current, jclass member))extern "C" { jboolean JVM_AreNestMates(JNIEnv *env, jclass current , jclass member) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1885 | { |
1886 | Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
1887 | assert(c->is_instance_klass(), "must be")do { if (!(c->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1887, "assert(" "c->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1888 | InstanceKlass* ck = InstanceKlass::cast(c); |
1889 | Klass* m = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(member)); |
1890 | assert(m->is_instance_klass(), "must be")do { if (!(m->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1890, "assert(" "m->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1891 | InstanceKlass* mk = InstanceKlass::cast(m); |
1892 | return ck->has_nestmate_access_to(mk, THREAD__the_thread__); |
1893 | } |
1894 | JVM_END} } |
1895 | |
1896 | JVM_ENTRY(jclass, JVM_GetNestHost(JNIEnv* env, jclass current))extern "C" { jclass JVM_GetNestHost(JNIEnv* env, jclass current ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1897 | { |
1898 | // current is not a primitive or array class |
1899 | Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
1900 | assert(c->is_instance_klass(), "must be")do { if (!(c->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1900, "assert(" "c->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1901 | InstanceKlass* ck = InstanceKlass::cast(c); |
1902 | InstanceKlass* host = ck->nest_host(THREAD__the_thread__); |
1903 | return (jclass) (host == NULL__null ? NULL__null : |
1904 | JNIHandles::make_local(THREAD__the_thread__, host->java_mirror())); |
1905 | } |
1906 | JVM_END} } |
1907 | |
1908 | JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current))extern "C" { jobjectArray JVM_GetNestMembers(JNIEnv* env, jclass current) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1909 | { |
1910 | // current is not a primitive or array class |
1911 | ResourceMark rm(THREAD__the_thread__); |
1912 | Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); |
1913 | assert(c->is_instance_klass(), "must be")do { if (!(c->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1913, "assert(" "c->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1914 | InstanceKlass* ck = InstanceKlass::cast(c); |
1915 | InstanceKlass* host = ck->nest_host(THREAD__the_thread__); |
1916 | |
1917 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>("Calling GetNestMembers for type %s with nest-host %s", |
1918 | ck->external_name(), host->external_name()); |
1919 | { |
1920 | JvmtiVMObjectAllocEventCollector oam; |
1921 | Array<u2>* members = host->nest_members(); |
1922 | int length = members == NULL__null ? 0 : members->length(); |
1923 | |
1924 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>(" - host has %d listed nest members", length); |
1925 | |
1926 | // nest host is first in the array so make it one bigger |
1927 | objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), |
1928 | length + 1, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1929 | objArrayHandle result(THREAD__the_thread__, r); |
1930 | result->obj_at_put(0, host->java_mirror()); |
1931 | if (length != 0) { |
1932 | int count = 0; |
1933 | for (int i = 0; i < length; i++) { |
1934 | int cp_index = members->at(i); |
1935 | Klass* k = host->constants()->klass_at(cp_index, THREAD__the_thread__); |
1936 | if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) { |
1937 | if (PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->pending_exception())->is_a(vmClasses::VirtualMachineError_klass())) { |
1938 | return NULL__null; // propagate VMEs |
1939 | } |
1940 | if (log_is_enabled(Trace, class, nestmates)(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag:: __NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG )>::is_level(LogLevel::Trace))) { |
1941 | stringStream ss; |
1942 | char* target_member_class = host->constants()->klass_name_at(cp_index)->as_C_string(); |
1943 | ss.print(" - resolution of nest member %s failed: ", target_member_class); |
1944 | java_lang_Throwable::print(PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->pending_exception()), &ss); |
1945 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>("%s", ss.as_string()); |
1946 | } |
1947 | CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception( )); |
1948 | continue; |
1949 | } |
1950 | if (k->is_instance_klass()) { |
1951 | InstanceKlass* ik = InstanceKlass::cast(k); |
1952 | InstanceKlass* nest_host_k = ik->nest_host(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1953 | if (nest_host_k == host) { |
1954 | result->obj_at_put(count+1, k->java_mirror()); |
1955 | count++; |
1956 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>(" - [%d] = %s", count, ik->external_name()); |
1957 | } else { |
1958 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>(" - skipping member %s with different host %s", |
1959 | ik->external_name(), nest_host_k->external_name()); |
1960 | } |
1961 | } else { |
1962 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>(" - skipping member %s that is not an instance class", |
1963 | k->external_name()); |
1964 | } |
1965 | } |
1966 | if (count < length) { |
1967 | // we had invalid entries so we need to compact the array |
1968 | log_trace(class, nestmates)(!(LogImpl<(LogTag::_class), (LogTag::_nestmates), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl <(LogTag::_class), (LogTag::_nestmates), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Trace>(" - compacting array from length %d to %d", |
1969 | length + 1, count + 1); |
1970 | |
1971 | objArrayOop r2 = oopFactory::new_objArray(vmClasses::Class_klass(), |
1972 | count + 1, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
1973 | objArrayHandle result2(THREAD__the_thread__, r2); |
1974 | for (int i = 0; i < count + 1; i++) { |
1975 | result2->obj_at_put(i, result->obj_at(i)); |
1976 | } |
1977 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result2()); |
1978 | } |
1979 | } |
1980 | else { |
1981 | assert(host == ck || ck->is_hidden(), "must be singleton nest or dynamic nestmate")do { if (!(host == ck || ck->is_hidden())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1981, "assert(" "host == ck || ck->is_hidden()" ") failed" , "must be singleton nest or dynamic nestmate"); ::breakpoint (); } } while (0); |
1982 | } |
1983 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result()); |
1984 | } |
1985 | } |
1986 | JVM_END} } |
1987 | |
1988 | JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current))extern "C" { jobjectArray JVM_GetPermittedSubclasses(JNIEnv* env , jclass current) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
1989 | { |
1990 | oop mirror = JNIHandles::resolve_non_null(current); |
1991 | assert(!java_lang_Class::is_primitive(mirror), "should not be")do { if (!(!java_lang_Class::is_primitive(mirror))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1991, "assert(" "!java_lang_Class::is_primitive(mirror)" ") failed" , "should not be"); ::breakpoint(); } } while (0); |
1992 | Klass* c = java_lang_Class::as_Klass(mirror); |
1993 | assert(c->is_instance_klass(), "must be")do { if (!(c->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 1993, "assert(" "c->is_instance_klass()" ") failed", "must be" ); ::breakpoint(); } } while (0); |
1994 | InstanceKlass* ik = InstanceKlass::cast(c); |
1995 | ResourceMark rm(THREAD__the_thread__); |
1996 | log_trace(class, sealed)(!(LogImpl<(LogTag::_class), (LogTag::_sealed), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_sealed), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Trace>("Calling GetPermittedSubclasses for %s type %s", |
1997 | ik->is_sealed() ? "sealed" : "non-sealed", ik->external_name()); |
1998 | if (ik->is_sealed()) { |
1999 | JvmtiVMObjectAllocEventCollector oam; |
2000 | Array<u2>* subclasses = ik->permitted_subclasses(); |
2001 | int length = subclasses->length(); |
2002 | |
2003 | log_trace(class, sealed)(!(LogImpl<(LogTag::_class), (LogTag::_sealed), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_sealed), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Trace>(" - sealed class has %d permitted subclasses", length); |
2004 | |
2005 | objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), |
2006 | length, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2007 | objArrayHandle result(THREAD__the_thread__, r); |
2008 | int count = 0; |
2009 | for (int i = 0; i < length; i++) { |
2010 | int cp_index = subclasses->at(i); |
2011 | Klass* k = ik->constants()->klass_at(cp_index, THREAD__the_thread__); |
2012 | if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) { |
2013 | if (PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->pending_exception())->is_a(vmClasses::VirtualMachineError_klass())) { |
2014 | return NULL__null; // propagate VMEs |
2015 | } |
2016 | if (log_is_enabled(Trace, class, sealed)(LogImpl<(LogTag::_class), (LogTag::_sealed), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Trace))) { |
2017 | stringStream ss; |
2018 | char* permitted_subclass = ik->constants()->klass_name_at(cp_index)->as_C_string(); |
2019 | ss.print(" - resolution of permitted subclass %s failed: ", permitted_subclass); |
2020 | java_lang_Throwable::print(PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->pending_exception()), &ss); |
2021 | log_trace(class, sealed)(!(LogImpl<(LogTag::_class), (LogTag::_sealed), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_sealed), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Trace>("%s", ss.as_string()); |
2022 | } |
2023 | |
2024 | CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception( )); |
2025 | continue; |
2026 | } |
2027 | if (k->is_instance_klass()) { |
2028 | result->obj_at_put(count++, k->java_mirror()); |
2029 | log_trace(class, sealed)(!(LogImpl<(LogTag::_class), (LogTag::_sealed), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag ::_class), (LogTag::_sealed), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Trace>(" - [%d] = %s", count, k->external_name()); |
2030 | } |
2031 | } |
2032 | if (count < length) { |
2033 | // we had invalid entries so we need to compact the array |
2034 | objArrayOop r2 = oopFactory::new_objArray(vmClasses::Class_klass(), |
2035 | count, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2036 | objArrayHandle result2(THREAD__the_thread__, r2); |
2037 | for (int i = 0; i < count; i++) { |
2038 | result2->obj_at_put(i, result->obj_at(i)); |
2039 | } |
2040 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result2()); |
2041 | } |
2042 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, result()); |
2043 | } else { |
2044 | return NULL__null; |
2045 | } |
2046 | } |
2047 | JVM_END} } |
2048 | |
2049 | // Constant pool access ////////////////////////////////////////////////////////// |
2050 | |
2051 | JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls))extern "C" { jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2052 | { |
2053 | JvmtiVMObjectAllocEventCollector oam; |
2054 | oop mirror = JNIHandles::resolve_non_null(cls); |
2055 | // Return null for primitives and arrays |
2056 | if (!java_lang_Class::is_primitive(mirror)) { |
2057 | Klass* k = java_lang_Class::as_Klass(mirror); |
2058 | if (k->is_instance_klass()) { |
2059 | InstanceKlass* k_h = InstanceKlass::cast(k); |
2060 | Handle jcp = reflect_ConstantPool::create(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2061 | reflect_ConstantPool::set_cp(jcp(), k_h->constants()); |
2062 | return JNIHandles::make_local(THREAD__the_thread__, jcp()); |
2063 | } |
2064 | } |
2065 | return NULL__null; |
2066 | } |
2067 | JVM_END} } |
2068 | |
2069 | |
2070 | JVM_ENTRY(jint, JVM_ConstantPoolGetSize(JNIEnv *env, jobject obj, jobject unused))extern "C" { jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject obj, jobject unused) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2071 | { |
2072 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2073 | return cp->length(); |
2074 | } |
2075 | JVM_END} } |
2076 | |
2077 | |
2078 | JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2079 | { |
2080 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2081 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2082 | constantTag tag = cp->tag_at(index); |
2083 | if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
2084 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2084, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2085 | } |
2086 | Klass* k = cp->klass_at(index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2087 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, k->java_mirror()); |
2088 | } |
2089 | JVM_END} } |
2090 | |
2091 | JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2092 | { |
2093 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2094 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2095 | constantTag tag = cp->tag_at(index); |
2096 | if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
2097 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2097, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2098 | } |
2099 | Klass* k = ConstantPool::klass_at_if_loaded(cp, index); |
2100 | if (k == NULL__null) return NULL__null; |
2101 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, k->java_mirror()); |
2102 | } |
2103 | JVM_END} } |
2104 | |
2105 | static jobject get_method_at_helper(const constantPoolHandle& cp, jint index, bool force_resolution, TRAPSJavaThread* __the_thread__) { |
2106 | constantTag tag = cp->tag_at(index); |
2107 | if (!tag.is_method() && !tag.is_interface_method()) { |
2108 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2108, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2109 | } |
2110 | int klass_ref = cp->uncached_klass_ref_index_at(index); |
2111 | Klass* k_o; |
2112 | if (force_resolution) { |
2113 | k_o = cp->klass_at(klass_ref, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2114 | } else { |
2115 | k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
2116 | if (k_o == NULL__null) return NULL__null; |
2117 | } |
2118 | InstanceKlass* k = InstanceKlass::cast(k_o); |
2119 | Symbol* name = cp->uncached_name_ref_at(index); |
2120 | Symbol* sig = cp->uncached_signature_ref_at(index); |
2121 | methodHandle m (THREAD__the_thread__, k->find_method(name, sig)); |
2122 | if (m.is_null()) { |
2123 | THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2123, vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class" ); return 0; }; |
2124 | } |
2125 | oop method; |
2126 | if (!m->is_initializer() || m->is_static()) { |
2127 | method = Reflection::new_method(m, true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2128 | } else { |
2129 | method = Reflection::new_constructor(m, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2130 | } |
2131 | return JNIHandles::make_local(THREAD__the_thread__, method); |
2132 | } |
2133 | |
2134 | JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2135 | { |
2136 | JvmtiVMObjectAllocEventCollector oam; |
2137 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2138 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2139 | jobject res = get_method_at_helper(cp, index, true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2140 | return res; |
2141 | } |
2142 | JVM_END} } |
2143 | |
2144 | JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2145 | { |
2146 | JvmtiVMObjectAllocEventCollector oam; |
2147 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2148 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2149 | jobject res = get_method_at_helper(cp, index, false, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2150 | return res; |
2151 | } |
2152 | JVM_END} } |
2153 | |
2154 | static jobject get_field_at_helper(constantPoolHandle cp, jint index, bool force_resolution, TRAPSJavaThread* __the_thread__) { |
2155 | constantTag tag = cp->tag_at(index); |
2156 | if (!tag.is_field()) { |
2157 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2157, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2158 | } |
2159 | int klass_ref = cp->uncached_klass_ref_index_at(index); |
2160 | Klass* k_o; |
2161 | if (force_resolution) { |
2162 | k_o = cp->klass_at(klass_ref, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2163 | } else { |
2164 | k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
2165 | if (k_o == NULL__null) return NULL__null; |
2166 | } |
2167 | InstanceKlass* k = InstanceKlass::cast(k_o); |
2168 | Symbol* name = cp->uncached_name_ref_at(index); |
2169 | Symbol* sig = cp->uncached_signature_ref_at(index); |
2170 | fieldDescriptor fd; |
2171 | Klass* target_klass = k->find_field(name, sig, &fd); |
2172 | if (target_klass == NULL__null) { |
2173 | THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2173, vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class" ); return 0; }; |
2174 | } |
2175 | oop field = Reflection::new_field(&fd, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2176 | return JNIHandles::make_local(THREAD__the_thread__, field); |
2177 | } |
2178 | |
2179 | JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject obj, jobject unusedl, jint index))extern "C" { jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject obj, jobject unusedl, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2180 | { |
2181 | JvmtiVMObjectAllocEventCollector oam; |
2182 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2183 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2184 | jobject res = get_field_at_helper(cp, index, true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2185 | return res; |
2186 | } |
2187 | JVM_END} } |
2188 | |
2189 | JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2190 | { |
2191 | JvmtiVMObjectAllocEventCollector oam; |
2192 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2193 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2194 | jobject res = get_field_at_helper(cp, index, false, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2195 | return res; |
2196 | } |
2197 | JVM_END} } |
2198 | |
2199 | JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jobjectArray JVM_ConstantPoolGetMemberRefInfoAt( JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2200 | { |
2201 | JvmtiVMObjectAllocEventCollector oam; |
2202 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2203 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2204 | constantTag tag = cp->tag_at(index); |
2205 | if (!tag.is_field_or_method()) { |
2206 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2206, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2207 | } |
2208 | int klass_ref = cp->uncached_klass_ref_index_at(index); |
2209 | Symbol* klass_name = cp->klass_name_at(klass_ref); |
2210 | Symbol* member_name = cp->uncached_name_ref_at(index); |
2211 | Symbol* member_sig = cp->uncached_signature_ref_at(index); |
2212 | objArrayOop dest_o = oopFactory::new_objArray(vmClasses::String_klass(), 3, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2213 | objArrayHandle dest(THREAD__the_thread__, dest_o); |
2214 | Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2215 | dest->obj_at_put(0, str()); |
2216 | str = java_lang_String::create_from_symbol(member_name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2217 | dest->obj_at_put(1, str()); |
2218 | str = java_lang_String::create_from_symbol(member_sig, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2219 | dest->obj_at_put(2, str()); |
2220 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, dest()); |
2221 | } |
2222 | JVM_END} } |
2223 | |
2224 | JVM_ENTRY(jint, JVM_ConstantPoolGetClassRefIndexAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jint JVM_ConstantPoolGetClassRefIndexAt(JNIEnv * env, jobject obj, jobject unused, jint index) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2225 | { |
2226 | JvmtiVMObjectAllocEventCollector oam; |
2227 | constantPoolHandle cp(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2228 | bounds_check(cp, index, CHECK_0__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0; (void)(0); |
2229 | constantTag tag = cp->tag_at(index); |
2230 | if (!tag.is_field_or_method()) { |
2231 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2231, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2232 | } |
2233 | return (jint) cp->uncached_klass_ref_index_at(index); |
2234 | } |
2235 | JVM_END} } |
2236 | |
2237 | JVM_ENTRY(jint, JVM_ConstantPoolGetNameAndTypeRefIndexAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jint JVM_ConstantPoolGetNameAndTypeRefIndexAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2238 | { |
2239 | JvmtiVMObjectAllocEventCollector oam; |
2240 | constantPoolHandle cp(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2241 | bounds_check(cp, index, CHECK_0__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0; (void)(0); |
2242 | constantTag tag = cp->tag_at(index); |
2243 | if (!tag.is_invoke_dynamic() && !tag.is_field_or_method()) { |
2244 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2244, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2245 | } |
2246 | return (jint) cp->uncached_name_and_type_ref_index_at(index); |
2247 | } |
2248 | JVM_END} } |
2249 | |
2250 | JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetNameAndTypeRefInfoAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jobjectArray JVM_ConstantPoolGetNameAndTypeRefInfoAt (JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2251 | { |
2252 | JvmtiVMObjectAllocEventCollector oam; |
2253 | constantPoolHandle cp(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2254 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2255 | constantTag tag = cp->tag_at(index); |
2256 | if (!tag.is_name_and_type()) { |
2257 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2257, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2258 | } |
2259 | Symbol* member_name = cp->symbol_at(cp->name_ref_index_at(index)); |
2260 | Symbol* member_sig = cp->symbol_at(cp->signature_ref_index_at(index)); |
2261 | objArrayOop dest_o = oopFactory::new_objArray(vmClasses::String_klass(), 2, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2262 | objArrayHandle dest(THREAD__the_thread__, dest_o); |
2263 | Handle str = java_lang_String::create_from_symbol(member_name, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2264 | dest->obj_at_put(0, str()); |
2265 | str = java_lang_String::create_from_symbol(member_sig, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2266 | dest->obj_at_put(1, str()); |
2267 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, dest()); |
2268 | } |
2269 | JVM_END} } |
2270 | |
2271 | JVM_ENTRY(jint, JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2272 | { |
2273 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2274 | bounds_check(cp, index, CHECK_0__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0; (void)(0); |
2275 | constantTag tag = cp->tag_at(index); |
2276 | if (!tag.is_int()) { |
2277 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2277, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2278 | } |
2279 | return cp->int_at(index); |
2280 | } |
2281 | JVM_END} } |
2282 | |
2283 | JVM_ENTRY(jlong, JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2284 | { |
2285 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2286 | bounds_check(cp, index, CHECK_(0L)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0L; (void)(0); |
2287 | constantTag tag = cp->tag_at(index); |
2288 | if (!tag.is_long()) { |
2289 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2289, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2290 | } |
2291 | return cp->long_at(index); |
2292 | } |
2293 | JVM_END} } |
2294 | |
2295 | JVM_ENTRY(jfloat, JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2296 | { |
2297 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2298 | bounds_check(cp, index, CHECK_(0.0f)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0.0f; (void)(0); |
2299 | constantTag tag = cp->tag_at(index); |
2300 | if (!tag.is_float()) { |
2301 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2301, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2302 | } |
2303 | return cp->float_at(index); |
2304 | } |
2305 | JVM_END} } |
2306 | |
2307 | JVM_ENTRY(jdouble, JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2308 | { |
2309 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2310 | bounds_check(cp, index, CHECK_(0.0)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0.0; (void)(0); |
2311 | constantTag tag = cp->tag_at(index); |
2312 | if (!tag.is_double()) { |
2313 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2313, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2314 | } |
2315 | return cp->double_at(index); |
2316 | } |
2317 | JVM_END} } |
2318 | |
2319 | JVM_ENTRY(jstring, JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2320 | { |
2321 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2322 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2323 | constantTag tag = cp->tag_at(index); |
2324 | if (!tag.is_string()) { |
2325 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2325, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2326 | } |
2327 | oop str = cp->string_at(index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2328 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, str); |
2329 | } |
2330 | JVM_END} } |
2331 | |
2332 | JVM_ENTRY(jstring, JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2333 | { |
2334 | JvmtiVMObjectAllocEventCollector oam; |
2335 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2336 | bounds_check(cp, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2337 | constantTag tag = cp->tag_at(index); |
2338 | if (!tag.is_symbol()) { |
2339 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2339, vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index" ); return 0; }; |
2340 | } |
2341 | Symbol* sym = cp->symbol_at(index); |
2342 | Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2343 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, str()); |
2344 | } |
2345 | JVM_END} } |
2346 | |
2347 | JVM_ENTRY(jbyte, JVM_ConstantPoolGetTagAt(JNIEnv *env, jobject obj, jobject unused, jint index))extern "C" { jbyte JVM_ConstantPoolGetTagAt(JNIEnv *env, jobject obj, jobject unused, jint index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2348 | { |
2349 | constantPoolHandle cp = constantPoolHandle(THREAD__the_thread__, reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2350 | bounds_check(cp, index, CHECK_0__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0; (void)(0); |
2351 | constantTag tag = cp->tag_at(index); |
2352 | jbyte result = tag.value(); |
2353 | // If returned tag values are not from the JVM spec, e.g. tags from 100 to 105, |
2354 | // they are changed to the corresponding tags from the JVM spec, so that java code in |
2355 | // sun.reflect.ConstantPool will return only tags from the JVM spec, not internal ones. |
2356 | if (tag.is_klass_or_reference()) { |
2357 | result = JVM_CONSTANT_Class; |
2358 | } else if (tag.is_string_index()) { |
2359 | result = JVM_CONSTANT_String; |
2360 | } else if (tag.is_method_type_in_error()) { |
2361 | result = JVM_CONSTANT_MethodType; |
2362 | } else if (tag.is_method_handle_in_error()) { |
2363 | result = JVM_CONSTANT_MethodHandle; |
2364 | } else if (tag.is_dynamic_constant_in_error()) { |
2365 | result = JVM_CONSTANT_Dynamic; |
2366 | } |
2367 | return result; |
2368 | } |
2369 | JVM_END} } |
2370 | |
2371 | // Assertion support. ////////////////////////////////////////////////////////// |
2372 | |
2373 | JVM_ENTRY(jboolean, JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls))extern "C" { jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls) { JavaThread* thread=JavaThread:: thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2374 | assert(cls != NULL, "bad class")do { if (!(cls != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2374, "assert(" "cls != __null" ") failed", "bad class"); :: breakpoint(); } } while (0); |
2375 | |
2376 | oop r = JNIHandles::resolve(cls); |
2377 | assert(! java_lang_Class::is_primitive(r), "primitive classes not allowed")do { if (!(! java_lang_Class::is_primitive(r))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2377, "assert(" "! java_lang_Class::is_primitive(r)" ") failed" , "primitive classes not allowed"); ::breakpoint(); } } while (0); |
2378 | if (java_lang_Class::is_primitive(r)) return false; |
2379 | |
2380 | Klass* k = java_lang_Class::as_Klass(r); |
2381 | assert(k->is_instance_klass(), "must be an instance klass")do { if (!(k->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2381, "assert(" "k->is_instance_klass()" ") failed", "must be an instance klass" ); ::breakpoint(); } } while (0); |
2382 | if (!k->is_instance_klass()) return false; |
2383 | |
2384 | ResourceMark rm(THREAD__the_thread__); |
2385 | const char* name = k->name()->as_C_string(); |
2386 | bool system_class = k->class_loader() == NULL__null; |
2387 | return JavaAssertions::enabled(name, system_class); |
2388 | |
2389 | JVM_END} } |
2390 | |
2391 | |
2392 | // Return a new AssertionStatusDirectives object with the fields filled in with |
2393 | // command-line assertion arguments (i.e., -ea, -da). |
2394 | JVM_ENTRY(jobject, JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused))extern "C" { jobject JVM_AssertionStatusDirectives(JNIEnv *env , jclass unused) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2395 | JvmtiVMObjectAllocEventCollector oam; |
2396 | oop asd = JavaAssertions::createAssertionStatusDirectives(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
2397 | return JNIHandles::make_local(THREAD__the_thread__, asd); |
2398 | JVM_END} } |
2399 | |
2400 | // Verification //////////////////////////////////////////////////////////////////////////////// |
2401 | |
2402 | // Reflection for the verifier ///////////////////////////////////////////////////////////////// |
2403 | |
2404 | // RedefineClasses support: bug 6214132 caused verification to fail. |
2405 | // All functions from this section should call the jvmtiThreadSate function: |
2406 | // Klass* class_to_verify_considering_redefinition(Klass* klass). |
2407 | // The function returns a Klass* of the _scratch_class if the verifier |
2408 | // was invoked in the middle of the class redefinition. |
2409 | // Otherwise it returns its argument value which is the _the_class Klass*. |
2410 | // Please, refer to the description in the jvmtiThreadSate.hpp. |
2411 | |
2412 | JVM_ENTRY(const char*, JVM_GetClassNameUTF(JNIEnv *env, jclass cls))extern "C" { const char* JVM_GetClassNameUTF(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2413 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2414 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2415 | return k->name()->as_utf8(); |
2416 | JVM_END} } |
2417 | |
2418 | |
2419 | JVM_ENTRY(void, JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types))extern "C" { void JVM_GetClassCPTypes(JNIEnv *env, jclass cls , unsigned char *types) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2420 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2421 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2422 | // types will have length zero if this is not an InstanceKlass |
2423 | // (length is determined by call to JVM_GetClassCPEntriesCount) |
2424 | if (k->is_instance_klass()) { |
2425 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2426 | for (int index = cp->length() - 1; index >= 0; index--) { |
2427 | constantTag tag = cp->tag_at(index); |
2428 | types[index] = (tag.is_unresolved_klass()) ? (unsigned char) JVM_CONSTANT_Class : tag.value(); |
2429 | } |
2430 | } |
2431 | JVM_END} } |
2432 | |
2433 | |
2434 | JVM_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls))extern "C" { jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2435 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2436 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2437 | return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->constants()->length(); |
2438 | JVM_END} } |
2439 | |
2440 | |
2441 | JVM_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls))extern "C" { jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2442 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2443 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2444 | return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->java_fields_count(); |
2445 | JVM_END} } |
2446 | |
2447 | |
2448 | JVM_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls))extern "C" { jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2449 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2450 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2451 | return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->methods()->length(); |
2452 | JVM_END} } |
2453 | |
2454 | |
2455 | // The following methods, used for the verifier, are never called with |
2456 | // array klasses, so a direct cast to InstanceKlass is safe. |
2457 | // Typically, these methods are called in a loop with bounds determined |
2458 | // by the results of JVM_GetClass{Fields,Methods}Count, which return |
2459 | // zero for arrays. |
2460 | JVM_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions))extern "C" { void JVM_GetMethodIxExceptionIndexes(JNIEnv *env , jclass cls, jint method_index, unsigned short *exceptions) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2461 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2462 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2463 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2464 | int length = method->checked_exceptions_length(); |
2465 | if (length > 0) { |
2466 | CheckedExceptionElement* table= method->checked_exceptions_start(); |
2467 | for (int i = 0; i < length; i++) { |
2468 | exceptions[i] = table[i].class_cp_index; |
2469 | } |
2470 | } |
2471 | JVM_END} } |
2472 | |
2473 | |
2474 | JVM_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index))extern "C" { jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2475 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2476 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2477 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2478 | return method->checked_exceptions_length(); |
2479 | JVM_END} } |
2480 | |
2481 | |
2482 | JVM_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code))extern "C" { void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2483 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2484 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2485 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2486 | memcpy(code, method->code_base(), method->code_size()); |
2487 | JVM_END} } |
2488 | |
2489 | |
2490 | JVM_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index))extern "C" { jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2491 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2492 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2493 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2494 | return method->code_size(); |
2495 | JVM_END} } |
2496 | |
2497 | |
2498 | JVM_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry))extern "C" { void JVM_GetMethodIxExceptionTableEntry(JNIEnv * env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2499 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2500 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2501 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2502 | ExceptionTable extable(method); |
2503 | entry->start_pc = extable.start_pc(entry_index); |
2504 | entry->end_pc = extable.end_pc(entry_index); |
2505 | entry->handler_pc = extable.handler_pc(entry_index); |
2506 | entry->catchType = extable.catch_type_index(entry_index); |
2507 | JVM_END} } |
2508 | |
2509 | |
2510 | JVM_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index))extern "C" { jint JVM_GetMethodIxExceptionTableLength(JNIEnv * env, jclass cls, int method_index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2511 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2512 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2513 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2514 | return method->exception_table_length(); |
2515 | JVM_END} } |
2516 | |
2517 | |
2518 | JVM_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index))extern "C" { jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2519 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2520 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2521 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2522 | return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS(JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC | JVM_ACC_FINAL | JVM_ACC_SYNCHRONIZED | JVM_ACC_BRIDGE | JVM_ACC_VARARGS | JVM_ACC_NATIVE | JVM_ACC_ABSTRACT | JVM_ACC_STRICT | JVM_ACC_SYNTHETIC ); |
2523 | JVM_END} } |
2524 | |
2525 | |
2526 | JVM_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index))extern "C" { jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2527 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2528 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2529 | return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS(JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC | JVM_ACC_FINAL | JVM_ACC_VOLATILE | JVM_ACC_TRANSIENT | JVM_ACC_ENUM | JVM_ACC_SYNTHETIC); |
2530 | JVM_END} } |
2531 | |
2532 | |
2533 | JVM_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index))extern "C" { jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2534 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2535 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2536 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2537 | return method->max_locals(); |
2538 | JVM_END} } |
2539 | |
2540 | |
2541 | JVM_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index))extern "C" { jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2542 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2543 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2544 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2545 | return method->size_of_parameters(); |
2546 | JVM_END} } |
2547 | |
2548 | |
2549 | JVM_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index))extern "C" { jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2550 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2551 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2552 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2553 | return method->verifier_max_stack(); |
2554 | JVM_END} } |
2555 | |
2556 | |
2557 | JVM_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index))extern "C" { jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2558 | ResourceMark rm(THREAD__the_thread__); |
2559 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2560 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2561 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2562 | return method->name() == vmSymbols::object_initializer_name(); |
2563 | JVM_END} } |
2564 | |
2565 | |
2566 | JVM_ENTRY(jboolean, JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index))extern "C" { jboolean JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2567 | ResourceMark rm(THREAD__the_thread__); |
2568 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2569 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2570 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2571 | return method->is_overpass(); |
2572 | JVM_END} } |
2573 | |
2574 | JVM_ENTRY(const char*, JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index))extern "C" { const char* JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2575 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2576 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2577 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2578 | return method->name()->as_utf8(); |
2579 | JVM_END} } |
2580 | |
2581 | |
2582 | JVM_ENTRY(const char*, JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index))extern "C" { const char* JVM_GetMethodIxSignatureUTF(JNIEnv * env, jclass cls, jint method_index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2583 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2584 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2585 | Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2586 | return method->signature()->as_utf8(); |
2587 | JVM_END} } |
2588 | |
2589 | /** |
2590 | * All of these JVM_GetCP-xxx methods are used by the old verifier to |
2591 | * read entries in the constant pool. Since the old verifier always |
2592 | * works on a copy of the code, it will not see any rewriting that |
2593 | * may possibly occur in the middle of verification. So it is important |
2594 | * that nothing it calls tries to use the cpCache instead of the raw |
2595 | * constant pool, so we must use cp->uncached_x methods when appropriate. |
2596 | */ |
2597 | JVM_ENTRY(const char*, JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2598 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2599 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2600 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2601 | switch (cp->tag_at(cp_index).value()) { |
2602 | case JVM_CONSTANT_Fieldref: |
2603 | return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2604 | default: |
2605 | fatal("JVM_GetCPFieldNameUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2605, "JVM_GetCPFieldNameUTF: illegal constant"); ::breakpoint (); } while (0); |
2606 | } |
2607 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2607); ::breakpoint(); } while (0); |
2608 | return NULL__null; |
2609 | JVM_END} } |
2610 | |
2611 | |
2612 | JVM_ENTRY(const char*, JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2613 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2614 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2615 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2616 | switch (cp->tag_at(cp_index).value()) { |
2617 | case JVM_CONSTANT_InterfaceMethodref: |
2618 | case JVM_CONSTANT_Methodref: |
2619 | return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2620 | default: |
2621 | fatal("JVM_GetCPMethodNameUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2621, "JVM_GetCPMethodNameUTF: illegal constant"); ::breakpoint (); } while (0); |
2622 | } |
2623 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2623); ::breakpoint(); } while (0); |
2624 | return NULL__null; |
2625 | JVM_END} } |
2626 | |
2627 | |
2628 | JVM_ENTRY(const char*, JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPMethodSignatureUTF(JNIEnv * env, jclass cls, jint cp_index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2629 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2630 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2631 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2632 | switch (cp->tag_at(cp_index).value()) { |
2633 | case JVM_CONSTANT_InterfaceMethodref: |
2634 | case JVM_CONSTANT_Methodref: |
2635 | return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2636 | default: |
2637 | fatal("JVM_GetCPMethodSignatureUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2637, "JVM_GetCPMethodSignatureUTF: illegal constant"); ::breakpoint (); } while (0); |
2638 | } |
2639 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2639); ::breakpoint(); } while (0); |
2640 | return NULL__null; |
2641 | JVM_END} } |
2642 | |
2643 | |
2644 | JVM_ENTRY(const char*, JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPFieldSignatureUTF(JNIEnv *env , jclass cls, jint cp_index) { JavaThread* thread=JavaThread:: thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2645 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2646 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2647 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2648 | switch (cp->tag_at(cp_index).value()) { |
2649 | case JVM_CONSTANT_Fieldref: |
2650 | return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2651 | default: |
2652 | fatal("JVM_GetCPFieldSignatureUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2652, "JVM_GetCPFieldSignatureUTF: illegal constant"); ::breakpoint (); } while (0); |
2653 | } |
2654 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2654); ::breakpoint(); } while (0); |
2655 | return NULL__null; |
2656 | JVM_END} } |
2657 | |
2658 | |
2659 | JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2660 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2661 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2662 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2663 | Symbol* classname = cp->klass_name_at(cp_index); |
2664 | return classname->as_utf8(); |
2665 | JVM_END} } |
2666 | |
2667 | |
2668 | JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPFieldClassNameUTF(JNIEnv *env , jclass cls, jint cp_index) { JavaThread* thread=JavaThread:: thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2669 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2670 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2671 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2672 | switch (cp->tag_at(cp_index).value()) { |
2673 | case JVM_CONSTANT_Fieldref: { |
2674 | int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2675 | Symbol* classname = cp->klass_name_at(class_index); |
2676 | return classname->as_utf8(); |
2677 | } |
2678 | default: |
2679 | fatal("JVM_GetCPFieldClassNameUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2679, "JVM_GetCPFieldClassNameUTF: illegal constant"); ::breakpoint (); } while (0); |
2680 | } |
2681 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2681); ::breakpoint(); } while (0); |
2682 | return NULL__null; |
2683 | JVM_END} } |
2684 | |
2685 | |
2686 | JVM_ENTRY(const char*, JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index))extern "C" { const char* JVM_GetCPMethodClassNameUTF(JNIEnv * env, jclass cls, jint cp_index) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2687 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2688 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2689 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2690 | switch (cp->tag_at(cp_index).value()) { |
2691 | case JVM_CONSTANT_Methodref: |
2692 | case JVM_CONSTANT_InterfaceMethodref: { |
2693 | int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2694 | Symbol* classname = cp->klass_name_at(class_index); |
2695 | return classname->as_utf8(); |
2696 | } |
2697 | default: |
2698 | fatal("JVM_GetCPMethodClassNameUTF: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2698, "JVM_GetCPMethodClassNameUTF: illegal constant"); ::breakpoint (); } while (0); |
2699 | } |
2700 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2700); ::breakpoint(); } while (0); |
2701 | return NULL__null; |
2702 | JVM_END} } |
2703 | |
2704 | |
2705 | JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))extern "C" { jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2706 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2707 | Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
2708 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2709 | k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2710 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2711 | ConstantPool* cp_called = InstanceKlass::cast(k_called)->constants(); |
2712 | switch (cp->tag_at(cp_index).value()) { |
2713 | case JVM_CONSTANT_Fieldref: { |
2714 | Symbol* name = cp->uncached_name_ref_at(cp_index); |
2715 | Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2716 | InstanceKlass* ik = InstanceKlass::cast(k_called); |
2717 | for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { |
2718 | if (fs.name() == name && fs.signature() == signature) { |
2719 | return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS(JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC | JVM_ACC_FINAL | JVM_ACC_VOLATILE | JVM_ACC_TRANSIENT | JVM_ACC_ENUM | JVM_ACC_SYNTHETIC); |
2720 | } |
2721 | } |
2722 | return -1; |
2723 | } |
2724 | default: |
2725 | fatal("JVM_GetCPFieldModifiers: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2725, "JVM_GetCPFieldModifiers: illegal constant"); ::breakpoint (); } while (0); |
2726 | } |
2727 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2727); ::breakpoint(); } while (0); |
2728 | return 0; |
2729 | JVM_END} } |
2730 | |
2731 | |
2732 | JVM_ENTRY(jint, JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))extern "C" { jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
2733 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2734 | Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
2735 | k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2736 | k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2737 | ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2738 | switch (cp->tag_at(cp_index).value()) { |
2739 | case JVM_CONSTANT_Methodref: |
2740 | case JVM_CONSTANT_InterfaceMethodref: { |
2741 | Symbol* name = cp->uncached_name_ref_at(cp_index); |
2742 | Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2743 | Array<Method*>* methods = InstanceKlass::cast(k_called)->methods(); |
2744 | int methods_count = methods->length(); |
2745 | for (int i = 0; i < methods_count; i++) { |
2746 | Method* method = methods->at(i); |
2747 | if (method->name() == name && method->signature() == signature) { |
2748 | return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS(JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC | JVM_ACC_FINAL | JVM_ACC_SYNCHRONIZED | JVM_ACC_BRIDGE | JVM_ACC_VARARGS | JVM_ACC_NATIVE | JVM_ACC_ABSTRACT | JVM_ACC_STRICT | JVM_ACC_SYNTHETIC ); |
2749 | } |
2750 | } |
2751 | return -1; |
2752 | } |
2753 | default: |
2754 | fatal("JVM_GetCPMethodModifiers: illegal constant")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2754, "JVM_GetCPMethodModifiers: illegal constant"); ::breakpoint (); } while (0); |
2755 | } |
2756 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2756); ::breakpoint(); } while (0); |
2757 | return 0; |
2758 | JVM_END} } |
2759 | |
2760 | |
2761 | // Misc ////////////////////////////////////////////////////////////////////////////////////////////// |
2762 | |
2763 | JVM_LEAF(void, JVM_ReleaseUTF(const char *utf))extern "C" { void JVM_ReleaseUTF(const char *utf) { VM_Exit:: block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
2764 | // So long as UTF8::convert_to_utf8 returns resource strings, we don't have to do anything |
2765 | JVM_END} } |
2766 | |
2767 | |
2768 | JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2))extern "C" { jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2769 | oop class1_mirror = JNIHandles::resolve_non_null(class1); |
2770 | oop class2_mirror = JNIHandles::resolve_non_null(class2); |
2771 | Klass* klass1 = java_lang_Class::as_Klass(class1_mirror); |
2772 | Klass* klass2 = java_lang_Class::as_Klass(class2_mirror); |
2773 | return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2774 | JVM_END} } |
2775 | |
2776 | // Printing support ////////////////////////////////////////////////// |
2777 | extern "C" { |
2778 | |
2779 | ATTRIBUTE_PRINTF(3, 0)__attribute__((format(printf, 3, 0))) |
2780 | int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
2781 | // Reject count values that are negative signed values converted to |
2782 | // unsigned; see bug 4399518, 4417214 |
2783 | if ((intptr_t)count <= 0) return -1; |
2784 | |
2785 | int result = os::vsnprintf(str, count, fmt, args); |
2786 | if (result > 0 && (size_t)result >= count) { |
2787 | result = -1; |
2788 | } |
2789 | |
2790 | return result; |
2791 | } |
2792 | |
2793 | ATTRIBUTE_PRINTF(3, 4)__attribute__((format(printf, 3, 4))) |
2794 | int jio_snprintf(char *str, size_t count, const char *fmt, ...) { |
2795 | va_list args; |
2796 | int len; |
2797 | va_start(args, fmt)__builtin_va_start(args, fmt); |
2798 | len = jio_vsnprintf(str, count, fmt, args); |
2799 | va_end(args)__builtin_va_end(args); |
2800 | return len; |
2801 | } |
2802 | |
2803 | ATTRIBUTE_PRINTF(2, 3)__attribute__((format(printf, 2, 3))) |
2804 | int jio_fprintf(FILE* f, const char *fmt, ...) { |
2805 | int len; |
2806 | va_list args; |
2807 | va_start(args, fmt)__builtin_va_start(args, fmt); |
2808 | len = jio_vfprintf(f, fmt, args); |
2809 | va_end(args)__builtin_va_end(args); |
2810 | return len; |
2811 | } |
2812 | |
2813 | ATTRIBUTE_PRINTF(2, 0)__attribute__((format(printf, 2, 0))) |
2814 | int jio_vfprintf(FILE* f, const char *fmt, va_list args) { |
2815 | if (Arguments::vfprintf_hook() != NULL__null) { |
2816 | return Arguments::vfprintf_hook()(f, fmt, args); |
2817 | } else { |
2818 | return vfprintf(f, fmt, args); |
2819 | } |
2820 | } |
2821 | |
2822 | ATTRIBUTE_PRINTF(1, 2)__attribute__((format(printf, 1, 2))) |
2823 | JNIEXPORT__attribute__((visibility("default"))) int jio_printf(const char *fmt, ...) { |
2824 | int len; |
2825 | va_list args; |
2826 | va_start(args, fmt)__builtin_va_start(args, fmt); |
2827 | len = jio_vfprintf(defaultStream::output_stream(), fmt, args); |
2828 | va_end(args)__builtin_va_end(args); |
2829 | return len; |
2830 | } |
2831 | |
2832 | // HotSpot specific jio method |
2833 | void jio_print(const char* s, size_t len) { |
2834 | // Try to make this function as atomic as possible. |
2835 | if (Arguments::vfprintf_hook() != NULL__null) { |
2836 | jio_fprintf(defaultStream::output_stream(), "%.*s", (int)len, s); |
2837 | } else { |
2838 | // Make an unused local variable to avoid warning from gcc compiler. |
2839 | size_t count = ::write(defaultStream::output_fd(), s, (int)len); |
Value stored to 'count' during its initialization is never read | |
2840 | } |
2841 | } |
2842 | |
2843 | } // Extern C |
2844 | |
2845 | // java.lang.Thread ////////////////////////////////////////////////////////////////////////////// |
2846 | |
2847 | // In most of the JVM thread support functions we need to access the |
2848 | // thread through a ThreadsListHandle to prevent it from exiting and |
2849 | // being reclaimed while we try to operate on it. The exceptions to this |
2850 | // rule are when operating on the current thread, or if the monitor of |
2851 | // the target java.lang.Thread is locked at the Java level - in both |
2852 | // cases the target cannot exit. |
2853 | |
2854 | static void thread_entry(JavaThread* thread, TRAPSJavaThread* __the_thread__) { |
2855 | HandleMark hm(THREAD__the_thread__); |
2856 | Handle obj(THREAD__the_thread__, thread->threadObj()); |
2857 | JavaValue result(T_VOID); |
2858 | JavaCalls::call_virtual(&result, |
2859 | obj, |
2860 | vmClasses::Thread_klass(), |
2861 | vmSymbols::run_method_name(), |
2862 | vmSymbols::void_method_signature(), |
2863 | THREAD__the_thread__); |
2864 | } |
2865 | |
2866 | |
2867 | JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread))extern "C" { void JVM_StartThread(JNIEnv* env, jobject jthread ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2868 | JavaThread *native_thread = NULL__null; |
2869 | |
2870 | // We cannot hold the Threads_lock when we throw an exception, |
2871 | // due to rank ordering issues. Example: we might need to grab the |
2872 | // Heap_lock while we construct the exception. |
2873 | bool throw_illegal_thread_state = false; |
2874 | |
2875 | // We must release the Threads_lock before we can post a jvmti event |
2876 | // in Thread::start. |
2877 | { |
2878 | // Ensure that the C++ Thread and OSThread structures aren't freed before |
2879 | // we operate. |
2880 | MutexLocker mu(Threads_lock); |
2881 | |
2882 | // Since JDK 5 the java.lang.Thread threadStatus is used to prevent |
2883 | // re-starting an already started thread, so we should usually find |
2884 | // that the JavaThread is null. However for a JNI attached thread |
2885 | // there is a small window between the Thread object being created |
2886 | // (with its JavaThread set) and the update to its threadStatus, so we |
2887 | // have to check for this |
2888 | if (java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)) != NULL__null) { |
2889 | throw_illegal_thread_state = true; |
2890 | } else { |
2891 | // We could also check the stillborn flag to see if this thread was already stopped, but |
2892 | // for historical reasons we let the thread detect that itself when it starts running |
2893 | |
2894 | jlong size = |
2895 | java_lang_Thread::stackSize(JNIHandles::resolve_non_null(jthread)); |
2896 | // Allocate the C++ Thread structure and create the native thread. The |
2897 | // stack size retrieved from java is 64-bit signed, but the constructor takes |
2898 | // size_t (an unsigned type), which may be 32 or 64-bit depending on the platform. |
2899 | // - Avoid truncating on 32-bit platforms if size is greater than UINT_MAX. |
2900 | // - Avoid passing negative values which would result in really large stacks. |
2901 | NOT_LP64(if (size > SIZE_MAX) size = SIZE_MAX;) |
2902 | size_t sz = size > 0 ? (size_t) size : 0; |
2903 | native_thread = new JavaThread(&thread_entry, sz); |
2904 | |
2905 | // At this point it may be possible that no osthread was created for the |
2906 | // JavaThread due to lack of memory. Check for this situation and throw |
2907 | // an exception if necessary. Eventually we may want to change this so |
2908 | // that we only grab the lock if the thread was created successfully - |
2909 | // then we can also do this check and throw the exception in the |
2910 | // JavaThread constructor. |
2911 | if (native_thread->osthread() != NULL__null) { |
2912 | // Note: the current thread is not being used within "prepare". |
2913 | native_thread->prepare(jthread); |
2914 | } |
2915 | } |
2916 | } |
2917 | |
2918 | if (throw_illegal_thread_state) { |
2919 | THROW(vmSymbols::java_lang_IllegalThreadStateException()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2919, vmSymbols::java_lang_IllegalThreadStateException(), __null ); return; }; |
2920 | } |
2921 | |
2922 | assert(native_thread != NULL, "Starting null thread?")do { if (!(native_thread != __null)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2922, "assert(" "native_thread != __null" ") failed", "Starting null thread?" ); ::breakpoint(); } } while (0); |
2923 | |
2924 | if (native_thread->osthread() == NULL__null) { |
2925 | ResourceMark rm(thread); |
2926 | log_warning(os, thread)(!(LogImpl<(LogTag::_os), (LogTag::_thread), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Warning))) ? (void)0 : LogImpl<(LogTag ::_os), (LogTag::_thread), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Warning>("Failed to start the native thread for java.lang.Thread \"%s\"", |
2927 | JavaThread::name_for(JNIHandles::resolve_non_null(jthread))); |
2928 | // No one should hold a reference to the 'native_thread'. |
2929 | native_thread->smr_delete(); |
2930 | if (JvmtiExport::should_post_resource_exhausted()) { |
2931 | JvmtiExport::post_resource_exhausted( |
2932 | JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, |
2933 | os::native_thread_creation_failed_msg()); |
2934 | } |
2935 | THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),{ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2936, vmSymbols::java_lang_OutOfMemoryError(), os::native_thread_creation_failed_msg ()); return; } |
2936 | os::native_thread_creation_failed_msg()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2936, vmSymbols::java_lang_OutOfMemoryError(), os::native_thread_creation_failed_msg ()); return; }; |
2937 | } |
2938 | |
2939 | #if INCLUDE_JFR1 |
2940 | if (Jfr::is_recording() && EventThreadStart::is_enabled() && |
2941 | EventThreadStart::is_stacktrace_enabled()) { |
2942 | JfrThreadLocal* tl = native_thread->jfr_thread_local(); |
2943 | // skip Thread.start() and Thread.start0() |
2944 | tl->set_cached_stack_trace_id(JfrStackTraceRepository::record(thread, 2)); |
2945 | } |
2946 | #endif |
2947 | |
2948 | Thread::start(native_thread); |
2949 | |
2950 | JVM_END} } |
2951 | |
2952 | |
2953 | // JVM_Stop is implemented using a VM_Operation, so threads are forced to safepoints |
2954 | // before the quasi-asynchronous exception is delivered. This is a little obtrusive, |
2955 | // but is thought to be reliable and simple. In the case, where the receiver is the |
2956 | // same thread as the sender, no VM_Operation is needed. |
2957 | JVM_ENTRY(void, JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable))extern "C" { void JVM_StopThread(JNIEnv* env, jobject jthread , jobject throwable) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2958 | ThreadsListHandle tlh(thread); |
2959 | oop java_throwable = JNIHandles::resolve(throwable); |
2960 | if (java_throwable == NULL__null) { |
2961 | THROW(vmSymbols::java_lang_NullPointerException()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2961, vmSymbols::java_lang_NullPointerException(), __null); return; }; |
2962 | } |
2963 | oop java_thread = NULL__null; |
2964 | JavaThread* receiver = NULL__null; |
2965 | bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, &java_thread); |
2966 | Events::log_exception(thread, |
2967 | "JVM_StopThread thread JavaThread " INTPTR_FORMAT"0x%016" "l" "x" " as oop " INTPTR_FORMAT"0x%016" "l" "x" " [exception " INTPTR_FORMAT"0x%016" "l" "x" "]", |
2968 | p2i(receiver), p2i(java_thread), p2i(throwable)); |
2969 | |
2970 | if (is_alive) { |
2971 | // jthread refers to a live JavaThread. |
2972 | if (thread == receiver) { |
2973 | // Exception is getting thrown at self so no VM_Operation needed. |
2974 | THROW_OOP(java_throwable){ Exceptions::_throw_oop(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 2974, java_throwable); return; }; |
2975 | } else { |
2976 | // Use a VM_Operation to throw the exception. |
2977 | JavaThread::send_async_exception(receiver, java_throwable); |
2978 | } |
2979 | } else { |
2980 | // Either: |
2981 | // - target thread has not been started before being stopped, or |
2982 | // - target thread already terminated |
2983 | // We could read the threadStatus to determine which case it is |
2984 | // but that is overkill as it doesn't matter. We must set the |
2985 | // stillborn flag for the first case, and if the thread has already |
2986 | // exited setting this flag has no effect. |
2987 | java_lang_Thread::set_stillborn(java_thread); |
2988 | } |
2989 | JVM_END} } |
2990 | |
2991 | |
2992 | JVM_ENTRY(jboolean, JVM_IsThreadAlive(JNIEnv* env, jobject jthread))extern "C" { jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2993 | oop thread_oop = JNIHandles::resolve_non_null(jthread); |
2994 | return java_lang_Thread::is_alive(thread_oop); |
2995 | JVM_END} } |
2996 | |
2997 | |
2998 | JVM_ENTRY(void, JVM_SuspendThread(JNIEnv* env, jobject jthread))extern "C" { void JVM_SuspendThread(JNIEnv* env, jobject jthread ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
2999 | ThreadsListHandle tlh(thread); |
3000 | JavaThread* receiver = NULL__null; |
3001 | bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL__null); |
3002 | if (is_alive) { |
3003 | // jthread refers to a live JavaThread, but java_suspend() will |
3004 | // detect a thread that has started to exit and will ignore it. |
3005 | receiver->java_suspend(); |
3006 | } |
3007 | JVM_END} } |
3008 | |
3009 | |
3010 | JVM_ENTRY(void, JVM_ResumeThread(JNIEnv* env, jobject jthread))extern "C" { void JVM_ResumeThread(JNIEnv* env, jobject jthread ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3011 | ThreadsListHandle tlh(thread); |
3012 | JavaThread* receiver = NULL__null; |
3013 | bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL__null); |
3014 | if (is_alive) { |
3015 | // jthread refers to a live JavaThread. |
3016 | receiver->java_resume(); |
3017 | } |
3018 | JVM_END} } |
3019 | |
3020 | |
3021 | JVM_ENTRY(void, JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio))extern "C" { void JVM_SetThreadPriority(JNIEnv* env, jobject jthread , jint prio) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3022 | ThreadsListHandle tlh(thread); |
3023 | oop java_thread = NULL__null; |
3024 | JavaThread* receiver = NULL__null; |
3025 | bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, &java_thread); |
3026 | java_lang_Thread::set_priority(java_thread, (ThreadPriority)prio); |
3027 | |
3028 | if (is_alive) { |
3029 | // jthread refers to a live JavaThread. |
3030 | Thread::set_priority(receiver, (ThreadPriority)prio); |
3031 | } |
3032 | // Implied else: If the JavaThread hasn't started yet, then the |
3033 | // priority set in the java.lang.Thread object above will be pushed |
3034 | // down when it does start. |
3035 | JVM_END} } |
3036 | |
3037 | |
3038 | JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass))extern "C" { void JVM_Yield(JNIEnv *env, jclass threadClass) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3039 | if (os::dont_yield()) return; |
3040 | HOTSPOT_THREAD_YIELD(); |
3041 | os::naked_yield(); |
3042 | JVM_END} } |
3043 | |
3044 | static void post_thread_sleep_event(EventThreadSleep* event, jlong millis) { |
3045 | assert(event != NULL, "invariant")do { if (!(event != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3045, "assert(" "event != __null" ") failed", "invariant"); ::breakpoint(); } } while (0); |
3046 | assert(event->should_commit(), "invariant")do { if (!(event->should_commit())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3046, "assert(" "event->should_commit()" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
3047 | event->set_time(millis); |
3048 | event->commit(); |
3049 | } |
3050 | |
3051 | JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis))extern "C" { void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3052 | if (millis < 0) { |
3053 | THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3053, vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative" ); return; }; |
3054 | } |
3055 | |
3056 | if (thread->is_interrupted(true) && !HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) { |
3057 | THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3057, vmSymbols::java_lang_InterruptedException(), "sleep interrupted" ); return; }; |
3058 | } |
3059 | |
3060 | // Save current thread state and restore it at the end of this block. |
3061 | // And set new thread state to SLEEPING. |
3062 | JavaThreadSleepState jtss(thread); |
3063 | |
3064 | HOTSPOT_THREAD_SLEEP_BEGIN(millis); |
3065 | EventThreadSleep event; |
3066 | |
3067 | if (millis == 0) { |
3068 | os::naked_yield(); |
3069 | } else { |
3070 | ThreadState old_state = thread->osthread()->get_state(); |
3071 | thread->osthread()->set_state(SLEEPING); |
3072 | if (!thread->sleep(millis)) { // interrupted |
3073 | // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on |
3074 | // us while we were sleeping. We do not overwrite those. |
3075 | if (!HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) { |
3076 | if (event.should_commit()) { |
3077 | post_thread_sleep_event(&event, millis); |
3078 | } |
3079 | HOTSPOT_THREAD_SLEEP_END(1); |
3080 | |
3081 | // TODO-FIXME: THROW_MSG returns which means we will not call set_state() |
3082 | // to properly restore the thread state. That's likely wrong. |
3083 | THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3083, vmSymbols::java_lang_InterruptedException(), "sleep interrupted" ); return; }; |
3084 | } |
3085 | } |
3086 | thread->osthread()->set_state(old_state); |
3087 | } |
3088 | if (event.should_commit()) { |
3089 | post_thread_sleep_event(&event, millis); |
3090 | } |
3091 | HOTSPOT_THREAD_SLEEP_END(0); |
3092 | JVM_END} } |
3093 | |
3094 | JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass))extern "C" { jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3095 | oop jthread = thread->threadObj(); |
3096 | assert(jthread != NULL, "no current thread!")do { if (!(jthread != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3096, "assert(" "jthread != __null" ") failed", "no current thread!" ); ::breakpoint(); } } while (0); |
3097 | return JNIHandles::make_local(THREAD__the_thread__, jthread); |
3098 | JVM_END} } |
3099 | |
3100 | JVM_ENTRY(void, JVM_Interrupt(JNIEnv* env, jobject jthread))extern "C" { void JVM_Interrupt(JNIEnv* env, jobject jthread) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3101 | ThreadsListHandle tlh(thread); |
3102 | JavaThread* receiver = NULL__null; |
3103 | bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL__null); |
3104 | if (is_alive) { |
3105 | // jthread refers to a live JavaThread. |
3106 | receiver->interrupt(); |
3107 | } |
3108 | JVM_END} } |
3109 | |
3110 | |
3111 | // Return true iff the current thread has locked the object passed in |
3112 | |
3113 | JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj))extern "C" { jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass , jobject obj) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3114 | if (obj == NULL__null) { |
3115 | THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3115, vmSymbols::java_lang_NullPointerException(), __null); return 0; }; |
3116 | } |
3117 | Handle h_obj(THREAD__the_thread__, JNIHandles::resolve(obj)); |
3118 | return ObjectSynchronizer::current_thread_holds_lock(thread, h_obj); |
3119 | JVM_END} } |
3120 | |
3121 | |
3122 | JVM_ENTRY(void, JVM_DumpAllStacks(JNIEnv* env, jclass))extern "C" { void JVM_DumpAllStacks(JNIEnv* env, jclass) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3123 | VM_PrintThreads op; |
3124 | VMThread::execute(&op); |
3125 | if (JvmtiExport::should_post_data_dump()) { |
3126 | JvmtiExport::post_data_dump(); |
3127 | } |
3128 | JVM_END} } |
3129 | |
3130 | JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))extern "C" { void JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3131 | // We don't use a ThreadsListHandle here because the current thread |
3132 | // must be alive. |
3133 | oop java_thread = JNIHandles::resolve_non_null(jthread); |
3134 | JavaThread* thr = java_lang_Thread::thread(java_thread); |
3135 | if (thread == thr && !thr->has_attached_via_jni()) { |
3136 | // Thread naming is only supported for the current thread and |
3137 | // we don't set the name of an attached thread to avoid stepping |
3138 | // on other programs. |
3139 | ResourceMark rm(thread); |
3140 | const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); |
3141 | os::set_native_thread_name(thread_name); |
3142 | } |
3143 | JVM_END} } |
3144 | |
3145 | // java.lang.SecurityManager /////////////////////////////////////////////////////////////////////// |
3146 | |
3147 | JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))extern "C" { jobjectArray JVM_GetClassContext(JNIEnv *env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3148 | ResourceMark rm(THREAD__the_thread__); |
3149 | JvmtiVMObjectAllocEventCollector oam; |
3150 | vframeStream vfst(thread); |
3151 | |
3152 | if (vmClasses::reflect_CallerSensitive_klass() != NULL__null) { |
3153 | // This must only be called from SecurityManager.getClassContext |
3154 | Method* m = vfst.method(); |
3155 | if (!(m->method_holder() == vmClasses::SecurityManager_klass() && |
3156 | m->name() == vmSymbols::getClassContext_name() && |
3157 | m->signature() == vmSymbols::void_class_array_signature())) { |
3158 | THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3158, vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext" ); return __null; }; |
3159 | } |
3160 | } |
3161 | |
3162 | // Collect method holders |
3163 | GrowableArray<Klass*>* klass_array = new GrowableArray<Klass*>(); |
3164 | for (; !vfst.at_end(); vfst.security_next()) { |
3165 | Method* m = vfst.method(); |
3166 | // Native frames are not returned |
3167 | if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { |
3168 | Klass* holder = m->method_holder(); |
3169 | assert(holder->is_klass(), "just checking")do { if (!(holder->is_klass())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3169, "assert(" "holder->is_klass()" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
3170 | klass_array->append(holder); |
3171 | } |
3172 | } |
3173 | |
3174 | // Create result array of type [Ljava/lang/Class; |
3175 | objArrayOop result = oopFactory::new_objArray(vmClasses::Class_klass(), klass_array->length(), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3176 | // Fill in mirrors corresponding to method holders |
3177 | for (int i = 0; i < klass_array->length(); i++) { |
3178 | result->obj_at_put(i, klass_array->at(i)->java_mirror()); |
3179 | } |
3180 | |
3181 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result); |
3182 | JVM_END} } |
3183 | |
3184 | |
3185 | // java.lang.Package //////////////////////////////////////////////////////////////// |
3186 | |
3187 | |
3188 | JVM_ENTRY(jstring, JVM_GetSystemPackage(JNIEnv *env, jstring name))extern "C" { jstring JVM_GetSystemPackage(JNIEnv *env, jstring name) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3189 | ResourceMark rm(THREAD__the_thread__); |
3190 | JvmtiVMObjectAllocEventCollector oam; |
3191 | char* str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); |
3192 | oop result = ClassLoader::get_system_package(str, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3193 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, result); |
3194 | JVM_END} } |
3195 | |
3196 | |
3197 | JVM_ENTRY(jobjectArray, JVM_GetSystemPackages(JNIEnv *env))extern "C" { jobjectArray JVM_GetSystemPackages(JNIEnv *env) { JavaThread* thread=JavaThread::thread_from_jni_environment(env ); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3198 | JvmtiVMObjectAllocEventCollector oam; |
3199 | objArrayOop result = ClassLoader::get_system_packages(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3200 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result); |
3201 | JVM_END} } |
3202 | |
3203 | |
3204 | // java.lang.ref.Reference /////////////////////////////////////////////////////////////// |
3205 | |
3206 | |
3207 | JVM_ENTRY(jobject, JVM_GetAndClearReferencePendingList(JNIEnv* env))extern "C" { jobject JVM_GetAndClearReferencePendingList(JNIEnv * env) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3208 | MonitorLocker ml(Heap_lock); |
3209 | oop ref = Universe::reference_pending_list(); |
3210 | if (ref != NULL__null) { |
3211 | Universe::clear_reference_pending_list(); |
3212 | } |
3213 | return JNIHandles::make_local(THREAD__the_thread__, ref); |
3214 | JVM_END} } |
3215 | |
3216 | JVM_ENTRY(jboolean, JVM_HasReferencePendingList(JNIEnv* env))extern "C" { jboolean JVM_HasReferencePendingList(JNIEnv* env ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3217 | MonitorLocker ml(Heap_lock); |
3218 | return Universe::has_reference_pending_list(); |
3219 | JVM_END} } |
3220 | |
3221 | JVM_ENTRY(void, JVM_WaitForReferencePendingList(JNIEnv* env))extern "C" { void JVM_WaitForReferencePendingList(JNIEnv* env ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3222 | MonitorLocker ml(Heap_lock); |
3223 | while (!Universe::has_reference_pending_list()) { |
3224 | ml.wait(); |
3225 | } |
3226 | JVM_END} } |
3227 | |
3228 | JVM_ENTRY(jboolean, JVM_ReferenceRefersTo(JNIEnv* env, jobject ref, jobject o))extern "C" { jboolean JVM_ReferenceRefersTo(JNIEnv* env, jobject ref, jobject o) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3229 | oop ref_oop = JNIHandles::resolve_non_null(ref); |
3230 | oop referent = java_lang_ref_Reference::weak_referent_no_keepalive(ref_oop); |
3231 | return referent == JNIHandles::resolve(o); |
3232 | JVM_END} } |
3233 | |
3234 | JVM_ENTRY(void, JVM_ReferenceClear(JNIEnv* env, jobject ref))extern "C" { void JVM_ReferenceClear(JNIEnv* env, jobject ref ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3235 | oop ref_oop = JNIHandles::resolve_non_null(ref); |
3236 | // FinalReference has it's own implementation of clear(). |
3237 | assert(!java_lang_ref_Reference::is_final(ref_oop), "precondition")do { if (!(!java_lang_ref_Reference::is_final(ref_oop))) { (* g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3237, "assert(" "!java_lang_ref_Reference::is_final(ref_oop)" ") failed", "precondition"); ::breakpoint(); } } while (0); |
3238 | if (java_lang_ref_Reference::unknown_referent_no_keepalive(ref_oop) == NULL__null) { |
3239 | // If the referent has already been cleared then done. |
3240 | // However, if the referent is dead but has not yet been cleared by |
3241 | // concurrent reference processing, it should NOT be cleared here. |
3242 | // Instead, clearing should be left to the GC. Clearing it here could |
3243 | // detectably lose an expected notification, which is impossible with |
3244 | // STW reference processing. The clearing in enqueue() doesn't have |
3245 | // this problem, since the enqueue covers the notification, but it's not |
3246 | // worth the effort to handle that case specially. |
3247 | return; |
3248 | } |
3249 | java_lang_ref_Reference::clear_referent(ref_oop); |
3250 | JVM_END} } |
3251 | |
3252 | |
3253 | // java.lang.ref.PhantomReference ////////////////////////////////////////////////// |
3254 | |
3255 | |
3256 | JVM_ENTRY(jboolean, JVM_PhantomReferenceRefersTo(JNIEnv* env, jobject ref, jobject o))extern "C" { jboolean JVM_PhantomReferenceRefersTo(JNIEnv* env , jobject ref, jobject o) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3257 | oop ref_oop = JNIHandles::resolve_non_null(ref); |
3258 | oop referent = java_lang_ref_Reference::phantom_referent_no_keepalive(ref_oop); |
3259 | return referent == JNIHandles::resolve(o); |
3260 | JVM_END} } |
3261 | |
3262 | |
3263 | // ObjectInputStream /////////////////////////////////////////////////////////////// |
3264 | |
3265 | // Return the first user-defined class loader up the execution stack, or null |
3266 | // if only code from the bootstrap or platform class loader is on the stack. |
3267 | |
3268 | JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env))extern "C" { jobject JVM_LatestUserDefinedLoader(JNIEnv *env) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3269 | for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3270 | InstanceKlass* ik = vfst.method()->method_holder(); |
3271 | oop loader = ik->class_loader(); |
3272 | if (loader != NULL__null && !SystemDictionary::is_platform_class_loader(loader)) { |
3273 | // Skip reflection related frames |
3274 | if (!ik->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass()) && |
3275 | !ik->is_subclass_of(vmClasses::reflect_ConstructorAccessorImpl_klass())) { |
3276 | return JNIHandles::make_local(THREAD__the_thread__, loader); |
3277 | } |
3278 | } |
3279 | } |
3280 | return NULL__null; |
3281 | JVM_END} } |
3282 | |
3283 | |
3284 | // Array /////////////////////////////////////////////////////////////////////////////////////////// |
3285 | |
3286 | |
3287 | // resolve array handle and check arguments |
3288 | static inline arrayOop check_array(JNIEnv *env, jobject arr, bool type_array_only, TRAPSJavaThread* __the_thread__) { |
3289 | if (arr == NULL__null) { |
3290 | THROW_0(vmSymbols::java_lang_NullPointerException()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3290, vmSymbols::java_lang_NullPointerException(), __null); return 0; }; |
3291 | } |
3292 | oop a = JNIHandles::resolve_non_null(arr); |
3293 | if (!a->is_array()) { |
3294 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3294, vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array" ); return 0; }; |
3295 | } else if (type_array_only && !a->is_typeArray()) { |
3296 | THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array of primitive type"){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3296, vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array of primitive type" ); return 0; }; |
3297 | } |
3298 | return arrayOop(a); |
3299 | } |
3300 | |
3301 | |
3302 | JVM_ENTRY(jint, JVM_GetArrayLength(JNIEnv *env, jobject arr))extern "C" { jint JVM_GetArrayLength(JNIEnv *env, jobject arr ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3303 | arrayOop a = check_array(env, arr, false, CHECK_0__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return 0; (void)(0); |
3304 | return a->length(); |
3305 | JVM_END} } |
3306 | |
3307 | |
3308 | JVM_ENTRY(jobject, JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index))extern "C" { jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3309 | JvmtiVMObjectAllocEventCollector oam; |
3310 | arrayOop a = check_array(env, arr, false, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3311 | jvalue value; |
3312 | BasicType type = Reflection::array_get(&value, a, index, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3313 | oop box = Reflection::box(&value, type, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3314 | return JNIHandles::make_local(THREAD__the_thread__, box); |
3315 | JVM_END} } |
3316 | |
3317 | |
3318 | JVM_ENTRY(jvalue, JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode))extern "C" { jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3319 | jvalue value; |
3320 | value.i = 0; // to initialize value before getting used in CHECK |
3321 | arrayOop a = check_array(env, arr, true, CHECK_(value)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return value; (void)(0); |
3322 | assert(a->is_typeArray(), "just checking")do { if (!(a->is_typeArray())) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3322, "assert(" "a->is_typeArray()" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
3323 | BasicType type = Reflection::array_get(&value, a, index, CHECK_(value)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return value; (void)(0); |
3324 | BasicType wide_type = (BasicType) wCode; |
3325 | if (type != wide_type) { |
3326 | Reflection::widen(&value, type, wide_type, CHECK_(value)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return value; (void)(0); |
3327 | } |
3328 | return value; |
3329 | JVM_END} } |
3330 | |
3331 | |
3332 | JVM_ENTRY(void, JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val))extern "C" { void JVM_SetArrayElement(JNIEnv *env, jobject arr , jint index, jobject val) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3333 | arrayOop a = check_array(env, arr, false, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3334 | oop box = JNIHandles::resolve(val); |
3335 | jvalue value; |
3336 | value.i = 0; // to initialize value before getting used in CHECK |
3337 | BasicType value_type; |
3338 | if (a->is_objArray()) { |
3339 | // Make sure we do no unbox e.g. java/lang/Integer instances when storing into an object array |
3340 | value_type = Reflection::unbox_for_regular_object(box, &value); |
3341 | } else { |
3342 | value_type = Reflection::unbox_for_primitive(box, &value, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3343 | } |
3344 | Reflection::array_set(&value, a, index, value_type, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3345 | JVM_END} } |
3346 | |
3347 | |
3348 | JVM_ENTRY(void, JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode))extern "C" { void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3349 | arrayOop a = check_array(env, arr, true, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3350 | assert(a->is_typeArray(), "just checking")do { if (!(a->is_typeArray())) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3350, "assert(" "a->is_typeArray()" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
3351 | BasicType value_type = (BasicType) vCode; |
3352 | Reflection::array_set(&v, a, index, value_type, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3353 | JVM_END} } |
3354 | |
3355 | |
3356 | JVM_ENTRY(jobject, JVM_NewArray(JNIEnv *env, jclass eltClass, jint length))extern "C" { jobject JVM_NewArray(JNIEnv *env, jclass eltClass , jint length) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3357 | JvmtiVMObjectAllocEventCollector oam; |
3358 | oop element_mirror = JNIHandles::resolve(eltClass); |
3359 | oop result = Reflection::reflect_new_array(element_mirror, length, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3360 | return JNIHandles::make_local(THREAD__the_thread__, result); |
3361 | JVM_END} } |
3362 | |
3363 | |
3364 | JVM_ENTRY(jobject, JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim))extern "C" { jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass , jintArray dim) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3365 | JvmtiVMObjectAllocEventCollector oam; |
3366 | arrayOop dim_array = check_array(env, dim, true, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3367 | oop element_mirror = JNIHandles::resolve(eltClass); |
3368 | assert(dim_array->is_typeArray(), "just checking")do { if (!(dim_array->is_typeArray())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3368, "assert(" "dim_array->is_typeArray()" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
3369 | oop result = Reflection::reflect_new_multi_array(element_mirror, typeArrayOop(dim_array), CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3370 | return JNIHandles::make_local(THREAD__the_thread__, result); |
3371 | JVM_END} } |
3372 | |
3373 | |
3374 | // Library support /////////////////////////////////////////////////////////////////////////// |
3375 | |
3376 | JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name, jboolean throwException))extern "C" { void* JVM_LoadLibrary(const char* name, jboolean throwException) { JavaThread* thread = JavaThread::current() ; ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew ; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3377 | //%note jvm_ct |
3378 | char ebuf[1024]; |
3379 | void *load_result; |
3380 | { |
3381 | ThreadToNativeFromVM ttnfvm(thread); |
3382 | load_result = os::dll_load(name, ebuf, sizeof ebuf); |
3383 | } |
3384 | if (load_result == NULL__null) { |
3385 | if (throwException) { |
3386 | char msg[1024]; |
3387 | jio_snprintf(msg, sizeof msg, "%s: %s", name, ebuf); |
3388 | // Since 'ebuf' may contain a string encoded using |
3389 | // platform encoding scheme, we need to pass |
3390 | // Exceptions::unsafe_to_utf8 to the new_exception method |
3391 | // as the last argument. See bug 6367357. |
3392 | Handle h_exception = |
3393 | Exceptions::new_exception(thread, |
3394 | vmSymbols::java_lang_UnsatisfiedLinkError(), |
3395 | msg, Exceptions::unsafe_to_utf8); |
3396 | |
3397 | THROW_HANDLE_0(h_exception){ Exceptions::_throw(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3397, h_exception); return 0; }; |
3398 | } else { |
3399 | log_info(library)(!(LogImpl<(LogTag::_library), (LogTag::__NO_TAG), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Info))) ? (void)0 : LogImpl <(LogTag::_library), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Info>("Failed to load library %s", name); |
3400 | return load_result; |
3401 | } |
3402 | } |
3403 | log_info(library)(!(LogImpl<(LogTag::_library), (LogTag::__NO_TAG), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Info))) ? (void)0 : LogImpl <(LogTag::_library), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Info>("Loaded library %s, handle " INTPTR_FORMAT"0x%016" "l" "x", name, p2i(load_result)); |
3404 | return load_result; |
3405 | JVM_END} } |
3406 | |
3407 | |
3408 | JVM_LEAF(void, JVM_UnloadLibrary(void* handle))extern "C" { void JVM_UnloadLibrary(void* handle) { VM_Exit:: block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
3409 | os::dll_unload(handle); |
3410 | log_info(library)(!(LogImpl<(LogTag::_library), (LogTag::__NO_TAG), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Info))) ? (void)0 : LogImpl <(LogTag::_library), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Info>("Unloaded library with handle " INTPTR_FORMAT"0x%016" "l" "x", p2i(handle)); |
3411 | JVM_END} } |
3412 | |
3413 | |
3414 | JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name))extern "C" { void* JVM_FindLibraryEntry(void* handle, const char * name) { VM_Exit::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment(); |
3415 | void* find_result = os::dll_lookup(handle, name); |
3416 | log_info(library)(!(LogImpl<(LogTag::_library), (LogTag::__NO_TAG), (LogTag ::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag:: __NO_TAG)>::is_level(LogLevel::Info))) ? (void)0 : LogImpl <(LogTag::_library), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::write<LogLevel::Info>("%s %s in library with handle " INTPTR_FORMAT"0x%016" "l" "x", |
3417 | find_result != NULL__null ? "Found" : "Failed to find", |
3418 | name, p2i(handle)); |
3419 | return find_result; |
3420 | JVM_END} } |
3421 | |
3422 | |
3423 | // JNI version /////////////////////////////////////////////////////////////////////////////// |
3424 | |
3425 | JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version))extern "C" { jboolean JVM_IsSupportedJNIVersion(jint version) { VM_Exit::block_if_vm_exited(); NoHandleMark __hm; ; os::verify_stack_alignment (); |
3426 | return Threads::is_supported_jni_version_including_1_1(version); |
3427 | JVM_END} } |
3428 | |
3429 | |
3430 | // String support /////////////////////////////////////////////////////////////////////////// |
3431 | |
3432 | JVM_ENTRY(jstring, JVM_InternString(JNIEnv *env, jstring str))extern "C" { jstring JVM_InternString(JNIEnv *env, jstring str ) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3433 | JvmtiVMObjectAllocEventCollector oam; |
3434 | if (str == NULL__null) return NULL__null; |
3435 | oop string = JNIHandles::resolve_non_null(str); |
3436 | oop result = StringTable::intern(string, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3437 | return (jstring) JNIHandles::make_local(THREAD__the_thread__, result); |
3438 | JVM_END} } |
3439 | |
3440 | |
3441 | // VM Raw monitor support ////////////////////////////////////////////////////////////////////// |
3442 | |
3443 | // VM Raw monitors (not to be confused with JvmtiRawMonitors) are a simple mutual exclusion |
3444 | // lock (not actually monitors: no wait/notify) that is exported by the VM for use by JDK |
3445 | // library code. They may be used by JavaThreads and non-JavaThreads and do not participate |
3446 | // in the safepoint protocol, thread suspension, thread interruption, or anything of that |
3447 | // nature. JavaThreads will be "in native" when using this API from JDK code. |
3448 | |
3449 | |
3450 | JNIEXPORT__attribute__((visibility("default"))) void* JNICALL JVM_RawMonitorCreate(void) { |
3451 | VM_Exit::block_if_vm_exited(); |
3452 | return new os::PlatformMutex(); |
3453 | } |
3454 | |
3455 | |
3456 | JNIEXPORT__attribute__((visibility("default"))) void JNICALL JVM_RawMonitorDestroy(void *mon) { |
3457 | VM_Exit::block_if_vm_exited(); |
3458 | delete ((os::PlatformMutex*) mon); |
3459 | } |
3460 | |
3461 | |
3462 | JNIEXPORT__attribute__((visibility("default"))) jint JNICALL JVM_RawMonitorEnter(void *mon) { |
3463 | VM_Exit::block_if_vm_exited(); |
3464 | ((os::PlatformMutex*) mon)->lock(); |
3465 | return 0; |
3466 | } |
3467 | |
3468 | |
3469 | JNIEXPORT__attribute__((visibility("default"))) void JNICALL JVM_RawMonitorExit(void *mon) { |
3470 | VM_Exit::block_if_vm_exited(); |
3471 | ((os::PlatformMutex*) mon)->unlock(); |
3472 | } |
3473 | |
3474 | |
3475 | // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3476 | |
3477 | jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, |
3478 | Handle loader, Handle protection_domain, |
3479 | jboolean throwError, TRAPSJavaThread* __the_thread__) { |
3480 | // Security Note: |
3481 | // The Java level wrapper will perform the necessary security check allowing |
3482 | // us to pass the NULL as the initiating class loader. The VM is responsible for |
3483 | // the checkPackageAccess relative to the initiating class loader via the |
3484 | // protection_domain. The protection_domain is passed as NULL by the java code |
3485 | // if there is no security manager in 3-arg Class.forName(). |
3486 | Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3487 | |
3488 | // Check if we should initialize the class |
3489 | if (init && klass->is_instance_klass()) { |
3490 | klass->initialize(CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3491 | } |
3492 | return (jclass) JNIHandles::make_local(THREAD__the_thread__, klass->java_mirror()); |
3493 | } |
3494 | |
3495 | |
3496 | // Method /////////////////////////////////////////////////////////////////////////////////////////// |
3497 | |
3498 | JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0))extern "C" { jobject JVM_InvokeMethod(JNIEnv *env, jobject method , jobject obj, jobjectArray args0) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3499 | Handle method_handle; |
3500 | if (thread->stack_overflow_state()->stack_available((address) &method_handle) >= JVMInvokeMethodSlack) { |
3501 | method_handle = Handle(THREAD__the_thread__, JNIHandles::resolve(method)); |
3502 | Handle receiver(THREAD__the_thread__, JNIHandles::resolve(obj)); |
3503 | objArrayHandle args(THREAD__the_thread__, objArrayOop(JNIHandles::resolve(args0))); |
3504 | oop result = Reflection::invoke_method(method_handle(), receiver, args, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3505 | jobject res = JNIHandles::make_local(THREAD__the_thread__, result); |
3506 | if (JvmtiExport::should_post_vm_object_alloc()) { |
3507 | oop ret_type = java_lang_reflect_Method::return_type(method_handle()); |
3508 | assert(ret_type != NULL, "sanity check: ret_type oop must not be NULL!")do { if (!(ret_type != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3508, "assert(" "ret_type != __null" ") failed", "sanity check: ret_type oop must not be NULL!" ); ::breakpoint(); } } while (0); |
3509 | if (java_lang_Class::is_primitive(ret_type)) { |
3510 | // Only for primitive type vm allocates memory for java object. |
3511 | // See box() method. |
3512 | JvmtiExport::post_vm_object_alloc(thread, result); |
3513 | } |
3514 | } |
3515 | return res; |
3516 | } else { |
3517 | THROW_0(vmSymbols::java_lang_StackOverflowError()){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3517, vmSymbols::java_lang_StackOverflowError(), __null); return 0; }; |
3518 | } |
3519 | JVM_END} } |
3520 | |
3521 | |
3522 | JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0))extern "C" { jobject JVM_NewInstanceFromConstructor(JNIEnv *env , jobject c, jobjectArray args0) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3523 | oop constructor_mirror = JNIHandles::resolve(c); |
3524 | objArrayHandle args(THREAD__the_thread__, objArrayOop(JNIHandles::resolve(args0))); |
3525 | oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3526 | jobject res = JNIHandles::make_local(THREAD__the_thread__, result); |
3527 | if (JvmtiExport::should_post_vm_object_alloc()) { |
3528 | JvmtiExport::post_vm_object_alloc(thread, result); |
3529 | } |
3530 | return res; |
3531 | JVM_END} } |
3532 | |
3533 | // Atomic /////////////////////////////////////////////////////////////////////////////////////////// |
3534 | |
3535 | JVM_LEAF(jboolean, JVM_SupportsCX8())extern "C" { jboolean JVM_SupportsCX8() { VM_Exit::block_if_vm_exited (); NoHandleMark __hm; ; os::verify_stack_alignment(); |
3536 | return VM_Version::supports_cx8(); |
3537 | JVM_END} } |
3538 | |
3539 | JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls))extern "C" { void JVM_InitializeFromArchive(JNIEnv* env, jclass cls) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3540 | Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
3541 | assert(k->is_klass(), "just checking")do { if (!(k->is_klass())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3541, "assert(" "k->is_klass()" ") failed", "just checking" ); ::breakpoint(); } } while (0); |
3542 | HeapShared::initialize_from_archived_subgraph(k, THREAD__the_thread__); |
3543 | JVM_END} } |
3544 | |
3545 | JVM_ENTRY(void, JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3546 | jclass caller,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3547 | jstring interfaceMethodName,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3548 | jobject factoryType,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3549 | jobject interfaceMethodType,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3550 | jobject implementationMember,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3551 | jobject dynamicMethodType,extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3552 | jclass lambdaProxyClass))extern "C" { void JVM_RegisterLambdaProxyClassForArchiving(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType, jclass lambdaProxyClass) { JavaThread* thread =JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3553 | #if INCLUDE_CDS1 |
3554 | if (!Arguments::is_dumping_archive()) { |
3555 | return; |
3556 | } |
3557 | |
3558 | Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller)); |
3559 | InstanceKlass* caller_ik = InstanceKlass::cast(caller_k); |
3560 | if (caller_ik->is_hidden()) { |
3561 | // Hidden classes not of type lambda proxy classes are currently not being archived. |
3562 | // If the caller_ik is of one of the above types, the corresponding lambda proxy class won't be |
3563 | // registered for archiving. |
3564 | return; |
3565 | } |
3566 | Klass* lambda_k = java_lang_Class::as_Klass(JNIHandles::resolve(lambdaProxyClass)); |
3567 | InstanceKlass* lambda_ik = InstanceKlass::cast(lambda_k); |
3568 | assert(lambda_ik->is_hidden(), "must be a hidden class")do { if (!(lambda_ik->is_hidden())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3568, "assert(" "lambda_ik->is_hidden()" ") failed", "must be a hidden class" ); ::breakpoint(); } } while (0); |
3569 | assert(!lambda_ik->is_non_strong_hidden(), "expected a strong hidden class")do { if (!(!lambda_ik->is_non_strong_hidden())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3569, "assert(" "!lambda_ik->is_non_strong_hidden()" ") failed" , "expected a strong hidden class"); ::breakpoint(); } } while (0); |
3570 | |
3571 | Symbol* interface_method_name = NULL__null; |
3572 | if (interfaceMethodName != NULL__null) { |
3573 | interface_method_name = java_lang_String::as_symbol(JNIHandles::resolve_non_null(interfaceMethodName)); |
3574 | } |
3575 | Handle factory_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(factoryType)); |
3576 | Symbol* factory_type = java_lang_invoke_MethodType::as_signature(factory_type_oop(), true); |
3577 | |
3578 | Handle interface_method_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(interfaceMethodType)); |
3579 | Symbol* interface_method_type = java_lang_invoke_MethodType::as_signature(interface_method_type_oop(), true); |
3580 | |
3581 | Handle implementation_member_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(implementationMember)); |
3582 | assert(java_lang_invoke_MemberName::is_method(implementation_member_oop()), "must be")do { if (!(java_lang_invoke_MemberName::is_method(implementation_member_oop ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3582, "assert(" "java_lang_invoke_MemberName::is_method(implementation_member_oop())" ") failed", "must be"); ::breakpoint(); } } while (0); |
3583 | Method* m = java_lang_invoke_MemberName::vmtarget(implementation_member_oop()); |
3584 | |
3585 | Handle dynamic_method_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(dynamicMethodType)); |
3586 | Symbol* dynamic_method_type = java_lang_invoke_MethodType::as_signature(dynamic_method_type_oop(), true); |
3587 | |
3588 | SystemDictionaryShared::add_lambda_proxy_class(caller_ik, lambda_ik, interface_method_name, factory_type, |
3589 | interface_method_type, m, dynamic_method_type, THREAD__the_thread__); |
3590 | #endif // INCLUDE_CDS |
3591 | JVM_END} } |
3592 | |
3593 | JVM_ENTRY(jclass, JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3594 | jclass caller,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3595 | jstring interfaceMethodName,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3596 | jobject factoryType,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3597 | jobject interfaceMethodType,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3598 | jobject implementationMember,extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3599 | jobject dynamicMethodType))extern "C" { jclass JVM_LookupLambdaProxyClassFromArchive(JNIEnv * env, jclass caller, jstring interfaceMethodName, jobject factoryType , jobject interfaceMethodType, jobject implementationMember, jobject dynamicMethodType) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3600 | #if INCLUDE_CDS1 |
3601 | |
3602 | if (interfaceMethodName == NULL__null || factoryType == NULL__null || interfaceMethodType == NULL__null || |
3603 | implementationMember == NULL__null || dynamicMethodType == NULL__null) { |
3604 | THROW_(vmSymbols::java_lang_NullPointerException(), NULL){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3604, vmSymbols::java_lang_NullPointerException(), __null); return __null; }; |
3605 | } |
3606 | |
3607 | Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller)); |
3608 | InstanceKlass* caller_ik = InstanceKlass::cast(caller_k); |
3609 | if (!caller_ik->is_shared()) { |
3610 | // there won't be a shared lambda class if the caller_ik is not in the shared archive. |
3611 | return NULL__null; |
3612 | } |
3613 | |
3614 | Symbol* interface_method_name = java_lang_String::as_symbol(JNIHandles::resolve_non_null(interfaceMethodName)); |
3615 | Handle factory_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(factoryType)); |
3616 | Symbol* factory_type = java_lang_invoke_MethodType::as_signature(factory_type_oop(), true); |
3617 | |
3618 | Handle interface_method_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(interfaceMethodType)); |
3619 | Symbol* interface_method_type = java_lang_invoke_MethodType::as_signature(interface_method_type_oop(), true); |
3620 | |
3621 | Handle implementation_member_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(implementationMember)); |
3622 | assert(java_lang_invoke_MemberName::is_method(implementation_member_oop()), "must be")do { if (!(java_lang_invoke_MemberName::is_method(implementation_member_oop ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3622, "assert(" "java_lang_invoke_MemberName::is_method(implementation_member_oop())" ") failed", "must be"); ::breakpoint(); } } while (0); |
3623 | Method* m = java_lang_invoke_MemberName::vmtarget(implementation_member_oop()); |
3624 | |
3625 | Handle dynamic_method_type_oop(THREAD__the_thread__, JNIHandles::resolve_non_null(dynamicMethodType)); |
3626 | Symbol* dynamic_method_type = java_lang_invoke_MethodType::as_signature(dynamic_method_type_oop(), true); |
3627 | |
3628 | InstanceKlass* lambda_ik = SystemDictionaryShared::get_shared_lambda_proxy_class(caller_ik, interface_method_name, factory_type, |
3629 | interface_method_type, m, dynamic_method_type); |
3630 | jclass jcls = NULL__null; |
3631 | if (lambda_ik != NULL__null) { |
3632 | InstanceKlass* loaded_lambda = SystemDictionaryShared::prepare_shared_lambda_proxy_class(lambda_ik, caller_ik, THREAD__the_thread__); |
3633 | jcls = loaded_lambda == NULL__null ? NULL__null : (jclass) JNIHandles::make_local(THREAD__the_thread__, loaded_lambda->java_mirror()); |
3634 | } |
3635 | return jcls; |
3636 | #else |
3637 | return NULL__null; |
3638 | #endif // INCLUDE_CDS |
3639 | JVM_END} } |
3640 | |
3641 | JVM_ENTRY(jboolean, JVM_IsCDSDumpingEnabled(JNIEnv* env))extern "C" { jboolean JVM_IsCDSDumpingEnabled(JNIEnv* env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3642 | return Arguments::is_dumping_archive(); |
3643 | JVM_END} } |
3644 | |
3645 | JVM_ENTRY(jboolean, JVM_IsSharingEnabled(JNIEnv* env))extern "C" { jboolean JVM_IsSharingEnabled(JNIEnv* env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3646 | return UseSharedSpaces; |
3647 | JVM_END} } |
3648 | |
3649 | JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForDumping())extern "C" { jlong JVM_GetRandomSeedForDumping() { JavaThread * thread = JavaThread::current(); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3650 | if (DumpSharedSpaces) { |
3651 | const char* release = VM_Version::vm_release(); |
3652 | const char* dbg_level = VM_Version::jdk_debug_level(); |
3653 | const char* version = VM_Version::internal_vm_info_string(); |
3654 | jlong seed = (jlong)(java_lang_String::hash_code((const jbyte*)release, (int)strlen(release)) ^ |
3655 | java_lang_String::hash_code((const jbyte*)dbg_level, (int)strlen(dbg_level)) ^ |
3656 | java_lang_String::hash_code((const jbyte*)version, (int)strlen(version))); |
3657 | seed += (jlong)VM_Version::vm_major_version(); |
3658 | seed += (jlong)VM_Version::vm_minor_version(); |
3659 | seed += (jlong)VM_Version::vm_security_version(); |
3660 | seed += (jlong)VM_Version::vm_patch_version(); |
3661 | if (seed == 0) { // don't let this ever be zero. |
3662 | seed = 0x87654321; |
3663 | } |
3664 | log_debug(cds)(!(LogImpl<(LogTag::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG) >::is_level(LogLevel::Debug))) ? (void)0 : LogImpl<(LogTag ::_cds), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG ), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel ::Debug>("JVM_GetRandomSeedForDumping() = " JLONG_FORMAT"%" "l" "d", seed); |
3665 | return seed; |
3666 | } else { |
3667 | return 0; |
3668 | } |
3669 | JVM_END} } |
3670 | |
3671 | JVM_ENTRY(jboolean, JVM_IsDumpingClassList(JNIEnv *env))extern "C" { jboolean JVM_IsDumpingClassList(JNIEnv *env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3672 | #if INCLUDE_CDS1 |
3673 | return ClassListWriter::is_enabled() || DynamicDumpSharedSpaces; |
3674 | #else |
3675 | return false; |
3676 | #endif // INCLUDE_CDS |
3677 | JVM_END} } |
3678 | |
3679 | JVM_ENTRY(void, JVM_LogLambdaFormInvoker(JNIEnv *env, jstring line))extern "C" { void JVM_LogLambdaFormInvoker(JNIEnv *env, jstring line) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3680 | #if INCLUDE_CDS1 |
3681 | assert(ClassListWriter::is_enabled() || DynamicDumpSharedSpaces, "Should be set and open or do dynamic dump")do { if (!(ClassListWriter::is_enabled() || DynamicDumpSharedSpaces )) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3681, "assert(" "ClassListWriter::is_enabled() || DynamicDumpSharedSpaces" ") failed", "Should be set and open or do dynamic dump"); :: breakpoint(); } } while (0); |
3682 | if (line != NULL__null) { |
3683 | ResourceMark rm(THREAD__the_thread__); |
3684 | Handle h_line (THREAD__the_thread__, JNIHandles::resolve_non_null(line)); |
3685 | char* c_line = java_lang_String::as_utf8_string(h_line()); |
3686 | if (DynamicDumpSharedSpaces) { |
3687 | // Note: LambdaFormInvokers::append_filtered and LambdaFormInvokers::append take same format which is not |
3688 | // same as below the print format. The line does not include LAMBDA_FORM_TAG. |
3689 | LambdaFormInvokers::append_filtered(os::strdup((const char*)c_line, mtInternal)); |
3690 | } |
3691 | if (ClassListWriter::is_enabled()) { |
3692 | ClassListWriter w; |
3693 | w.stream()->print_cr("%s %s", LAMBDA_FORM_TAG"@lambda-form-invoker", c_line); |
3694 | } |
3695 | } |
3696 | #endif // INCLUDE_CDS |
3697 | JVM_END} } |
3698 | |
3699 | JVM_ENTRY(void, JVM_DumpClassListToFile(JNIEnv *env, jstring listFileName))extern "C" { void JVM_DumpClassListToFile(JNIEnv *env, jstring listFileName) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3700 | #if INCLUDE_CDS1 |
3701 | ResourceMark rm(THREAD__the_thread__); |
3702 | Handle file_handle(THREAD__the_thread__, JNIHandles::resolve_non_null(listFileName)); |
3703 | char* file_name = java_lang_String::as_utf8_string(file_handle()); |
3704 | MetaspaceShared::dump_loaded_classes(file_name, THREAD__the_thread__); |
3705 | #endif // INCLUDE_CDS |
3706 | JVM_END} } |
3707 | |
3708 | JVM_ENTRY(void, JVM_DumpDynamicArchive(JNIEnv *env, jstring archiveName))extern "C" { void JVM_DumpDynamicArchive(JNIEnv *env, jstring archiveName) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3709 | #if INCLUDE_CDS1 |
3710 | ResourceMark rm(THREAD__the_thread__); |
3711 | Handle file_handle(THREAD__the_thread__, JNIHandles::resolve_non_null(archiveName)); |
3712 | char* archive_name = java_lang_String::as_utf8_string(file_handle()); |
3713 | DynamicArchive::dump_for_jcmd(archive_name, CHECK__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return ; (void)(0); |
3714 | #endif // INCLUDE_CDS |
3715 | JVM_END} } |
3716 | |
3717 | // Returns an array of all live Thread objects (VM internal JavaThreads, |
3718 | // jvmti agent threads, and JNI attaching threads are skipped) |
3719 | // See CR 6404306 regarding JNI attaching threads |
3720 | JVM_ENTRY(jobjectArray, JVM_GetAllThreads(JNIEnv *env, jclass dummy))extern "C" { jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3721 | ResourceMark rm(THREAD__the_thread__); |
3722 | ThreadsListEnumerator tle(THREAD__the_thread__, false, false); |
3723 | JvmtiVMObjectAllocEventCollector oam; |
3724 | |
3725 | int num_threads = tle.num_threads(); |
3726 | objArrayOop r = oopFactory::new_objArray(vmClasses::Thread_klass(), num_threads, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3727 | objArrayHandle threads_ah(THREAD__the_thread__, r); |
3728 | |
3729 | for (int i = 0; i < num_threads; i++) { |
3730 | Handle h = tle.get_threadObj(i); |
3731 | threads_ah->obj_at_put(i, h()); |
3732 | } |
3733 | |
3734 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, threads_ah()); |
3735 | JVM_END} } |
3736 | |
3737 | |
3738 | // Support for java.lang.Thread.getStackTrace() and getAllStackTraces() methods |
3739 | // Return StackTraceElement[][], each element is the stack trace of a thread in |
3740 | // the corresponding entry in the given threads array |
3741 | JVM_ENTRY(jobjectArray, JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads))extern "C" { jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads) { JavaThread* thread=JavaThread ::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3742 | JvmtiVMObjectAllocEventCollector oam; |
3743 | |
3744 | // Check if threads is null |
3745 | if (threads == NULL__null) { |
3746 | THROW_(vmSymbols::java_lang_NullPointerException(), 0){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3746, vmSymbols::java_lang_NullPointerException(), __null); return 0; }; |
3747 | } |
3748 | |
3749 | objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(threads)); |
3750 | objArrayHandle ah(THREAD__the_thread__, a); |
3751 | int num_threads = ah->length(); |
3752 | // check if threads is non-empty array |
3753 | if (num_threads == 0) { |
3754 | THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3754, vmSymbols::java_lang_IllegalArgumentException(), __null ); return 0; }; |
3755 | } |
3756 | |
3757 | // check if threads is not an array of objects of Thread class |
3758 | Klass* k = ObjArrayKlass::cast(ah->klass())->element_klass(); |
3759 | if (k != vmClasses::Thread_klass()) { |
3760 | THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0){ Exceptions::_throw_msg(__the_thread__, "/home/daniel/Projects/java/jdk/src/hotspot/share/prims/jvm.cpp" , 3760, vmSymbols::java_lang_IllegalArgumentException(), __null ); return 0; }; |
3761 | } |
3762 | |
3763 | ResourceMark rm(THREAD__the_thread__); |
3764 | |
3765 | GrowableArray<instanceHandle>* thread_handle_array = new GrowableArray<instanceHandle>(num_threads); |
3766 | for (int i = 0; i < num_threads; i++) { |
3767 | oop thread_obj = ah->obj_at(i); |
3768 | instanceHandle h(THREAD__the_thread__, (instanceOop) thread_obj); |
3769 | thread_handle_array->append(h); |
3770 | } |
3771 | |
3772 | // The JavaThread references in thread_handle_array are validated |
3773 | // in VM_ThreadDump::doit(). |
3774 | Handle stacktraces = ThreadService::dump_stack_traces(thread_handle_array, num_threads, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3775 | return (jobjectArray)JNIHandles::make_local(THREAD__the_thread__, stacktraces()); |
3776 | |
3777 | JVM_END} } |
3778 | |
3779 | // JVM monitoring and management support |
3780 | JVM_ENTRY_NO_ENV(void*, JVM_GetManagement(jint version))extern "C" { void* JVM_GetManagement(jint version) { JavaThread * thread = JavaThread::current(); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3781 | return Management::get_jmm_interface(version); |
3782 | JVM_END} } |
3783 | |
3784 | // com.sun.tools.attach.VirtualMachine agent properties support |
3785 | // |
3786 | // Initialize the agent properties with the properties maintained in the VM |
3787 | JVM_ENTRY(jobject, JVM_InitAgentProperties(JNIEnv *env, jobject properties))extern "C" { jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3788 | ResourceMark rm; |
3789 | |
3790 | Handle props(THREAD__the_thread__, JNIHandles::resolve_non_null(properties)); |
3791 | |
3792 | PUTPROP(props, "sun.java.command", Arguments::java_command())set_property((props), ("sun.java.command"), (Arguments::java_command ()), __the_thread__); if ((((ThreadShadow*)__the_thread__)-> has_pending_exception())) return properties; (void)(0);; |
3793 | PUTPROP(props, "sun.jvm.flags", Arguments::jvm_flags())set_property((props), ("sun.jvm.flags"), (Arguments::jvm_flags ()), __the_thread__); if ((((ThreadShadow*)__the_thread__)-> has_pending_exception())) return properties; (void)(0);; |
3794 | PUTPROP(props, "sun.jvm.args", Arguments::jvm_args())set_property((props), ("sun.jvm.args"), (Arguments::jvm_args( )), __the_thread__); if ((((ThreadShadow*)__the_thread__)-> has_pending_exception())) return properties; (void)(0);; |
3795 | return properties; |
3796 | JVM_END} } |
3797 | |
3798 | JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass))extern "C" { jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv * env, jclass ofClass) { JavaThread* thread=JavaThread::thread_from_jni_environment (env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment(); |
3799 | { |
3800 | JvmtiVMObjectAllocEventCollector oam; |
3801 | |
3802 | if (ofClass == NULL__null) { |
3803 | return NULL__null; |
3804 | } |
3805 | Handle mirror(THREAD__the_thread__, JNIHandles::resolve_non_null(ofClass)); |
3806 | // Special handling for primitive objects |
3807 | if (java_lang_Class::is_primitive(mirror())) { |
3808 | return NULL__null; |
3809 | } |
3810 | Klass* k = java_lang_Class::as_Klass(mirror()); |
3811 | if (!k->is_instance_klass()) { |
3812 | return NULL__null; |
3813 | } |
3814 | InstanceKlass* ik = InstanceKlass::cast(k); |
3815 | int encl_method_class_idx = ik->enclosing_method_class_index(); |
3816 | if (encl_method_class_idx == 0) { |
3817 | return NULL__null; |
3818 | } |
3819 | objArrayOop dest_o = oopFactory::new_objArray(vmClasses::Object_klass(), 3, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3820 | objArrayHandle dest(THREAD__the_thread__, dest_o); |
3821 | Klass* enc_k = ik->constants()->klass_at(encl_method_class_idx, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3822 | dest->obj_at_put(0, enc_k->java_mirror()); |
3823 | int encl_method_method_idx = ik->enclosing_method_method_index(); |
3824 | if (encl_method_method_idx != 0) { |
3825 | Symbol* sym = ik->constants()->symbol_at( |
3826 | extract_low_short_from_int( |
3827 | ik->constants()->name_and_type_at(encl_method_method_idx))); |
3828 | Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3829 | dest->obj_at_put(1, str()); |
3830 | sym = ik->constants()->symbol_at( |
3831 | extract_high_short_from_int( |
3832 | ik->constants()->name_and_type_at(encl_method_method_idx))); |
3833 | str = java_lang_String::create_from_symbol(sym, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3834 | dest->obj_at_put(2, str()); |
3835 | } |
3836 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, dest()); |
3837 | } |
3838 | JVM_END} } |
3839 | |
3840 | // Returns an array of java.lang.String objects containing the input arguments to the VM. |
3841 | JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))extern "C" { jobjectArray JVM_GetVmArguments(JNIEnv *env) { JavaThread * thread=JavaThread::thread_from_jni_environment(env); ; ThreadInVMfromNative __tiv(thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm(thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3842 | ResourceMark rm(THREAD__the_thread__); |
3843 | |
3844 | if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) { |
3845 | return NULL__null; |
3846 | } |
3847 | |
3848 | char** vm_flags = Arguments::jvm_flags_array(); |
3849 | char** vm_args = Arguments::jvm_args_array(); |
3850 | int num_flags = Arguments::num_jvm_flags(); |
3851 | int num_args = Arguments::num_jvm_args(); |
3852 | |
3853 | InstanceKlass* ik = vmClasses::String_klass(); |
3854 | objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3855 | objArrayHandle result_h(THREAD__the_thread__, r); |
3856 | |
3857 | int index = 0; |
3858 | for (int j = 0; j < num_flags; j++, index++) { |
3859 | Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3860 | result_h->obj_at_put(index, h()); |
3861 | } |
3862 | for (int i = 0; i < num_args; i++, index++) { |
3863 | Handle h = java_lang_String::create_from_platform_dependent_str(vm_args[i], CHECK_NULL__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return __null; (void)(0); |
3864 | result_h->obj_at_put(index, h()); |
3865 | } |
3866 | return (jobjectArray) JNIHandles::make_local(THREAD__the_thread__, result_h()); |
3867 | JVM_END} } |
3868 | |
3869 | JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))extern "C" { jint JVM_FindSignal(const char *name) { JavaThread * thread = JavaThread::current(); ; ThreadInVMfromNative __tiv (thread); VMNativeEntryWrapper __vew; HandleMarkCleaner __hm( thread); JavaThread* __the_thread__ = thread; os::verify_stack_alignment (); |
3870 | return os::get_signal_number(name); |
3871 | JVM_END} } |
3872 |