Print this page
rev 2143 : 6839872: remove implementation inheritance from JSR 292 APIs
Summary: Move all JSR 292 classes into the java.dyn package.
Reviewed-by:
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/classfile/systemDictionary.hpp
+++ new/src/share/vm/classfile/systemDictionary.hpp
1 1 /*
2 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
26 26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
27 27
28 28 #include "classfile/classFileStream.hpp"
29 29 #include "classfile/classLoader.hpp"
30 30 #include "oops/objArrayOop.hpp"
31 31 #include "oops/symbol.hpp"
32 32 #include "runtime/java.hpp"
33 33 #include "runtime/reflectionUtils.hpp"
34 34 #include "utilities/hashtable.hpp"
35 35
36 36 // The system dictionary stores all loaded classes and maps:
37 37 //
38 38 // [class name,class loader] -> class i.e. [Symbol*,oop] -> klassOop
39 39 //
40 40 // Classes are loaded lazily. The default VM class loader is
41 41 // represented as NULL.
42 42
43 43 // The underlying data structure is an open hash table with a fixed number
44 44 // of buckets. During loading the loader object is locked, (for the VM loader
45 45 // a private lock object is used). Class loading can thus be done concurrently,
46 46 // but only by different loaders.
47 47 //
48 48 // During loading a placeholder (name, loader) is temporarily placed in
49 49 // a side data structure, and is used to detect ClassCircularityErrors
50 50 // and to perform verification during GC. A GC can occur in the midst
51 51 // of class loading, as we call out to Java, have to take locks, etc.
52 52 //
53 53 // When class loading is finished, a new entry is added to the system
54 54 // dictionary and the place holder is removed. Note that the protection
55 55 // domain field of the system dictionary has not yet been filled in when
56 56 // the "real" system dictionary entry is created.
57 57 //
58 58 // Clients of this class who are interested in finding if a class has
59 59 // been completely loaded -- not classes in the process of being loaded --
60 60 // can read the SystemDictionary unlocked. This is safe because
61 61 // - entries are only deleted at safepoints
62 62 // - readers cannot come to a safepoint while actively examining
63 63 // an entry (an entry cannot be deleted from under a reader)
64 64 // - entries must be fully formed before they are available to concurrent
65 65 // readers (we must ensure write ordering)
66 66 //
67 67 // Note that placeholders are deleted at any time, as they are removed
68 68 // when a class is completely loaded. Therefore, readers as well as writers
69 69 // of placeholders must hold the SystemDictionary_lock.
70 70 //
71 71
72 72 class Dictionary;
73 73 class PlaceholderTable;
74 74 class LoaderConstraintTable;
75 75 class HashtableBucket;
76 76 class ResolutionErrorTable;
77 77 class SymbolPropertyTable;
78 78
79 79 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
80 80 // They are all "well-known", in the sense that no class loader is allowed
81 81 // to provide a different definition.
82 82 //
83 83 // These klasses must all have names defined in vmSymbols.
84 84
85 85 #define WK_KLASS_ENUM_NAME(kname) kname##_knum
86 86
87 87 // Each well-known class has a short klass name (like object_klass),
88 88 // a vmSymbol name (like java_lang_Object), and a flag word
89 89 // that makes some minor distinctions, like whether the klass
90 90 // is preloaded, optional, release-specific, etc.
91 91 // The order of these definitions is significant; it is the order in which
92 92 // preloading is actually performed by initialize_preloaded_classes.
93 93
94 94 #define WK_KLASSES_DO(template) \
95 95 /* well-known classes */ \
96 96 template(Object_klass, java_lang_Object, Pre) \
97 97 template(String_klass, java_lang_String, Pre) \
98 98 template(Class_klass, java_lang_Class, Pre) \
99 99 template(Cloneable_klass, java_lang_Cloneable, Pre) \
100 100 template(ClassLoader_klass, java_lang_ClassLoader, Pre) \
101 101 template(Serializable_klass, java_io_Serializable, Pre) \
102 102 template(System_klass, java_lang_System, Pre) \
103 103 template(Throwable_klass, java_lang_Throwable, Pre) \
104 104 template(Error_klass, java_lang_Error, Pre) \
105 105 template(ThreadDeath_klass, java_lang_ThreadDeath, Pre) \
106 106 template(Exception_klass, java_lang_Exception, Pre) \
107 107 template(RuntimeException_klass, java_lang_RuntimeException, Pre) \
108 108 template(ProtectionDomain_klass, java_security_ProtectionDomain, Pre) \
109 109 template(AccessControlContext_klass, java_security_AccessControlContext, Pre) \
110 110 template(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre) \
111 111 template(NoClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre) \
112 112 template(LinkageError_klass, java_lang_LinkageError, Pre) \
113 113 template(ClassCastException_klass, java_lang_ClassCastException, Pre) \
114 114 template(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre) \
115 115 template(VirtualMachineError_klass, java_lang_VirtualMachineError, Pre) \
116 116 template(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre) \
117 117 template(StackOverflowError_klass, java_lang_StackOverflowError, Pre) \
118 118 template(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre) \
119 119 template(Reference_klass, java_lang_ref_Reference, Pre) \
120 120 \
121 121 /* Preload ref klasses and set reference types */ \
122 122 template(SoftReference_klass, java_lang_ref_SoftReference, Pre) \
123 123 template(WeakReference_klass, java_lang_ref_WeakReference, Pre) \
124 124 template(FinalReference_klass, java_lang_ref_FinalReference, Pre) \
125 125 template(PhantomReference_klass, java_lang_ref_PhantomReference, Pre) \
126 126 template(Finalizer_klass, java_lang_ref_Finalizer, Pre) \
127 127 \
128 128 template(Thread_klass, java_lang_Thread, Pre) \
129 129 template(ThreadGroup_klass, java_lang_ThreadGroup, Pre) \
130 130 template(Properties_klass, java_util_Properties, Pre) \
131 131 template(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre) \
132 132 template(reflect_Field_klass, java_lang_reflect_Field, Pre) \
133 133 template(reflect_Method_klass, java_lang_reflect_Method, Pre) \
134 134 template(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre) \
135 135 \
136 136 /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
137 137 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
138 138 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
139 139 template(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt) \
140 140 template(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
141 141 template(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
142 142 template(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt) \
143 143 template(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15) \
144 144 template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \
145 145 \
146 146 /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
147 - template(MethodHandle_klass, java_dyn_MethodHandle, Opt) \
148 - template(MemberName_klass, sun_dyn_MemberName, Opt) \
149 - template(MethodHandleImpl_klass, sun_dyn_MethodHandleImpl, Opt) \
150 - template(MethodHandleNatives_klass, sun_dyn_MethodHandleNatives, Opt) \
151 - template(AdapterMethodHandle_klass, sun_dyn_AdapterMethodHandle, Opt) \
152 - template(BoundMethodHandle_klass, sun_dyn_BoundMethodHandle, Opt) \
153 - template(DirectMethodHandle_klass, sun_dyn_DirectMethodHandle, Opt) \
154 - template(MethodType_klass, java_dyn_MethodType, Opt) \
155 - template(MethodTypeForm_klass, java_dyn_MethodTypeForm, Opt) \
156 - template(WrongMethodTypeException_klass, java_dyn_WrongMethodTypeException, Opt) \
157 - template(Linkage_klass, java_dyn_Linkage, Opt) \
158 - template(CallSite_klass, java_dyn_CallSite, Opt) \
147 + template(MethodHandle_klass, java_dyn_MethodHandle, Pre_JSR292) \
148 + template(MemberName_klass, java_dyn_MemberName, Pre_JSR292) \
149 + template(MethodHandleImpl_klass, java_dyn_MethodHandleImpl, Pre_JSR292) /* AllowTransitionalJSR292 ONLY */ \
150 + template(MethodHandleNatives_klass, java_dyn_MethodHandleNatives, Pre_JSR292) \
151 + template(AdapterMethodHandle_klass, java_dyn_AdapterMethodHandle, Pre_JSR292) \
152 + template(BoundMethodHandle_klass, java_dyn_BoundMethodHandle, Pre_JSR292) \
153 + template(DirectMethodHandle_klass, java_dyn_DirectMethodHandle, Pre_JSR292) \
154 + template(MethodType_klass, java_dyn_MethodType, Pre_JSR292) \
155 + template(MethodTypeForm_klass, java_dyn_MethodTypeForm, Pre_JSR292) \
156 + template(WrongMethodTypeException_klass, java_dyn_WrongMethodTypeException, Pre_JSR292) \
157 + template(Linkage_klass, java_dyn_Linkage, Pre_JSR292) \
158 + template(CallSite_klass, java_dyn_CallSite, Pre_JSR292) \
159 159 /* Note: MethodHandle must be first, and CallSite last in group */ \
160 160 \
161 161 template(StringBuffer_klass, java_lang_StringBuffer, Pre) \
162 162 template(StringBuilder_klass, java_lang_StringBuilder, Pre) \
163 163 \
164 164 /* It's NULL in non-1.4 JDKs. */ \
165 165 template(StackTraceElement_klass, java_lang_StackTraceElement, Opt) \
166 166 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
167 167 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
168 168 template(java_nio_Buffer_klass, java_nio_Buffer, Opt) \
169 169 \
170 170 /* If this class isn't present, it won't be referenced. */ \
171 171 template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl, Opt) \
172 172 \
173 173 template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \
174 174 \
175 175 template(sun_misc_PostVMInitHook_klass, sun_misc_PostVMInitHook, Opt) \
176 176 \
177 177 /* Preload boxing klasses */ \
178 178 template(Boolean_klass, java_lang_Boolean, Pre) \
179 179 template(Character_klass, java_lang_Character, Pre) \
180 180 template(Float_klass, java_lang_Float, Pre) \
181 181 template(Double_klass, java_lang_Double, Pre) \
182 182 template(Byte_klass, java_lang_Byte, Pre) \
183 183 template(Short_klass, java_lang_Short, Pre) \
184 184 template(Integer_klass, java_lang_Integer, Pre) \
185 185 template(Long_klass, java_lang_Long, Pre) \
186 186 /*end*/
187 187
188 188
189 189 class SystemDictionary : AllStatic {
190 190 friend class VMStructs;
191 191 friend class CompactingPermGenGen;
192 192 friend class SystemDictionaryHandles;
193 193 NOT_PRODUCT(friend class instanceKlassKlass;)
194 194
195 195 public:
196 196 enum WKID {
197 197 NO_WKID = 0,
198 198
199 199 #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name),
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
200 200 WK_KLASSES_DO(WK_KLASS_ENUM)
201 201 #undef WK_KLASS_ENUM
202 202
203 203 WKID_LIMIT,
204 204
205 205 FIRST_WKID = NO_WKID + 1
206 206 };
207 207
208 208 enum InitOption {
209 209 Pre, // preloaded; error if not present
210 + Pre_JSR292, // preloaded if EnableMethodHandles
210 211
211 212 // Order is significant. Options before this point require resolve_or_fail.
212 213 // Options after this point will use resolve_or_null instead.
213 214
214 215 Opt, // preload tried; NULL if not present
215 216 Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection
216 217 Opt_Only_JDK15, // preload tried; use only with JDK1.5+
217 218 Opt_Kernel, // preload tried only #ifdef KERNEL
218 219 OPTION_LIMIT,
219 220 CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
220 221 };
221 222
222 223
223 224 // Returns a class with a given class name and class loader. Loads the
224 225 // class if needed. If not found a NoClassDefFoundError or a
225 226 // ClassNotFoundException is thrown, depending on the value on the
226 227 // throw_error flag. For most uses the throw_error argument should be set
227 228 // to true.
228 229
229 230 static klassOop resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
230 231 // Convenient call for null loader and protection domain.
231 232 static klassOop resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
232 233 private:
233 234 // handle error translation for resolve_or_null results
234 235 static klassOop handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
235 236
236 237 public:
237 238
238 239 // Returns a class with a given class name and class loader.
239 240 // Loads the class if needed. If not found NULL is returned.
240 241 static klassOop resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
241 242 // Version with null loader and protection domain
242 243 static klassOop resolve_or_null(Symbol* class_name, TRAPS);
243 244
244 245 // Resolve a superclass or superinterface. Called from ClassFileParser,
245 246 // parse_interfaces, resolve_instance_class_or_null, load_shared_class
246 247 // "child_name" is the class whose super class or interface is being resolved.
247 248 static klassOop resolve_super_or_fail(Symbol* child_name,
248 249 Symbol* class_name,
249 250 Handle class_loader,
250 251 Handle protection_domain,
251 252 bool is_superclass,
252 253 TRAPS);
253 254
254 255 // Parse new stream. This won't update the system dictionary or
255 256 // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
256 257 static klassOop parse_stream(Symbol* class_name,
257 258 Handle class_loader,
258 259 Handle protection_domain,
259 260 ClassFileStream* st,
260 261 TRAPS) {
261 262 KlassHandle nullHandle;
262 263 return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);
263 264 }
264 265 static klassOop parse_stream(Symbol* class_name,
265 266 Handle class_loader,
266 267 Handle protection_domain,
267 268 ClassFileStream* st,
268 269 KlassHandle host_klass,
269 270 GrowableArray<Handle>* cp_patches,
270 271 TRAPS);
271 272
272 273 // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
273 274 static klassOop resolve_from_stream(Symbol* class_name, Handle class_loader,
274 275 Handle protection_domain,
275 276 ClassFileStream* st, bool verify, TRAPS);
276 277
277 278 // Lookup an already loaded class. If not found NULL is returned.
278 279 static klassOop find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
279 280
280 281 // Lookup an already loaded instance or array class.
281 282 // Do not make any queries to class loaders; consult only the cache.
282 283 // If not found NULL is returned.
283 284 static klassOop find_instance_or_array_klass(Symbol* class_name,
284 285 Handle class_loader,
285 286 Handle protection_domain,
286 287 TRAPS);
287 288
288 289 // If the given name is known to vmSymbols, return the well-know klass:
289 290 static klassOop find_well_known_klass(Symbol* class_name);
290 291
291 292 // Lookup an instance or array class that has already been loaded
292 293 // either into the given class loader, or else into another class
293 294 // loader that is constrained (via loader constraints) to produce
294 295 // a consistent class. Do not take protection domains into account.
295 296 // Do not make any queries to class loaders; consult only the cache.
296 297 // Return NULL if the class is not found.
297 298 //
298 299 // This function is a strict superset of find_instance_or_array_klass.
299 300 // This function (the unchecked version) makes a conservative prediction
300 301 // of the result of the checked version, assuming successful lookup.
301 302 // If both functions return non-null, they must return the same value.
302 303 // Also, the unchecked version may sometimes be non-null where the
303 304 // checked version is null. This can occur in several ways:
304 305 // 1. No query has yet been made to the class loader.
305 306 // 2. The class loader was queried, but chose not to delegate.
306 307 // 3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
307 308 // 4. Loading was attempted, but there was a linkage error of some sort.
308 309 // In all of these cases, the loader constraints on this type are
309 310 // satisfied, and it is safe for classes in the given class loader
310 311 // to manipulate strongly-typed values of the found class, subject
311 312 // to local linkage and access checks.
312 313 static klassOop find_constrained_instance_or_array_klass(Symbol* class_name,
313 314 Handle class_loader,
314 315 TRAPS);
315 316
316 317 // Iterate over all klasses in dictionary
317 318 // Just the classes from defining class loaders
318 319 static void classes_do(void f(klassOop));
319 320 // Added for initialize_itable_for_klass to handle exceptions
320 321 static void classes_do(void f(klassOop, TRAPS), TRAPS);
321 322 // All classes, and their class loaders
322 323 static void classes_do(void f(klassOop, oop));
323 324 // All classes, and their class loaders
324 325 // (added for helpers that use HandleMarks and ResourceMarks)
325 326 static void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
326 327 // All entries in the placeholder table and their class loaders
327 328 static void placeholders_do(void f(Symbol*, oop));
328 329
329 330 // Iterate over all methods in all klasses in dictionary
330 331 static void methods_do(void f(methodOop));
331 332
332 333 // Garbage collection support
333 334
334 335 // This method applies "blk->do_oop" to all the pointers to "system"
335 336 // classes and loaders.
336 337 static void always_strong_oops_do(OopClosure* blk);
337 338 static void always_strong_classes_do(OopClosure* blk);
338 339 // This method applies "blk->do_oop" to all the placeholders.
339 340 static void placeholders_do(OopClosure* blk);
340 341
341 342 // Unload (that is, break root links to) all unmarked classes and
342 343 // loaders. Returns "true" iff something was unloaded.
343 344 static bool do_unloading(BoolObjectClosure* is_alive);
344 345
345 346 // Applies "f->do_oop" to all root oops in the system dictionary.
346 347 static void oops_do(OopClosure* f);
347 348
348 349 // System loader lock
349 350 static oop system_loader_lock() { return _system_loader_lock_obj; }
350 351
351 352 private:
352 353 // Traverses preloaded oops: various system classes. These are
353 354 // guaranteed to be in the perm gen.
354 355 static void preloaded_oops_do(OopClosure* f);
355 356 static void lazily_loaded_oops_do(OopClosure* f);
356 357
357 358 public:
358 359 // Sharing support.
359 360 static void reorder_dictionary();
360 361 static void copy_buckets(char** top, char* end);
361 362 static void copy_table(char** top, char* end);
362 363 static void reverse();
363 364 static void set_shared_dictionary(HashtableBucket* t, int length,
364 365 int number_of_entries);
365 366 // Printing
366 367 static void print() PRODUCT_RETURN;
367 368 static void print_class_statistics() PRODUCT_RETURN;
368 369 static void print_method_statistics() PRODUCT_RETURN;
369 370
370 371 // Number of contained klasses
371 372 // This is both fully loaded classes and classes in the process
372 373 // of being loaded
373 374 static int number_of_classes();
374 375
375 376 // Monotonically increasing counter which grows as classes are
376 377 // loaded or modifications such as hot-swapping or setting/removing
377 378 // of breakpoints are performed
378 379 static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
379 380 // Needed by evolution and breakpoint code
380 381 static inline void notice_modification() { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications; }
381 382
382 383 // Verification
383 384 static void verify();
384 385
385 386 #ifdef ASSERT
386 387 static bool is_internal_format(Symbol* class_name);
387 388 #endif
388 389
389 390 // Verify class is in dictionary
390 391 static void verify_obj_klass_present(Handle obj,
391 392 Symbol* class_name,
392 393 Handle class_loader);
393 394
↓ open down ↓ |
174 lines elided |
↑ open up ↑ |
394 395 // Initialization
395 396 static void initialize(TRAPS);
396 397
397 398 // Fast access to commonly used classes (preloaded)
398 399 static klassOop check_klass(klassOop k) {
399 400 assert(k != NULL, "preloaded klass not initialized");
400 401 return k;
401 402 }
402 403
403 404 static klassOop check_klass_Pre(klassOop k) { return check_klass(k); }
405 + static klassOop check_klass_Pre_JSR292(klassOop k) { return EnableInvokeDynamic ? check_klass(k) : k; }
404 406 static klassOop check_klass_Opt(klassOop k) { return k; }
405 407 static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt
406 408 static klassOop check_klass_Opt_Only_JDK15(klassOop k) {
407 409 assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
408 410 return k;
409 411 }
410 412 static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) {
411 413 assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
412 414 // despite the optional loading, if you use this it must be present:
413 415 return check_klass(k);
414 416 }
415 417
416 418 static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
417 419 static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
418 420 static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
419 421 int limit = (int)end_id + 1;
420 422 initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
421 423 }
422 424
425 + static Symbol* find_backup_symbol(Symbol* symbol, const char* from_prefix, const char* to_prefix);
426 +
423 427 public:
424 428 #define WK_KLASS_DECLARE(name, ignore_symbol, option) \
425 429 static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
426 430 WK_KLASSES_DO(WK_KLASS_DECLARE);
427 431 #undef WK_KLASS_DECLARE
428 432
429 433 // Local definition for direct access to the private array:
430 434 #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
431 435
432 436 static klassOop box_klass(BasicType t) {
433 437 assert((uint)t < T_VOID+1, "range check");
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
434 438 return check_klass(_box_klasses[t]);
435 439 }
436 440 static BasicType box_klass_type(klassOop k); // inverse of box_klass
437 441
438 442 // methods returning lazily loaded klasses
439 443 // The corresponding method to load the class must be called before calling them.
440 444 static klassOop abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }
441 445
442 446 static void load_abstract_ownable_synchronizer_klass(TRAPS);
443 447
448 + static Symbol* find_backup_class_name(Symbol* class_name_symbol);
449 + static Symbol* find_backup_signature(Symbol* signature_symbol);
450 +
444 451 private:
445 452 // Tells whether ClassLoader.loadClassInternal is present
446 453 static bool has_loadClassInternal() { return _has_loadClassInternal; }
447 454
448 455 public:
449 456 // Tells whether ClassLoader.checkPackageAccess is present
450 457 static bool has_checkPackageAccess() { return _has_checkPackageAccess; }
451 458
452 459 static bool Class_klass_loaded() { return WK_KLASS(Class_klass) != NULL; }
453 460 static bool Cloneable_klass_loaded() { return WK_KLASS(Cloneable_klass) != NULL; }
454 461
455 462 // Returns default system loader
456 463 static oop java_system_loader();
457 464
458 465 // Compute the default system loader
459 466 static void compute_java_system_loader(TRAPS);
460 467
461 468 private:
462 469 // Mirrors for primitive classes (created eagerly)
463 470 static oop check_mirror(oop m) {
464 471 assert(m != NULL, "mirror not initialized");
465 472 return m;
466 473 }
467 474
468 475 public:
469 476 // Note: java_lang_Class::primitive_type is the inverse of java_mirror
470 477
471 478 // Check class loader constraints
472 479 static bool add_loader_constraint(Symbol* name, Handle loader1,
473 480 Handle loader2, TRAPS);
474 481 static char* check_signature_loaders(Symbol* signature, Handle loader1,
475 482 Handle loader2, bool is_method, TRAPS);
476 483
477 484 // JSR 292
478 485 // find the java.dyn.MethodHandles::invoke method for a given signature
479 486 static methodOop find_method_handle_invoke(Symbol* name,
480 487 Symbol* signature,
481 488 KlassHandle accessing_klass,
482 489 TRAPS);
483 490 // ask Java to compute a java.dyn.MethodType object for a given signature
484 491 static Handle find_method_handle_type(Symbol* signature,
485 492 KlassHandle accessing_klass,
486 493 bool for_invokeGeneric,
487 494 bool& return_bcp_flag,
488 495 TRAPS);
489 496 // ask Java to compute a java.dyn.MethodHandle object for a given CP entry
490 497 static Handle link_method_handle_constant(KlassHandle caller,
491 498 int ref_kind, //e.g., JVM_REF_invokeVirtual
492 499 KlassHandle callee,
493 500 Symbol* name,
494 501 Symbol* signature,
495 502 TRAPS);
496 503 // ask Java to create a dynamic call site, while linking an invokedynamic op
497 504 static Handle make_dynamic_call_site(Handle bootstrap_method,
498 505 // Callee information:
499 506 Symbol* name,
500 507 methodHandle signature_invoker,
501 508 Handle info,
502 509 // Caller information:
503 510 methodHandle caller_method,
504 511 int caller_bci,
505 512 TRAPS);
506 513
507 514 // coordinate with Java about bootstrap methods
508 515 static Handle find_bootstrap_method(methodHandle caller_method,
509 516 int caller_bci, // N.B. must be an invokedynamic
510 517 int cache_index, // must be corresponding main_entry
511 518 Handle &argument_info_result, // static BSM arguments, if any
512 519 TRAPS);
513 520
514 521 // Utility for printing loader "name" as part of tracing constraints
515 522 static const char* loader_name(oop loader) {
516 523 return ((loader) == NULL ? "<bootloader>" :
517 524 instanceKlass::cast((loader)->klass())->name()->as_C_string() );
518 525 }
519 526
520 527 // Record the error when the first attempt to resolve a reference from a constant
521 528 // pool entry to a class fails.
522 529 static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
523 530 static Symbol* find_resolution_error(constantPoolHandle pool, int which);
524 531
525 532 private:
526 533
527 534 enum Constants {
528 535 _loader_constraint_size = 107, // number of entries in constraint table
529 536 _resolution_error_size = 107, // number of entries in resolution error table
530 537 _invoke_method_size = 139, // number of entries in invoke method table
531 538 _nof_buckets = 1009 // number of buckets in hash table
532 539 };
533 540
534 541
535 542 // Static variables
536 543
537 544 // Hashtable holding loaded classes.
538 545 static Dictionary* _dictionary;
539 546
540 547 // Hashtable holding placeholders for classes being loaded.
541 548 static PlaceholderTable* _placeholders;
542 549
543 550 // Hashtable holding classes from the shared archive.
544 551 static Dictionary* _shared_dictionary;
545 552
546 553 // Monotonically increasing counter which grows with
547 554 // _number_of_classes as well as hot-swapping and breakpoint setting
548 555 // and removal.
549 556 static int _number_of_modifications;
550 557
551 558 // Lock object for system class loader
552 559 static oop _system_loader_lock_obj;
553 560
554 561 // Constraints on class loaders
555 562 static LoaderConstraintTable* _loader_constraints;
556 563
557 564 // Resolution errors
558 565 static ResolutionErrorTable* _resolution_errors;
559 566
560 567 // Invoke methods (JSR 292)
561 568 static SymbolPropertyTable* _invoke_method_table;
562 569
563 570 public:
564 571 // for VM_CounterDecay iteration support
565 572 friend class CounterDecay;
566 573 static klassOop try_get_next_class();
567 574
568 575 private:
569 576 static void validate_protection_domain(instanceKlassHandle klass,
570 577 Handle class_loader,
571 578 Handle protection_domain, TRAPS);
572 579
573 580 friend class VM_PopulateDumpSharedSpace;
574 581 friend class TraversePlaceholdersClosure;
575 582 static Dictionary* dictionary() { return _dictionary; }
576 583 static Dictionary* shared_dictionary() { return _shared_dictionary; }
577 584 static PlaceholderTable* placeholders() { return _placeholders; }
578 585 static LoaderConstraintTable* constraints() { return _loader_constraints; }
579 586 static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
580 587 static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
581 588
582 589 // Basic loading operations
583 590 static klassOop resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
584 591 static klassOop resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
585 592 static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
586 593 // Wait on SystemDictionary_lock; unlocks lockObject before
587 594 // waiting; relocks lockObject with correct recursion count
588 595 // after waiting, but before reentering SystemDictionary_lock
589 596 // to preserve lock order semantics.
590 597 static void double_lock_wait(Handle lockObject, TRAPS);
591 598 static void define_instance_class(instanceKlassHandle k, TRAPS);
592 599 static instanceKlassHandle find_or_define_instance_class(Symbol* class_name,
593 600 Handle class_loader,
594 601 instanceKlassHandle k, TRAPS);
595 602 static instanceKlassHandle load_shared_class(Symbol* class_name,
596 603 Handle class_loader, TRAPS);
597 604 static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
598 605 Handle class_loader, TRAPS);
599 606 static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
600 607 static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
601 608 static void check_loader_lock_contention(Handle loader_lock, TRAPS);
602 609 static bool is_parallelCapable(Handle class_loader);
603 610 static bool is_parallelDefine(Handle class_loader);
604 611
605 612 static klassOop find_shared_class(Symbol* class_name);
606 613
607 614 // Setup link to hierarchy
608 615 static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
609 616
610 617 private:
611 618 // We pass in the hashtable index so we can calculate it outside of
612 619 // the SystemDictionary_lock.
613 620
614 621 // Basic find on loaded classes
615 622 static klassOop find_class(int index, unsigned int hash,
616 623 Symbol* name, Handle loader);
617 624 static klassOop find_class(Symbol* class_name, Handle class_loader);
618 625
619 626 // Basic find on classes in the midst of being loaded
620 627 static Symbol* find_placeholder(Symbol* name, Handle loader);
621 628
622 629 // Updating entry in dictionary
623 630 // Add a completely loaded class
624 631 static void add_klass(int index, Symbol* class_name,
625 632 Handle class_loader, KlassHandle obj);
626 633
627 634 // Add a placeholder for a class being loaded
628 635 static void add_placeholder(int index,
629 636 Symbol* class_name,
630 637 Handle class_loader);
631 638 static void remove_placeholder(int index,
632 639 Symbol* class_name,
633 640 Handle class_loader);
634 641
635 642 // Performs cleanups after resolve_super_or_fail. This typically needs
636 643 // to be called on failure.
637 644 // Won't throw, but can block.
638 645 static void resolution_cleanups(Symbol* class_name,
639 646 Handle class_loader,
640 647 TRAPS);
641 648
642 649 // Initialization
643 650 static void initialize_preloaded_classes(TRAPS);
644 651
645 652 // Class loader constraints
646 653 static void check_constraints(int index, unsigned int hash,
647 654 instanceKlassHandle k, Handle loader,
648 655 bool defining, TRAPS);
649 656 static void update_dictionary(int d_index, unsigned int d_hash,
650 657 int p_index, unsigned int p_hash,
651 658 instanceKlassHandle k, Handle loader, TRAPS);
652 659
653 660 // Variables holding commonly used klasses (preloaded)
654 661 static klassOop _well_known_klasses[];
655 662
656 663 // Lazily loaded klasses
657 664 static volatile klassOop _abstract_ownable_synchronizer_klass;
658 665
659 666 // table of box klasses (int_klass, etc.)
660 667 static klassOop _box_klasses[T_VOID+1];
661 668
662 669 static oop _java_system_loader;
663 670
664 671 static bool _has_loadClassInternal;
665 672 static bool _has_checkPackageAccess;
666 673 };
667 674
668 675 class SystemDictionaryHandles : AllStatic {
669 676 public:
670 677 #define WK_KLASS_HANDLE_DECLARE(name, ignore_symbol, option) \
671 678 static KlassHandle name() { \
672 679 SystemDictionary::name(); \
673 680 klassOop* loc = &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \
674 681 return KlassHandle(loc, true); \
675 682 }
676 683 WK_KLASSES_DO(WK_KLASS_HANDLE_DECLARE);
677 684 #undef WK_KLASS_HANDLE_DECLARE
678 685
679 686 static KlassHandle box_klass(BasicType t);
680 687 };
681 688
682 689 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
↓ open down ↓ |
229 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX