duke@435: /* xdono@1014: * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // The system dictionary stores all loaded classes and maps: duke@435: // duke@435: // [class name,class loader] -> class i.e. [symbolOop,oop] -> klassOop duke@435: // duke@435: // Classes are loaded lazily. The default VM class loader is duke@435: // represented as NULL. duke@435: duke@435: // The underlying data structure is an open hash table with a fixed number duke@435: // of buckets. During loading the loader object is locked, (for the VM loader duke@435: // a private lock object is used). Class loading can thus be done concurrently, duke@435: // but only by different loaders. duke@435: // duke@435: // During loading a placeholder (name, loader) is temporarily placed in duke@435: // a side data structure, and is used to detect ClassCircularityErrors duke@435: // and to perform verification during GC. A GC can occur in the midst duke@435: // of class loading, as we call out to Java, have to take locks, etc. duke@435: // duke@435: // When class loading is finished, a new entry is added to the system duke@435: // dictionary and the place holder is removed. Note that the protection duke@435: // domain field of the system dictionary has not yet been filled in when duke@435: // the "real" system dictionary entry is created. duke@435: // duke@435: // Clients of this class who are interested in finding if a class has duke@435: // been completely loaded -- not classes in the process of being loaded -- duke@435: // can read the SystemDictionary unlocked. This is safe because duke@435: // - entries are only deleted at safepoints duke@435: // - readers cannot come to a safepoint while actively examining duke@435: // an entry (an entry cannot be deleted from under a reader) duke@435: // - entries must be fully formed before they are available to concurrent duke@435: // readers (we must ensure write ordering) duke@435: // duke@435: // Note that placeholders are deleted at any time, as they are removed duke@435: // when a class is completely loaded. Therefore, readers as well as writers duke@435: // of placeholders must hold the SystemDictionary_lock. duke@435: // duke@435: duke@435: class Dictionary; duke@435: class PlaceholderTable; duke@435: class LoaderConstraintTable; duke@435: class HashtableBucket; duke@435: class ResolutionErrorTable; jrose@1145: class SymbolPropertyTable; duke@435: jrose@567: // Certain classes are preloaded, such as java.lang.Object and java.lang.String. jrose@567: // They are all "well-known", in the sense that no class loader is allowed jrose@567: // to provide a different definition. jrose@567: // jrose@567: // These klasses must all have names defined in vmSymbols. jrose@567: jrose@567: #define WK_KLASS_ENUM_NAME(kname) kname##_knum jrose@567: jrose@567: // Each well-known class has a short klass name (like object_klass), jrose@567: // a vmSymbol name (like java_lang_Object), and a flag word jrose@567: // that makes some minor distinctions, like whether the klass jrose@567: // is preloaded, optional, release-specific, etc. jrose@567: // The order of these definitions is significant; it is the order in which jrose@567: // preloading is actually performed by initialize_preloaded_classes. jrose@567: jrose@567: #define WK_KLASSES_DO(template) \ jrose@567: /* well-known classes */ \ jrose@567: template(object_klass, java_lang_Object, Pre) \ jrose@567: template(string_klass, java_lang_String, Pre) \ jrose@567: template(class_klass, java_lang_Class, Pre) \ jrose@567: template(cloneable_klass, java_lang_Cloneable, Pre) \ jrose@567: template(classloader_klass, java_lang_ClassLoader, Pre) \ jrose@567: template(serializable_klass, java_io_Serializable, Pre) \ jrose@567: template(system_klass, java_lang_System, Pre) \ jrose@567: template(throwable_klass, java_lang_Throwable, Pre) \ jrose@567: template(error_klass, java_lang_Error, Pre) \ jrose@567: template(threaddeath_klass, java_lang_ThreadDeath, Pre) \ jrose@567: template(exception_klass, java_lang_Exception, Pre) \ jrose@567: template(runtime_exception_klass, java_lang_RuntimeException, Pre) \ jrose@567: template(protectionDomain_klass, java_security_ProtectionDomain, Pre) \ jrose@567: template(AccessControlContext_klass, java_security_AccessControlContext, Pre) \ jrose@567: template(classNotFoundException_klass, java_lang_ClassNotFoundException, Pre) \ jrose@567: template(noClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre) \ jrose@567: template(linkageError_klass, java_lang_LinkageError, Pre) \ jrose@567: template(ClassCastException_klass, java_lang_ClassCastException, Pre) \ jrose@567: template(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre) \ jrose@567: template(virtualMachineError_klass, java_lang_VirtualMachineError, Pre) \ jrose@567: template(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre) \ jrose@567: template(StackOverflowError_klass, java_lang_StackOverflowError, Pre) \ jrose@567: template(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre) \ jrose@567: template(reference_klass, java_lang_ref_Reference, Pre) \ jrose@567: \ jrose@567: /* Preload ref klasses and set reference types */ \ jrose@567: template(soft_reference_klass, java_lang_ref_SoftReference, Pre) \ jrose@567: template(weak_reference_klass, java_lang_ref_WeakReference, Pre) \ jrose@567: template(final_reference_klass, java_lang_ref_FinalReference, Pre) \ jrose@567: template(phantom_reference_klass, java_lang_ref_PhantomReference, Pre) \ jrose@567: template(finalizer_klass, java_lang_ref_Finalizer, Pre) \ jrose@567: \ jrose@567: template(thread_klass, java_lang_Thread, Pre) \ jrose@567: template(threadGroup_klass, java_lang_ThreadGroup, Pre) \ jrose@567: template(properties_klass, java_util_Properties, Pre) \ jrose@567: template(reflect_accessible_object_klass, java_lang_reflect_AccessibleObject, Pre) \ jrose@567: template(reflect_field_klass, java_lang_reflect_Field, Pre) \ jrose@567: template(reflect_method_klass, java_lang_reflect_Method, Pre) \ jrose@567: template(reflect_constructor_klass, java_lang_reflect_Constructor, Pre) \ jrose@567: \ jrose@567: /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \ jrose@567: /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ jrose@567: /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ jrose@567: template(reflect_magic_klass, sun_reflect_MagicAccessorImpl, Opt) \ jrose@567: template(reflect_method_accessor_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \ jrose@567: template(reflect_constructor_accessor_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \ jrose@567: template(reflect_delegating_classloader_klass, sun_reflect_DelegatingClassLoader, Opt) \ jrose@567: template(reflect_constant_pool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15) \ jrose@567: template(reflect_unsafe_static_field_accessor_impl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \ jrose@567: \ jrose@1145: /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ jrose@1145: template(MethodHandle_klass, java_dyn_MethodHandle, Opt) \ jrose@1145: template(MemberName_klass, sun_dyn_MemberName, Opt) \ jrose@1145: template(MethodHandleImpl_klass, sun_dyn_MethodHandleImpl, Opt) \ jrose@1145: template(AdapterMethodHandle_klass, sun_dyn_AdapterMethodHandle, Opt) \ jrose@1145: template(BoundMethodHandle_klass, sun_dyn_BoundMethodHandle, Opt) \ jrose@1145: template(DirectMethodHandle_klass, sun_dyn_DirectMethodHandle, Opt) \ jrose@1145: template(MethodType_klass, java_dyn_MethodType, Opt) \ jrose@1145: template(MethodTypeForm_klass, java_dyn_MethodTypeForm, Opt) \ jrose@1145: template(WrongMethodTypeException_klass, java_dyn_WrongMethodTypeException, Opt) \ jrose@567: template(vector_klass, java_util_Vector, Pre) \ jrose@567: template(hashtable_klass, java_util_Hashtable, Pre) \ jrose@567: template(stringBuffer_klass, java_lang_StringBuffer, Pre) \ jrose@567: \ jrose@567: /* It's NULL in non-1.4 JDKs. */ \ jrose@567: template(stackTraceElement_klass, java_lang_StackTraceElement, Opt) \ jrose@567: /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ jrose@567: /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ jrose@567: template(java_nio_Buffer_klass, java_nio_Buffer, Opt) \ jrose@567: \ jrose@567: /* If this class isn't present, it won't be referenced. */ \ jrose@567: template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl, Opt) \ jrose@567: \ jrose@567: template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \ jrose@567: \ jrose@567: /* Preload boxing klasses */ \ jrose@567: template(boolean_klass, java_lang_Boolean, Pre) \ jrose@567: template(char_klass, java_lang_Character, Pre) \ jrose@567: template(float_klass, java_lang_Float, Pre) \ jrose@567: template(double_klass, java_lang_Double, Pre) \ jrose@567: template(byte_klass, java_lang_Byte, Pre) \ jrose@567: template(short_klass, java_lang_Short, Pre) \ jrose@567: template(int_klass, java_lang_Integer, Pre) \ jrose@567: template(long_klass, java_lang_Long, Pre) \ jrose@567: /*end*/ jrose@567: jrose@567: duke@435: class SystemDictionary : AllStatic { duke@435: friend class VMStructs; duke@435: friend class CompactingPermGenGen; jrose@1100: friend class SystemDictionaryHandles; duke@435: NOT_PRODUCT(friend class instanceKlassKlass;) duke@435: duke@435: public: jrose@567: enum WKID { jrose@567: NO_WKID = 0, jrose@567: jrose@567: #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name), jrose@567: WK_KLASSES_DO(WK_KLASS_ENUM) jrose@567: #undef WK_KLASS_ENUM jrose@567: jrose@567: WKID_LIMIT, jrose@567: jrose@567: FIRST_WKID = NO_WKID + 1 jrose@567: }; jrose@567: jrose@567: enum InitOption { jrose@567: Pre, // preloaded; error if not present jrose@567: jrose@567: // Order is significant. Options before this point require resolve_or_fail. jrose@567: // Options after this point will use resolve_or_null instead. jrose@567: jrose@567: Opt, // preload tried; NULL if not present jrose@567: Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection jrose@567: Opt_Only_JDK15, // preload tried; use only with JDK1.5+ jrose@567: Opt_Kernel, // preload tried only #ifdef KERNEL jrose@567: OPTION_LIMIT, jrose@567: CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<* cp_patches, duke@435: TRAPS); duke@435: duke@435: // Resolve from stream (called by jni_DefineClass and JVM_DefineClass) duke@435: static klassOop resolve_from_stream(symbolHandle class_name, Handle class_loader, Handle protection_domain, ClassFileStream* st, TRAPS); duke@435: duke@435: // Lookup an already loaded class. If not found NULL is returned. duke@435: static klassOop find(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS); duke@435: duke@435: // Lookup an already loaded instance or array class. duke@435: // Do not make any queries to class loaders; consult only the cache. duke@435: // If not found NULL is returned. duke@435: static klassOop find_instance_or_array_klass(symbolHandle class_name, duke@435: Handle class_loader, duke@435: Handle protection_domain, duke@435: TRAPS); duke@435: jrose@567: // If the given name is known to vmSymbols, return the well-know klass: jrose@567: static klassOop find_well_known_klass(symbolOop class_name); jrose@567: duke@435: // Lookup an instance or array class that has already been loaded duke@435: // either into the given class loader, or else into another class duke@435: // loader that is constrained (via loader constraints) to produce duke@435: // a consistent class. Do not take protection domains into account. duke@435: // Do not make any queries to class loaders; consult only the cache. duke@435: // Return NULL if the class is not found. duke@435: // duke@435: // This function is a strict superset of find_instance_or_array_klass. duke@435: // This function (the unchecked version) makes a conservative prediction duke@435: // of the result of the checked version, assuming successful lookup. duke@435: // If both functions return non-null, they must return the same value. duke@435: // Also, the unchecked version may sometimes be non-null where the duke@435: // checked version is null. This can occur in several ways: duke@435: // 1. No query has yet been made to the class loader. duke@435: // 2. The class loader was queried, but chose not to delegate. duke@435: // 3. ClassLoader.checkPackageAccess rejected a proposed protection domain. duke@435: // 4. Loading was attempted, but there was a linkage error of some sort. duke@435: // In all of these cases, the loader constraints on this type are duke@435: // satisfied, and it is safe for classes in the given class loader duke@435: // to manipulate strongly-typed values of the found class, subject duke@435: // to local linkage and access checks. duke@435: static klassOop find_constrained_instance_or_array_klass(symbolHandle class_name, duke@435: Handle class_loader, duke@435: TRAPS); duke@435: duke@435: // Iterate over all klasses in dictionary duke@435: // Just the classes from defining class loaders duke@435: static void classes_do(void f(klassOop)); duke@435: // Added for initialize_itable_for_klass to handle exceptions duke@435: static void classes_do(void f(klassOop, TRAPS), TRAPS); duke@435: // All classes, and their class loaders duke@435: static void classes_do(void f(klassOop, oop)); duke@435: // All classes, and their class loaders duke@435: // (added for helpers that use HandleMarks and ResourceMarks) duke@435: static void classes_do(void f(klassOop, oop, TRAPS), TRAPS); duke@435: // All entries in the placeholder table and their class loaders duke@435: static void placeholders_do(void f(symbolOop, oop)); duke@435: duke@435: // Iterate over all methods in all klasses in dictionary duke@435: static void methods_do(void f(methodOop)); duke@435: duke@435: // Garbage collection support duke@435: duke@435: // This method applies "blk->do_oop" to all the pointers to "system" duke@435: // classes and loaders. duke@435: static void always_strong_oops_do(OopClosure* blk); duke@435: static void always_strong_classes_do(OopClosure* blk); duke@435: // This method applies "blk->do_oop" to all the placeholders. duke@435: static void placeholders_do(OopClosure* blk); duke@435: duke@435: // Unload (that is, break root links to) all unmarked classes and duke@435: // loaders. Returns "true" iff something was unloaded. duke@435: static bool do_unloading(BoolObjectClosure* is_alive); duke@435: duke@435: // Applies "f->do_oop" to all root oops in the system dictionary. duke@435: static void oops_do(OopClosure* f); duke@435: duke@435: // System loader lock duke@435: static oop system_loader_lock() { return _system_loader_lock_obj; } duke@435: duke@435: private: duke@435: // Traverses preloaded oops: various system classes. These are duke@435: // guaranteed to be in the perm gen. duke@435: static void preloaded_oops_do(OopClosure* f); duke@435: static void lazily_loaded_oops_do(OopClosure* f); duke@435: duke@435: public: duke@435: // Sharing support. duke@435: static void reorder_dictionary(); duke@435: static void copy_buckets(char** top, char* end); duke@435: static void copy_table(char** top, char* end); duke@435: static void reverse(); duke@435: static void set_shared_dictionary(HashtableBucket* t, int length, duke@435: int number_of_entries); duke@435: // Printing duke@435: static void print() PRODUCT_RETURN; duke@435: static void print_class_statistics() PRODUCT_RETURN; duke@435: static void print_method_statistics() PRODUCT_RETURN; duke@435: duke@435: // Number of contained klasses duke@435: // This is both fully loaded classes and classes in the process duke@435: // of being loaded duke@435: static int number_of_classes(); duke@435: duke@435: // Monotonically increasing counter which grows as classes are duke@435: // loaded or modifications such as hot-swapping or setting/removing duke@435: // of breakpoints are performed duke@435: static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; } duke@435: // Needed by evolution and breakpoint code duke@435: static inline void notice_modification() { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications; } duke@435: duke@435: // Verification duke@435: static void verify(); duke@435: duke@435: #ifdef ASSERT duke@435: static bool is_internal_format(symbolHandle class_name); duke@435: #endif duke@435: duke@435: // Verify class is in dictionary duke@435: static void verify_obj_klass_present(Handle obj, duke@435: symbolHandle class_name, duke@435: Handle class_loader); duke@435: duke@435: // Initialization duke@435: static void initialize(TRAPS); duke@435: duke@435: // Fast access to commonly used classes (preloaded) duke@435: static klassOop check_klass(klassOop k) { duke@435: assert(k != NULL, "preloaded klass not initialized"); duke@435: return k; duke@435: } duke@435: jrose@567: static klassOop check_klass_Pre(klassOop k) { return check_klass(k); } jrose@567: static klassOop check_klass_Opt(klassOop k) { return k; } jrose@567: static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt jrose@567: static klassOop check_klass_Opt_Only_JDK15(klassOop k) { jrose@567: assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only"); jrose@567: return k; jrose@567: } jrose@567: static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) { duke@435: assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only"); jrose@567: // despite the optional loading, if you use this it must be present: jrose@567: return check_klass(k); duke@435: } duke@435: jrose@567: static bool initialize_wk_klass(WKID id, int init_opt, TRAPS); jrose@567: static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS); jrose@567: static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) { jrose@567: int limit = (int)end_id + 1; jrose@567: initialize_wk_klasses_until((WKID) limit, start_id, THREAD); jrose@567: } duke@435: jrose@567: public: jrose@567: #define WK_KLASS_DECLARE(name, ignore_symbol, option) \ jrose@567: static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } jrose@567: WK_KLASSES_DO(WK_KLASS_DECLARE); jrose@567: #undef WK_KLASS_DECLARE duke@435: jrose@567: // Local definition for direct access to the private array: jrose@582: #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)] duke@435: duke@435: static klassOop box_klass(BasicType t) { duke@435: assert((uint)t < T_VOID+1, "range check"); duke@435: return check_klass(_box_klasses[t]); duke@435: } duke@435: static BasicType box_klass_type(klassOop k); // inverse of box_klass duke@435: duke@435: // methods returning lazily loaded klasses duke@435: // The corresponding method to load the class must be called before calling them. duke@435: static klassOop abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); } duke@435: duke@435: static void load_abstract_ownable_synchronizer_klass(TRAPS); duke@435: duke@435: private: duke@435: // Tells whether ClassLoader.loadClassInternal is present duke@435: static bool has_loadClassInternal() { return _has_loadClassInternal; } duke@435: duke@435: public: duke@435: // Tells whether ClassLoader.checkPackageAccess is present duke@435: static bool has_checkPackageAccess() { return _has_checkPackageAccess; } duke@435: jrose@567: static bool class_klass_loaded() { return WK_KLASS(class_klass) != NULL; } jrose@567: static bool cloneable_klass_loaded() { return WK_KLASS(cloneable_klass) != NULL; } duke@435: duke@435: // Returns default system loader duke@435: static oop java_system_loader(); duke@435: duke@435: // Compute the default system loader duke@435: static void compute_java_system_loader(TRAPS); duke@435: duke@435: private: duke@435: // Mirrors for primitive classes (created eagerly) duke@435: static oop check_mirror(oop m) { duke@435: assert(m != NULL, "mirror not initialized"); duke@435: return m; duke@435: } duke@435: duke@435: public: duke@435: // Note: java_lang_Class::primitive_type is the inverse of java_mirror duke@435: duke@435: // Check class loader constraints duke@435: static bool add_loader_constraint(symbolHandle name, Handle loader1, duke@435: Handle loader2, TRAPS); duke@435: static char* check_signature_loaders(symbolHandle signature, Handle loader1, duke@435: Handle loader2, bool is_method, TRAPS); duke@435: jrose@1145: // JSR 292 jrose@1145: // find the java.dyn.MethodHandles::invoke method for a given signature jrose@1145: static methodOop find_method_handle_invoke(symbolHandle signature, jrose@1145: Handle class_loader, jrose@1145: Handle protection_domain, jrose@1145: TRAPS); jrose@1145: // ask Java to compute the java.dyn.MethodType object for a given signature jrose@1145: static Handle compute_method_handle_type(symbolHandle signature, jrose@1145: Handle class_loader, jrose@1145: Handle protection_domain, jrose@1145: TRAPS); duke@435: // Utility for printing loader "name" as part of tracing constraints duke@435: static const char* loader_name(oop loader) { duke@435: return ((loader) == NULL ? "" : duke@435: instanceKlass::cast((loader)->klass())->name()->as_C_string() ); duke@435: } duke@435: duke@435: // Record the error when the first attempt to resolve a reference from a constant duke@435: // pool entry to a class fails. duke@435: static void add_resolution_error(constantPoolHandle pool, int which, symbolHandle error); duke@435: static symbolOop find_resolution_error(constantPoolHandle pool, int which); duke@435: duke@435: private: duke@435: duke@435: enum Constants { duke@435: _loader_constraint_size = 107, // number of entries in constraint table duke@435: _resolution_error_size = 107, // number of entries in resolution error table jrose@1145: _invoke_method_size = 139, // number of entries in invoke method table duke@435: _nof_buckets = 1009 // number of buckets in hash table duke@435: }; duke@435: duke@435: duke@435: // Static variables duke@435: duke@435: // Hashtable holding loaded classes. duke@435: static Dictionary* _dictionary; duke@435: duke@435: // Hashtable holding placeholders for classes being loaded. duke@435: static PlaceholderTable* _placeholders; duke@435: duke@435: // Hashtable holding classes from the shared archive. duke@435: static Dictionary* _shared_dictionary; duke@435: duke@435: // Monotonically increasing counter which grows with duke@435: // _number_of_classes as well as hot-swapping and breakpoint setting duke@435: // and removal. duke@435: static int _number_of_modifications; duke@435: duke@435: // Lock object for system class loader duke@435: static oop _system_loader_lock_obj; duke@435: duke@435: // Constraints on class loaders duke@435: static LoaderConstraintTable* _loader_constraints; duke@435: duke@435: // Resolution errors duke@435: static ResolutionErrorTable* _resolution_errors; duke@435: jrose@1145: // Invoke methods (JSR 292) jrose@1145: static SymbolPropertyTable* _invoke_method_table; jrose@1145: duke@435: public: duke@435: // for VM_CounterDecay iteration support duke@435: friend class CounterDecay; duke@435: static klassOop try_get_next_class(); duke@435: duke@435: private: duke@435: static void validate_protection_domain(instanceKlassHandle klass, duke@435: Handle class_loader, duke@435: Handle protection_domain, TRAPS); duke@435: duke@435: friend class VM_PopulateDumpSharedSpace; duke@435: friend class TraversePlaceholdersClosure; duke@435: static Dictionary* dictionary() { return _dictionary; } duke@435: static Dictionary* shared_dictionary() { return _shared_dictionary; } duke@435: static PlaceholderTable* placeholders() { return _placeholders; } duke@435: static LoaderConstraintTable* constraints() { return _loader_constraints; } duke@435: static ResolutionErrorTable* resolution_errors() { return _resolution_errors; } jrose@1145: static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; } duke@435: duke@435: // Basic loading operations duke@435: static klassOop resolve_instance_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS); duke@435: static klassOop resolve_array_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS); duke@435: static instanceKlassHandle handle_parallel_super_load(symbolHandle class_name, symbolHandle supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS); duke@435: // Wait on SystemDictionary_lock; unlocks lockObject before duke@435: // waiting; relocks lockObject with correct recursion count duke@435: // after waiting, but before reentering SystemDictionary_lock duke@435: // to preserve lock order semantics. duke@435: static void double_lock_wait(Handle lockObject, TRAPS); duke@435: static void define_instance_class(instanceKlassHandle k, TRAPS); duke@435: static instanceKlassHandle find_or_define_instance_class(symbolHandle class_name, duke@435: Handle class_loader, duke@435: instanceKlassHandle k, TRAPS); duke@435: static instanceKlassHandle load_shared_class(symbolHandle class_name, duke@435: Handle class_loader, TRAPS); duke@435: static instanceKlassHandle load_shared_class(instanceKlassHandle ik, duke@435: Handle class_loader, TRAPS); duke@435: static instanceKlassHandle load_instance_class(symbolHandle class_name, Handle class_loader, TRAPS); duke@435: static Handle compute_loader_lock_object(Handle class_loader, TRAPS); duke@435: static void check_loader_lock_contention(Handle loader_lock, TRAPS); acorn@949: static bool is_parallelCapable(Handle class_loader); duke@435: duke@435: static klassOop find_shared_class(symbolHandle class_name); duke@435: duke@435: // Setup link to hierarchy duke@435: static void add_to_hierarchy(instanceKlassHandle k, TRAPS); duke@435: duke@435: private: duke@435: // We pass in the hashtable index so we can calculate it outside of duke@435: // the SystemDictionary_lock. duke@435: duke@435: // Basic find on loaded classes duke@435: static klassOop find_class(int index, unsigned int hash, duke@435: symbolHandle name, Handle loader); duke@435: duke@435: // Basic find on classes in the midst of being loaded duke@435: static symbolOop find_placeholder(int index, unsigned int hash, duke@435: symbolHandle name, Handle loader); duke@435: duke@435: // Basic find operation of loaded classes and classes in the midst duke@435: // of loading; used for assertions and verification only. duke@435: static oop find_class_or_placeholder(symbolHandle class_name, duke@435: Handle class_loader); duke@435: duke@435: // Updating entry in dictionary duke@435: // Add a completely loaded class duke@435: static void add_klass(int index, symbolHandle class_name, duke@435: Handle class_loader, KlassHandle obj); duke@435: duke@435: // Add a placeholder for a class being loaded duke@435: static void add_placeholder(int index, duke@435: symbolHandle class_name, duke@435: Handle class_loader); duke@435: static void remove_placeholder(int index, duke@435: symbolHandle class_name, duke@435: Handle class_loader); duke@435: duke@435: // Performs cleanups after resolve_super_or_fail. This typically needs duke@435: // to be called on failure. duke@435: // Won't throw, but can block. duke@435: static void resolution_cleanups(symbolHandle class_name, duke@435: Handle class_loader, duke@435: TRAPS); duke@435: duke@435: // Initialization duke@435: static void initialize_preloaded_classes(TRAPS); duke@435: duke@435: // Class loader constraints duke@435: static void check_constraints(int index, unsigned int hash, duke@435: instanceKlassHandle k, Handle loader, duke@435: bool defining, TRAPS); duke@435: static void update_dictionary(int d_index, unsigned int d_hash, duke@435: int p_index, unsigned int p_hash, duke@435: instanceKlassHandle k, Handle loader, TRAPS); duke@435: duke@435: // Variables holding commonly used klasses (preloaded) jrose@567: static klassOop _well_known_klasses[]; duke@435: duke@435: // Lazily loaded klasses duke@435: static volatile klassOop _abstract_ownable_synchronizer_klass; duke@435: jrose@567: // table of box klasses (int_klass, etc.) duke@435: static klassOop _box_klasses[T_VOID+1]; duke@435: duke@435: static oop _java_system_loader; duke@435: duke@435: static bool _has_loadClassInternal; duke@435: static bool _has_checkPackageAccess; duke@435: }; jrose@1100: jrose@1100: // Cf. vmSymbols vs. vmSymbolHandles jrose@1100: class SystemDictionaryHandles : AllStatic { jrose@1100: public: jrose@1100: #define WK_KLASS_HANDLE_DECLARE(name, ignore_symbol, option) \ jrose@1100: static KlassHandle name() { \ jrose@1100: SystemDictionary::name(); \ jrose@1100: klassOop* loc = &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \ jrose@1100: return KlassHandle(loc, true); \ jrose@1100: } jrose@1100: WK_KLASSES_DO(WK_KLASS_HANDLE_DECLARE); jrose@1100: #undef WK_KLASS_HANDLE_DECLARE jrose@1100: jrose@1100: static KlassHandle box_klass(BasicType t); jrose@1100: };