Mercurial > hg > truffle
annotate src/share/vm/prims/jvm.cpp @ 7788:dbbe8ce3bfa5
commands: accept 'server0' as a vm, accept version number which have '-...' suffix (-internal, -ea...)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 13 Feb 2013 18:33:54 +0100 |
parents | 3ac7d10a6572 |
children | 5fc51c1ecdeb |
rev | line source |
---|---|
0 | 1 /* |
7624
b14da2e6f2dc
7174978: NPG: Fix bactrace builder for class redefinition
coleenp
parents:
7588
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1324
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1324
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1324
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/classLoader.hpp" | |
27 #include "classfile/javaAssertions.hpp" | |
28 #include "classfile/javaClasses.hpp" | |
29 #include "classfile/symbolTable.hpp" | |
30 #include "classfile/systemDictionary.hpp" | |
31 #include "classfile/vmSymbols.hpp" | |
32 #include "gc_interface/collectedHeap.inline.hpp" | |
33 #include "memory/oopFactory.hpp" | |
34 #include "memory/universe.inline.hpp" | |
3938 | 35 #include "oops/fieldStreams.hpp" |
1972 | 36 #include "oops/instanceKlass.hpp" |
37 #include "oops/objArrayKlass.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
38 #include "oops/method.hpp" |
1972 | 39 #include "prims/jvm.h" |
40 #include "prims/jvm_misc.hpp" | |
41 #include "prims/jvmtiExport.hpp" | |
42 #include "prims/jvmtiThreadState.hpp" | |
43 #include "prims/nativeLookup.hpp" | |
44 #include "prims/privilegedStack.hpp" | |
45 #include "runtime/arguments.hpp" | |
46 #include "runtime/dtraceJSDT.hpp" | |
47 #include "runtime/handles.inline.hpp" | |
48 #include "runtime/init.hpp" | |
49 #include "runtime/interfaceSupport.hpp" | |
50 #include "runtime/java.hpp" | |
51 #include "runtime/javaCalls.hpp" | |
52 #include "runtime/jfieldIDWorkaround.hpp" | |
53 #include "runtime/os.hpp" | |
54 #include "runtime/perfData.hpp" | |
55 #include "runtime/reflection.hpp" | |
56 #include "runtime/vframe.hpp" | |
57 #include "runtime/vm_operations.hpp" | |
58 #include "services/attachListener.hpp" | |
59 #include "services/management.hpp" | |
60 #include "services/threadService.hpp" | |
61 #include "utilities/copy.hpp" | |
62 #include "utilities/defaultStream.hpp" | |
63 #include "utilities/dtrace.hpp" | |
64 #include "utilities/events.hpp" | |
65 #include "utilities/histogram.hpp" | |
66 #include "utilities/top.hpp" | |
67 #include "utilities/utf8.hpp" | |
68 #ifdef TARGET_OS_FAMILY_linux | |
69 # include "jvm_linux.h" | |
70 #endif | |
71 #ifdef TARGET_OS_FAMILY_solaris | |
72 # include "jvm_solaris.h" | |
73 #endif | |
74 #ifdef TARGET_OS_FAMILY_windows | |
75 # include "jvm_windows.h" | |
76 #endif | |
3960 | 77 #ifdef TARGET_OS_FAMILY_bsd |
78 # include "jvm_bsd.h" | |
79 #endif | |
1972 | 80 |
0 | 81 #include <errno.h> |
82 | |
4006 | 83 #ifndef USDT2 |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
84 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); |
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
85 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); |
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
86 HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); |
4006 | 87 #endif /* !USDT2 */ |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
88 |
0 | 89 /* |
90 NOTE about use of any ctor or function call that can trigger a safepoint/GC: | |
91 such ctors and calls MUST NOT come between an oop declaration/init and its | |
92 usage because if objects are move this may cause various memory stomps, bus | |
93 errors and segfaults. Here is a cookbook for causing so called "naked oop | |
94 failures": | |
95 | |
96 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields<etc> { | |
97 JVMWrapper("JVM_GetClassDeclaredFields"); | |
98 | |
99 // Object address to be held directly in mirror & not visible to GC | |
100 oop mirror = JNIHandles::resolve_non_null(ofClass); | |
101 | |
102 // If this ctor can hit a safepoint, moving objects around, then | |
103 ComplexConstructor foo; | |
104 | |
105 // Boom! mirror may point to JUNK instead of the intended object | |
106 (some dereference of mirror) | |
107 | |
108 // Here's another call that may block for GC, making mirror stale | |
109 MutexLocker ml(some_lock); | |
110 | |
111 // And here's an initializer that can result in a stale oop | |
112 // all in one step. | |
113 oop o = call_that_can_throw_exception(TRAPS); | |
114 | |
115 | |
116 The solution is to keep the oop declaration BELOW the ctor or function | |
117 call that might cause a GC, do another resolve to reassign the oop, or | |
118 consider use of a Handle instead of an oop so there is immunity from object | |
119 motion. But note that the "QUICK" entries below do not have a handlemark | |
120 and thus can only support use of handles passed in. | |
121 */ | |
122 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
123 static void trace_class_resolution_impl(Klass* to_class, TRAPS) { |
0 | 124 ResourceMark rm; |
125 int line_number = -1; | |
126 const char * source_file = NULL; | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
127 const char * trace = "explicit"; |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
128 InstanceKlass* caller = NULL; |
0 | 129 JavaThread* jthread = JavaThread::current(); |
130 if (jthread->has_last_Java_frame()) { | |
131 vframeStream vfst(jthread); | |
132 | |
133 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
134 TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
135 Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
136 TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
137 Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
138 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
139 Method* last_caller = NULL; |
0 | 140 |
141 while (!vfst.at_end()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
142 Method* m = vfst.method(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
143 if (!vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass())&& |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
144 !vfst.method()->method_holder()->is_subclass_of(access_controller_klass) && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
145 !vfst.method()->method_holder()->is_subclass_of(privileged_action_klass)) { |
0 | 146 break; |
147 } | |
148 last_caller = m; | |
149 vfst.next(); | |
150 } | |
151 // if this is called from Class.forName0 and that is called from Class.forName, | |
152 // then print the caller of Class.forName. If this is Class.loadClass, then print | |
153 // that caller, otherwise keep quiet since this should be picked up elsewhere. | |
154 bool found_it = false; | |
155 if (!vfst.at_end() && | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
156 vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
0 | 157 vfst.method()->name() == vmSymbols::forName0_name()) { |
158 vfst.next(); | |
159 if (!vfst.at_end() && | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
160 vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
0 | 161 vfst.method()->name() == vmSymbols::forName_name()) { |
162 vfst.next(); | |
163 found_it = true; | |
164 } | |
165 } else if (last_caller != NULL && | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
166 last_caller->method_holder()->name() == |
0 | 167 vmSymbols::java_lang_ClassLoader() && |
168 (last_caller->name() == vmSymbols::loadClassInternal_name() || | |
169 last_caller->name() == vmSymbols::loadClass_name())) { | |
170 found_it = true; | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
171 } else if (!vfst.at_end()) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
172 if (vfst.method()->is_native()) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
173 // JNI call |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
174 found_it = true; |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
175 } |
0 | 176 } |
177 if (found_it && !vfst.at_end()) { | |
178 // found the caller | |
179 caller = vfst.method()->method_holder(); | |
180 line_number = vfst.method()->line_number_from_bci(vfst.bci()); | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
181 if (line_number == -1) { |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
182 // show method name if it's a native method |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
183 trace = vfst.method()->name_and_sig_as_C_string(); |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
184 } |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
185 Symbol* s = caller->source_file_name(); |
0 | 186 if (s != NULL) { |
187 source_file = s->as_C_string(); | |
188 } | |
189 } | |
190 } | |
191 if (caller != NULL) { | |
192 if (to_class != caller) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
193 const char * from = caller->external_name(); |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
194 const char * to = to_class->external_name(); |
0 | 195 // print in a single call to reduce interleaving between threads |
196 if (source_file != NULL) { | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
197 tty->print("RESOLVE %s %s %s:%d (%s)\n", from, to, source_file, line_number, trace); |
0 | 198 } else { |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
199 tty->print("RESOLVE %s %s (%s)\n", from, to, trace); |
0 | 200 } |
201 } | |
202 } | |
203 } | |
204 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
205 void trace_class_resolution(Klass* to_class) { |
0 | 206 EXCEPTION_MARK; |
207 trace_class_resolution_impl(to_class, THREAD); | |
208 if (HAS_PENDING_EXCEPTION) { | |
209 CLEAR_PENDING_EXCEPTION; | |
210 } | |
211 } | |
212 | |
213 // Wrapper to trace JVM functions | |
214 | |
215 #ifdef ASSERT | |
216 class JVMTraceWrapper : public StackObj { | |
217 public: | |
218 JVMTraceWrapper(const char* format, ...) { | |
219 if (TraceJVMCalls) { | |
220 va_list ap; | |
221 va_start(ap, format); | |
222 tty->print("JVM "); | |
223 tty->vprint_cr(format, ap); | |
224 va_end(ap); | |
225 } | |
226 } | |
227 }; | |
228 | |
229 Histogram* JVMHistogram; | |
230 volatile jint JVMHistogram_lock = 0; | |
231 | |
232 class JVMHistogramElement : public HistogramElement { | |
233 public: | |
234 JVMHistogramElement(const char* name); | |
235 }; | |
236 | |
237 JVMHistogramElement::JVMHistogramElement(const char* elementName) { | |
238 _name = elementName; | |
239 uintx count = 0; | |
240 | |
241 while (Atomic::cmpxchg(1, &JVMHistogram_lock, 0) != 0) { | |
242 while (OrderAccess::load_acquire(&JVMHistogram_lock) != 0) { | |
243 count +=1; | |
244 if ( (WarnOnStalledSpinLock > 0) | |
245 && (count % WarnOnStalledSpinLock == 0)) { | |
246 warning("JVMHistogram_lock seems to be stalled"); | |
247 } | |
248 } | |
249 } | |
250 | |
251 if(JVMHistogram == NULL) | |
252 JVMHistogram = new Histogram("JVM Call Counts",100); | |
253 | |
254 JVMHistogram->add_element(this); | |
255 Atomic::dec(&JVMHistogram_lock); | |
256 } | |
257 | |
258 #define JVMCountWrapper(arg) \ | |
259 static JVMHistogramElement* e = new JVMHistogramElement(arg); \ | |
260 if (e != NULL) e->increment_count(); // Due to bug in VC++, we need a NULL check here eventhough it should never happen! | |
261 | |
262 #define JVMWrapper(arg1) JVMCountWrapper(arg1); JVMTraceWrapper(arg1) | |
263 #define JVMWrapper2(arg1, arg2) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2) | |
264 #define JVMWrapper3(arg1, arg2, arg3) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2, arg3) | |
265 #define JVMWrapper4(arg1, arg2, arg3, arg4) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2, arg3, arg4) | |
266 #else | |
267 #define JVMWrapper(arg1) | |
268 #define JVMWrapper2(arg1, arg2) | |
269 #define JVMWrapper3(arg1, arg2, arg3) | |
270 #define JVMWrapper4(arg1, arg2, arg3, arg4) | |
271 #endif | |
272 | |
273 | |
274 // Interface version ///////////////////////////////////////////////////////////////////// | |
275 | |
276 | |
277 JVM_LEAF(jint, JVM_GetInterfaceVersion()) | |
278 return JVM_INTERFACE_VERSION; | |
279 JVM_END | |
280 | |
281 | |
282 // java.lang.System ////////////////////////////////////////////////////////////////////// | |
283 | |
284 | |
285 JVM_LEAF(jlong, JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)) | |
286 JVMWrapper("JVM_CurrentTimeMillis"); | |
287 return os::javaTimeMillis(); | |
288 JVM_END | |
289 | |
290 JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored)) | |
291 JVMWrapper("JVM_NanoTime"); | |
292 return os::javaTimeNanos(); | |
293 JVM_END | |
294 | |
295 | |
296 JVM_ENTRY(void, JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, | |
297 jobject dst, jint dst_pos, jint length)) | |
298 JVMWrapper("JVM_ArrayCopy"); | |
299 // Check if we have null pointers | |
300 if (src == NULL || dst == NULL) { | |
301 THROW(vmSymbols::java_lang_NullPointerException()); | |
302 } | |
303 arrayOop s = arrayOop(JNIHandles::resolve_non_null(src)); | |
304 arrayOop d = arrayOop(JNIHandles::resolve_non_null(dst)); | |
305 assert(s->is_oop(), "JVM_ArrayCopy: src not an oop"); | |
306 assert(d->is_oop(), "JVM_ArrayCopy: dst not an oop"); | |
307 // Do copy | |
6983 | 308 s->klass()->copy_array(s, src_pos, d, dst_pos, length, thread); |
0 | 309 JVM_END |
310 | |
311 | |
312 static void set_property(Handle props, const char* key, const char* value, TRAPS) { | |
313 JavaValue r(T_OBJECT); | |
314 // public synchronized Object put(Object key, Object value); | |
315 HandleMark hm(THREAD); | |
316 Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); | |
317 Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); | |
318 JavaCalls::call_virtual(&r, | |
319 props, | |
1142 | 320 KlassHandle(THREAD, SystemDictionary::Properties_klass()), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
321 vmSymbols::put_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
322 vmSymbols::object_object_object_signature(), |
0 | 323 key_str, |
324 value_str, | |
325 THREAD); | |
326 } | |
327 | |
328 | |
329 #define PUTPROP(props, name, value) set_property((props), (name), (value), CHECK_(properties)); | |
330 | |
331 | |
332 JVM_ENTRY(jobject, JVM_InitProperties(JNIEnv *env, jobject properties)) | |
333 JVMWrapper("JVM_InitProperties"); | |
334 ResourceMark rm; | |
335 | |
336 Handle props(THREAD, JNIHandles::resolve_non_null(properties)); | |
337 | |
338 // System property list includes both user set via -D option and | |
339 // jvm system specific properties. | |
340 for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { | |
341 PUTPROP(props, p->key(), p->value()); | |
342 } | |
343 | |
344 // Convert the -XX:MaxDirectMemorySize= command line flag | |
345 // to the sun.nio.MaxDirectMemorySize property. | |
346 // Do this after setting user properties to prevent people | |
347 // from setting the value with a -D option, as requested. | |
348 { | |
6199
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
349 if (FLAG_IS_DEFAULT(MaxDirectMemorySize)) { |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
350 PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1"); |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
351 } else { |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
352 char as_chars[256]; |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
353 jio_snprintf(as_chars, sizeof(as_chars), UINTX_FORMAT, MaxDirectMemorySize); |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
354 PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars); |
3f1ab0c19c30
7179383: MaxDirectMemorySize argument parsing is broken for values >2G
dholmes
parents:
5967
diff
changeset
|
355 } |
0 | 356 } |
357 | |
358 // JVM monitoring and management support | |
359 // Add the sun.management.compiler property for the compiler's name | |
360 { | |
361 #undef CSIZE | |
362 #if defined(_LP64) || defined(_WIN64) | |
363 #define CSIZE "64-Bit " | |
364 #else | |
365 #define CSIZE | |
366 #endif // 64bit | |
367 | |
368 #ifdef TIERED | |
369 const char* compiler_name = "HotSpot " CSIZE "Tiered Compilers"; | |
370 #else | |
371 #if defined(COMPILER1) | |
372 const char* compiler_name = "HotSpot " CSIZE "Client Compiler"; | |
373 #elif defined(COMPILER2) | |
374 const char* compiler_name = "HotSpot " CSIZE "Server Compiler"; | |
7125
1baf7f1e3f23
decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents:
6983
diff
changeset
|
375 #elif defined(GRAAL) |
1baf7f1e3f23
decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents:
6983
diff
changeset
|
376 const char* compiler_name = "HotSpot " CSIZE "Graal Compiler"; |
0 | 377 #else |
378 const char* compiler_name = ""; | |
379 #endif // compilers | |
380 #endif // TIERED | |
381 | |
382 if (*compiler_name != '\0' && | |
383 (Arguments::mode() != Arguments::_int)) { | |
384 PUTPROP(props, "sun.management.compiler", compiler_name); | |
385 } | |
386 } | |
387 | |
388 return properties; | |
389 JVM_END | |
390 | |
391 | |
392 // java.lang.Runtime ///////////////////////////////////////////////////////////////////////// | |
393 | |
394 extern volatile jint vm_created; | |
395 | |
396 JVM_ENTRY_NO_ENV(void, JVM_Exit(jint code)) | |
397 if (vm_created != 0 && (code == 0)) { | |
398 // The VM is about to exit. We call back into Java to check whether finalizers should be run | |
399 Universe::run_finalizers_on_exit(); | |
400 } | |
401 before_exit(thread); | |
402 vm_exit(code); | |
403 JVM_END | |
404 | |
405 | |
406 JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code)) | |
407 before_exit(thread); | |
408 vm_exit(code); | |
409 JVM_END | |
410 | |
411 | |
412 JVM_LEAF(void, JVM_OnExit(void (*func)(void))) | |
413 register_on_exit_function(func); | |
414 JVM_END | |
415 | |
416 | |
417 JVM_ENTRY_NO_ENV(void, JVM_GC(void)) | |
418 JVMWrapper("JVM_GC"); | |
419 if (!DisableExplicitGC) { | |
420 Universe::heap()->collect(GCCause::_java_lang_system_gc); | |
421 } | |
422 JVM_END | |
423 | |
424 | |
425 JVM_LEAF(jlong, JVM_MaxObjectInspectionAge(void)) | |
426 JVMWrapper("JVM_MaxObjectInspectionAge"); | |
427 return Universe::heap()->millis_since_last_gc(); | |
428 JVM_END | |
429 | |
430 | |
431 JVM_LEAF(void, JVM_TraceInstructions(jboolean on)) | |
432 if (PrintJVMWarnings) warning("JVM_TraceInstructions not supported"); | |
433 JVM_END | |
434 | |
435 | |
436 JVM_LEAF(void, JVM_TraceMethodCalls(jboolean on)) | |
437 if (PrintJVMWarnings) warning("JVM_TraceMethodCalls not supported"); | |
438 JVM_END | |
439 | |
440 static inline jlong convert_size_t_to_jlong(size_t val) { | |
441 // In the 64-bit vm, a size_t can overflow a jlong (which is signed). | |
442 NOT_LP64 (return (jlong)val;) | |
443 LP64_ONLY(return (jlong)MIN2(val, (size_t)max_jlong);) | |
444 } | |
445 | |
446 JVM_ENTRY_NO_ENV(jlong, JVM_TotalMemory(void)) | |
447 JVMWrapper("JVM_TotalMemory"); | |
448 size_t n = Universe::heap()->capacity(); | |
449 return convert_size_t_to_jlong(n); | |
450 JVM_END | |
451 | |
452 | |
453 JVM_ENTRY_NO_ENV(jlong, JVM_FreeMemory(void)) | |
454 JVMWrapper("JVM_FreeMemory"); | |
455 CollectedHeap* ch = Universe::heap(); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
116
diff
changeset
|
456 size_t n; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
116
diff
changeset
|
457 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
116
diff
changeset
|
458 MutexLocker x(Heap_lock); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
116
diff
changeset
|
459 n = ch->capacity() - ch->used(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
116
diff
changeset
|
460 } |
0 | 461 return convert_size_t_to_jlong(n); |
462 JVM_END | |
463 | |
464 | |
465 JVM_ENTRY_NO_ENV(jlong, JVM_MaxMemory(void)) | |
466 JVMWrapper("JVM_MaxMemory"); | |
467 size_t n = Universe::heap()->max_capacity(); | |
468 return convert_size_t_to_jlong(n); | |
469 JVM_END | |
470 | |
471 | |
472 JVM_ENTRY_NO_ENV(jint, JVM_ActiveProcessorCount(void)) | |
473 JVMWrapper("JVM_ActiveProcessorCount"); | |
474 return os::active_processor_count(); | |
475 JVM_END | |
476 | |
477 | |
478 | |
479 // java.lang.Throwable ////////////////////////////////////////////////////// | |
480 | |
481 | |
482 JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver)) | |
483 JVMWrapper("JVM_FillInStackTrace"); | |
484 Handle exception(thread, JNIHandles::resolve_non_null(receiver)); | |
485 java_lang_Throwable::fill_in_stack_trace(exception); | |
486 JVM_END | |
487 | |
488 | |
489 JVM_ENTRY(jint, JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)) | |
490 JVMWrapper("JVM_GetStackTraceDepth"); | |
491 oop exception = JNIHandles::resolve(throwable); | |
492 return java_lang_Throwable::get_stack_trace_depth(exception, THREAD); | |
493 JVM_END | |
494 | |
495 | |
496 JVM_ENTRY(jobject, JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)) | |
497 JVMWrapper("JVM_GetStackTraceElement"); | |
498 JvmtiVMObjectAllocEventCollector oam; // This ctor (throughout this module) may trigger a safepoint/GC | |
499 oop exception = JNIHandles::resolve(throwable); | |
500 oop element = java_lang_Throwable::get_stack_trace_element(exception, index, CHECK_NULL); | |
501 return JNIHandles::make_local(env, element); | |
502 JVM_END | |
503 | |
504 | |
505 // java.lang.Object /////////////////////////////////////////////// | |
506 | |
507 | |
508 JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle)) | |
509 JVMWrapper("JVM_IHashCode"); | |
510 // as implemented in the classic virtual machine; return 0 if object is NULL | |
511 return handle == NULL ? 0 : ObjectSynchronizer::FastHashCode (THREAD, JNIHandles::resolve_non_null(handle)) ; | |
512 JVM_END | |
513 | |
514 | |
515 JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)) | |
516 JVMWrapper("JVM_MonitorWait"); | |
517 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | |
518 JavaThreadInObjectWaitState jtiows(thread, ms != 0); | |
519 if (JvmtiExport::should_post_monitor_wait()) { | |
520 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); | |
521 } | |
522 ObjectSynchronizer::wait(obj, ms, CHECK); | |
523 JVM_END | |
524 | |
525 | |
526 JVM_ENTRY(void, JVM_MonitorNotify(JNIEnv* env, jobject handle)) | |
527 JVMWrapper("JVM_MonitorNotify"); | |
528 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | |
529 ObjectSynchronizer::notify(obj, CHECK); | |
530 JVM_END | |
531 | |
532 | |
533 JVM_ENTRY(void, JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)) | |
534 JVMWrapper("JVM_MonitorNotifyAll"); | |
535 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | |
536 ObjectSynchronizer::notifyall(obj, CHECK); | |
537 JVM_END | |
538 | |
539 | |
540 JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) | |
541 JVMWrapper("JVM_Clone"); | |
542 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | |
543 const KlassHandle klass (THREAD, obj->klass()); | |
544 JvmtiVMObjectAllocEventCollector oam; | |
545 | |
546 #ifdef ASSERT | |
547 // Just checking that the cloneable flag is set correct | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
548 if (obj->is_array()) { |
0 | 549 guarantee(klass->is_cloneable(), "all arrays are cloneable"); |
550 } else { | |
551 guarantee(obj->is_instance(), "should be instanceOop"); | |
1142 | 552 bool cloneable = klass->is_subtype_of(SystemDictionary::Cloneable_klass()); |
0 | 553 guarantee(cloneable == klass->is_cloneable(), "incorrect cloneable flag"); |
554 } | |
555 #endif | |
556 | |
557 // Check if class of obj supports the Cloneable interface. | |
558 // All arrays are considered to be cloneable (See JLS 20.1.5) | |
559 if (!klass->is_cloneable()) { | |
560 ResourceMark rm(THREAD); | |
561 THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name()); | |
562 } | |
563 | |
564 // Make shallow object copy | |
565 const int size = obj->size(); | |
566 oop new_obj = NULL; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
567 if (obj->is_array()) { |
0 | 568 const int length = ((arrayOop)obj())->length(); |
569 new_obj = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL); | |
570 } else { | |
571 new_obj = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); | |
572 } | |
573 // 4839641 (4840070): We must do an oop-atomic copy, because if another thread | |
574 // is modifying a reference field in the clonee, a non-oop-atomic copy might | |
575 // be suspended in the middle of copying the pointer and end up with parts | |
576 // of two different pointers in the field. Subsequent dereferences will crash. | |
577 // 4846409: an oop-copy of objects with long or double fields or arrays of same | |
578 // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead | |
579 // of oops. We know objects are aligned on a minimum of an jlong boundary. | |
580 // The same is true of StubRoutines::object_copy and the various oop_copy | |
581 // variants, and of the code generated by the inline_native_clone intrinsic. | |
582 assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned"); | |
583 Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj, | |
584 (size_t)align_object_size(size) / HeapWordsPerLong); | |
585 // Clear the header | |
586 new_obj->init_mark(); | |
587 | |
588 // Store check (mark entire object and let gc sort it out) | |
589 BarrierSet* bs = Universe::heap()->barrier_set(); | |
590 assert(bs->has_write_region_opt(), "Barrier set does not have write_region"); | |
591 bs->write_region(MemRegion((HeapWord*)new_obj, size)); | |
592 | |
593 // Caution: this involves a java upcall, so the clone should be | |
594 // "gc-robust" by this stage. | |
595 if (klass->has_finalizer()) { | |
596 assert(obj->is_instance(), "should be instanceOop"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
597 new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); |
0 | 598 } |
599 | |
600 return JNIHandles::make_local(env, oop(new_obj)); | |
601 JVM_END | |
602 | |
603 // java.lang.Compiler //////////////////////////////////////////////////// | |
604 | |
605 // The initial cuts of the HotSpot VM will not support JITs, and all existing | |
606 // JITs would need extensive changes to work with HotSpot. The JIT-related JVM | |
607 // functions are all silently ignored unless JVM warnings are printed. | |
608 | |
609 JVM_LEAF(void, JVM_InitializeCompiler (JNIEnv *env, jclass compCls)) | |
610 if (PrintJVMWarnings) warning("JVM_InitializeCompiler not supported"); | |
611 JVM_END | |
612 | |
613 | |
614 JVM_LEAF(jboolean, JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)) | |
615 if (PrintJVMWarnings) warning("JVM_IsSilentCompiler not supported"); | |
616 return JNI_FALSE; | |
617 JVM_END | |
618 | |
619 | |
620 JVM_LEAF(jboolean, JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)) | |
621 if (PrintJVMWarnings) warning("JVM_CompileClass not supported"); | |
622 return JNI_FALSE; | |
623 JVM_END | |
624 | |
625 | |
626 JVM_LEAF(jboolean, JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)) | |
627 if (PrintJVMWarnings) warning("JVM_CompileClasses not supported"); | |
628 return JNI_FALSE; | |
629 JVM_END | |
630 | |
631 | |
632 JVM_LEAF(jobject, JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)) | |
633 if (PrintJVMWarnings) warning("JVM_CompilerCommand not supported"); | |
634 return NULL; | |
635 JVM_END | |
636 | |
637 | |
638 JVM_LEAF(void, JVM_EnableCompiler(JNIEnv *env, jclass compCls)) | |
639 if (PrintJVMWarnings) warning("JVM_EnableCompiler not supported"); | |
640 JVM_END | |
641 | |
642 | |
643 JVM_LEAF(void, JVM_DisableCompiler(JNIEnv *env, jclass compCls)) | |
644 if (PrintJVMWarnings) warning("JVM_DisableCompiler not supported"); | |
645 JVM_END | |
646 | |
647 | |
648 | |
649 // Error message support ////////////////////////////////////////////////////// | |
650 | |
651 JVM_LEAF(jint, JVM_GetLastErrorString(char *buf, int len)) | |
652 JVMWrapper("JVM_GetLastErrorString"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
653 return (jint)os::lasterror(buf, len); |
0 | 654 JVM_END |
655 | |
656 | |
657 // java.io.File /////////////////////////////////////////////////////////////// | |
658 | |
659 JVM_LEAF(char*, JVM_NativePath(char* path)) | |
660 JVMWrapper2("JVM_NativePath (%s)", path); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
661 return os::native_path(path); |
0 | 662 JVM_END |
663 | |
664 | |
665 // Misc. class handling /////////////////////////////////////////////////////////// | |
666 | |
667 | |
668 JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) | |
669 JVMWrapper("JVM_GetCallerClass"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
670 Klass* k = thread->security_get_caller_class(depth); |
6983 | 671 return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); |
0 | 672 JVM_END |
673 | |
674 | |
675 JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) | |
676 JVMWrapper("JVM_FindPrimitiveClass"); | |
677 oop mirror = NULL; | |
678 BasicType t = name2type(utf); | |
679 if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) { | |
680 mirror = Universe::java_mirror(t); | |
681 } | |
682 if (mirror == NULL) { | |
683 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf); | |
684 } else { | |
685 return (jclass) JNIHandles::make_local(env, mirror); | |
686 } | |
687 JVM_END | |
688 | |
689 | |
690 JVM_ENTRY(void, JVM_ResolveClass(JNIEnv* env, jclass cls)) | |
691 JVMWrapper("JVM_ResolveClass"); | |
692 if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented"); | |
693 JVM_END | |
694 | |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
695 |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
696 // Returns a class loaded by the bootstrap class loader; or null |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
697 // if not found. ClassNotFoundException is not thrown. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
698 // |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
699 // Rationale behind JVM_FindClassFromBootLoader |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
700 // a> JVM_FindClassFromClassLoader was never exported in the export tables. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
701 // b> because of (a) java.dll has a direct dependecy on the unexported |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
702 // private symbol "_JVM_FindClassFromClassLoader@20". |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
703 // c> the launcher cannot use the private symbol as it dynamically opens |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
704 // the entry point, so if something changes, the launcher will fail |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
705 // unexpectedly at runtime, it is safest for the launcher to dlopen a |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
706 // stable exported interface. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
707 // d> re-exporting JVM_FindClassFromClassLoader as public, will cause its |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
708 // signature to change from _JVM_FindClassFromClassLoader@20 to |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
709 // JVM_FindClassFromClassLoader and will not be backward compatible |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
710 // with older JDKs. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
711 // Thus a public/stable exported entry point is the right solution, |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
712 // public here means public in linker semantics, and is exported only |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
713 // to the JDK, and is not intended to be a public API. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
714 |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
715 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
716 const char* name)) |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
717 JVMWrapper2("JVM_FindClassFromBootLoader %s", name); |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
718 |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
719 // Java libraries should ensure that name is never null... |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
720 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
721 // It's impossible to create this class; the name cannot fit |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
722 // into the constant pool. |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
723 return NULL; |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
724 } |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
725 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
726 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
727 Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
728 if (k == NULL) { |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
729 return NULL; |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
730 } |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
731 |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
732 if (TraceClassResolution) { |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
733 trace_class_resolution(k); |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
734 } |
6983 | 735 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
736 JVM_END |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
737 |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
738 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
739 jboolean init, jobject loader, |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
740 jboolean throwError)) |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
741 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, |
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
742 throwError ? "error" : "exception"); |
388 | 743 // Java libraries should ensure that name is never null... |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
744 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
388 | 745 // It's impossible to create this class; the name cannot fit |
746 // into the constant pool. | |
747 if (throwError) { | |
748 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | |
749 } else { | |
750 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); | |
751 } | |
752 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
753 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
388 | 754 Handle h_loader(THREAD, JNIHandles::resolve(loader)); |
755 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, | |
756 Handle(), throwError, THREAD); | |
757 | |
758 if (TraceClassResolution && result != NULL) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
759 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
388 | 760 } |
761 return result; | |
0 | 762 JVM_END |
763 | |
764 | |
765 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, | |
766 jboolean init, jclass from)) | |
767 JVMWrapper2("JVM_FindClassFromClass %s", name); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
768 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
0 | 769 // It's impossible to create this class; the name cannot fit |
770 // into the constant pool. | |
771 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | |
772 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
773 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
0 | 774 oop from_class_oop = JNIHandles::resolve(from); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
775 Klass* from_class = (from_class_oop == NULL) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
776 ? (Klass*)NULL |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
777 : java_lang_Class::as_Klass(from_class_oop); |
0 | 778 oop class_loader = NULL; |
779 oop protection_domain = NULL; | |
780 if (from_class != NULL) { | |
6983 | 781 class_loader = from_class->class_loader(); |
782 protection_domain = from_class->protection_domain(); | |
0 | 783 } |
784 Handle h_loader(THREAD, class_loader); | |
785 Handle h_prot (THREAD, protection_domain); | |
786 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, | |
787 h_prot, true, thread); | |
788 | |
789 if (TraceClassResolution && result != NULL) { | |
790 // this function is generally only used for class loading during verification. | |
791 ResourceMark rm; | |
792 oop from_mirror = JNIHandles::resolve_non_null(from); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
793 Klass* from_class = java_lang_Class::as_Klass(from_mirror); |
6983 | 794 const char * from_name = from_class->external_name(); |
0 | 795 |
796 oop mirror = JNIHandles::resolve_non_null(result); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
797 Klass* to_class = java_lang_Class::as_Klass(mirror); |
6983 | 798 const char * to = to_class->external_name(); |
0 | 799 tty->print("RESOLVE %s %s (verification)\n", from_name, to); |
800 } | |
801 | |
802 return result; | |
803 JVM_END | |
804 | |
805 static void is_lock_held_by_thread(Handle loader, PerfCounter* counter, TRAPS) { | |
806 if (loader.is_null()) { | |
807 return; | |
808 } | |
809 | |
810 // check whether the current caller thread holds the lock or not. | |
811 // If not, increment the corresponding counter | |
812 if (ObjectSynchronizer::query_lock_ownership((JavaThread*)THREAD, loader) != | |
813 ObjectSynchronizer::owner_self) { | |
814 counter->inc(); | |
815 } | |
816 } | |
817 | |
818 // common code for JVM_DefineClass() and JVM_DefineClassWithSource() | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
819 // and JVM_DefineClassWithSourceCond() |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
820 static jclass jvm_define_class_common(JNIEnv *env, const char *name, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
821 jobject loader, const jbyte *buf, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
822 jsize len, jobject pd, const char *source, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
823 jboolean verify, TRAPS) { |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
388
diff
changeset
|
824 if (source == NULL) source = "__JVM_DefineClass__"; |
0 | 825 |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
826 assert(THREAD->is_Java_thread(), "must be a JavaThread"); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
827 JavaThread* jt = (JavaThread*) THREAD; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
828 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
829 PerfClassTraceTime vmtimer(ClassLoader::perf_define_appclass_time(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
830 ClassLoader::perf_define_appclass_selftime(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
831 ClassLoader::perf_define_appclasses(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
832 jt->get_thread_stat()->perf_recursion_counts_addr(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
833 jt->get_thread_stat()->perf_timers_addr(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
834 PerfClassTraceTime::DEFINE_CLASS); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
835 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
836 if (UsePerfData) { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
837 ClassLoader::perf_app_classfile_bytes_read()->inc(len); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
838 } |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
839 |
0 | 840 // Since exceptions can be thrown, class initialization can take place |
841 // if name is NULL no check for class name in .class stream has to be made. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
842 TempNewSymbol class_name = NULL; |
0 | 843 if (name != NULL) { |
844 const int str_len = (int)strlen(name); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
845 if (str_len > Symbol::max_length()) { |
0 | 846 // It's impossible to create this class; the name cannot fit |
847 // into the constant pool. | |
848 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | |
849 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
850 class_name = SymbolTable::new_symbol(name, str_len, CHECK_NULL); |
0 | 851 } |
852 | |
853 ResourceMark rm(THREAD); | |
854 ClassFileStream st((u1*) buf, len, (char *)source); | |
855 Handle class_loader (THREAD, JNIHandles::resolve(loader)); | |
856 if (UsePerfData) { | |
857 is_lock_held_by_thread(class_loader, | |
858 ClassLoader::sync_JVMDefineClassLockFreeCounter(), | |
859 THREAD); | |
860 } | |
861 Handle protection_domain (THREAD, JNIHandles::resolve(pd)); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
862 Klass* k = SystemDictionary::resolve_from_stream(class_name, class_loader, |
0 | 863 protection_domain, &st, |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
864 verify != 0, |
0 | 865 CHECK_NULL); |
866 | |
867 if (TraceClassResolution && k != NULL) { | |
868 trace_class_resolution(k); | |
869 } | |
870 | |
6983 | 871 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
0 | 872 } |
873 | |
874 | |
875 JVM_ENTRY(jclass, JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)) | |
876 JVMWrapper2("JVM_DefineClass %s", name); | |
877 | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
878 return jvm_define_class_common(env, name, loader, buf, len, pd, NULL, true, THREAD); |
0 | 879 JVM_END |
880 | |
881 | |
882 JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)) | |
883 JVMWrapper2("JVM_DefineClassWithSource %s", name); | |
884 | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
885 return jvm_define_class_common(env, name, loader, buf, len, pd, source, true, THREAD); |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
886 JVM_END |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
887 |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
888 JVM_ENTRY(jclass, JVM_DefineClassWithSourceCond(JNIEnv *env, const char *name, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
889 jobject loader, const jbyte *buf, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
890 jsize len, jobject pd, |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
891 const char *source, jboolean verify)) |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
892 JVMWrapper2("JVM_DefineClassWithSourceCond %s", name); |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
893 |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
894 return jvm_define_class_common(env, name, loader, buf, len, pd, source, verify, THREAD); |
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
878
diff
changeset
|
895 JVM_END |
0 | 896 |
897 JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)) | |
898 JVMWrapper("JVM_FindLoadedClass"); | |
899 ResourceMark rm(THREAD); | |
900 | |
901 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); | |
902 Handle string = java_lang_String::internalize_classname(h_name, CHECK_NULL); | |
903 | |
904 const char* str = java_lang_String::as_utf8_string(string()); | |
905 // Sanity check, don't expect null | |
906 if (str == NULL) return NULL; | |
907 | |
908 const int str_len = (int)strlen(str); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
909 if (str_len > Symbol::max_length()) { |
0 | 910 // It's impossible to create this class; the name cannot fit |
911 // into the constant pool. | |
912 return NULL; | |
913 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
914 TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL); |
0 | 915 |
916 // Security Note: | |
917 // The Java level wrapper will perform the necessary security check allowing | |
918 // us to pass the NULL as the initiating class loader. | |
919 Handle h_loader(THREAD, JNIHandles::resolve(loader)); | |
920 if (UsePerfData) { | |
921 is_lock_held_by_thread(h_loader, | |
922 ClassLoader::sync_JVMFindLoadedClassLockFreeCounter(), | |
923 THREAD); | |
924 } | |
925 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
926 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name, |
0 | 927 h_loader, |
928 Handle(), | |
929 CHECK_NULL); | |
930 | |
931 return (k == NULL) ? NULL : | |
6983 | 932 (jclass) JNIHandles::make_local(env, k->java_mirror()); |
0 | 933 JVM_END |
934 | |
935 | |
936 // Reflection support ////////////////////////////////////////////////////////////////////////////// | |
937 | |
938 JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls)) | |
939 assert (cls != NULL, "illegal class"); | |
940 JVMWrapper("JVM_GetClassName"); | |
941 JvmtiVMObjectAllocEventCollector oam; | |
942 ResourceMark rm(THREAD); | |
943 const char* name; | |
944 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
945 name = type2name(java_lang_Class::primitive_type(JNIHandles::resolve(cls))); | |
946 } else { | |
947 // Consider caching interned string in Klass | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
948 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
0 | 949 assert(k->is_klass(), "just checking"); |
6983 | 950 name = k->external_name(); |
0 | 951 } |
952 oop result = StringTable::intern((char*) name, CHECK_NULL); | |
953 return (jstring) JNIHandles::make_local(env, result); | |
954 JVM_END | |
955 | |
956 | |
957 JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) | |
958 JVMWrapper("JVM_GetClassInterfaces"); | |
959 JvmtiVMObjectAllocEventCollector oam; | |
960 oop mirror = JNIHandles::resolve_non_null(cls); | |
961 | |
962 // Special handling for primitive objects | |
963 if (java_lang_Class::is_primitive(mirror)) { | |
964 // Primitive objects does not have any interfaces | |
1142 | 965 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
0 | 966 return (jobjectArray) JNIHandles::make_local(env, r); |
967 } | |
968 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
969 KlassHandle klass(thread, java_lang_Class::as_Klass(mirror)); |
0 | 970 // Figure size of result array |
971 int size; | |
972 if (klass->oop_is_instance()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
973 size = InstanceKlass::cast(klass())->local_interfaces()->length(); |
0 | 974 } else { |
975 assert(klass->oop_is_objArray() || klass->oop_is_typeArray(), "Illegal mirror klass"); | |
976 size = 2; | |
977 } | |
978 | |
979 // Allocate result array | |
1142 | 980 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), size, CHECK_NULL); |
0 | 981 objArrayHandle result (THREAD, r); |
982 // Fill in result | |
983 if (klass->oop_is_instance()) { | |
984 // Regular instance klass, fill in all local interfaces | |
985 for (int index = 0; index < size; index++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
986 Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index); |
6983 | 987 result->obj_at_put(index, k->java_mirror()); |
0 | 988 } |
989 } else { | |
990 // All arrays implement java.lang.Cloneable and java.io.Serializable | |
6983 | 991 result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror()); |
992 result->obj_at_put(1, SystemDictionary::Serializable_klass()->java_mirror()); | |
0 | 993 } |
994 return (jobjectArray) JNIHandles::make_local(env, result()); | |
995 JVM_END | |
996 | |
997 | |
998 JVM_ENTRY(jobject, JVM_GetClassLoader(JNIEnv *env, jclass cls)) | |
999 JVMWrapper("JVM_GetClassLoader"); | |
1000 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
1001 return NULL; | |
1002 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1003 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
6983 | 1004 oop loader = k->class_loader(); |
0 | 1005 return JNIHandles::make_local(env, loader); |
1006 JVM_END | |
1007 | |
1008 | |
1009 JVM_QUICK_ENTRY(jboolean, JVM_IsInterface(JNIEnv *env, jclass cls)) | |
1010 JVMWrapper("JVM_IsInterface"); | |
1011 oop mirror = JNIHandles::resolve_non_null(cls); | |
1012 if (java_lang_Class::is_primitive(mirror)) { | |
1013 return JNI_FALSE; | |
1014 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1015 Klass* k = java_lang_Class::as_Klass(mirror); |
6983 | 1016 jboolean result = k->is_interface(); |
1017 assert(!result || k->oop_is_instance(), | |
0 | 1018 "all interfaces are instance types"); |
1019 // The compiler intrinsic for isInterface tests the | |
1020 // Klass::_access_flags bits in the same way. | |
1021 return result; | |
1022 JVM_END | |
1023 | |
1024 | |
1025 JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls)) | |
1026 JVMWrapper("JVM_GetClassSigners"); | |
1027 JvmtiVMObjectAllocEventCollector oam; | |
1028 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
1029 // There are no signers for primitive types | |
1030 return NULL; | |
1031 } | |
1032 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1033 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 1034 objArrayOop signers = NULL; |
6983 | 1035 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1036 signers = InstanceKlass::cast(k)->signers(); |
0 | 1037 } |
1038 | |
1039 // If there are no signers set in the class, or if the class | |
1040 // is an array, return NULL. | |
1041 if (signers == NULL) return NULL; | |
1042 | |
1043 // copy of the signers array | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
1044 Klass* element = ObjArrayKlass::cast(signers->klass())->element_klass(); |
0 | 1045 objArrayOop signers_copy = oopFactory::new_objArray(element, signers->length(), CHECK_NULL); |
1046 for (int index = 0; index < signers->length(); index++) { | |
1047 signers_copy->obj_at_put(index, signers->obj_at(index)); | |
1048 } | |
1049 | |
1050 // return the copy | |
1051 return (jobjectArray) JNIHandles::make_local(env, signers_copy); | |
1052 JVM_END | |
1053 | |
1054 | |
1055 JVM_ENTRY(void, JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)) | |
1056 JVMWrapper("JVM_SetClassSigners"); | |
1057 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
1058 // This call is ignored for primitive types and arrays. | |
1059 // Signers are only set once, ClassLoader.java, and thus shouldn't | |
1060 // be called with an array. Only the bootstrap loader creates arrays. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1061 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
6983 | 1062 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1063 InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); |
0 | 1064 } |
1065 } | |
1066 JVM_END | |
1067 | |
1068 | |
1069 JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls)) | |
1070 JVMWrapper("JVM_GetProtectionDomain"); | |
1071 if (JNIHandles::resolve(cls) == NULL) { | |
1072 THROW_(vmSymbols::java_lang_NullPointerException(), NULL); | |
1073 } | |
1074 | |
1075 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
1076 // Primitive types does not have a protection domain. | |
1077 return NULL; | |
1078 } | |
1079 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1080 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
6983 | 1081 return (jobject) JNIHandles::make_local(env, k->protection_domain()); |
0 | 1082 JVM_END |
1083 | |
1084 | |
1085 // Obsolete since 1.2 (Class.setProtectionDomain removed), although | |
1086 // still defined in core libraries as of 1.5. | |
1087 JVM_ENTRY(void, JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)) | |
1088 JVMWrapper("JVM_SetProtectionDomain"); | |
1089 if (JNIHandles::resolve(cls) == NULL) { | |
1090 THROW(vmSymbols::java_lang_NullPointerException()); | |
1091 } | |
1092 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
1093 // Call is ignored for primitive types | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1094 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
0 | 1095 |
1096 // cls won't be an array, as this called only from ClassLoader.defineClass | |
6983 | 1097 if (k->oop_is_instance()) { |
0 | 1098 oop pd = JNIHandles::resolve(protection_domain); |
1099 assert(pd == NULL || pd->is_oop(), "just checking"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1100 InstanceKlass::cast(k)->set_protection_domain(pd); |
0 | 1101 } |
1102 } | |
1103 JVM_END | |
1104 | |
1105 | |
1106 JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)) | |
1107 JVMWrapper("JVM_DoPrivileged"); | |
1108 | |
1109 if (action == NULL) { | |
1110 THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), "Null action"); | |
1111 } | |
1112 | |
1113 // Stack allocated list of privileged stack elements | |
1114 PrivilegedElement pi; | |
1115 | |
1116 // Check that action object understands "Object run()" | |
1117 Handle object (THREAD, JNIHandles::resolve(action)); | |
1118 | |
1119 // get run() method | |
6983 | 1120 Method* m_oop = object->klass()->uncached_lookup_method( |
0 | 1121 vmSymbols::run_method_name(), |
1122 vmSymbols::void_object_signature()); | |
1123 methodHandle m (THREAD, m_oop); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1124 if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) { |
0 | 1125 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method"); |
1126 } | |
1127 | |
1128 // Compute the frame initiating the do privileged operation and setup the privileged stack | |
1129 vframeStream vfst(thread); | |
1130 vfst.security_get_caller_frame(1); | |
1131 | |
1132 if (!vfst.at_end()) { | |
1133 pi.initialize(&vfst, JNIHandles::resolve(context), thread->privileged_stack_top(), CHECK_NULL); | |
1134 thread->set_privileged_stack_top(&pi); | |
1135 } | |
1136 | |
1137 | |
1138 // invoke the Object run() in the action object. We cannot use call_interface here, since the static type | |
1139 // is not really known - it is either java.security.PrivilegedAction or java.security.PrivilegedExceptionAction | |
1140 Handle pending_exception; | |
1141 JavaValue result(T_OBJECT); | |
1142 JavaCallArguments args(object); | |
1143 JavaCalls::call(&result, m, &args, THREAD); | |
1144 | |
1145 // done with action, remove ourselves from the list | |
1146 if (!vfst.at_end()) { | |
1147 assert(thread->privileged_stack_top() != NULL && thread->privileged_stack_top() == &pi, "wrong top element"); | |
1148 thread->set_privileged_stack_top(thread->privileged_stack_top()->next()); | |
1149 } | |
1150 | |
1151 if (HAS_PENDING_EXCEPTION) { | |
1152 pending_exception = Handle(THREAD, PENDING_EXCEPTION); | |
1153 CLEAR_PENDING_EXCEPTION; | |
1154 | |
1142 | 1155 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && |
1156 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { | |
0 | 1157 // Throw a java.security.PrivilegedActionException(Exception e) exception |
1158 JavaCallArguments args(pending_exception); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1159 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1160 vmSymbols::exception_void_signature(), |
0 | 1161 &args); |
1162 } | |
1163 } | |
1164 | |
1165 if (pending_exception.not_null()) THROW_OOP_0(pending_exception()); | |
1166 return JNIHandles::make_local(env, (oop) result.get_jobject()); | |
1167 JVM_END | |
1168 | |
1169 | |
1170 // Returns the inherited_access_control_context field of the running thread. | |
1171 JVM_ENTRY(jobject, JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)) | |
1172 JVMWrapper("JVM_GetInheritedAccessControlContext"); | |
1173 oop result = java_lang_Thread::inherited_access_control_context(thread->threadObj()); | |
1174 return JNIHandles::make_local(env, result); | |
1175 JVM_END | |
1176 | |
1177 class RegisterArrayForGC { | |
1178 private: | |
1179 JavaThread *_thread; | |
1180 public: | |
1181 RegisterArrayForGC(JavaThread *thread, GrowableArray<oop>* array) { | |
1182 _thread = thread; | |
1183 _thread->register_array_for_gc(array); | |
1184 } | |
1185 | |
1186 ~RegisterArrayForGC() { | |
1187 _thread->register_array_for_gc(NULL); | |
1188 } | |
1189 }; | |
1190 | |
1191 | |
1192 JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) | |
1193 JVMWrapper("JVM_GetStackAccessControlContext"); | |
1194 if (!UsePrivilegedStack) return NULL; | |
1195 | |
1196 ResourceMark rm(THREAD); | |
1197 GrowableArray<oop>* local_array = new GrowableArray<oop>(12); | |
1198 JvmtiVMObjectAllocEventCollector oam; | |
1199 | |
1200 // count the protection domains on the execution stack. We collapse | |
1201 // duplicate consecutive protection domains into a single one, as | |
1202 // well as stopping when we hit a privileged frame. | |
1203 | |
1204 // Use vframeStream to iterate through Java frames | |
1205 vframeStream vfst(thread); | |
1206 | |
1207 oop previous_protection_domain = NULL; | |
1208 Handle privileged_context(thread, NULL); | |
1209 bool is_privileged = false; | |
1210 oop protection_domain = NULL; | |
1211 | |
1212 for(; !vfst.at_end(); vfst.next()) { | |
1213 // get method of frame | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1214 Method* method = vfst.method(); |
0 | 1215 intptr_t* frame_id = vfst.frame_id(); |
1216 | |
1217 // check the privileged frames to see if we have a match | |
1218 if (thread->privileged_stack_top() && thread->privileged_stack_top()->frame_id() == frame_id) { | |
1219 // this frame is privileged | |
1220 is_privileged = true; | |
1221 privileged_context = Handle(thread, thread->privileged_stack_top()->privileged_context()); | |
1222 protection_domain = thread->privileged_stack_top()->protection_domain(); | |
1223 } else { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
1224 protection_domain = method->method_holder()->protection_domain(); |
0 | 1225 } |
1226 | |
1227 if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { | |
1228 local_array->push(protection_domain); | |
1229 previous_protection_domain = protection_domain; | |
1230 } | |
1231 | |
1232 if (is_privileged) break; | |
1233 } | |
1234 | |
1235 | |
1236 // either all the domains on the stack were system domains, or | |
1237 // we had a privileged system domain | |
1238 if (local_array->is_empty()) { | |
1239 if (is_privileged && privileged_context.is_null()) return NULL; | |
1240 | |
1241 oop result = java_security_AccessControlContext::create(objArrayHandle(), is_privileged, privileged_context, CHECK_NULL); | |
1242 return JNIHandles::make_local(env, result); | |
1243 } | |
1244 | |
1245 // the resource area must be registered in case of a gc | |
1246 RegisterArrayForGC ragc(thread, local_array); | |
1142 | 1247 objArrayOop context = oopFactory::new_objArray(SystemDictionary::ProtectionDomain_klass(), |
0 | 1248 local_array->length(), CHECK_NULL); |
1249 objArrayHandle h_context(thread, context); | |
1250 for (int index = 0; index < local_array->length(); index++) { | |
1251 h_context->obj_at_put(index, local_array->at(index)); | |
1252 } | |
1253 | |
1254 oop result = java_security_AccessControlContext::create(h_context, is_privileged, privileged_context, CHECK_NULL); | |
1255 | |
1256 return JNIHandles::make_local(env, result); | |
1257 JVM_END | |
1258 | |
1259 | |
1260 JVM_QUICK_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls)) | |
1261 JVMWrapper("JVM_IsArrayClass"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1262 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
6983 | 1263 return (k != NULL) && k->oop_is_array() ? true : false; |
0 | 1264 JVM_END |
1265 | |
1266 | |
1267 JVM_QUICK_ENTRY(jboolean, JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)) | |
1268 JVMWrapper("JVM_IsPrimitiveClass"); | |
1269 oop mirror = JNIHandles::resolve_non_null(cls); | |
1270 return (jboolean) java_lang_Class::is_primitive(mirror); | |
1271 JVM_END | |
1272 | |
1273 | |
1274 JVM_ENTRY(jclass, JVM_GetComponentType(JNIEnv *env, jclass cls)) | |
1275 JVMWrapper("JVM_GetComponentType"); | |
1276 oop mirror = JNIHandles::resolve_non_null(cls); | |
1277 oop result = Reflection::array_component_type(mirror, CHECK_NULL); | |
1278 return (jclass) JNIHandles::make_local(env, result); | |
1279 JVM_END | |
1280 | |
1281 | |
1282 JVM_ENTRY(jint, JVM_GetClassModifiers(JNIEnv *env, jclass cls)) | |
1283 JVMWrapper("JVM_GetClassModifiers"); | |
1284 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
1285 // Primitive type | |
1286 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; | |
1287 } | |
1288 | |
6983 | 1289 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 1290 debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0)); |
1291 assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK"); | |
1292 return k->modifier_flags(); | |
1293 JVM_END | |
1294 | |
1295 | |
1296 // Inner class reflection /////////////////////////////////////////////////////////////////////////////// | |
1297 | |
1298 JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) | |
1299 JvmtiVMObjectAllocEventCollector oam; | |
1300 // ofClass is a reference to a java_lang_Class object. The mirror object | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1301 // of an InstanceKlass |
0 | 1302 |
1303 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || | |
6983 | 1304 ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) { |
1142 | 1305 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
0 | 1306 return (jobjectArray)JNIHandles::make_local(env, result); |
1307 } | |
1308 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1309 instanceKlassHandle k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1310 InnerClassesIterator iter(k); |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1311 |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1312 if (iter.length() == 0) { |
0 | 1313 // Neither an inner nor outer class |
1142 | 1314 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
0 | 1315 return (jobjectArray)JNIHandles::make_local(env, result); |
1316 } | |
1317 | |
1318 // find inner class info | |
1319 constantPoolHandle cp(thread, k->constants()); | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1320 int length = iter.length(); |
0 | 1321 |
1322 // Allocate temp. result array | |
1142 | 1323 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), length/4, CHECK_NULL); |
0 | 1324 objArrayHandle result (THREAD, r); |
1325 int members = 0; | |
1326 | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1327 for (; !iter.done(); iter.next()) { |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1328 int ioff = iter.inner_class_info_index(); |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1329 int ooff = iter.outer_class_info_index(); |
0 | 1330 |
1331 if (ioff != 0 && ooff != 0) { | |
1332 // Check to see if the name matches the class we're looking for | |
1333 // before attempting to find the class. | |
1334 if (cp->klass_name_at_matches(k, ooff)) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1335 Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); |
0 | 1336 if (outer_klass == k()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1337 Klass* ik = cp->klass_at(ioff, CHECK_NULL); |
0 | 1338 instanceKlassHandle inner_klass (THREAD, ik); |
1339 | |
1340 // Throws an exception if outer klass has not declared k as | |
1341 // an inner klass | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1342 Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL); |
0 | 1343 |
1344 result->obj_at_put(members, inner_klass->java_mirror()); | |
1345 members++; | |
1346 } | |
1347 } | |
1348 } | |
1349 } | |
1350 | |
1351 if (members != length) { | |
1352 // Return array of right length | |
1142 | 1353 objArrayOop res = oopFactory::new_objArray(SystemDictionary::Class_klass(), members, CHECK_NULL); |
0 | 1354 for(int i = 0; i < members; i++) { |
1355 res->obj_at_put(i, result->obj_at(i)); | |
1356 } | |
1357 return (jobjectArray)JNIHandles::make_local(env, res); | |
1358 } | |
1359 | |
1360 return (jobjectArray)JNIHandles::make_local(env, result()); | |
1361 JVM_END | |
1362 | |
1363 | |
1364 JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1365 { |
0 | 1366 // ofClass is a reference to a java_lang_Class object. |
1367 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || | |
6983 | 1368 ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) { |
0 | 1369 return NULL; |
1370 } | |
1371 | |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1372 bool inner_is_member = false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1373 Klass* outer_klass |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1374 = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)) |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1375 )->compute_enclosing_class(&inner_is_member, CHECK_NULL); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1376 if (outer_klass == NULL) return NULL; // already a top-level class |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1377 if (!inner_is_member) return NULL; // an anonymous class (inside a method) |
6983 | 1378 return (jclass) JNIHandles::make_local(env, outer_klass->java_mirror()); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1379 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1380 JVM_END |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1381 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1382 // should be in InstanceKlass.cpp, but is here for historical reasons |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1383 Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle k, |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1384 bool* inner_is_member, |
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1385 TRAPS) { |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1386 Thread* thread = THREAD; |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1387 InnerClassesIterator iter(k); |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1388 if (iter.length() == 0) { |
0 | 1389 // No inner class info => no declaring class |
1390 return NULL; | |
1391 } | |
1392 | |
1393 constantPoolHandle i_cp(thread, k->constants()); | |
1394 | |
1395 bool found = false; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1396 Klass* ok; |
0 | 1397 instanceKlassHandle outer_klass; |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1398 *inner_is_member = false; |
0 | 1399 |
1400 // Find inner_klass attribute | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1401 for (; !iter.done() && !found; iter.next()) { |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1402 int ioff = iter.inner_class_info_index(); |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1403 int ooff = iter.outer_class_info_index(); |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4872
diff
changeset
|
1404 int noff = iter.inner_name_index(); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1405 if (ioff != 0) { |
0 | 1406 // Check to see if the name matches the class we're looking for |
1407 // before attempting to find the class. | |
1408 if (i_cp->klass_name_at_matches(k, ioff)) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1409 Klass* inner_klass = i_cp->klass_at(ioff, CHECK_NULL); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1410 found = (k() == inner_klass); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1411 if (found && ooff != 0) { |
0 | 1412 ok = i_cp->klass_at(ooff, CHECK_NULL); |
1413 outer_klass = instanceKlassHandle(thread, ok); | |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1414 *inner_is_member = true; |
0 | 1415 } |
1416 } | |
1417 } | |
1418 } | |
1419 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1420 if (found && outer_klass.is_null()) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1421 // It may be anonymous; try for that. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1422 int encl_method_class_idx = k->enclosing_method_class_index(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1423 if (encl_method_class_idx != 0) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1424 ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1425 outer_klass = instanceKlassHandle(thread, ok); |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1426 *inner_is_member = false; |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1427 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1428 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1429 |
0 | 1430 // If no inner class attribute found for this class. |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1431 if (outer_klass.is_null()) return NULL; |
0 | 1432 |
1433 // Throws an exception if outer klass has not declared k as an inner klass | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1434 // We need evidence that each klass knows about the other, or else |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1435 // the system could allow a spoof of an inner class to gain access rights. |
1126
933a3e806ce6
6895168: JCK api/signaturetest/sigtest.basic.html#basic test fails for jdk 5.0 with HS 16 in nightly build
xlu
parents:
1059
diff
changeset
|
1436 Reflection::check_for_inner_class(outer_klass, k, *inner_is_member, CHECK_NULL); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1437 return outer_klass(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
1438 } |
0 | 1439 |
1440 JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls)) | |
1441 assert (cls != NULL, "illegal class"); | |
1442 JVMWrapper("JVM_GetClassSignature"); | |
1443 JvmtiVMObjectAllocEventCollector oam; | |
1444 ResourceMark rm(THREAD); | |
1445 // Return null for arrays and primatives | |
1446 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1447 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
6983 | 1448 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1449 Symbol* sym = InstanceKlass::cast(k)->generic_signature(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1450 if (sym == NULL) return NULL; |
0 | 1451 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
1452 return (jstring) JNIHandles::make_local(env, str()); | |
1453 } | |
1454 } | |
1455 return NULL; | |
1456 JVM_END | |
1457 | |
1458 | |
1459 JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) | |
1460 assert (cls != NULL, "illegal class"); | |
1461 JVMWrapper("JVM_GetClassAnnotations"); | |
1462 ResourceMark rm(THREAD); | |
1463 // Return null for arrays and primitives | |
1464 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1465 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
6983 | 1466 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1467 typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->class_annotations(), CHECK_NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1468 return (jbyteArray) JNIHandles::make_local(env, a); |
0 | 1469 } |
1470 } | |
1471 return NULL; | |
1472 JVM_END | |
1473 | |
1474 | |
1475 JVM_ENTRY(jbyteArray, JVM_GetFieldAnnotations(JNIEnv *env, jobject field)) | |
1476 assert(field != NULL, "illegal field"); | |
1477 JVMWrapper("JVM_GetFieldAnnotations"); | |
1478 | |
1479 // some of this code was adapted from from jni_FromReflectedField | |
1480 | |
1481 // field is a handle to a java.lang.reflect.Field object | |
1482 oop reflected = JNIHandles::resolve_non_null(field); | |
1483 oop mirror = java_lang_reflect_Field::clazz(reflected); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1484 Klass* k = java_lang_Class::as_Klass(mirror); |
0 | 1485 int slot = java_lang_reflect_Field::slot(reflected); |
1486 int modifiers = java_lang_reflect_Field::modifiers(reflected); | |
1487 | |
1488 fieldDescriptor fd; | |
1489 KlassHandle kh(THREAD, k); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1490 intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); |
0 | 1491 |
1492 if (modifiers & JVM_ACC_STATIC) { | |
1493 // for static fields we only look in the current class | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1494 if (!InstanceKlass::cast(kh())->find_local_field_from_offset(offset, true, &fd)) { |
0 | 1495 assert(false, "cannot find static field"); |
1496 return NULL; // robustness | |
1497 } | |
1498 } else { | |
1499 // for instance fields we start with the current class and work | |
1500 // our way up through the superclass chain | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1501 if (!InstanceKlass::cast(kh())->find_field_from_offset(offset, false, &fd)) { |
0 | 1502 assert(false, "cannot find instance field"); |
1503 return NULL; // robustness | |
1504 } | |
1505 } | |
1506 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1507 return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.annotations(), THREAD)); |
0 | 1508 JVM_END |
1509 | |
1510 | |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1511 static Method* jvm_get_method_common(jobject method) { |
0 | 1512 // some of this code was adapted from from jni_FromReflectedMethod |
1513 | |
1514 oop reflected = JNIHandles::resolve_non_null(method); | |
1515 oop mirror = NULL; | |
1516 int slot = 0; | |
1517 | |
1142 | 1518 if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { |
0 | 1519 mirror = java_lang_reflect_Constructor::clazz(reflected); |
1520 slot = java_lang_reflect_Constructor::slot(reflected); | |
1521 } else { | |
1142 | 1522 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), |
0 | 1523 "wrong type"); |
1524 mirror = java_lang_reflect_Method::clazz(reflected); | |
1525 slot = java_lang_reflect_Method::slot(reflected); | |
1526 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1527 Klass* k = java_lang_Class::as_Klass(mirror); |
0 | 1528 |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1529 Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); |
0 | 1530 if (m == NULL) { |
1531 assert(false, "cannot find method"); | |
1532 return NULL; // robustness | |
1533 } | |
1534 | |
1535 return m; | |
1536 } | |
1537 | |
1538 | |
1539 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) | |
1540 JVMWrapper("JVM_GetMethodAnnotations"); | |
1541 | |
1542 // method is a handle to a java.lang.reflect.Method object | |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1543 Method* m = jvm_get_method_common(method); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1544 return (jbyteArray) JNIHandles::make_local(env, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1545 Annotations::make_java_array(m->annotations(), THREAD)); |
0 | 1546 JVM_END |
1547 | |
1548 | |
1549 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) | |
1550 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); | |
1551 | |
1552 // method is a handle to a java.lang.reflect.Method object | |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1553 Method* m = jvm_get_method_common(method); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1554 return (jbyteArray) JNIHandles::make_local(env, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1555 Annotations::make_java_array(m->annotation_default(), THREAD)); |
0 | 1556 JVM_END |
1557 | |
1558 | |
1559 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) | |
1560 JVMWrapper("JVM_GetMethodParameterAnnotations"); | |
1561 | |
1562 // method is a handle to a java.lang.reflect.Method object | |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1563 Method* m = jvm_get_method_common(method); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1564 return (jbyteArray) JNIHandles::make_local(env, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1565 Annotations::make_java_array(m->parameter_annotations(), THREAD)); |
0 | 1566 JVM_END |
1567 | |
7457
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1568 /* Type use annotations support (JDK 1.8) */ |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1569 |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1570 JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1571 assert (cls != NULL, "illegal class"); |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1572 JVMWrapper("JVM_GetClassTypeAnnotations"); |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1573 ResourceMark rm(THREAD); |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1574 // Return null for arrays and primitives |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1575 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1576 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1577 if (k->oop_is_instance()) { |
7611
ff0a7943fd29
8005994: Method annotations are allocated unnecessarily during class file parsing
stefank
parents:
7462
diff
changeset
|
1578 Annotations* type_annotations = InstanceKlass::cast(k)->type_annotations(); |
ff0a7943fd29
8005994: Method annotations are allocated unnecessarily during class file parsing
stefank
parents:
7462
diff
changeset
|
1579 if (type_annotations != NULL) { |
ff0a7943fd29
8005994: Method annotations are allocated unnecessarily during class file parsing
stefank
parents:
7462
diff
changeset
|
1580 typeArrayOop a = Annotations::make_java_array(type_annotations->class_annotations(), CHECK_NULL); |
ff0a7943fd29
8005994: Method annotations are allocated unnecessarily during class file parsing
stefank
parents:
7462
diff
changeset
|
1581 return (jbyteArray) JNIHandles::make_local(env, a); |
ff0a7943fd29
8005994: Method annotations are allocated unnecessarily during class file parsing
stefank
parents:
7462
diff
changeset
|
1582 } |
7457
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1583 } |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1584 } |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1585 return NULL; |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1586 JVM_END |
35431a769282
8004823: Add VM support for type annotation reflection
stefank
parents:
6983
diff
changeset
|
1587 |
7588
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1588 static void bounds_check(constantPoolHandle cp, jint index, TRAPS) { |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1589 if (!cp->is_within_bounds(index)) { |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1590 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds"); |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1591 } |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1592 } |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1593 |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1594 JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1595 { |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1596 JVMWrapper("JVM_GetMethodParameters"); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1597 // method is a handle to a java.lang.reflect.Method object |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1598 Method* method_ptr = jvm_get_method_common(method); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1599 methodHandle mh (THREAD, method_ptr); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1600 Handle reflected_method (THREAD, JNIHandles::resolve_non_null(method)); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1601 const int num_params = mh->method_parameters_length(); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1602 |
7588
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1603 if (0 != num_params) { |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1604 // make sure all the symbols are properly formatted |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1605 for (int i = 0; i < num_params; i++) { |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1606 MethodParametersElement* params = mh->method_parameters_start(); |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1607 int index = params[i].name_cp_index; |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1608 bounds_check(mh->constants(), index, CHECK_NULL); |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1609 |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1610 if (0 != index && !mh->constants()->tag_at(index).is_utf8()) { |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1611 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1612 "Wrong type at constant pool index"); |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1613 } |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1614 |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1615 } |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1616 |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1617 objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1618 objArrayHandle result (THREAD, result_oop); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1619 |
7588
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1620 for (int i = 0; i < num_params; i++) { |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1621 MethodParametersElement* params = mh->method_parameters_start(); |
7588
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1622 // For a 0 index, give a NULL symbol |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1623 Symbol* const sym = 0 != params[i].name_cp_index ? |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1624 mh->constants()->symbol_at(params[i].name_cp_index) : NULL; |
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1625 int flags = build_int_from_shorts(params[i].flags_lo, params[i].flags_hi); |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1626 oop param = Reflection::new_parameter(reflected_method, i, sym, |
7588
f9eb431c3efe
8006005: Fix constant pool index validation and alignment trap for method parameter reflection
coleenp
parents:
7462
diff
changeset
|
1627 flags, CHECK_NULL); |
7462
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1628 result->obj_at_put(i, param); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1629 } |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1630 return (jobjectArray)JNIHandles::make_local(env, result()); |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1631 } else { |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1632 return (jobjectArray)NULL; |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1633 } |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1634 } |
ade95d680b42
8004728: Add hotspot support for parameter reflection
coleenp
parents:
7457
diff
changeset
|
1635 JVM_END |
0 | 1636 |
1637 // New (JDK 1.4) reflection implementation ///////////////////////////////////// | |
1638 | |
1639 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)) | |
1640 { | |
1641 JVMWrapper("JVM_GetClassDeclaredFields"); | |
1642 JvmtiVMObjectAllocEventCollector oam; | |
1643 | |
1644 // Exclude primitive types and array types | |
1645 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || | |
6983 | 1646 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { |
0 | 1647 // Return empty array |
1142 | 1648 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); |
0 | 1649 return (jobjectArray) JNIHandles::make_local(env, res); |
1650 } | |
1651 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1652 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
0 | 1653 constantPoolHandle cp(THREAD, k->constants()); |
1654 | |
1655 // Ensure class is linked | |
1656 k->link_class(CHECK_NULL); | |
1657 | |
1658 // 4496456 We need to filter out java.lang.Throwable.backtrace | |
1659 bool skip_backtrace = false; | |
1660 | |
1661 // Allocate result | |
1662 int num_fields; | |
1663 | |
1664 if (publicOnly) { | |
1665 num_fields = 0; | |
3938 | 1666 for (JavaFieldStream fs(k()); !fs.done(); fs.next()) { |
1667 if (fs.access_flags().is_public()) ++num_fields; | |
0 | 1668 } |
1669 } else { | |
3938 | 1670 num_fields = k->java_fields_count(); |
0 | 1671 |
1142 | 1672 if (k() == SystemDictionary::Throwable_klass()) { |
0 | 1673 num_fields--; |
1674 skip_backtrace = true; | |
1675 } | |
1676 } | |
1677 | |
1142 | 1678 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), num_fields, CHECK_NULL); |
0 | 1679 objArrayHandle result (THREAD, r); |
1680 | |
1681 int out_idx = 0; | |
1682 fieldDescriptor fd; | |
3938 | 1683 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
0 | 1684 if (skip_backtrace) { |
1685 // 4496456 skip java.lang.Throwable.backtrace | |
3938 | 1686 int offset = fs.offset(); |
0 | 1687 if (offset == java_lang_Throwable::get_backtrace_offset()) continue; |
1688 } | |
1689 | |
3938 | 1690 if (!publicOnly || fs.access_flags().is_public()) { |
1691 fd.initialize(k(), fs.index()); | |
0 | 1692 oop field = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); |
1693 result->obj_at_put(out_idx, field); | |
1694 ++out_idx; | |
1695 } | |
1696 } | |
1697 assert(out_idx == num_fields, "just checking"); | |
1698 return (jobjectArray) JNIHandles::make_local(env, result()); | |
1699 } | |
1700 JVM_END | |
1701 | |
1702 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)) | |
1703 { | |
1704 JVMWrapper("JVM_GetClassDeclaredMethods"); | |
1705 JvmtiVMObjectAllocEventCollector oam; | |
1706 | |
1707 // Exclude primitive types and array types | |
1708 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) | |
6983 | 1709 || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { |
0 | 1710 // Return empty array |
1142 | 1711 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL); |
0 | 1712 return (jobjectArray) JNIHandles::make_local(env, res); |
1713 } | |
1714 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1715 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
0 | 1716 |
1717 // Ensure class is linked | |
1718 k->link_class(CHECK_NULL); | |
1719 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1720 Array<Method*>* methods = k->methods(); |
0 | 1721 int methods_length = methods->length(); |
1722 int num_methods = 0; | |
1723 | |
1724 int i; | |
1725 for (i = 0; i < methods_length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1726 methodHandle method(THREAD, methods->at(i)); |
0 | 1727 if (!method->is_initializer()) { |
1728 if (!publicOnly || method->is_public()) { | |
1729 ++num_methods; | |
1730 } | |
1731 } | |
1732 } | |
1733 | |
1734 // Allocate result | |
1142 | 1735 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), num_methods, CHECK_NULL); |
0 | 1736 objArrayHandle result (THREAD, r); |
1737 | |
1738 int out_idx = 0; | |
1739 for (i = 0; i < methods_length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1740 methodHandle method(THREAD, methods->at(i)); |
0 | 1741 if (!method->is_initializer()) { |
1742 if (!publicOnly || method->is_public()) { | |
1743 oop m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL); | |
1744 result->obj_at_put(out_idx, m); | |
1745 ++out_idx; | |
1746 } | |
1747 } | |
1748 } | |
1749 assert(out_idx == num_methods, "just checking"); | |
1750 return (jobjectArray) JNIHandles::make_local(env, result()); | |
1751 } | |
1752 JVM_END | |
1753 | |
1754 JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)) | |
1755 { | |
1756 JVMWrapper("JVM_GetClassDeclaredConstructors"); | |
1757 JvmtiVMObjectAllocEventCollector oam; | |
1758 | |
1759 // Exclude primitive types and array types | |
1760 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) | |
6983 | 1761 || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) { |
0 | 1762 // Return empty array |
1142 | 1763 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL); |
0 | 1764 return (jobjectArray) JNIHandles::make_local(env, res); |
1765 } | |
1766 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1767 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
0 | 1768 |
1769 // Ensure class is linked | |
1770 k->link_class(CHECK_NULL); | |
1771 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1772 Array<Method*>* methods = k->methods(); |
0 | 1773 int methods_length = methods->length(); |
1774 int num_constructors = 0; | |
1775 | |
1776 int i; | |
1777 for (i = 0; i < methods_length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1778 methodHandle method(THREAD, methods->at(i)); |
0 | 1779 if (method->is_initializer() && !method->is_static()) { |
1780 if (!publicOnly || method->is_public()) { | |
1781 ++num_constructors; | |
1782 } | |
1783 } | |
1784 } | |
1785 | |
1786 // Allocate result | |
1142 | 1787 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), num_constructors, CHECK_NULL); |
0 | 1788 objArrayHandle result(THREAD, r); |
1789 | |
1790 int out_idx = 0; | |
1791 for (i = 0; i < methods_length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1792 methodHandle method(THREAD, methods->at(i)); |
0 | 1793 if (method->is_initializer() && !method->is_static()) { |
1794 if (!publicOnly || method->is_public()) { | |
1795 oop m = Reflection::new_constructor(method, CHECK_NULL); | |
1796 result->obj_at_put(out_idx, m); | |
1797 ++out_idx; | |
1798 } | |
1799 } | |
1800 } | |
1801 assert(out_idx == num_constructors, "just checking"); | |
1802 return (jobjectArray) JNIHandles::make_local(env, result()); | |
1803 } | |
1804 JVM_END | |
1805 | |
1806 JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)) | |
1807 { | |
1808 JVMWrapper("JVM_GetClassAccessFlags"); | |
1809 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
1810 // Primitive type | |
1811 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; | |
1812 } | |
1813 | |
6983 | 1814 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 1815 return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1816 } | |
1817 JVM_END | |
1818 | |
1819 | |
1820 // Constant pool access ////////////////////////////////////////////////////////// | |
1821 | |
1822 JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls)) | |
1823 { | |
1824 JVMWrapper("JVM_GetClassConstantPool"); | |
1825 JvmtiVMObjectAllocEventCollector oam; | |
1826 | |
1827 // Return null for primitives and arrays | |
1828 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1829 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
6983 | 1830 if (k->oop_is_instance()) { |
0 | 1831 instanceKlassHandle k_h(THREAD, k); |
1832 Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1833 sun_reflect_ConstantPool::set_cp(jcp(), k_h->constants()); |
0 | 1834 return JNIHandles::make_local(jcp()); |
1835 } | |
1836 } | |
1837 return NULL; | |
1838 } | |
1839 JVM_END | |
1840 | |
1841 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1842 JVM_ENTRY(jint, JVM_ConstantPoolGetSize(JNIEnv *env, jobject obj, jobject unused)) |
0 | 1843 { |
1844 JVMWrapper("JVM_ConstantPoolGetSize"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1845 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1846 return cp->length(); |
1847 } | |
1848 JVM_END | |
1849 | |
1850 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1851 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1852 { |
1853 JVMWrapper("JVM_ConstantPoolGetClassAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1854 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1855 bounds_check(cp, index, CHECK_NULL); |
1856 constantTag tag = cp->tag_at(index); | |
1857 if (!tag.is_klass() && !tag.is_unresolved_klass()) { | |
1858 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
1859 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1860 Klass* k = cp->klass_at(index, CHECK_NULL); |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2191
diff
changeset
|
1861 return (jclass) JNIHandles::make_local(k->java_mirror()); |
0 | 1862 } |
1863 JVM_END | |
1864 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1865 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1866 { |
1867 JVMWrapper("JVM_ConstantPoolGetClassAtIfLoaded"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1868 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1869 bounds_check(cp, index, CHECK_NULL); |
1870 constantTag tag = cp->tag_at(index); | |
1871 if (!tag.is_klass() && !tag.is_unresolved_klass()) { | |
1872 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
1873 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1874 Klass* k = ConstantPool::klass_at_if_loaded(cp, index); |
0 | 1875 if (k == NULL) return NULL; |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2191
diff
changeset
|
1876 return (jclass) JNIHandles::make_local(k->java_mirror()); |
0 | 1877 } |
1878 JVM_END | |
1879 | |
1880 static jobject get_method_at_helper(constantPoolHandle cp, jint index, bool force_resolution, TRAPS) { | |
1881 constantTag tag = cp->tag_at(index); | |
1882 if (!tag.is_method() && !tag.is_interface_method()) { | |
1883 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
1884 } | |
1885 int klass_ref = cp->uncached_klass_ref_index_at(index); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1886 Klass* k_o; |
0 | 1887 if (force_resolution) { |
1888 k_o = cp->klass_at(klass_ref, CHECK_NULL); | |
1889 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1890 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
0 | 1891 if (k_o == NULL) return NULL; |
1892 } | |
1893 instanceKlassHandle k(THREAD, k_o); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1894 Symbol* name = cp->uncached_name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1895 Symbol* sig = cp->uncached_signature_ref_at(index); |
0 | 1896 methodHandle m (THREAD, k->find_method(name, sig)); |
1897 if (m.is_null()) { | |
1898 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); | |
1899 } | |
1900 oop method; | |
1901 if (!m->is_initializer() || m->is_static()) { | |
1902 method = Reflection::new_method(m, true, true, CHECK_NULL); | |
1903 } else { | |
1904 method = Reflection::new_constructor(m, CHECK_NULL); | |
1905 } | |
1906 return JNIHandles::make_local(method); | |
1907 } | |
1908 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1909 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1910 { |
1911 JVMWrapper("JVM_ConstantPoolGetMethodAt"); | |
1912 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1913 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1914 bounds_check(cp, index, CHECK_NULL); |
1915 jobject res = get_method_at_helper(cp, index, true, CHECK_NULL); | |
1916 return res; | |
1917 } | |
1918 JVM_END | |
1919 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1920 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1921 { |
1922 JVMWrapper("JVM_ConstantPoolGetMethodAtIfLoaded"); | |
1923 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1924 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1925 bounds_check(cp, index, CHECK_NULL); |
1926 jobject res = get_method_at_helper(cp, index, false, CHECK_NULL); | |
1927 return res; | |
1928 } | |
1929 JVM_END | |
1930 | |
1931 static jobject get_field_at_helper(constantPoolHandle cp, jint index, bool force_resolution, TRAPS) { | |
1932 constantTag tag = cp->tag_at(index); | |
1933 if (!tag.is_field()) { | |
1934 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
1935 } | |
1936 int klass_ref = cp->uncached_klass_ref_index_at(index); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1937 Klass* k_o; |
0 | 1938 if (force_resolution) { |
1939 k_o = cp->klass_at(klass_ref, CHECK_NULL); | |
1940 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1941 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
0 | 1942 if (k_o == NULL) return NULL; |
1943 } | |
1944 instanceKlassHandle k(THREAD, k_o); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1945 Symbol* name = cp->uncached_name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1946 Symbol* sig = cp->uncached_signature_ref_at(index); |
0 | 1947 fieldDescriptor fd; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1948 Klass* target_klass = k->find_field(name, sig, &fd); |
0 | 1949 if (target_klass == NULL) { |
1950 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); | |
1951 } | |
1952 oop field = Reflection::new_field(&fd, true, CHECK_NULL); | |
1953 return JNIHandles::make_local(field); | |
1954 } | |
1955 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1956 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject obj, jobject unusedl, jint index)) |
0 | 1957 { |
1958 JVMWrapper("JVM_ConstantPoolGetFieldAt"); | |
1959 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1960 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1961 bounds_check(cp, index, CHECK_NULL); |
1962 jobject res = get_field_at_helper(cp, index, true, CHECK_NULL); | |
1963 return res; | |
1964 } | |
1965 JVM_END | |
1966 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1967 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1968 { |
1969 JVMWrapper("JVM_ConstantPoolGetFieldAtIfLoaded"); | |
1970 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1971 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1972 bounds_check(cp, index, CHECK_NULL); |
1973 jobject res = get_field_at_helper(cp, index, false, CHECK_NULL); | |
1974 return res; | |
1975 } | |
1976 JVM_END | |
1977 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1978 JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 1979 { |
1980 JVMWrapper("JVM_ConstantPoolGetMemberRefInfoAt"); | |
1981 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1982 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 1983 bounds_check(cp, index, CHECK_NULL); |
1984 constantTag tag = cp->tag_at(index); | |
1985 if (!tag.is_field_or_method()) { | |
1986 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
1987 } | |
1988 int klass_ref = cp->uncached_klass_ref_index_at(index); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1989 Symbol* klass_name = cp->klass_name_at(klass_ref); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1990 Symbol* member_name = cp->uncached_name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
1991 Symbol* member_sig = cp->uncached_signature_ref_at(index); |
1142 | 1992 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 3, CHECK_NULL); |
0 | 1993 objArrayHandle dest(THREAD, dest_o); |
1994 Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL); | |
1995 dest->obj_at_put(0, str()); | |
1996 str = java_lang_String::create_from_symbol(member_name, CHECK_NULL); | |
1997 dest->obj_at_put(1, str()); | |
1998 str = java_lang_String::create_from_symbol(member_sig, CHECK_NULL); | |
1999 dest->obj_at_put(2, str()); | |
2000 return (jobjectArray) JNIHandles::make_local(dest()); | |
2001 } | |
2002 JVM_END | |
2003 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2004 JVM_ENTRY(jint, JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2005 { |
2006 JVMWrapper("JVM_ConstantPoolGetIntAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2007 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2008 bounds_check(cp, index, CHECK_0); |
2009 constantTag tag = cp->tag_at(index); | |
2010 if (!tag.is_int()) { | |
2011 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
2012 } | |
2013 return cp->int_at(index); | |
2014 } | |
2015 JVM_END | |
2016 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2017 JVM_ENTRY(jlong, JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2018 { |
2019 JVMWrapper("JVM_ConstantPoolGetLongAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2020 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2021 bounds_check(cp, index, CHECK_(0L)); |
2022 constantTag tag = cp->tag_at(index); | |
2023 if (!tag.is_long()) { | |
2024 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
2025 } | |
2026 return cp->long_at(index); | |
2027 } | |
2028 JVM_END | |
2029 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2030 JVM_ENTRY(jfloat, JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2031 { |
2032 JVMWrapper("JVM_ConstantPoolGetFloatAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2033 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2034 bounds_check(cp, index, CHECK_(0.0f)); |
2035 constantTag tag = cp->tag_at(index); | |
2036 if (!tag.is_float()) { | |
2037 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
2038 } | |
2039 return cp->float_at(index); | |
2040 } | |
2041 JVM_END | |
2042 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2043 JVM_ENTRY(jdouble, JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2044 { |
2045 JVMWrapper("JVM_ConstantPoolGetDoubleAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2046 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2047 bounds_check(cp, index, CHECK_(0.0)); |
2048 constantTag tag = cp->tag_at(index); | |
2049 if (!tag.is_double()) { | |
2050 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
2051 } | |
2052 return cp->double_at(index); | |
2053 } | |
2054 JVM_END | |
2055 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2056 JVM_ENTRY(jstring, JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2057 { |
2058 JVMWrapper("JVM_ConstantPoolGetStringAt"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2059 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2060 bounds_check(cp, index, CHECK_NULL); |
2061 constantTag tag = cp->tag_at(index); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2062 if (!tag.is_string()) { |
0 | 2063 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2064 } | |
2065 oop str = cp->string_at(index, CHECK_NULL); | |
2066 return (jstring) JNIHandles::make_local(str); | |
2067 } | |
2068 JVM_END | |
2069 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2070 JVM_ENTRY(jstring, JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject obj, jobject unused, jint index)) |
0 | 2071 { |
2072 JVMWrapper("JVM_ConstantPoolGetUTF8At"); | |
2073 JvmtiVMObjectAllocEventCollector oam; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2074 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
0 | 2075 bounds_check(cp, index, CHECK_NULL); |
2076 constantTag tag = cp->tag_at(index); | |
2077 if (!tag.is_symbol()) { | |
2078 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | |
2079 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2080 Symbol* sym = cp->symbol_at(index); |
0 | 2081 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
2082 return (jstring) JNIHandles::make_local(str()); | |
2083 } | |
2084 JVM_END | |
2085 | |
2086 | |
2087 // Assertion support. ////////////////////////////////////////////////////////// | |
2088 | |
2089 JVM_ENTRY(jboolean, JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)) | |
2090 JVMWrapper("JVM_DesiredAssertionStatus"); | |
2091 assert(cls != NULL, "bad class"); | |
2092 | |
2093 oop r = JNIHandles::resolve(cls); | |
2094 assert(! java_lang_Class::is_primitive(r), "primitive classes not allowed"); | |
2095 if (java_lang_Class::is_primitive(r)) return false; | |
2096 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2097 Klass* k = java_lang_Class::as_Klass(r); |
6983 | 2098 assert(k->oop_is_instance(), "must be an instance klass"); |
2099 if (! k->oop_is_instance()) return false; | |
0 | 2100 |
2101 ResourceMark rm(THREAD); | |
6983 | 2102 const char* name = k->name()->as_C_string(); |
2103 bool system_class = k->class_loader() == NULL; | |
0 | 2104 return JavaAssertions::enabled(name, system_class); |
2105 | |
2106 JVM_END | |
2107 | |
2108 | |
2109 // Return a new AssertionStatusDirectives object with the fields filled in with | |
2110 // command-line assertion arguments (i.e., -ea, -da). | |
2111 JVM_ENTRY(jobject, JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)) | |
2112 JVMWrapper("JVM_AssertionStatusDirectives"); | |
2113 JvmtiVMObjectAllocEventCollector oam; | |
2114 oop asd = JavaAssertions::createAssertionStatusDirectives(CHECK_NULL); | |
2115 return JNIHandles::make_local(env, asd); | |
2116 JVM_END | |
2117 | |
2118 // Verification //////////////////////////////////////////////////////////////////////////////// | |
2119 | |
2120 // Reflection for the verifier ///////////////////////////////////////////////////////////////// | |
2121 | |
2122 // RedefineClasses support: bug 6214132 caused verification to fail. | |
2123 // All functions from this section should call the jvmtiThreadSate function: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2124 // Klass* class_to_verify_considering_redefinition(Klass* klass). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2125 // The function returns a Klass* of the _scratch_class if the verifier |
0 | 2126 // was invoked in the middle of the class redefinition. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2127 // Otherwise it returns its argument value which is the _the_class Klass*. |
0 | 2128 // Please, refer to the description in the jvmtiThreadSate.hpp. |
2129 | |
2130 JVM_ENTRY(const char*, JVM_GetClassNameUTF(JNIEnv *env, jclass cls)) | |
2131 JVMWrapper("JVM_GetClassNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2132 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2133 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6983 | 2134 return k->name()->as_utf8(); |
0 | 2135 JVM_END |
2136 | |
2137 | |
2138 JVM_QUICK_ENTRY(void, JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)) | |
2139 JVMWrapper("JVM_GetClassCPTypes"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2140 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2141 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2142 // types will have length zero if this is not an InstanceKlass |
0 | 2143 // (length is determined by call to JVM_GetClassCPEntriesCount) |
6983 | 2144 if (k->oop_is_instance()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2145 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2146 for (int index = cp->length() - 1; index >= 0; index--) { |
2147 constantTag tag = cp->tag_at(index); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2148 types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : tag.value(); |
0 | 2149 } |
2150 } | |
2151 JVM_END | |
2152 | |
2153 | |
2154 JVM_QUICK_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) | |
2155 JVMWrapper("JVM_GetClassCPEntriesCount"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2156 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2157 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6983 | 2158 if (!k->oop_is_instance()) |
0 | 2159 return 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2160 return InstanceKlass::cast(k)->constants()->length(); |
0 | 2161 JVM_END |
2162 | |
2163 | |
2164 JVM_QUICK_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) | |
2165 JVMWrapper("JVM_GetClassFieldsCount"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2166 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2167 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6983 | 2168 if (!k->oop_is_instance()) |
0 | 2169 return 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2170 return InstanceKlass::cast(k)->java_fields_count(); |
0 | 2171 JVM_END |
2172 | |
2173 | |
2174 JVM_QUICK_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) | |
2175 JVMWrapper("JVM_GetClassMethodsCount"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2176 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2177 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6983 | 2178 if (!k->oop_is_instance()) |
0 | 2179 return 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2180 return InstanceKlass::cast(k)->methods()->length(); |
0 | 2181 JVM_END |
2182 | |
2183 | |
2184 // The following methods, used for the verifier, are never called with | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2185 // array klasses, so a direct cast to InstanceKlass is safe. |
0 | 2186 // Typically, these methods are called in a loop with bounds determined |
2187 // by the results of JVM_GetClass{Fields,Methods}Count, which return | |
2188 // zero for arrays. | |
2189 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)) | |
2190 JVMWrapper("JVM_GetMethodIxExceptionIndexes"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2191 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2192 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2193 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2194 int length = method->checked_exceptions_length(); |
0 | 2195 if (length > 0) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2196 CheckedExceptionElement* table= method->checked_exceptions_start(); |
0 | 2197 for (int i = 0; i < length; i++) { |
2198 exceptions[i] = table[i].class_cp_index; | |
2199 } | |
2200 } | |
2201 JVM_END | |
2202 | |
2203 | |
2204 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)) | |
2205 JVMWrapper("JVM_GetMethodIxExceptionsCount"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2206 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2207 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2208 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2209 return method->checked_exceptions_length(); |
0 | 2210 JVM_END |
2211 | |
2212 | |
2213 JVM_QUICK_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)) | |
2214 JVMWrapper("JVM_GetMethodIxByteCode"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2215 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2216 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2217 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2218 memcpy(code, method->code_base(), method->code_size()); |
0 | 2219 JVM_END |
2220 | |
2221 | |
2222 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)) | |
2223 JVMWrapper("JVM_GetMethodIxByteCodeLength"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2224 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2225 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2226 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2227 return method->code_size(); |
0 | 2228 JVM_END |
2229 | |
2230 | |
2231 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)) | |
2232 JVMWrapper("JVM_GetMethodIxExceptionTableEntry"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2233 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2234 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2235 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2236 ExceptionTable extable(method); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
5967
diff
changeset
|
2237 entry->start_pc = extable.start_pc(entry_index); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
5967
diff
changeset
|
2238 entry->end_pc = extable.end_pc(entry_index); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
5967
diff
changeset
|
2239 entry->handler_pc = extable.handler_pc(entry_index); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
5967
diff
changeset
|
2240 entry->catchType = extable.catch_type_index(entry_index); |
0 | 2241 JVM_END |
2242 | |
2243 | |
2244 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)) | |
2245 JVMWrapper("JVM_GetMethodIxExceptionTableLength"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2246 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2247 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2248 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2249 return method->exception_table_length(); |
0 | 2250 JVM_END |
2251 | |
2252 | |
2253 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)) | |
2254 JVMWrapper("JVM_GetMethodIxModifiers"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2255 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2256 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2257 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2258 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
0 | 2259 JVM_END |
2260 | |
2261 | |
2262 JVM_QUICK_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) | |
2263 JVMWrapper("JVM_GetFieldIxModifiers"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2264 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2265 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2266 return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; |
0 | 2267 JVM_END |
2268 | |
2269 | |
2270 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)) | |
2271 JVMWrapper("JVM_GetMethodIxLocalsCount"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2272 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2273 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2274 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2275 return method->max_locals(); |
0 | 2276 JVM_END |
2277 | |
2278 | |
2279 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)) | |
2280 JVMWrapper("JVM_GetMethodIxArgsSize"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2281 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2282 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2283 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2284 return method->size_of_parameters(); |
0 | 2285 JVM_END |
2286 | |
2287 | |
2288 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)) | |
2289 JVMWrapper("JVM_GetMethodIxMaxStack"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2290 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2291 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2292 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2293 return method->verifier_max_stack(); |
0 | 2294 JVM_END |
2295 | |
2296 | |
2297 JVM_QUICK_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)) | |
2298 JVMWrapper("JVM_IsConstructorIx"); | |
2299 ResourceMark rm(THREAD); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2300 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2301 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2302 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2303 return method->name() == vmSymbols::object_initializer_name(); |
0 | 2304 JVM_END |
2305 | |
2306 | |
2307 JVM_ENTRY(const char*, JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)) | |
2308 JVMWrapper("JVM_GetMethodIxIxUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2309 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2310 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2311 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2312 return method->name()->as_utf8(); |
0 | 2313 JVM_END |
2314 | |
2315 | |
2316 JVM_ENTRY(const char*, JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)) | |
2317 JVMWrapper("JVM_GetMethodIxSignatureUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2318 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2319 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2320 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2321 return method->signature()->as_utf8(); |
0 | 2322 JVM_END |
2323 | |
2324 /** | |
2325 * All of these JVM_GetCP-xxx methods are used by the old verifier to | |
2326 * read entries in the constant pool. Since the old verifier always | |
2327 * works on a copy of the code, it will not see any rewriting that | |
2328 * may possibly occur in the middle of verification. So it is important | |
2329 * that nothing it calls tries to use the cpCache instead of the raw | |
2330 * constant pool, so we must use cp->uncached_x methods when appropriate. | |
2331 */ | |
2332 JVM_ENTRY(const char*, JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2333 JVMWrapper("JVM_GetCPFieldNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2334 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2335 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2336 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2337 switch (cp->tag_at(cp_index).value()) { |
2338 case JVM_CONSTANT_Fieldref: | |
2339 return cp->uncached_name_ref_at(cp_index)->as_utf8(); | |
2340 default: | |
2341 fatal("JVM_GetCPFieldNameUTF: illegal constant"); | |
2342 } | |
2343 ShouldNotReachHere(); | |
2344 return NULL; | |
2345 JVM_END | |
2346 | |
2347 | |
2348 JVM_ENTRY(const char*, JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2349 JVMWrapper("JVM_GetCPMethodNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2350 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2351 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2352 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2353 switch (cp->tag_at(cp_index).value()) { |
2354 case JVM_CONSTANT_InterfaceMethodref: | |
2355 case JVM_CONSTANT_Methodref: | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
973
diff
changeset
|
2356 case JVM_CONSTANT_NameAndType: // for invokedynamic |
0 | 2357 return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2358 default: | |
2359 fatal("JVM_GetCPMethodNameUTF: illegal constant"); | |
2360 } | |
2361 ShouldNotReachHere(); | |
2362 return NULL; | |
2363 JVM_END | |
2364 | |
2365 | |
2366 JVM_ENTRY(const char*, JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2367 JVMWrapper("JVM_GetCPMethodSignatureUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2368 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2369 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2370 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2371 switch (cp->tag_at(cp_index).value()) { |
2372 case JVM_CONSTANT_InterfaceMethodref: | |
2373 case JVM_CONSTANT_Methodref: | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
973
diff
changeset
|
2374 case JVM_CONSTANT_NameAndType: // for invokedynamic |
0 | 2375 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2376 default: | |
2377 fatal("JVM_GetCPMethodSignatureUTF: illegal constant"); | |
2378 } | |
2379 ShouldNotReachHere(); | |
2380 return NULL; | |
2381 JVM_END | |
2382 | |
2383 | |
2384 JVM_ENTRY(const char*, JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2385 JVMWrapper("JVM_GetCPFieldSignatureUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2386 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2387 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2388 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2389 switch (cp->tag_at(cp_index).value()) { |
2390 case JVM_CONSTANT_Fieldref: | |
2391 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); | |
2392 default: | |
2393 fatal("JVM_GetCPFieldSignatureUTF: illegal constant"); | |
2394 } | |
2395 ShouldNotReachHere(); | |
2396 return NULL; | |
2397 JVM_END | |
2398 | |
2399 | |
2400 JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2401 JVMWrapper("JVM_GetCPClassNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2402 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2403 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2404 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2405 Symbol* classname = cp->klass_name_at(cp_index); |
0 | 2406 return classname->as_utf8(); |
2407 JVM_END | |
2408 | |
2409 | |
2410 JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2411 JVMWrapper("JVM_GetCPFieldClassNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2412 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2413 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2414 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2415 switch (cp->tag_at(cp_index).value()) { |
2416 case JVM_CONSTANT_Fieldref: { | |
2417 int class_index = cp->uncached_klass_ref_index_at(cp_index); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2418 Symbol* classname = cp->klass_name_at(class_index); |
0 | 2419 return classname->as_utf8(); |
2420 } | |
2421 default: | |
2422 fatal("JVM_GetCPFieldClassNameUTF: illegal constant"); | |
2423 } | |
2424 ShouldNotReachHere(); | |
2425 return NULL; | |
2426 JVM_END | |
2427 | |
2428 | |
2429 JVM_ENTRY(const char*, JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | |
2430 JVMWrapper("JVM_GetCPMethodClassNameUTF"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2431 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
0 | 2432 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2433 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2434 switch (cp->tag_at(cp_index).value()) { |
2435 case JVM_CONSTANT_Methodref: | |
2436 case JVM_CONSTANT_InterfaceMethodref: { | |
2437 int class_index = cp->uncached_klass_ref_index_at(cp_index); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2438 Symbol* classname = cp->klass_name_at(class_index); |
0 | 2439 return classname->as_utf8(); |
2440 } | |
2441 default: | |
2442 fatal("JVM_GetCPMethodClassNameUTF: illegal constant"); | |
2443 } | |
2444 ShouldNotReachHere(); | |
2445 return NULL; | |
2446 JVM_END | |
2447 | |
2448 | |
3938 | 2449 JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) |
0 | 2450 JVMWrapper("JVM_GetCPFieldModifiers"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2451 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2452 Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
0 | 2453 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2454 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2455 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2456 ConstantPool* cp_called = InstanceKlass::cast(k_called)->constants(); |
0 | 2457 switch (cp->tag_at(cp_index).value()) { |
2458 case JVM_CONSTANT_Fieldref: { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2459 Symbol* name = cp->uncached_name_ref_at(cp_index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2460 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
3938 | 2461 for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) { |
2462 if (fs.name() == name && fs.signature() == signature) { | |
2463 return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; | |
0 | 2464 } |
2465 } | |
2466 return -1; | |
2467 } | |
2468 default: | |
2469 fatal("JVM_GetCPFieldModifiers: illegal constant"); | |
2470 } | |
2471 ShouldNotReachHere(); | |
2472 return 0; | |
2473 JVM_END | |
2474 | |
2475 | |
2476 JVM_QUICK_ENTRY(jint, JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) | |
2477 JVMWrapper("JVM_GetCPMethodModifiers"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2478 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2479 Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
0 | 2480 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2481 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2482 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
0 | 2483 switch (cp->tag_at(cp_index).value()) { |
2484 case JVM_CONSTANT_Methodref: | |
2485 case JVM_CONSTANT_InterfaceMethodref: { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2486 Symbol* name = cp->uncached_name_ref_at(cp_index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2487 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2488 Array<Method*>* methods = InstanceKlass::cast(k_called)->methods(); |
0 | 2489 int methods_count = methods->length(); |
2490 for (int i = 0; i < methods_count; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2491 Method* method = methods->at(i); |
0 | 2492 if (method->name() == name && method->signature() == signature) { |
2493 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; | |
2494 } | |
2495 } | |
2496 return -1; | |
2497 } | |
2498 default: | |
2499 fatal("JVM_GetCPMethodModifiers: illegal constant"); | |
2500 } | |
2501 ShouldNotReachHere(); | |
2502 return 0; | |
2503 JVM_END | |
2504 | |
2505 | |
2506 // Misc ////////////////////////////////////////////////////////////////////////////////////////////// | |
2507 | |
2508 JVM_LEAF(void, JVM_ReleaseUTF(const char *utf)) | |
2509 // So long as UTF8::convert_to_utf8 returns resource strings, we don't have to do anything | |
2510 JVM_END | |
2511 | |
2512 | |
2513 JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)) | |
2514 JVMWrapper("JVM_IsSameClassPackage"); | |
2515 oop class1_mirror = JNIHandles::resolve_non_null(class1); | |
2516 oop class2_mirror = JNIHandles::resolve_non_null(class2); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2517 Klass* klass1 = java_lang_Class::as_Klass(class1_mirror); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
2518 Klass* klass2 = java_lang_Class::as_Klass(class2_mirror); |
0 | 2519 return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2520 JVM_END | |
2521 | |
2522 | |
2523 // IO functions //////////////////////////////////////////////////////////////////////////////////////// | |
2524 | |
2525 JVM_LEAF(jint, JVM_Open(const char *fname, jint flags, jint mode)) | |
2526 JVMWrapper2("JVM_Open (%s)", fname); | |
2527 | |
2528 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2529 int result = os::open(fname, flags, mode); |
0 | 2530 if (result >= 0) { |
2531 return result; | |
2532 } else { | |
2533 switch(errno) { | |
2534 case EEXIST: | |
2535 return JVM_EEXIST; | |
2536 default: | |
2537 return -1; | |
2538 } | |
2539 } | |
2540 JVM_END | |
2541 | |
2542 | |
2543 JVM_LEAF(jint, JVM_Close(jint fd)) | |
2544 JVMWrapper2("JVM_Close (0x%x)", fd); | |
2545 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2546 return os::close(fd); |
0 | 2547 JVM_END |
2548 | |
2549 | |
2550 JVM_LEAF(jint, JVM_Read(jint fd, char *buf, jint nbytes)) | |
2551 JVMWrapper2("JVM_Read (0x%x)", fd); | |
2552 | |
2553 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2554 return (jint)os::restartable_read(fd, buf, nbytes); |
0 | 2555 JVM_END |
2556 | |
2557 | |
2558 JVM_LEAF(jint, JVM_Write(jint fd, char *buf, jint nbytes)) | |
2559 JVMWrapper2("JVM_Write (0x%x)", fd); | |
2560 | |
2561 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2562 return (jint)os::write(fd, buf, nbytes); |
0 | 2563 JVM_END |
2564 | |
2565 | |
2566 JVM_LEAF(jint, JVM_Available(jint fd, jlong *pbytes)) | |
2567 JVMWrapper2("JVM_Available (0x%x)", fd); | |
2568 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2569 return os::available(fd, pbytes); |
0 | 2570 JVM_END |
2571 | |
2572 | |
2573 JVM_LEAF(jlong, JVM_Lseek(jint fd, jlong offset, jint whence)) | |
2574 JVMWrapper4("JVM_Lseek (0x%x, %Ld, %d)", fd, offset, whence); | |
2575 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2576 return os::lseek(fd, offset, whence); |
0 | 2577 JVM_END |
2578 | |
2579 | |
2580 JVM_LEAF(jint, JVM_SetLength(jint fd, jlong length)) | |
2581 JVMWrapper3("JVM_SetLength (0x%x, %Ld)", fd, length); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2582 return os::ftruncate(fd, length); |
0 | 2583 JVM_END |
2584 | |
2585 | |
2586 JVM_LEAF(jint, JVM_Sync(jint fd)) | |
2587 JVMWrapper2("JVM_Sync (0x%x)", fd); | |
2588 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
2589 return os::fsync(fd); |
0 | 2590 JVM_END |
2591 | |
2592 | |
2593 // Printing support ////////////////////////////////////////////////// | |
2594 extern "C" { | |
2595 | |
2596 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { | |
2597 // see bug 4399518, 4417214 | |
2598 if ((intptr_t)count <= 0) return -1; | |
2599 return vsnprintf(str, count, fmt, args); | |
2600 } | |
2601 | |
2602 | |
2603 int jio_snprintf(char *str, size_t count, const char *fmt, ...) { | |
2604 va_list args; | |
2605 int len; | |
2606 va_start(args, fmt); | |
2607 len = jio_vsnprintf(str, count, fmt, args); | |
2608 va_end(args); | |
2609 return len; | |
2610 } | |
2611 | |
2612 | |
2613 int jio_fprintf(FILE* f, const char *fmt, ...) { | |
2614 int len; | |
2615 va_list args; | |
2616 va_start(args, fmt); | |
2617 len = jio_vfprintf(f, fmt, args); | |
2618 va_end(args); | |
2619 return len; | |
2620 } | |
2621 | |
2622 | |
2623 int jio_vfprintf(FILE* f, const char *fmt, va_list args) { | |
2624 if (Arguments::vfprintf_hook() != NULL) { | |
2625 return Arguments::vfprintf_hook()(f, fmt, args); | |
2626 } else { | |
2627 return vfprintf(f, fmt, args); | |
2628 } | |
2629 } | |
2630 | |
2631 | |
2191 | 2632 JNIEXPORT int jio_printf(const char *fmt, ...) { |
0 | 2633 int len; |
2634 va_list args; | |
2635 va_start(args, fmt); | |
2636 len = jio_vfprintf(defaultStream::output_stream(), fmt, args); | |
2637 va_end(args); | |
2638 return len; | |
2639 } | |
2640 | |
2641 | |
2642 // HotSpot specific jio method | |
2643 void jio_print(const char* s) { | |
2644 // Try to make this function as atomic as possible. | |
2645 if (Arguments::vfprintf_hook() != NULL) { | |
2646 jio_fprintf(defaultStream::output_stream(), "%s", s); | |
2647 } else { | |
513
2328d1d3f8cf
6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents:
431
diff
changeset
|
2648 // Make an unused local variable to avoid warning from gcc 4.x compiler. |
2328d1d3f8cf
6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents:
431
diff
changeset
|
2649 size_t count = ::write(defaultStream::output_fd(), s, (int)strlen(s)); |
0 | 2650 } |
2651 } | |
2652 | |
2653 } // Extern C | |
2654 | |
2655 // java.lang.Thread ////////////////////////////////////////////////////////////////////////////// | |
2656 | |
2657 // In most of the JVM Thread support functions we need to be sure to lock the Threads_lock | |
2658 // to prevent the target thread from exiting after we have a pointer to the C++ Thread or | |
2659 // OSThread objects. The exception to this rule is when the target object is the thread | |
2660 // doing the operation, in which case we know that the thread won't exit until the | |
2661 // operation is done (all exits being voluntary). There are a few cases where it is | |
2662 // rather silly to do operations on yourself, like resuming yourself or asking whether | |
2663 // you are alive. While these can still happen, they are not subject to deadlocks if | |
2664 // the lock is held while the operation occurs (this is not the case for suspend, for | |
2665 // instance), and are very unlikely. Because IsAlive needs to be fast and its | |
2666 // implementation is local to this file, we always lock Threads_lock for that one. | |
2667 | |
2668 static void thread_entry(JavaThread* thread, TRAPS) { | |
2669 HandleMark hm(THREAD); | |
2670 Handle obj(THREAD, thread->threadObj()); | |
2671 JavaValue result(T_VOID); | |
2672 JavaCalls::call_virtual(&result, | |
2673 obj, | |
1142 | 2674 KlassHandle(THREAD, SystemDictionary::Thread_klass()), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2675 vmSymbols::run_method_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
2676 vmSymbols::void_method_signature(), |
0 | 2677 THREAD); |
2678 } | |
2679 | |
2680 | |
2681 JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) | |
2682 JVMWrapper("JVM_StartThread"); | |
2683 JavaThread *native_thread = NULL; | |
2684 | |
2685 // We cannot hold the Threads_lock when we throw an exception, | |
2686 // due to rank ordering issues. Example: we might need to grab the | |
2687 // Heap_lock while we construct the exception. | |
2688 bool throw_illegal_thread_state = false; | |
2689 | |
2690 // We must release the Threads_lock before we can post a jvmti event | |
2691 // in Thread::start. | |
2692 { | |
2693 // Ensure that the C++ Thread and OSThread structures aren't freed before | |
2694 // we operate. | |
2695 MutexLocker mu(Threads_lock); | |
2696 | |
2162
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2697 // Since JDK 5 the java.lang.Thread threadStatus is used to prevent |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2698 // re-starting an already started thread, so we should usually find |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2699 // that the JavaThread is null. However for a JNI attached thread |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2700 // there is a small window between the Thread object being created |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2701 // (with its JavaThread set) and the update to its threadStatus, so we |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2702 // have to check for this |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2703 if (java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)) != NULL) { |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2704 throw_illegal_thread_state = true; |
0 | 2705 } else { |
2162
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2706 // We could also check the stillborn flag to see if this thread was already stopped, but |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2707 // for historical reasons we let the thread detect that itself when it starts running |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2708 |
0 | 2709 jlong size = |
2710 java_lang_Thread::stackSize(JNIHandles::resolve_non_null(jthread)); | |
2711 // Allocate the C++ Thread structure and create the native thread. The | |
2712 // stack size retrieved from java is signed, but the constructor takes | |
2713 // size_t (an unsigned type), so avoid passing negative values which would | |
2714 // result in really large stacks. | |
2715 size_t sz = size > 0 ? (size_t) size : 0; | |
2716 native_thread = new JavaThread(&thread_entry, sz); | |
2717 | |
2718 // At this point it may be possible that no osthread was created for the | |
2719 // JavaThread due to lack of memory. Check for this situation and throw | |
2720 // an exception if necessary. Eventually we may want to change this so | |
2721 // that we only grab the lock if the thread was created successfully - | |
2722 // then we can also do this check and throw the exception in the | |
2723 // JavaThread constructor. | |
2724 if (native_thread->osthread() != NULL) { | |
2725 // Note: the current thread is not being used within "prepare". | |
2726 native_thread->prepare(jthread); | |
2727 } | |
2728 } | |
2729 } | |
2730 | |
2731 if (throw_illegal_thread_state) { | |
2732 THROW(vmSymbols::java_lang_IllegalThreadStateException()); | |
2733 } | |
2734 | |
2735 assert(native_thread != NULL, "Starting null thread?"); | |
2736 | |
2737 if (native_thread->osthread() == NULL) { | |
2738 // No one should hold a reference to the 'native_thread'. | |
2739 delete native_thread; | |
2740 if (JvmtiExport::should_post_resource_exhausted()) { | |
2741 JvmtiExport::post_resource_exhausted( | |
2742 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_THREADS, | |
2743 "unable to create new native thread"); | |
2744 } | |
2745 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), | |
2746 "unable to create new native thread"); | |
2747 } | |
2748 | |
2749 Thread::start(native_thread); | |
2750 | |
2751 JVM_END | |
2752 | |
2753 // JVM_Stop is implemented using a VM_Operation, so threads are forced to safepoints | |
2754 // before the quasi-asynchronous exception is delivered. This is a little obtrusive, | |
2755 // but is thought to be reliable and simple. In the case, where the receiver is the | |
2162
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2756 // same thread as the sender, no safepoint is needed. |
0 | 2757 JVM_ENTRY(void, JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)) |
2758 JVMWrapper("JVM_StopThread"); | |
2759 | |
2760 oop java_throwable = JNIHandles::resolve(throwable); | |
2761 if (java_throwable == NULL) { | |
2762 THROW(vmSymbols::java_lang_NullPointerException()); | |
2763 } | |
2764 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
2765 JavaThread* receiver = java_lang_Thread::thread(java_thread); | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4717
diff
changeset
|
2766 Events::log_exception(JavaThread::current(), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4717
diff
changeset
|
2767 "JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4717
diff
changeset
|
2768 receiver, (address)java_thread, throwable); |
2162
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2769 // First check if thread is alive |
0 | 2770 if (receiver != NULL) { |
2771 // Check if exception is getting thrown at self (use oop equality, since the | |
2772 // target object might exit) | |
2773 if (java_thread == thread->threadObj()) { | |
2774 THROW_OOP(java_throwable); | |
2775 } else { | |
2776 // Enques a VM_Operation to stop all threads and then deliver the exception... | |
2777 Thread::send_async_exception(java_thread, JNIHandles::resolve(throwable)); | |
2778 } | |
2779 } | |
2162
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2780 else { |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2781 // Either: |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2782 // - target thread has not been started before being stopped, or |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2783 // - target thread already terminated |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2784 // We could read the threadStatus to determine which case it is |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2785 // but that is overkill as it doesn't matter. We must set the |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2786 // stillborn flag for the first case, and if the thread has already |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2787 // exited setting this flag has no affect |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2788 java_lang_Thread::set_stillborn(java_thread); |
ccfcb502af3f
6566340: Restore use of stillborn flag to signify a thread that was stopped before it started
dholmes
parents:
1980
diff
changeset
|
2789 } |
0 | 2790 JVM_END |
2791 | |
2792 | |
2793 JVM_ENTRY(jboolean, JVM_IsThreadAlive(JNIEnv* env, jobject jthread)) | |
2794 JVMWrapper("JVM_IsThreadAlive"); | |
2795 | |
2796 oop thread_oop = JNIHandles::resolve_non_null(jthread); | |
2797 return java_lang_Thread::is_alive(thread_oop); | |
2798 JVM_END | |
2799 | |
2800 | |
2801 JVM_ENTRY(void, JVM_SuspendThread(JNIEnv* env, jobject jthread)) | |
2802 JVMWrapper("JVM_SuspendThread"); | |
2803 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
2804 JavaThread* receiver = java_lang_Thread::thread(java_thread); | |
2805 | |
2806 if (receiver != NULL) { | |
2807 // thread has run and has not exited (still on threads list) | |
2808 | |
2809 { | |
2810 MutexLockerEx ml(receiver->SR_lock(), Mutex::_no_safepoint_check_flag); | |
2811 if (receiver->is_external_suspend()) { | |
2812 // Don't allow nested external suspend requests. We can't return | |
2813 // an error from this interface so just ignore the problem. | |
2814 return; | |
2815 } | |
2816 if (receiver->is_exiting()) { // thread is in the process of exiting | |
2817 return; | |
2818 } | |
2819 receiver->set_external_suspend(); | |
2820 } | |
2821 | |
2822 // java_suspend() will catch threads in the process of exiting | |
2823 // and will ignore them. | |
2824 receiver->java_suspend(); | |
2825 | |
2826 // It would be nice to have the following assertion in all the | |
2827 // time, but it is possible for a racing resume request to have | |
2828 // resumed this thread right after we suspended it. Temporarily | |
2829 // enable this assertion if you are chasing a different kind of | |
2830 // bug. | |
2831 // | |
2832 // assert(java_lang_Thread::thread(receiver->threadObj()) == NULL || | |
2833 // receiver->is_being_ext_suspended(), "thread is not suspended"); | |
2834 } | |
2835 JVM_END | |
2836 | |
2837 | |
2838 JVM_ENTRY(void, JVM_ResumeThread(JNIEnv* env, jobject jthread)) | |
2839 JVMWrapper("JVM_ResumeThread"); | |
2840 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate. | |
2841 // We need to *always* get the threads lock here, since this operation cannot be allowed during | |
2842 // a safepoint. The safepoint code relies on suspending a thread to examine its state. If other | |
2843 // threads randomly resumes threads, then a thread might not be suspended when the safepoint code | |
2844 // looks at it. | |
2845 MutexLocker ml(Threads_lock); | |
2846 JavaThread* thr = java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)); | |
2847 if (thr != NULL) { | |
2848 // the thread has run and is not in the process of exiting | |
2849 thr->java_resume(); | |
2850 } | |
2851 JVM_END | |
2852 | |
2853 | |
2854 JVM_ENTRY(void, JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)) | |
2855 JVMWrapper("JVM_SetThreadPriority"); | |
2856 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate | |
2857 MutexLocker ml(Threads_lock); | |
2858 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
2859 java_lang_Thread::set_priority(java_thread, (ThreadPriority)prio); | |
2860 JavaThread* thr = java_lang_Thread::thread(java_thread); | |
2861 if (thr != NULL) { // Thread not yet started; priority pushed down when it is | |
2862 Thread::set_priority(thr, (ThreadPriority)prio); | |
2863 } | |
2864 JVM_END | |
2865 | |
2866 | |
2867 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) | |
2868 JVMWrapper("JVM_Yield"); | |
2869 if (os::dont_yield()) return; | |
4006 | 2870 #ifndef USDT2 |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
2871 HS_DTRACE_PROBE0(hotspot, thread__yield); |
4006 | 2872 #else /* USDT2 */ |
2873 HOTSPOT_THREAD_YIELD(); | |
2874 #endif /* USDT2 */ | |
0 | 2875 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. |
2876 // Critical for similar threading behaviour | |
2877 if (ConvertYieldToSleep) { | |
2878 os::sleep(thread, MinSleepInterval, false); | |
2879 } else { | |
2880 os::yield(); | |
2881 } | |
2882 JVM_END | |
2883 | |
2884 | |
2885 JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) | |
2886 JVMWrapper("JVM_Sleep"); | |
2887 | |
2888 if (millis < 0) { | |
2889 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative"); | |
2890 } | |
2891 | |
2892 if (Thread::is_interrupted (THREAD, true) && !HAS_PENDING_EXCEPTION) { | |
2893 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); | |
2894 } | |
2895 | |
2896 // Save current thread state and restore it at the end of this block. | |
2897 // And set new thread state to SLEEPING. | |
2898 JavaThreadSleepState jtss(thread); | |
2899 | |
4006 | 2900 #ifndef USDT2 |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
2901 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); |
4006 | 2902 #else /* USDT2 */ |
2903 HOTSPOT_THREAD_SLEEP_BEGIN( | |
2904 millis); | |
2905 #endif /* USDT2 */ | |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
2906 |
0 | 2907 if (millis == 0) { |
2908 // When ConvertSleepToYield is on, this matches the classic VM implementation of | |
2909 // JVM_Sleep. Critical for similar threading behaviour (Win32) | |
2910 // It appears that in certain GUI contexts, it may be beneficial to do a short sleep | |
2911 // for SOLARIS | |
2912 if (ConvertSleepToYield) { | |
2913 os::yield(); | |
2914 } else { | |
2915 ThreadState old_state = thread->osthread()->get_state(); | |
2916 thread->osthread()->set_state(SLEEPING); | |
2917 os::sleep(thread, MinSleepInterval, false); | |
2918 thread->osthread()->set_state(old_state); | |
2919 } | |
2920 } else { | |
2921 ThreadState old_state = thread->osthread()->get_state(); | |
2922 thread->osthread()->set_state(SLEEPING); | |
2923 if (os::sleep(thread, millis, true) == OS_INTRPT) { | |
2924 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on | |
2925 // us while we were sleeping. We do not overwrite those. | |
2926 if (!HAS_PENDING_EXCEPTION) { | |
4006 | 2927 #ifndef USDT2 |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
2928 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); |
4006 | 2929 #else /* USDT2 */ |
2930 HOTSPOT_THREAD_SLEEP_END( | |
2931 1); | |
2932 #endif /* USDT2 */ | |
0 | 2933 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() |
2934 // to properly restore the thread state. That's likely wrong. | |
2935 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); | |
2936 } | |
2937 } | |
2938 thread->osthread()->set_state(old_state); | |
2939 } | |
4006 | 2940 #ifndef USDT2 |
1324
e392695de029
6935224: Adding new DTrace probes to work with Palantir
fparain
parents:
1144
diff
changeset
|
2941 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); |
4006 | 2942 #else /* USDT2 */ |
2943 HOTSPOT_THREAD_SLEEP_END( | |
2944 0); | |
2945 #endif /* USDT2 */ | |
0 | 2946 JVM_END |
2947 | |
2948 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) | |
2949 JVMWrapper("JVM_CurrentThread"); | |
2950 oop jthread = thread->threadObj(); | |
2951 assert (thread != NULL, "no current thread!"); | |
2952 return JNIHandles::make_local(env, jthread); | |
2953 JVM_END | |
2954 | |
2955 | |
2956 JVM_ENTRY(jint, JVM_CountStackFrames(JNIEnv* env, jobject jthread)) | |
2957 JVMWrapper("JVM_CountStackFrames"); | |
2958 | |
2959 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate | |
2960 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
2961 bool throw_illegal_thread_state = false; | |
2962 int count = 0; | |
2963 | |
2964 { | |
2965 MutexLockerEx ml(thread->threadObj() == java_thread ? NULL : Threads_lock); | |
2966 // We need to re-resolve the java_thread, since a GC might have happened during the | |
2967 // acquire of the lock | |
2968 JavaThread* thr = java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)); | |
2969 | |
2970 if (thr == NULL) { | |
2971 // do nothing | |
2972 } else if(! thr->is_external_suspend() || ! thr->frame_anchor()->walkable()) { | |
2973 // Check whether this java thread has been suspended already. If not, throws | |
2974 // IllegalThreadStateException. We defer to throw that exception until | |
2975 // Threads_lock is released since loading exception class has to leave VM. | |
2976 // The correct way to test a thread is actually suspended is | |
2977 // wait_for_ext_suspend_completion(), but we can't call that while holding | |
2978 // the Threads_lock. The above tests are sufficient for our purposes | |
2979 // provided the walkability of the stack is stable - which it isn't | |
2980 // 100% but close enough for most practical purposes. | |
2981 throw_illegal_thread_state = true; | |
2982 } else { | |
2983 // Count all java activation, i.e., number of vframes | |
2984 for(vframeStream vfst(thr); !vfst.at_end(); vfst.next()) { | |
2985 // Native frames are not counted | |
2986 if (!vfst.method()->is_native()) count++; | |
2987 } | |
2988 } | |
2989 } | |
2990 | |
2991 if (throw_illegal_thread_state) { | |
2992 THROW_MSG_0(vmSymbols::java_lang_IllegalThreadStateException(), | |
2993 "this thread is not suspended"); | |
2994 } | |
2995 return count; | |
2996 JVM_END | |
2997 | |
2998 // Consider: A better way to implement JVM_Interrupt() is to acquire | |
2999 // Threads_lock to resolve the jthread into a Thread pointer, fetch | |
3000 // Thread->platformevent, Thread->native_thr, Thread->parker, etc., | |
3001 // drop Threads_lock, and the perform the unpark() and thr_kill() operations | |
3002 // outside the critical section. Threads_lock is hot so we want to minimize | |
3003 // the hold-time. A cleaner interface would be to decompose interrupt into | |
3004 // two steps. The 1st phase, performed under Threads_lock, would return | |
3005 // a closure that'd be invoked after Threads_lock was dropped. | |
3006 // This tactic is safe as PlatformEvent and Parkers are type-stable (TSM) and | |
3007 // admit spurious wakeups. | |
3008 | |
3009 JVM_ENTRY(void, JVM_Interrupt(JNIEnv* env, jobject jthread)) | |
3010 JVMWrapper("JVM_Interrupt"); | |
3011 | |
3012 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate | |
3013 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
3014 MutexLockerEx ml(thread->threadObj() == java_thread ? NULL : Threads_lock); | |
3015 // We need to re-resolve the java_thread, since a GC might have happened during the | |
3016 // acquire of the lock | |
3017 JavaThread* thr = java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)); | |
3018 if (thr != NULL) { | |
3019 Thread::interrupt(thr); | |
3020 } | |
3021 JVM_END | |
3022 | |
3023 | |
3024 JVM_QUICK_ENTRY(jboolean, JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)) | |
3025 JVMWrapper("JVM_IsInterrupted"); | |
3026 | |
3027 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate | |
3028 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
3029 MutexLockerEx ml(thread->threadObj() == java_thread ? NULL : Threads_lock); | |
3030 // We need to re-resolve the java_thread, since a GC might have happened during the | |
3031 // acquire of the lock | |
3032 JavaThread* thr = java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)); | |
3033 if (thr == NULL) { | |
3034 return JNI_FALSE; | |
3035 } else { | |
3036 return (jboolean) Thread::is_interrupted(thr, clear_interrupted != 0); | |
3037 } | |
3038 JVM_END | |
3039 | |
3040 | |
3041 // Return true iff the current thread has locked the object passed in | |
3042 | |
3043 JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)) | |
3044 JVMWrapper("JVM_HoldsLock"); | |
3045 assert(THREAD->is_Java_thread(), "sanity check"); | |
3046 if (obj == NULL) { | |
3047 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE); | |
3048 } | |
3049 Handle h_obj(THREAD, JNIHandles::resolve(obj)); | |
3050 return ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, h_obj); | |
3051 JVM_END | |
3052 | |
3053 | |
3054 JVM_ENTRY(void, JVM_DumpAllStacks(JNIEnv* env, jclass)) | |
3055 JVMWrapper("JVM_DumpAllStacks"); | |
3056 VM_PrintThreads op; | |
3057 VMThread::execute(&op); | |
3058 if (JvmtiExport::should_post_data_dump()) { | |
3059 JvmtiExport::post_data_dump(); | |
3060 } | |
3061 JVM_END | |
3062 | |
4006 | 3063 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name)) |
3064 JVMWrapper("JVM_SetNativeThreadName"); | |
3065 ResourceMark rm(THREAD); | |
3066 oop java_thread = JNIHandles::resolve_non_null(jthread); | |
3067 JavaThread* thr = java_lang_Thread::thread(java_thread); | |
3068 // Thread naming only supported for the current thread, doesn't work for | |
3069 // target threads. | |
3070 if (Thread::current() == thr && !thr->has_attached_via_jni()) { | |
3071 // we don't set the name of an attached thread to avoid stepping | |
3072 // on other programs | |
3073 const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); | |
3074 os::set_native_thread_name(thread_name); | |
3075 } | |
3076 JVM_END | |
0 | 3077 |
3078 // java.lang.SecurityManager /////////////////////////////////////////////////////////////////////// | |
3079 | |
3080 static bool is_trusted_frame(JavaThread* jthread, vframeStream* vfst) { | |
3081 assert(jthread->is_Java_thread(), "must be a Java thread"); | |
3082 if (jthread->privileged_stack_top() == NULL) return false; | |
3083 if (jthread->privileged_stack_top()->frame_id() == vfst->frame_id()) { | |
3084 oop loader = jthread->privileged_stack_top()->class_loader(); | |
3085 if (loader == NULL) return true; | |
3086 bool trusted = java_lang_ClassLoader::is_trusted_loader(loader); | |
3087 if (trusted) return true; | |
3088 } | |
3089 return false; | |
3090 } | |
3091 | |
3092 JVM_ENTRY(jclass, JVM_CurrentLoadedClass(JNIEnv *env)) | |
3093 JVMWrapper("JVM_CurrentLoadedClass"); | |
3094 ResourceMark rm(THREAD); | |
3095 | |
3096 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | |
3097 // if a method in a class in a trusted loader is in a doPrivileged, return NULL | |
3098 bool trusted = is_trusted_frame(thread, &vfst); | |
3099 if (trusted) return NULL; | |
3100 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3101 Method* m = vfst.method(); |
0 | 3102 if (!m->is_native()) { |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3103 InstanceKlass* holder = m->method_holder(); |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3104 oop loader = holder->class_loader(); |
0 | 3105 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3106 return (jclass) JNIHandles::make_local(env, holder->java_mirror()); |
0 | 3107 } |
3108 } | |
3109 } | |
3110 return NULL; | |
3111 JVM_END | |
3112 | |
3113 | |
3114 JVM_ENTRY(jobject, JVM_CurrentClassLoader(JNIEnv *env)) | |
3115 JVMWrapper("JVM_CurrentClassLoader"); | |
3116 ResourceMark rm(THREAD); | |
3117 | |
3118 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | |
3119 | |
3120 // if a method in a class in a trusted loader is in a doPrivileged, return NULL | |
3121 bool trusted = is_trusted_frame(thread, &vfst); | |
3122 if (trusted) return NULL; | |
3123 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3124 Method* m = vfst.method(); |
0 | 3125 if (!m->is_native()) { |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3126 InstanceKlass* holder = m->method_holder(); |
0 | 3127 assert(holder->is_klass(), "just checking"); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3128 oop loader = holder->class_loader(); |
0 | 3129 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3130 return JNIHandles::make_local(env, loader); | |
3131 } | |
3132 } | |
3133 } | |
3134 return NULL; | |
3135 JVM_END | |
3136 | |
3137 | |
3138 // Utility object for collecting method holders walking down the stack | |
3139 class KlassLink: public ResourceObj { | |
3140 public: | |
3141 KlassHandle klass; | |
3142 KlassLink* next; | |
3143 | |
3144 KlassLink(KlassHandle k) { klass = k; next = NULL; } | |
3145 }; | |
3146 | |
3147 | |
3148 JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) | |
3149 JVMWrapper("JVM_GetClassContext"); | |
3150 ResourceMark rm(THREAD); | |
3151 JvmtiVMObjectAllocEventCollector oam; | |
3152 // Collect linked list of (handles to) method holders | |
3153 KlassLink* first = NULL; | |
3154 KlassLink* last = NULL; | |
3155 int depth = 0; | |
3156 | |
3157 for(vframeStream vfst(thread); !vfst.at_end(); vfst.security_get_caller_frame(1)) { | |
3158 // Native frames are not returned | |
3159 if (!vfst.method()->is_native()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3160 Klass* holder = vfst.method()->method_holder(); |
0 | 3161 assert(holder->is_klass(), "just checking"); |
3162 depth++; | |
3163 KlassLink* l = new KlassLink(KlassHandle(thread, holder)); | |
3164 if (first == NULL) { | |
3165 first = last = l; | |
3166 } else { | |
3167 last->next = l; | |
3168 last = l; | |
3169 } | |
3170 } | |
3171 } | |
3172 | |
3173 // Create result array of type [Ljava/lang/Class; | |
1142 | 3174 objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), depth, CHECK_NULL); |
0 | 3175 // Fill in mirrors corresponding to method holders |
3176 int index = 0; | |
3177 while (first != NULL) { | |
6983 | 3178 result->obj_at_put(index++, first->klass()->java_mirror()); |
0 | 3179 first = first->next; |
3180 } | |
3181 assert(index == depth, "just checking"); | |
3182 | |
3183 return (jobjectArray) JNIHandles::make_local(env, result); | |
3184 JVM_END | |
3185 | |
3186 | |
3187 JVM_ENTRY(jint, JVM_ClassDepth(JNIEnv *env, jstring name)) | |
3188 JVMWrapper("JVM_ClassDepth"); | |
3189 ResourceMark rm(THREAD); | |
3190 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); | |
3191 Handle class_name_str = java_lang_String::internalize_classname(h_name, CHECK_0); | |
3192 | |
3193 const char* str = java_lang_String::as_utf8_string(class_name_str()); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
3194 TempNewSymbol class_name_sym = SymbolTable::probe(str, (int)strlen(str)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
3195 if (class_name_sym == NULL) { |
0 | 3196 return -1; |
3197 } | |
3198 | |
3199 int depth = 0; | |
3200 | |
3201 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | |
3202 if (!vfst.method()->is_native()) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3203 InstanceKlass* holder = vfst.method()->method_holder(); |
0 | 3204 assert(holder->is_klass(), "just checking"); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3205 if (holder->name() == class_name_sym) { |
0 | 3206 return depth; |
3207 } | |
3208 depth++; | |
3209 } | |
3210 } | |
3211 return -1; | |
3212 JVM_END | |
3213 | |
3214 | |
3215 JVM_ENTRY(jint, JVM_ClassLoaderDepth(JNIEnv *env)) | |
3216 JVMWrapper("JVM_ClassLoaderDepth"); | |
3217 ResourceMark rm(THREAD); | |
3218 int depth = 0; | |
3219 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | |
3220 // if a method in a class in a trusted loader is in a doPrivileged, return -1 | |
3221 bool trusted = is_trusted_frame(thread, &vfst); | |
3222 if (trusted) return -1; | |
3223 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3224 Method* m = vfst.method(); |
0 | 3225 if (!m->is_native()) { |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3226 InstanceKlass* holder = m->method_holder(); |
0 | 3227 assert(holder->is_klass(), "just checking"); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3228 oop loader = holder->class_loader(); |
0 | 3229 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3230 return depth; | |
3231 } | |
3232 depth++; | |
3233 } | |
3234 } | |
3235 return -1; | |
3236 JVM_END | |
3237 | |
3238 | |
3239 // java.lang.Package //////////////////////////////////////////////////////////////// | |
3240 | |
3241 | |
3242 JVM_ENTRY(jstring, JVM_GetSystemPackage(JNIEnv *env, jstring name)) | |
3243 JVMWrapper("JVM_GetSystemPackage"); | |
3244 ResourceMark rm(THREAD); | |
3245 JvmtiVMObjectAllocEventCollector oam; | |
3246 char* str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); | |
3247 oop result = ClassLoader::get_system_package(str, CHECK_NULL); | |
3248 return (jstring) JNIHandles::make_local(result); | |
3249 JVM_END | |
3250 | |
3251 | |
3252 JVM_ENTRY(jobjectArray, JVM_GetSystemPackages(JNIEnv *env)) | |
3253 JVMWrapper("JVM_GetSystemPackages"); | |
3254 JvmtiVMObjectAllocEventCollector oam; | |
3255 objArrayOop result = ClassLoader::get_system_packages(CHECK_NULL); | |
3256 return (jobjectArray) JNIHandles::make_local(result); | |
3257 JVM_END | |
3258 | |
3259 | |
3260 // ObjectInputStream /////////////////////////////////////////////////////////////// | |
3261 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3262 bool force_verify_field_access(Klass* current_class, Klass* field_class, AccessFlags access, bool classloader_only) { |
0 | 3263 if (current_class == NULL) { |
3264 return true; | |
3265 } | |
3266 if ((current_class == field_class) || access.is_public()) { | |
3267 return true; | |
3268 } | |
3269 | |
3270 if (access.is_protected()) { | |
3271 // See if current_class is a subclass of field_class | |
6983 | 3272 if (current_class->is_subclass_of(field_class)) { |
0 | 3273 return true; |
3274 } | |
3275 } | |
3276 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3277 return (!access.is_private() && InstanceKlass::cast(current_class)->is_same_class_package(field_class)); |
0 | 3278 } |
3279 | |
3280 | |
3281 // JVM_AllocateNewObject and JVM_AllocateNewArray are unused as of 1.4 | |
3282 JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)) | |
3283 JVMWrapper("JVM_AllocateNewObject"); | |
3284 JvmtiVMObjectAllocEventCollector oam; | |
3285 // Receiver is not used | |
3286 oop curr_mirror = JNIHandles::resolve_non_null(currClass); | |
3287 oop init_mirror = JNIHandles::resolve_non_null(initClass); | |
3288 | |
3289 // Cannot instantiate primitive types | |
3290 if (java_lang_Class::is_primitive(curr_mirror) || java_lang_Class::is_primitive(init_mirror)) { | |
3291 ResourceMark rm(THREAD); | |
3292 THROW_0(vmSymbols::java_lang_InvalidClassException()); | |
3293 } | |
3294 | |
3295 // Arrays not allowed here, must use JVM_AllocateNewArray | |
6983 | 3296 if (java_lang_Class::as_Klass(curr_mirror)->oop_is_array() || |
3297 java_lang_Class::as_Klass(init_mirror)->oop_is_array()) { | |
0 | 3298 ResourceMark rm(THREAD); |
3299 THROW_0(vmSymbols::java_lang_InvalidClassException()); | |
3300 } | |
3301 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3302 instanceKlassHandle curr_klass (THREAD, java_lang_Class::as_Klass(curr_mirror)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3303 instanceKlassHandle init_klass (THREAD, java_lang_Class::as_Klass(init_mirror)); |
0 | 3304 |
3305 assert(curr_klass->is_subclass_of(init_klass()), "just checking"); | |
3306 | |
3307 // Interfaces, abstract classes, and java.lang.Class classes cannot be instantiated directly. | |
3308 curr_klass->check_valid_for_instantiation(false, CHECK_NULL); | |
3309 | |
3310 // Make sure klass is initialized, since we are about to instantiate one of them. | |
3311 curr_klass->initialize(CHECK_NULL); | |
3312 | |
3313 methodHandle m (THREAD, | |
3314 init_klass->find_method(vmSymbols::object_initializer_name(), | |
3315 vmSymbols::void_method_signature())); | |
3316 if (m.is_null()) { | |
3317 ResourceMark rm(THREAD); | |
3318 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), | |
6983 | 3319 Method::name_and_sig_as_C_string(init_klass(), |
0 | 3320 vmSymbols::object_initializer_name(), |
3321 vmSymbols::void_method_signature())); | |
3322 } | |
3323 | |
3324 if (curr_klass == init_klass && !m->is_public()) { | |
3325 // Calling the constructor for class 'curr_klass'. | |
3326 // Only allow calls to a public no-arg constructor. | |
3327 // This path corresponds to creating an Externalizable object. | |
3328 THROW_0(vmSymbols::java_lang_IllegalAccessException()); | |
3329 } | |
3330 | |
3331 if (!force_verify_field_access(curr_klass(), init_klass(), m->access_flags(), false)) { | |
3332 // subclass 'curr_klass' does not have access to no-arg constructor of 'initcb' | |
3333 THROW_0(vmSymbols::java_lang_IllegalAccessException()); | |
3334 } | |
3335 | |
3336 Handle obj = curr_klass->allocate_instance_handle(CHECK_NULL); | |
3337 // Call constructor m. This might call a constructor higher up in the hierachy | |
3338 JavaCalls::call_default_constructor(thread, m, obj, CHECK_NULL); | |
3339 | |
3340 return JNIHandles::make_local(obj()); | |
3341 JVM_END | |
3342 | |
3343 | |
3344 JVM_ENTRY(jobject, JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)) | |
3345 JVMWrapper("JVM_AllocateNewArray"); | |
3346 JvmtiVMObjectAllocEventCollector oam; | |
3347 oop mirror = JNIHandles::resolve_non_null(currClass); | |
3348 | |
3349 if (java_lang_Class::is_primitive(mirror)) { | |
3350 THROW_0(vmSymbols::java_lang_InvalidClassException()); | |
3351 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3352 Klass* k = java_lang_Class::as_Klass(mirror); |
0 | 3353 oop result; |
3354 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3355 if (k->oop_is_typeArray()) { |
0 | 3356 // typeArray |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3357 result = TypeArrayKlass::cast(k)->allocate(length, CHECK_NULL); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3358 } else if (k->oop_is_objArray()) { |
0 | 3359 // objArray |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
3360 ObjArrayKlass* oak = ObjArrayKlass::cast(k); |
0 | 3361 oak->initialize(CHECK_NULL); // make sure class is initialized (matches Classic VM behavior) |
3362 result = oak->allocate(length, CHECK_NULL); | |
3363 } else { | |
3364 THROW_0(vmSymbols::java_lang_InvalidClassException()); | |
3365 } | |
3366 return JNIHandles::make_local(env, result); | |
3367 JVM_END | |
3368 | |
3369 | |
3370 // Return the first non-null class loader up the execution stack, or null | |
3371 // if only code from the null class loader is on the stack. | |
3372 | |
3373 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) | |
3374 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | |
3375 // UseNewReflection | |
3376 vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3377 oop loader = vfst.method()->method_holder()->class_loader(); |
0 | 3378 if (loader != NULL) { |
3379 return JNIHandles::make_local(env, loader); | |
3380 } | |
3381 } | |
3382 return NULL; | |
3383 JVM_END | |
3384 | |
3385 | |
3386 // Load a class relative to the most recent class on the stack with a non-null | |
3387 // classloader. | |
3388 // This function has been deprecated and should not be considered part of the | |
3389 // specified JVM interface. | |
3390 | |
3391 JVM_ENTRY(jclass, JVM_LoadClass0(JNIEnv *env, jobject receiver, | |
3392 jclass currClass, jstring currClassName)) | |
3393 JVMWrapper("JVM_LoadClass0"); | |
3394 // Receiver is not used | |
3395 ResourceMark rm(THREAD); | |
3396 | |
3397 // Class name argument is not guaranteed to be in internal format | |
3398 Handle classname (THREAD, JNIHandles::resolve_non_null(currClassName)); | |
3399 Handle string = java_lang_String::internalize_classname(classname, CHECK_NULL); | |
3400 | |
3401 const char* str = java_lang_String::as_utf8_string(string()); | |
3402 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
3403 if (str == NULL || (int)strlen(str) > Symbol::max_length()) { |
0 | 3404 // It's impossible to create this class; the name cannot fit |
3405 // into the constant pool. | |
3406 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), str); | |
3407 } | |
3408 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
3409 TempNewSymbol name = SymbolTable::new_symbol(str, CHECK_NULL); |
0 | 3410 Handle curr_klass (THREAD, JNIHandles::resolve(currClass)); |
3411 // Find the most recent class on the stack with a non-null classloader | |
3412 oop loader = NULL; | |
3413 oop protection_domain = NULL; | |
3414 if (curr_klass.is_null()) { | |
3415 for (vframeStream vfst(thread); | |
3416 !vfst.at_end() && loader == NULL; | |
3417 vfst.next()) { | |
3418 if (!vfst.method()->is_native()) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3419 InstanceKlass* holder = vfst.method()->method_holder(); |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3420 loader = holder->class_loader(); |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6831
diff
changeset
|
3421 protection_domain = holder->protection_domain(); |
0 | 3422 } |
3423 } | |
3424 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3425 Klass* curr_klass_oop = java_lang_Class::as_Klass(curr_klass()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3426 loader = InstanceKlass::cast(curr_klass_oop)->class_loader(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3427 protection_domain = InstanceKlass::cast(curr_klass_oop)->protection_domain(); |
0 | 3428 } |
3429 Handle h_loader(THREAD, loader); | |
3430 Handle h_prot (THREAD, protection_domain); | |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
3431 jclass result = find_class_from_class_loader(env, name, true, h_loader, h_prot, |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
3432 false, thread); |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
3433 if (TraceClassResolution && result != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3434 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
657
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
3435 } |
715dceaa89b7
6603316: Improve instrumentation for classes loaded at startup
acorn
parents:
579
diff
changeset
|
3436 return result; |
0 | 3437 JVM_END |
3438 | |
3439 | |
3440 // Array /////////////////////////////////////////////////////////////////////////////////////////// | |
3441 | |
3442 | |
3443 // resolve array handle and check arguments | |
3444 static inline arrayOop check_array(JNIEnv *env, jobject arr, bool type_array_only, TRAPS) { | |
3445 if (arr == NULL) { | |
3446 THROW_0(vmSymbols::java_lang_NullPointerException()); | |
3447 } | |
3448 oop a = JNIHandles::resolve_non_null(arr); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
3449 if (!a->is_array() || (type_array_only && !a->is_typeArray())) { |
0 | 3450 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array"); |
3451 } | |
3452 return arrayOop(a); | |
3453 } | |
3454 | |
3455 | |
3456 JVM_ENTRY(jint, JVM_GetArrayLength(JNIEnv *env, jobject arr)) | |
3457 JVMWrapper("JVM_GetArrayLength"); | |
3458 arrayOop a = check_array(env, arr, false, CHECK_0); | |
3459 return a->length(); | |
3460 JVM_END | |
3461 | |
3462 | |
3463 JVM_ENTRY(jobject, JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)) | |
3464 JVMWrapper("JVM_Array_Get"); | |
3465 JvmtiVMObjectAllocEventCollector oam; | |
3466 arrayOop a = check_array(env, arr, false, CHECK_NULL); | |
3467 jvalue value; | |
3468 BasicType type = Reflection::array_get(&value, a, index, CHECK_NULL); | |
3469 oop box = Reflection::box(&value, type, CHECK_NULL); | |
3470 return JNIHandles::make_local(env, box); | |
3471 JVM_END | |
3472 | |
3473 | |
3474 JVM_ENTRY(jvalue, JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)) | |
3475 JVMWrapper("JVM_GetPrimitiveArrayElement"); | |
3476 jvalue value; | |
3477 value.i = 0; // to initialize value before getting used in CHECK | |
3478 arrayOop a = check_array(env, arr, true, CHECK_(value)); | |
3479 assert(a->is_typeArray(), "just checking"); | |
3480 BasicType type = Reflection::array_get(&value, a, index, CHECK_(value)); | |
3481 BasicType wide_type = (BasicType) wCode; | |
3482 if (type != wide_type) { | |
3483 Reflection::widen(&value, type, wide_type, CHECK_(value)); | |
3484 } | |
3485 return value; | |
3486 JVM_END | |
3487 | |
3488 | |
3489 JVM_ENTRY(void, JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)) | |
3490 JVMWrapper("JVM_SetArrayElement"); | |
3491 arrayOop a = check_array(env, arr, false, CHECK); | |
3492 oop box = JNIHandles::resolve(val); | |
3493 jvalue value; | |
3494 value.i = 0; // to initialize value before getting used in CHECK | |
3495 BasicType value_type; | |
3496 if (a->is_objArray()) { | |
3497 // Make sure we do no unbox e.g. java/lang/Integer instances when storing into an object array | |
3498 value_type = Reflection::unbox_for_regular_object(box, &value); | |
3499 } else { | |
3500 value_type = Reflection::unbox_for_primitive(box, &value, CHECK); | |
3501 } | |
3502 Reflection::array_set(&value, a, index, value_type, CHECK); | |
3503 JVM_END | |
3504 | |
3505 | |
3506 JVM_ENTRY(void, JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)) | |
3507 JVMWrapper("JVM_SetPrimitiveArrayElement"); | |
3508 arrayOop a = check_array(env, arr, true, CHECK); | |
3509 assert(a->is_typeArray(), "just checking"); | |
3510 BasicType value_type = (BasicType) vCode; | |
3511 Reflection::array_set(&v, a, index, value_type, CHECK); | |
3512 JVM_END | |
3513 | |
3514 | |
3515 JVM_ENTRY(jobject, JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)) | |
3516 JVMWrapper("JVM_NewArray"); | |
3517 JvmtiVMObjectAllocEventCollector oam; | |
3518 oop element_mirror = JNIHandles::resolve(eltClass); | |
3519 oop result = Reflection::reflect_new_array(element_mirror, length, CHECK_NULL); | |
3520 return JNIHandles::make_local(env, result); | |
3521 JVM_END | |
3522 | |
3523 | |
3524 JVM_ENTRY(jobject, JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)) | |
3525 JVMWrapper("JVM_NewMultiArray"); | |
3526 JvmtiVMObjectAllocEventCollector oam; | |
3527 arrayOop dim_array = check_array(env, dim, true, CHECK_NULL); | |
3528 oop element_mirror = JNIHandles::resolve(eltClass); | |
3529 assert(dim_array->is_typeArray(), "just checking"); | |
3530 oop result = Reflection::reflect_new_multi_array(element_mirror, typeArrayOop(dim_array), CHECK_NULL); | |
3531 return JNIHandles::make_local(env, result); | |
3532 JVM_END | |
3533 | |
3534 | |
3535 // Networking library support //////////////////////////////////////////////////////////////////// | |
3536 | |
3537 JVM_LEAF(jint, JVM_InitializeSocketLibrary()) | |
3538 JVMWrapper("JVM_InitializeSocketLibrary"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3539 return 0; |
0 | 3540 JVM_END |
3541 | |
3542 | |
3543 JVM_LEAF(jint, JVM_Socket(jint domain, jint type, jint protocol)) | |
3544 JVMWrapper("JVM_Socket"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3545 return os::socket(domain, type, protocol); |
0 | 3546 JVM_END |
3547 | |
3548 | |
3549 JVM_LEAF(jint, JVM_SocketClose(jint fd)) | |
3550 JVMWrapper2("JVM_SocketClose (0x%x)", fd); | |
3551 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3552 return os::socket_close(fd); |
0 | 3553 JVM_END |
3554 | |
3555 | |
3556 JVM_LEAF(jint, JVM_SocketShutdown(jint fd, jint howto)) | |
3557 JVMWrapper2("JVM_SocketShutdown (0x%x)", fd); | |
3558 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3559 return os::socket_shutdown(fd, howto); |
0 | 3560 JVM_END |
3561 | |
3562 | |
3563 JVM_LEAF(jint, JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)) | |
3564 JVMWrapper2("JVM_Recv (0x%x)", fd); | |
3565 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3566 return os::recv(fd, buf, (size_t)nBytes, (uint)flags); |
0 | 3567 JVM_END |
3568 | |
3569 | |
3570 JVM_LEAF(jint, JVM_Send(jint fd, char *buf, jint nBytes, jint flags)) | |
3571 JVMWrapper2("JVM_Send (0x%x)", fd); | |
3572 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3573 return os::send(fd, buf, (size_t)nBytes, (uint)flags); |
0 | 3574 JVM_END |
3575 | |
3576 | |
3577 JVM_LEAF(jint, JVM_Timeout(int fd, long timeout)) | |
3578 JVMWrapper2("JVM_Timeout (0x%x)", fd); | |
3579 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3580 return os::timeout(fd, timeout); |
0 | 3581 JVM_END |
3582 | |
3583 | |
3584 JVM_LEAF(jint, JVM_Listen(jint fd, jint count)) | |
3585 JVMWrapper2("JVM_Listen (0x%x)", fd); | |
3586 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3587 return os::listen(fd, count); |
0 | 3588 JVM_END |
3589 | |
3590 | |
3591 JVM_LEAF(jint, JVM_Connect(jint fd, struct sockaddr *him, jint len)) | |
3592 JVMWrapper2("JVM_Connect (0x%x)", fd); | |
3593 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3594 return os::connect(fd, him, (socklen_t)len); |
0 | 3595 JVM_END |
3596 | |
3597 | |
3598 JVM_LEAF(jint, JVM_Bind(jint fd, struct sockaddr *him, jint len)) | |
3599 JVMWrapper2("JVM_Bind (0x%x)", fd); | |
3600 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3601 return os::bind(fd, him, (socklen_t)len); |
0 | 3602 JVM_END |
3603 | |
3604 | |
3605 JVM_LEAF(jint, JVM_Accept(jint fd, struct sockaddr *him, jint *len)) | |
3606 JVMWrapper2("JVM_Accept (0x%x)", fd); | |
3607 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3608 socklen_t socklen = (socklen_t)(*len); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3609 jint result = os::accept(fd, him, &socklen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3610 *len = (jint)socklen; |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3611 return result; |
0 | 3612 JVM_END |
3613 | |
3614 | |
3615 JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)) | |
3616 JVMWrapper2("JVM_RecvFrom (0x%x)", fd); | |
3617 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3618 socklen_t socklen = (socklen_t)(*fromlen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3619 jint result = os::recvfrom(fd, buf, (size_t)nBytes, (uint)flags, from, &socklen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3620 *fromlen = (int)socklen; |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3621 return result; |
0 | 3622 JVM_END |
3623 | |
3624 | |
3625 JVM_LEAF(jint, JVM_GetSockName(jint fd, struct sockaddr *him, int *len)) | |
3626 JVMWrapper2("JVM_GetSockName (0x%x)", fd); | |
3627 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3628 socklen_t socklen = (socklen_t)(*len); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3629 jint result = os::get_sock_name(fd, him, &socklen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3630 *len = (int)socklen; |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3631 return result; |
0 | 3632 JVM_END |
3633 | |
3634 | |
3635 JVM_LEAF(jint, JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)) | |
3636 JVMWrapper2("JVM_SendTo (0x%x)", fd); | |
3637 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3638 return os::sendto(fd, buf, (size_t)len, (uint)flags, to, (socklen_t)tolen); |
0 | 3639 JVM_END |
3640 | |
3641 | |
3642 JVM_LEAF(jint, JVM_SocketAvailable(jint fd, jint *pbytes)) | |
3643 JVMWrapper2("JVM_SocketAvailable (0x%x)", fd); | |
3644 //%note jvm_r6 | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3645 return os::socket_available(fd, pbytes); |
0 | 3646 JVM_END |
3647 | |
3648 | |
3649 JVM_LEAF(jint, JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)) | |
3650 JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); | |
3651 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3652 socklen_t socklen = (socklen_t)(*optlen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3653 jint result = os::get_sock_opt(fd, level, optname, optval, &socklen); |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3654 *optlen = (int)socklen; |
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3655 return result; |
0 | 3656 JVM_END |
3657 | |
3658 | |
3659 JVM_LEAF(jint, JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)) | |
3660 JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); | |
3661 //%note jvm_r6 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3662 return os::set_sock_opt(fd, level, optname, optval, (socklen_t)optlen); |
0 | 3663 JVM_END |
3664 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3665 |
0 | 3666 JVM_LEAF(int, JVM_GetHostName(char* name, int namelen)) |
3667 JVMWrapper("JVM_GetHostName"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3668 return os::get_host_name(name, namelen); |
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3669 JVM_END |
0 | 3670 |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3671 |
0 | 3672 // Library support /////////////////////////////////////////////////////////////////////////// |
3673 | |
3674 JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) | |
3675 //%note jvm_ct | |
3676 JVMWrapper2("JVM_LoadLibrary (%s)", name); | |
3677 char ebuf[1024]; | |
3678 void *load_result; | |
3679 { | |
3680 ThreadToNativeFromVM ttnfvm(thread); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3681 load_result = os::dll_load(name, ebuf, sizeof ebuf); |
0 | 3682 } |
3683 if (load_result == NULL) { | |
3684 char msg[1024]; | |
3685 jio_snprintf(msg, sizeof msg, "%s: %s", name, ebuf); | |
3686 // Since 'ebuf' may contain a string encoded using | |
3687 // platform encoding scheme, we need to pass | |
3688 // Exceptions::unsafe_to_utf8 to the new_exception method | |
3689 // as the last argument. See bug 6367357. | |
3690 Handle h_exception = | |
3691 Exceptions::new_exception(thread, | |
3692 vmSymbols::java_lang_UnsatisfiedLinkError(), | |
3693 msg, Exceptions::unsafe_to_utf8); | |
3694 | |
3695 THROW_HANDLE_0(h_exception); | |
3696 } | |
3697 return load_result; | |
3698 JVM_END | |
3699 | |
3700 | |
3701 JVM_LEAF(void, JVM_UnloadLibrary(void* handle)) | |
3702 JVMWrapper("JVM_UnloadLibrary"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3703 os::dll_unload(handle); |
0 | 3704 JVM_END |
3705 | |
3706 | |
3707 JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name)) | |
3708 JVMWrapper2("JVM_FindLibraryEntry (%s)", name); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
3709 return os::dll_lookup(handle, name); |
0 | 3710 JVM_END |
3711 | |
4717
11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
phh
parents:
4006
diff
changeset
|
3712 |
0 | 3713 // Floating point support //////////////////////////////////////////////////////////////////// |
3714 | |
3715 JVM_LEAF(jboolean, JVM_IsNaN(jdouble a)) | |
3716 JVMWrapper("JVM_IsNaN"); | |
3717 return g_isnan(a); | |
3718 JVM_END | |
3719 | |
3720 | |
3721 // JNI version /////////////////////////////////////////////////////////////////////////////// | |
3722 | |
3723 JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version)) | |
3724 JVMWrapper2("JVM_IsSupportedJNIVersion (%d)", version); | |
3725 return Threads::is_supported_jni_version_including_1_1(version); | |
3726 JVM_END | |
3727 | |
3728 | |
3729 // String support /////////////////////////////////////////////////////////////////////////// | |
3730 | |
3731 JVM_ENTRY(jstring, JVM_InternString(JNIEnv *env, jstring str)) | |
3732 JVMWrapper("JVM_InternString"); | |
3733 JvmtiVMObjectAllocEventCollector oam; | |
3734 if (str == NULL) return NULL; | |
3735 oop string = JNIHandles::resolve_non_null(str); | |
3736 oop result = StringTable::intern(string, CHECK_NULL); | |
3737 return (jstring) JNIHandles::make_local(env, result); | |
3738 JVM_END | |
3739 | |
3740 | |
3741 // Raw monitor support ////////////////////////////////////////////////////////////////////// | |
3742 | |
3743 // The lock routine below calls lock_without_safepoint_check in order to get a raw lock | |
3744 // without interfering with the safepoint mechanism. The routines are not JVM_LEAF because | |
3745 // they might be called by non-java threads. The JVM_LEAF installs a NoHandleMark check | |
3746 // that only works with java threads. | |
3747 | |
3748 | |
3749 JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void) { | |
3750 VM_Exit::block_if_vm_exited(); | |
3751 JVMWrapper("JVM_RawMonitorCreate"); | |
3752 return new Mutex(Mutex::native, "JVM_RawMonitorCreate"); | |
3753 } | |
3754 | |
3755 | |
3756 JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon) { | |
3757 VM_Exit::block_if_vm_exited(); | |
3758 JVMWrapper("JVM_RawMonitorDestroy"); | |
3759 delete ((Mutex*) mon); | |
3760 } | |
3761 | |
3762 | |
3763 JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon) { | |
3764 VM_Exit::block_if_vm_exited(); | |
3765 JVMWrapper("JVM_RawMonitorEnter"); | |
3766 ((Mutex*) mon)->jvm_raw_lock(); | |
3767 return 0; | |
3768 } | |
3769 | |
3770 | |
3771 JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) { | |
3772 VM_Exit::block_if_vm_exited(); | |
3773 JVMWrapper("JVM_RawMonitorExit"); | |
3774 ((Mutex*) mon)->jvm_raw_unlock(); | |
3775 } | |
3776 | |
3777 | |
3778 // Support for Serialization | |
3779 | |
3780 typedef jfloat (JNICALL *IntBitsToFloatFn )(JNIEnv* env, jclass cb, jint value); | |
3781 typedef jdouble (JNICALL *LongBitsToDoubleFn)(JNIEnv* env, jclass cb, jlong value); | |
3782 typedef jint (JNICALL *FloatToIntBitsFn )(JNIEnv* env, jclass cb, jfloat value); | |
3783 typedef jlong (JNICALL *DoubleToLongBitsFn)(JNIEnv* env, jclass cb, jdouble value); | |
3784 | |
3785 static IntBitsToFloatFn int_bits_to_float_fn = NULL; | |
3786 static LongBitsToDoubleFn long_bits_to_double_fn = NULL; | |
3787 static FloatToIntBitsFn float_to_int_bits_fn = NULL; | |
3788 static DoubleToLongBitsFn double_to_long_bits_fn = NULL; | |
3789 | |
3790 | |
3791 void initialize_converter_functions() { | |
3792 if (JDK_Version::is_gte_jdk14x_version()) { | |
3793 // These functions only exist for compatibility with 1.3.1 and earlier | |
3794 return; | |
3795 } | |
3796 | |
3797 // called from universe_post_init() | |
3798 assert( | |
3799 int_bits_to_float_fn == NULL && | |
3800 long_bits_to_double_fn == NULL && | |
3801 float_to_int_bits_fn == NULL && | |
3802 double_to_long_bits_fn == NULL , | |
3803 "initialization done twice" | |
3804 ); | |
3805 // initialize | |
3806 int_bits_to_float_fn = CAST_TO_FN_PTR(IntBitsToFloatFn , NativeLookup::base_library_lookup("java/lang/Float" , "intBitsToFloat" , "(I)F")); | |
3807 long_bits_to_double_fn = CAST_TO_FN_PTR(LongBitsToDoubleFn, NativeLookup::base_library_lookup("java/lang/Double", "longBitsToDouble", "(J)D")); | |
3808 float_to_int_bits_fn = CAST_TO_FN_PTR(FloatToIntBitsFn , NativeLookup::base_library_lookup("java/lang/Float" , "floatToIntBits" , "(F)I")); | |
3809 double_to_long_bits_fn = CAST_TO_FN_PTR(DoubleToLongBitsFn, NativeLookup::base_library_lookup("java/lang/Double", "doubleToLongBits", "(D)J")); | |
3810 // verify | |
3811 assert( | |
3812 int_bits_to_float_fn != NULL && | |
3813 long_bits_to_double_fn != NULL && | |
3814 float_to_int_bits_fn != NULL && | |
3815 double_to_long_bits_fn != NULL , | |
3816 "initialization failed" | |
3817 ); | |
3818 } | |
3819 | |
3820 | |
3821 // Serialization | |
3822 JVM_ENTRY(void, JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, | |
3823 jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)) | |
3824 assert(!JDK_Version::is_gte_jdk14x_version(), "should only be used in 1.3.1 and earlier"); | |
3825 | |
3826 typeArrayOop tcodes = typeArrayOop(JNIHandles::resolve(typecodes)); | |
3827 typeArrayOop dbuf = typeArrayOop(JNIHandles::resolve(data)); | |
3828 typeArrayOop fids = typeArrayOop(JNIHandles::resolve(fieldIDs)); | |
3829 oop o = JNIHandles::resolve(obj); | |
3830 | |
3831 if (o == NULL || fids == NULL || dbuf == NULL || tcodes == NULL) { | |
3832 THROW(vmSymbols::java_lang_NullPointerException()); | |
3833 } | |
3834 | |
3835 jsize nfids = fids->length(); | |
3836 if (nfids == 0) return; | |
3837 | |
3838 if (tcodes->length() < nfids) { | |
3839 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); | |
3840 } | |
3841 | |
3842 jsize off = 0; | |
3843 /* loop through fields, setting values */ | |
3844 for (jsize i = 0; i < nfids; i++) { | |
3845 jfieldID fid = (jfieldID)(intptr_t) fids->long_at(i); | |
3846 int field_offset; | |
3847 if (fid != NULL) { | |
3848 // NULL is a legal value for fid, but retrieving the field offset | |
3849 // trigger assertion in that case | |
3850 field_offset = jfieldIDWorkaround::from_instance_jfieldID(o->klass(), fid); | |
3851 } | |
3852 | |
3853 switch (tcodes->char_at(i)) { | |
3854 case 'Z': | |
3855 if (fid != NULL) { | |
3856 jboolean val = (dbuf->byte_at(off) != 0) ? JNI_TRUE : JNI_FALSE; | |
3857 o->bool_field_put(field_offset, val); | |
3858 } | |
3859 off++; | |
3860 break; | |
3861 | |
3862 case 'B': | |
3863 if (fid != NULL) { | |
3864 o->byte_field_put(field_offset, dbuf->byte_at(off)); | |
3865 } | |
3866 off++; | |
3867 break; | |
3868 | |
3869 case 'C': | |
3870 if (fid != NULL) { | |
3871 jchar val = ((dbuf->byte_at(off + 0) & 0xFF) << 8) | |
3872 + ((dbuf->byte_at(off + 1) & 0xFF) << 0); | |
3873 o->char_field_put(field_offset, val); | |
3874 } | |
3875 off += 2; | |
3876 break; | |
3877 | |
3878 case 'S': | |
3879 if (fid != NULL) { | |
3880 jshort val = ((dbuf->byte_at(off + 0) & 0xFF) << 8) | |
3881 + ((dbuf->byte_at(off + 1) & 0xFF) << 0); | |
3882 o->short_field_put(field_offset, val); | |
3883 } | |
3884 off += 2; | |
3885 break; | |
3886 | |
3887 case 'I': | |
3888 if (fid != NULL) { | |
3889 jint ival = ((dbuf->byte_at(off + 0) & 0xFF) << 24) | |
3890 + ((dbuf->byte_at(off + 1) & 0xFF) << 16) | |
3891 + ((dbuf->byte_at(off + 2) & 0xFF) << 8) | |
3892 + ((dbuf->byte_at(off + 3) & 0xFF) << 0); | |
3893 o->int_field_put(field_offset, ival); | |
3894 } | |
3895 off += 4; | |
3896 break; | |
3897 | |
3898 case 'F': | |
3899 if (fid != NULL) { | |
3900 jint ival = ((dbuf->byte_at(off + 0) & 0xFF) << 24) | |
3901 + ((dbuf->byte_at(off + 1) & 0xFF) << 16) | |
3902 + ((dbuf->byte_at(off + 2) & 0xFF) << 8) | |
3903 + ((dbuf->byte_at(off + 3) & 0xFF) << 0); | |
3904 jfloat fval = (*int_bits_to_float_fn)(env, NULL, ival); | |
3905 o->float_field_put(field_offset, fval); | |
3906 } | |
3907 off += 4; | |
3908 break; | |
3909 | |
3910 case 'J': | |
3911 if (fid != NULL) { | |
3912 jlong lval = (((jlong) dbuf->byte_at(off + 0) & 0xFF) << 56) | |
3913 + (((jlong) dbuf->byte_at(off + 1) & 0xFF) << 48) | |
3914 + (((jlong) dbuf->byte_at(off + 2) & 0xFF) << 40) | |
3915 + (((jlong) dbuf->byte_at(off + 3) & 0xFF) << 32) | |
3916 + (((jlong) dbuf->byte_at(off + 4) & 0xFF) << 24) | |
3917 + (((jlong) dbuf->byte_at(off + 5) & 0xFF) << 16) | |
3918 + (((jlong) dbuf->byte_at(off + 6) & 0xFF) << 8) | |
3919 + (((jlong) dbuf->byte_at(off + 7) & 0xFF) << 0); | |
3920 o->long_field_put(field_offset, lval); | |
3921 } | |
3922 off += 8; | |
3923 break; | |
3924 | |
3925 case 'D': | |
3926 if (fid != NULL) { | |
3927 jlong lval = (((jlong) dbuf->byte_at(off + 0) & 0xFF) << 56) | |
3928 + (((jlong) dbuf->byte_at(off + 1) & 0xFF) << 48) | |
3929 + (((jlong) dbuf->byte_at(off + 2) & 0xFF) << 40) | |
3930 + (((jlong) dbuf->byte_at(off + 3) & 0xFF) << 32) | |
3931 + (((jlong) dbuf->byte_at(off + 4) & 0xFF) << 24) | |
3932 + (((jlong) dbuf->byte_at(off + 5) & 0xFF) << 16) | |
3933 + (((jlong) dbuf->byte_at(off + 6) & 0xFF) << 8) | |
3934 + (((jlong) dbuf->byte_at(off + 7) & 0xFF) << 0); | |
3935 jdouble dval = (*long_bits_to_double_fn)(env, NULL, lval); | |
3936 o->double_field_put(field_offset, dval); | |
3937 } | |
3938 off += 8; | |
3939 break; | |
3940 | |
3941 default: | |
3942 // Illegal typecode | |
3943 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "illegal typecode"); | |
3944 } | |
3945 } | |
3946 JVM_END | |
3947 | |
3948 | |
3949 JVM_ENTRY(void, JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, | |
3950 jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)) | |
3951 assert(!JDK_Version::is_gte_jdk14x_version(), "should only be used in 1.3.1 and earlier"); | |
3952 | |
3953 typeArrayOop tcodes = typeArrayOop(JNIHandles::resolve(typecodes)); | |
3954 typeArrayOop dbuf = typeArrayOop(JNIHandles::resolve(data)); | |
3955 typeArrayOop fids = typeArrayOop(JNIHandles::resolve(fieldIDs)); | |
3956 oop o = JNIHandles::resolve(obj); | |
3957 | |
3958 if (o == NULL || fids == NULL || dbuf == NULL || tcodes == NULL) { | |
3959 THROW(vmSymbols::java_lang_NullPointerException()); | |
3960 } | |
3961 | |
3962 jsize nfids = fids->length(); | |
3963 if (nfids == 0) return; | |
3964 | |
3965 if (tcodes->length() < nfids) { | |
3966 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); | |
3967 } | |
3968 | |
3969 /* loop through fields, fetching values */ | |
3970 jsize off = 0; | |
3971 for (jsize i = 0; i < nfids; i++) { | |
3972 jfieldID fid = (jfieldID)(intptr_t) fids->long_at(i); | |
3973 if (fid == NULL) { | |
3974 THROW(vmSymbols::java_lang_NullPointerException()); | |
3975 } | |
3976 int field_offset = jfieldIDWorkaround::from_instance_jfieldID(o->klass(), fid); | |
3977 | |
3978 switch (tcodes->char_at(i)) { | |
3979 case 'Z': | |
3980 { | |
3981 jboolean val = o->bool_field(field_offset); | |
3982 dbuf->byte_at_put(off++, (val != 0) ? 1 : 0); | |
3983 } | |
3984 break; | |
3985 | |
3986 case 'B': | |
3987 dbuf->byte_at_put(off++, o->byte_field(field_offset)); | |
3988 break; | |
3989 | |
3990 case 'C': | |
3991 { | |
3992 jchar val = o->char_field(field_offset); | |
3993 dbuf->byte_at_put(off++, (val >> 8) & 0xFF); | |
3994 dbuf->byte_at_put(off++, (val >> 0) & 0xFF); | |
3995 } | |
3996 break; | |
3997 | |
3998 case 'S': | |
3999 { | |
4000 jshort val = o->short_field(field_offset); | |
4001 dbuf->byte_at_put(off++, (val >> 8) & 0xFF); | |
4002 dbuf->byte_at_put(off++, (val >> 0) & 0xFF); | |
4003 } | |
4004 break; | |
4005 | |
4006 case 'I': | |
4007 { | |
4008 jint val = o->int_field(field_offset); | |
4009 dbuf->byte_at_put(off++, (val >> 24) & 0xFF); | |
4010 dbuf->byte_at_put(off++, (val >> 16) & 0xFF); | |
4011 dbuf->byte_at_put(off++, (val >> 8) & 0xFF); | |
4012 dbuf->byte_at_put(off++, (val >> 0) & 0xFF); | |
4013 } | |
4014 break; | |
4015 | |
4016 case 'F': | |
4017 { | |
4018 jfloat fval = o->float_field(field_offset); | |
4019 jint ival = (*float_to_int_bits_fn)(env, NULL, fval); | |
4020 dbuf->byte_at_put(off++, (ival >> 24) & 0xFF); | |
4021 dbuf->byte_at_put(off++, (ival >> 16) & 0xFF); | |
4022 dbuf->byte_at_put(off++, (ival >> 8) & 0xFF); | |
4023 dbuf->byte_at_put(off++, (ival >> 0) & 0xFF); | |
4024 } | |
4025 break; | |
4026 | |
4027 case 'J': | |
4028 { | |
4029 jlong val = o->long_field(field_offset); | |
4030 dbuf->byte_at_put(off++, (val >> 56) & 0xFF); | |
4031 dbuf->byte_at_put(off++, (val >> 48) & 0xFF); | |
4032 dbuf->byte_at_put(off++, (val >> 40) & 0xFF); | |
4033 dbuf->byte_at_put(off++, (val >> 32) & 0xFF); | |
4034 dbuf->byte_at_put(off++, (val >> 24) & 0xFF); | |
4035 dbuf->byte_at_put(off++, (val >> 16) & 0xFF); | |
4036 dbuf->byte_at_put(off++, (val >> 8) & 0xFF); | |
4037 dbuf->byte_at_put(off++, (val >> 0) & 0xFF); | |
4038 } | |
4039 break; | |
4040 | |
4041 case 'D': | |
4042 { | |
4043 jdouble dval = o->double_field(field_offset); | |
4044 jlong lval = (*double_to_long_bits_fn)(env, NULL, dval); | |
4045 dbuf->byte_at_put(off++, (lval >> 56) & 0xFF); | |
4046 dbuf->byte_at_put(off++, (lval >> 48) & 0xFF); | |
4047 dbuf->byte_at_put(off++, (lval >> 40) & 0xFF); | |
4048 dbuf->byte_at_put(off++, (lval >> 32) & 0xFF); | |
4049 dbuf->byte_at_put(off++, (lval >> 24) & 0xFF); | |
4050 dbuf->byte_at_put(off++, (lval >> 16) & 0xFF); | |
4051 dbuf->byte_at_put(off++, (lval >> 8) & 0xFF); | |
4052 dbuf->byte_at_put(off++, (lval >> 0) & 0xFF); | |
4053 } | |
4054 break; | |
4055 | |
4056 default: | |
4057 // Illegal typecode | |
4058 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "illegal typecode"); | |
4059 } | |
4060 } | |
4061 JVM_END | |
4062 | |
4063 | |
4064 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// | |
4065 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
4066 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { |
0 | 4067 // Security Note: |
4068 // The Java level wrapper will perform the necessary security check allowing | |
4069 // us to pass the NULL as the initiating class loader. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
4070 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
875
diff
changeset
|
4071 |
0 | 4072 KlassHandle klass_handle(THREAD, klass); |
4073 // Check if we should initialize the class | |
4074 if (init && klass_handle->oop_is_instance()) { | |
4075 klass_handle->initialize(CHECK_NULL); | |
4076 } | |
4077 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); | |
4078 } | |
4079 | |
4080 | |
4081 // Internal SQE debugging support /////////////////////////////////////////////////////////// | |
4082 | |
4083 #ifndef PRODUCT | |
4084 | |
4085 extern "C" { | |
4086 JNIEXPORT jboolean JNICALL JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get); | |
4087 JNIEXPORT jboolean JNICALL JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get); | |
4088 JNIEXPORT void JNICALL JVM_VMBreakPoint(JNIEnv *env, jobject obj); | |
4089 } | |
4090 | |
4091 JVM_LEAF(jboolean, JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)) | |
4092 JVMWrapper("JVM_AccessBoolVMFlag"); | |
4093 return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, INTERNAL); | |
4094 JVM_END | |
4095 | |
4096 JVM_LEAF(jboolean, JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)) | |
4097 JVMWrapper("JVM_AccessVMIntFlag"); | |
4098 intx v; | |
4099 jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, INTERNAL); | |
4100 *value = (jint)v; | |
4101 return result; | |
4102 JVM_END | |
4103 | |
4104 | |
4105 JVM_ENTRY(void, JVM_VMBreakPoint(JNIEnv *env, jobject obj)) | |
4106 JVMWrapper("JVM_VMBreakPoint"); | |
4107 oop the_obj = JNIHandles::resolve(obj); | |
4108 BREAKPOINT; | |
4109 JVM_END | |
4110 | |
4111 | |
4112 #endif | |
4113 | |
4114 | |
4115 // Method /////////////////////////////////////////////////////////////////////////////////////////// | |
4116 | |
4117 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) | |
4118 JVMWrapper("JVM_InvokeMethod"); | |
4119 Handle method_handle; | |
4120 if (thread->stack_available((address) &method_handle) >= JVMInvokeMethodSlack) { | |
4121 method_handle = Handle(THREAD, JNIHandles::resolve(method)); | |
4122 Handle receiver(THREAD, JNIHandles::resolve(obj)); | |
4123 objArrayHandle args(THREAD, objArrayOop(JNIHandles::resolve(args0))); | |
4124 oop result = Reflection::invoke_method(method_handle(), receiver, args, CHECK_NULL); | |
4125 jobject res = JNIHandles::make_local(env, result); | |
4126 if (JvmtiExport::should_post_vm_object_alloc()) { | |
4127 oop ret_type = java_lang_reflect_Method::return_type(method_handle()); | |
4128 assert(ret_type != NULL, "sanity check: ret_type oop must not be NULL!"); | |
4129 if (java_lang_Class::is_primitive(ret_type)) { | |
4130 // Only for primitive type vm allocates memory for java object. | |
4131 // See box() method. | |
4132 JvmtiExport::post_vm_object_alloc(JavaThread::current(), result); | |
4133 } | |
4134 } | |
4135 return res; | |
4136 } else { | |
4137 THROW_0(vmSymbols::java_lang_StackOverflowError()); | |
4138 } | |
4139 JVM_END | |
4140 | |
4141 | |
4142 JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)) | |
4143 JVMWrapper("JVM_NewInstanceFromConstructor"); | |
4144 oop constructor_mirror = JNIHandles::resolve(c); | |
4145 objArrayHandle args(THREAD, objArrayOop(JNIHandles::resolve(args0))); | |
4146 oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL); | |
4147 jobject res = JNIHandles::make_local(env, result); | |
4148 if (JvmtiExport::should_post_vm_object_alloc()) { | |
4149 JvmtiExport::post_vm_object_alloc(JavaThread::current(), result); | |
4150 } | |
4151 return res; | |
4152 JVM_END | |
4153 | |
4154 // Atomic /////////////////////////////////////////////////////////////////////////////////////////// | |
4155 | |
4156 JVM_LEAF(jboolean, JVM_SupportsCX8()) | |
4157 JVMWrapper("JVM_SupportsCX8"); | |
4158 return VM_Version::supports_cx8(); | |
4159 JVM_END | |
4160 | |
4161 | |
4162 JVM_ENTRY(jboolean, JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)) | |
4163 JVMWrapper("JVM_CX8Field"); | |
4164 jlong res; | |
4165 oop o = JNIHandles::resolve(obj); | |
4166 intptr_t fldOffs = jfieldIDWorkaround::from_instance_jfieldID(o->klass(), fid); | |
4167 volatile jlong* addr = (volatile jlong*)((address)o + fldOffs); | |
4168 | |
4169 assert(VM_Version::supports_cx8(), "cx8 not supported"); | |
4170 res = Atomic::cmpxchg(newVal, addr, oldVal); | |
4171 | |
4172 return res == oldVal; | |
4173 JVM_END | |
4174 | |
116
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4175 // DTrace /////////////////////////////////////////////////////////////////// |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4176 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4177 JVM_ENTRY(jint, JVM_DTraceGetVersion(JNIEnv* env)) |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4178 JVMWrapper("JVM_DTraceGetVersion"); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4179 return (jint)JVM_TRACING_DTRACE_VERSION; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4180 JVM_END |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4181 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4182 JVM_ENTRY(jlong,JVM_DTraceActivate( |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4183 JNIEnv* env, jint version, jstring module_name, jint providers_count, |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4184 JVM_DTraceProvider* providers)) |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4185 JVMWrapper("JVM_DTraceActivate"); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4186 return DTraceJSDT::activate( |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4187 version, module_name, providers_count, providers, CHECK_0); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4188 JVM_END |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4189 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4190 JVM_ENTRY(jboolean,JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method)) |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4191 JVMWrapper("JVM_DTraceIsProbeEnabled"); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4192 return DTraceJSDT::is_probe_enabled(method); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4193 JVM_END |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4194 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4195 JVM_ENTRY(void,JVM_DTraceDispose(JNIEnv* env, jlong handle)) |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4196 JVMWrapper("JVM_DTraceDispose"); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4197 DTraceJSDT::dispose(handle); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4198 JVM_END |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4199 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4200 JVM_ENTRY(jboolean,JVM_DTraceIsSupported(JNIEnv* env)) |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4201 JVMWrapper("JVM_DTraceIsSupported"); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4202 return DTraceJSDT::is_supported(); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4203 JVM_END |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
4204 |
0 | 4205 // Returns an array of all live Thread objects (VM internal JavaThreads, |
4206 // jvmti agent threads, and JNI attaching threads are skipped) | |
4207 // See CR 6404306 regarding JNI attaching threads | |
4208 JVM_ENTRY(jobjectArray, JVM_GetAllThreads(JNIEnv *env, jclass dummy)) | |
4209 ResourceMark rm(THREAD); | |
4210 ThreadsListEnumerator tle(THREAD, false, false); | |
4211 JvmtiVMObjectAllocEventCollector oam; | |
4212 | |
4213 int num_threads = tle.num_threads(); | |
1142 | 4214 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Thread_klass(), num_threads, CHECK_NULL); |
0 | 4215 objArrayHandle threads_ah(THREAD, r); |
4216 | |
4217 for (int i = 0; i < num_threads; i++) { | |
4218 Handle h = tle.get_threadObj(i); | |
4219 threads_ah->obj_at_put(i, h()); | |
4220 } | |
4221 | |
4222 return (jobjectArray) JNIHandles::make_local(env, threads_ah()); | |
4223 JVM_END | |
4224 | |
4225 | |
4226 // Support for java.lang.Thread.getStackTrace() and getAllStackTraces() methods | |
4227 // Return StackTraceElement[][], each element is the stack trace of a thread in | |
4228 // the corresponding entry in the given threads array | |
4229 JVM_ENTRY(jobjectArray, JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)) | |
4230 JVMWrapper("JVM_DumpThreads"); | |
4231 JvmtiVMObjectAllocEventCollector oam; | |
4232 | |
4233 // Check if threads is null | |
4234 if (threads == NULL) { | |
4235 THROW_(vmSymbols::java_lang_NullPointerException(), 0); | |
4236 } | |
4237 | |
4238 objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(threads)); | |
4239 objArrayHandle ah(THREAD, a); | |
4240 int num_threads = ah->length(); | |
4241 // check if threads is non-empty array | |
4242 if (num_threads == 0) { | |
4243 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); | |
4244 } | |
4245 | |
4246 // check if threads is not an array of objects of Thread class | |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6725
diff
changeset
|
4247 Klass* k = ObjArrayKlass::cast(ah->klass())->element_klass(); |
1142 | 4248 if (k != SystemDictionary::Thread_klass()) { |
0 | 4249 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); |
4250 } | |
4251 | |
4252 ResourceMark rm(THREAD); | |
4253 | |
4254 GrowableArray<instanceHandle>* thread_handle_array = new GrowableArray<instanceHandle>(num_threads); | |
4255 for (int i = 0; i < num_threads; i++) { | |
4256 oop thread_obj = ah->obj_at(i); | |
4257 instanceHandle h(THREAD, (instanceOop) thread_obj); | |
4258 thread_handle_array->append(h); | |
4259 } | |
4260 | |
4261 Handle stacktraces = ThreadService::dump_stack_traces(thread_handle_array, num_threads, CHECK_NULL); | |
4262 return (jobjectArray)JNIHandles::make_local(env, stacktraces()); | |
4263 | |
4264 JVM_END | |
4265 | |
4266 // JVM monitoring and management support | |
4267 JVM_ENTRY_NO_ENV(void*, JVM_GetManagement(jint version)) | |
4268 return Management::get_jmm_interface(version); | |
4269 JVM_END | |
4270 | |
4271 // com.sun.tools.attach.VirtualMachine agent properties support | |
4272 // | |
4273 // Initialize the agent properties with the properties maintained in the VM | |
4274 JVM_ENTRY(jobject, JVM_InitAgentProperties(JNIEnv *env, jobject properties)) | |
4275 JVMWrapper("JVM_InitAgentProperties"); | |
4276 ResourceMark rm; | |
4277 | |
4278 Handle props(THREAD, JNIHandles::resolve_non_null(properties)); | |
4279 | |
4280 PUTPROP(props, "sun.java.command", Arguments::java_command()); | |
4281 PUTPROP(props, "sun.jvm.flags", Arguments::jvm_flags()); | |
4282 PUTPROP(props, "sun.jvm.args", Arguments::jvm_args()); | |
4283 return properties; | |
4284 JVM_END | |
4285 | |
4286 JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)) | |
4287 { | |
4288 JVMWrapper("JVM_GetEnclosingMethodInfo"); | |
4289 JvmtiVMObjectAllocEventCollector oam; | |
4290 | |
4291 if (ofClass == NULL) { | |
4292 return NULL; | |
4293 } | |
4294 Handle mirror(THREAD, JNIHandles::resolve_non_null(ofClass)); | |
4295 // Special handling for primitive objects | |
4296 if (java_lang_Class::is_primitive(mirror())) { | |
4297 return NULL; | |
4298 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
4299 Klass* k = java_lang_Class::as_Klass(mirror()); |
6983 | 4300 if (!k->oop_is_instance()) { |
0 | 4301 return NULL; |
4302 } | |
4303 instanceKlassHandle ik_h(THREAD, k); | |
4304 int encl_method_class_idx = ik_h->enclosing_method_class_index(); | |
4305 if (encl_method_class_idx == 0) { | |
4306 return NULL; | |
4307 } | |
1142 | 4308 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); |
0 | 4309 objArrayHandle dest(THREAD, dest_o); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
4310 Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
6983 | 4311 dest->obj_at_put(0, enc_k->java_mirror()); |
0 | 4312 int encl_method_method_idx = ik_h->enclosing_method_method_index(); |
4313 if (encl_method_method_idx != 0) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
4314 Symbol* sym = ik_h->constants()->symbol_at( |
0 | 4315 extract_low_short_from_int( |
4316 ik_h->constants()->name_and_type_at(encl_method_method_idx))); | |
4317 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | |
4318 dest->obj_at_put(1, str()); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2162
diff
changeset
|
4319 sym = ik_h->constants()->symbol_at( |
0 | 4320 extract_high_short_from_int( |
4321 ik_h->constants()->name_and_type_at(encl_method_method_idx))); | |
4322 str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | |
4323 dest->obj_at_put(2, str()); | |
4324 } | |
4325 return (jobjectArray) JNIHandles::make_local(dest()); | |
4326 } | |
4327 JVM_END | |
4328 | |
4329 JVM_ENTRY(jintArray, JVM_GetThreadStateValues(JNIEnv* env, | |
4330 jint javaThreadState)) | |
4331 { | |
4332 // If new thread states are added in future JDK and VM versions, | |
4333 // this should check if the JDK version is compatible with thread | |
4334 // states supported by the VM. Return NULL if not compatible. | |
4335 // | |
4336 // This function must map the VM java_lang_Thread::ThreadStatus | |
4337 // to the Java thread state that the JDK supports. | |
4338 // | |
4339 | |
4340 typeArrayHandle values_h; | |
4341 switch (javaThreadState) { | |
4342 case JAVA_THREAD_STATE_NEW : { | |
4343 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); | |
4344 values_h = typeArrayHandle(THREAD, r); | |
4345 values_h->int_at_put(0, java_lang_Thread::NEW); | |
4346 break; | |
4347 } | |
4348 case JAVA_THREAD_STATE_RUNNABLE : { | |
4349 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); | |
4350 values_h = typeArrayHandle(THREAD, r); | |
4351 values_h->int_at_put(0, java_lang_Thread::RUNNABLE); | |
4352 break; | |
4353 } | |
4354 case JAVA_THREAD_STATE_BLOCKED : { | |
4355 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); | |
4356 values_h = typeArrayHandle(THREAD, r); | |
4357 values_h->int_at_put(0, java_lang_Thread::BLOCKED_ON_MONITOR_ENTER); | |
4358 break; | |
4359 } | |
4360 case JAVA_THREAD_STATE_WAITING : { | |
4361 typeArrayOop r = oopFactory::new_typeArray(T_INT, 2, CHECK_NULL); | |
4362 values_h = typeArrayHandle(THREAD, r); | |
4363 values_h->int_at_put(0, java_lang_Thread::IN_OBJECT_WAIT); | |
4364 values_h->int_at_put(1, java_lang_Thread::PARKED); | |
4365 break; | |
4366 } | |
4367 case JAVA_THREAD_STATE_TIMED_WAITING : { | |
4368 typeArrayOop r = oopFactory::new_typeArray(T_INT, 3, CHECK_NULL); | |
4369 values_h = typeArrayHandle(THREAD, r); | |
4370 values_h->int_at_put(0, java_lang_Thread::SLEEPING); | |
4371 values_h->int_at_put(1, java_lang_Thread::IN_OBJECT_WAIT_TIMED); | |
4372 values_h->int_at_put(2, java_lang_Thread::PARKED_TIMED); | |
4373 break; | |
4374 } | |
4375 case JAVA_THREAD_STATE_TERMINATED : { | |
4376 typeArrayOop r = oopFactory::new_typeArray(T_INT, 1, CHECK_NULL); | |
4377 values_h = typeArrayHandle(THREAD, r); | |
4378 values_h->int_at_put(0, java_lang_Thread::TERMINATED); | |
4379 break; | |
4380 } | |
4381 default: | |
4382 // Unknown state - probably incompatible JDK version | |
4383 return NULL; | |
4384 } | |
4385 | |
4386 return (jintArray) JNIHandles::make_local(env, values_h()); | |
4387 } | |
4388 JVM_END | |
4389 | |
4390 | |
4391 JVM_ENTRY(jobjectArray, JVM_GetThreadStateNames(JNIEnv* env, | |
4392 jint javaThreadState, | |
4393 jintArray values)) | |
4394 { | |
4395 // If new thread states are added in future JDK and VM versions, | |
4396 // this should check if the JDK version is compatible with thread | |
4397 // states supported by the VM. Return NULL if not compatible. | |
4398 // | |
4399 // This function must map the VM java_lang_Thread::ThreadStatus | |
4400 // to the Java thread state that the JDK supports. | |
4401 // | |
4402 | |
4403 ResourceMark rm; | |
4404 | |
4405 // Check if threads is null | |
4406 if (values == NULL) { | |
4407 THROW_(vmSymbols::java_lang_NullPointerException(), 0); | |
4408 } | |
4409 | |
4410 typeArrayOop v = typeArrayOop(JNIHandles::resolve_non_null(values)); | |
4411 typeArrayHandle values_h(THREAD, v); | |
4412 | |
4413 objArrayHandle names_h; | |
4414 switch (javaThreadState) { | |
4415 case JAVA_THREAD_STATE_NEW : { | |
4416 assert(values_h->length() == 1 && | |
4417 values_h->int_at(0) == java_lang_Thread::NEW, | |
4418 "Invalid threadStatus value"); | |
4419 | |
1142 | 4420 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4421 1, /* only 1 substate */ |
4422 CHECK_NULL); | |
4423 names_h = objArrayHandle(THREAD, r); | |
4424 Handle name = java_lang_String::create_from_str("NEW", CHECK_NULL); | |
4425 names_h->obj_at_put(0, name()); | |
4426 break; | |
4427 } | |
4428 case JAVA_THREAD_STATE_RUNNABLE : { | |
4429 assert(values_h->length() == 1 && | |
4430 values_h->int_at(0) == java_lang_Thread::RUNNABLE, | |
4431 "Invalid threadStatus value"); | |
4432 | |
1142 | 4433 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4434 1, /* only 1 substate */ |
4435 CHECK_NULL); | |
4436 names_h = objArrayHandle(THREAD, r); | |
4437 Handle name = java_lang_String::create_from_str("RUNNABLE", CHECK_NULL); | |
4438 names_h->obj_at_put(0, name()); | |
4439 break; | |
4440 } | |
4441 case JAVA_THREAD_STATE_BLOCKED : { | |
4442 assert(values_h->length() == 1 && | |
4443 values_h->int_at(0) == java_lang_Thread::BLOCKED_ON_MONITOR_ENTER, | |
4444 "Invalid threadStatus value"); | |
4445 | |
1142 | 4446 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4447 1, /* only 1 substate */ |
4448 CHECK_NULL); | |
4449 names_h = objArrayHandle(THREAD, r); | |
4450 Handle name = java_lang_String::create_from_str("BLOCKED", CHECK_NULL); | |
4451 names_h->obj_at_put(0, name()); | |
4452 break; | |
4453 } | |
4454 case JAVA_THREAD_STATE_WAITING : { | |
4455 assert(values_h->length() == 2 && | |
4456 values_h->int_at(0) == java_lang_Thread::IN_OBJECT_WAIT && | |
4457 values_h->int_at(1) == java_lang_Thread::PARKED, | |
4458 "Invalid threadStatus value"); | |
1142 | 4459 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4460 2, /* number of substates */ |
4461 CHECK_NULL); | |
4462 names_h = objArrayHandle(THREAD, r); | |
4463 Handle name0 = java_lang_String::create_from_str("WAITING.OBJECT_WAIT", | |
4464 CHECK_NULL); | |
4465 Handle name1 = java_lang_String::create_from_str("WAITING.PARKED", | |
4466 CHECK_NULL); | |
4467 names_h->obj_at_put(0, name0()); | |
4468 names_h->obj_at_put(1, name1()); | |
4469 break; | |
4470 } | |
4471 case JAVA_THREAD_STATE_TIMED_WAITING : { | |
4472 assert(values_h->length() == 3 && | |
4473 values_h->int_at(0) == java_lang_Thread::SLEEPING && | |
4474 values_h->int_at(1) == java_lang_Thread::IN_OBJECT_WAIT_TIMED && | |
4475 values_h->int_at(2) == java_lang_Thread::PARKED_TIMED, | |
4476 "Invalid threadStatus value"); | |
1142 | 4477 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4478 3, /* number of substates */ |
4479 CHECK_NULL); | |
4480 names_h = objArrayHandle(THREAD, r); | |
4481 Handle name0 = java_lang_String::create_from_str("TIMED_WAITING.SLEEPING", | |
4482 CHECK_NULL); | |
4483 Handle name1 = java_lang_String::create_from_str("TIMED_WAITING.OBJECT_WAIT", | |
4484 CHECK_NULL); | |
4485 Handle name2 = java_lang_String::create_from_str("TIMED_WAITING.PARKED", | |
4486 CHECK_NULL); | |
4487 names_h->obj_at_put(0, name0()); | |
4488 names_h->obj_at_put(1, name1()); | |
4489 names_h->obj_at_put(2, name2()); | |
4490 break; | |
4491 } | |
4492 case JAVA_THREAD_STATE_TERMINATED : { | |
4493 assert(values_h->length() == 1 && | |
4494 values_h->int_at(0) == java_lang_Thread::TERMINATED, | |
4495 "Invalid threadStatus value"); | |
1142 | 4496 objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), |
0 | 4497 1, /* only 1 substate */ |
4498 CHECK_NULL); | |
4499 names_h = objArrayHandle(THREAD, r); | |
4500 Handle name = java_lang_String::create_from_str("TERMINATED", CHECK_NULL); | |
4501 names_h->obj_at_put(0, name()); | |
4502 break; | |
4503 } | |
4504 default: | |
4505 // Unknown state - probably incompatible JDK version | |
4506 return NULL; | |
4507 } | |
4508 return (jobjectArray) JNIHandles::make_local(env, names_h()); | |
4509 } | |
4510 JVM_END | |
4511 | |
4512 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)) | |
4513 { | |
4514 memset(info, 0, sizeof(info_size)); | |
4515 | |
4516 info->jvm_version = Abstract_VM_Version::jvm_version(); | |
4517 info->update_version = 0; /* 0 in HotSpot Express VM */ | |
4518 info->special_update_version = 0; /* 0 in HotSpot Express VM */ | |
4519 | |
4520 // when we add a new capability in the jvm_version_info struct, we should also | |
4521 // consider to expose this new capability in the sun.rt.jvmCapabilities jvmstat | |
4522 // counter defined in runtimeService.cpp. | |
4523 info->is_attachable = AttachListener::is_attach_supported(); | |
4524 #ifdef KERNEL | |
4525 info->is_kernel_jvm = 1; // true; | |
4526 #else // KERNEL | |
4527 info->is_kernel_jvm = 0; // false; | |
4528 #endif // KERNEL | |
4529 } | |
4530 JVM_END |