Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/classfile/systemDictionary.hpp
32285 views
/*1* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP25#define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP2627#include "classfile/classFileStream.hpp"28#include "classfile/classLoader.hpp"29#include "oops/objArrayOop.hpp"30#include "oops/symbol.hpp"31#include "runtime/java.hpp"32#include "runtime/reflectionUtils.hpp"33#include "utilities/hashtable.hpp"34#include "utilities/hashtable.inline.hpp"353637// The system dictionary stores all loaded classes and maps:38//39// [class name,class loader] -> class i.e. [Symbol*,oop] -> Klass*40//41// Classes are loaded lazily. The default VM class loader is42// represented as NULL.4344// The underlying data structure is an open hash table with a fixed number45// of buckets. During loading the loader object is locked, (for the VM loader46// a private lock object is used). Class loading can thus be done concurrently,47// but only by different loaders.48//49// During loading a placeholder (name, loader) is temporarily placed in50// a side data structure, and is used to detect ClassCircularityErrors51// and to perform verification during GC. A GC can occur in the midst52// of class loading, as we call out to Java, have to take locks, etc.53//54// When class loading is finished, a new entry is added to the system55// dictionary and the place holder is removed. Note that the protection56// domain field of the system dictionary has not yet been filled in when57// the "real" system dictionary entry is created.58//59// Clients of this class who are interested in finding if a class has60// been completely loaded -- not classes in the process of being loaded --61// can read the SystemDictionary unlocked. This is safe because62// - entries are only deleted at safepoints63// - readers cannot come to a safepoint while actively examining64// an entry (an entry cannot be deleted from under a reader)65// - entries must be fully formed before they are available to concurrent66// readers (we must ensure write ordering)67//68// Note that placeholders are deleted at any time, as they are removed69// when a class is completely loaded. Therefore, readers as well as writers70// of placeholders must hold the SystemDictionary_lock.71//7273class Dictionary;74class PlaceholderTable;75class LoaderConstraintTable;76template <MEMFLAGS F> class HashtableBucket;77class ResolutionErrorTable;78class SymbolPropertyTable;7980// Certain classes are preloaded, such as java.lang.Object and java.lang.String.81// They are all "well-known", in the sense that no class loader is allowed82// to provide a different definition.83//84// These klasses must all have names defined in vmSymbols.8586#define WK_KLASS_ENUM_NAME(kname) kname##_knum8788// Each well-known class has a short klass name (like object_klass),89// a vmSymbol name (like java_lang_Object), and a flag word90// that makes some minor distinctions, like whether the klass91// is preloaded, optional, release-specific, etc.92// The order of these definitions is significant; it is the order in which93// preloading is actually performed by initialize_preloaded_classes.9495#define WK_KLASSES_DO(do_klass) \96/* well-known classes */ \97do_klass(Object_klass, java_lang_Object, Pre ) \98do_klass(String_klass, java_lang_String, Pre ) \99do_klass(Class_klass, java_lang_Class, Pre ) \100do_klass(Cloneable_klass, java_lang_Cloneable, Pre ) \101do_klass(ClassLoader_klass, java_lang_ClassLoader, Pre ) \102do_klass(Serializable_klass, java_io_Serializable, Pre ) \103do_klass(System_klass, java_lang_System, Pre ) \104do_klass(Throwable_klass, java_lang_Throwable, Pre ) \105do_klass(Error_klass, java_lang_Error, Pre ) \106do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \107do_klass(Exception_klass, java_lang_Exception, Pre ) \108do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \109do_klass(SecurityManager_klass, java_lang_SecurityManager, Pre ) \110do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \111do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \112do_klass(SecureClassLoader_klass, java_security_SecureClassLoader, Pre ) \113do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \114do_klass(NoClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre ) \115do_klass(LinkageError_klass, java_lang_LinkageError, Pre ) \116do_klass(ClassCastException_klass, java_lang_ClassCastException, Pre ) \117do_klass(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre ) \118do_klass(VirtualMachineError_klass, java_lang_VirtualMachineError, Pre ) \119do_klass(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre ) \120do_klass(StackOverflowError_klass, java_lang_StackOverflowError, Pre ) \121do_klass(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre ) \122do_klass(Reference_klass, java_lang_ref_Reference, Pre ) \123\124/* Preload ref klasses and set reference types */ \125do_klass(SoftReference_klass, java_lang_ref_SoftReference, Pre ) \126do_klass(WeakReference_klass, java_lang_ref_WeakReference, Pre ) \127do_klass(FinalReference_klass, java_lang_ref_FinalReference, Pre ) \128do_klass(PhantomReference_klass, java_lang_ref_PhantomReference, Pre ) \129do_klass(Cleaner_klass, sun_misc_Cleaner, Pre ) \130do_klass(Finalizer_klass, java_lang_ref_Finalizer, Pre ) \131do_klass(ReferenceQueue_klass, java_lang_ref_ReferenceQueue, Pre ) \132\133do_klass(Thread_klass, java_lang_Thread, Pre ) \134do_klass(ThreadGroup_klass, java_lang_ThreadGroup, Pre ) \135do_klass(Properties_klass, java_util_Properties, Pre ) \136do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre ) \137do_klass(reflect_Field_klass, java_lang_reflect_Field, Pre ) \138do_klass(reflect_Parameter_klass, java_lang_reflect_Parameter, Opt ) \139do_klass(reflect_Method_klass, java_lang_reflect_Method, Pre ) \140do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \141\142/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \143/* Universe::is_gte_jdk14x_version() is not set up by this point. */ \144/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \145do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \146do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \147do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \148do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \149do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \150do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \151do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \152\153/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \154do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle, Opt ) \155do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \156do_klass(MemberName_klass, java_lang_invoke_MemberName, Pre_JSR292 ) \157do_klass(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives, Pre_JSR292 ) \158do_klass(LambdaForm_klass, java_lang_invoke_LambdaForm, Opt ) \159do_klass(MethodType_klass, java_lang_invoke_MethodType, Pre_JSR292 ) \160do_klass(BootstrapMethodError_klass, java_lang_BootstrapMethodError, Pre_JSR292 ) \161do_klass(CallSite_klass, java_lang_invoke_CallSite, Pre_JSR292 ) \162do_klass(ConstantCallSite_klass, java_lang_invoke_ConstantCallSite, Pre_JSR292 ) \163do_klass(MutableCallSite_klass, java_lang_invoke_MutableCallSite, Pre_JSR292 ) \164do_klass(VolatileCallSite_klass, java_lang_invoke_VolatileCallSite, Pre_JSR292 ) \165/* Note: MethodHandle must be first, and VolatileCallSite last in group */ \166\167do_klass(StringBuffer_klass, java_lang_StringBuffer, Pre ) \168do_klass(StringBuilder_klass, java_lang_StringBuilder, Pre ) \169do_klass(misc_Unsafe_klass, sun_misc_Unsafe, Pre ) \170\171/* support for CDS */ \172do_klass(ByteArrayInputStream_klass, java_io_ByteArrayInputStream, Pre ) \173do_klass(File_klass, java_io_File, Pre ) \174do_klass(URLClassLoader_klass, java_net_URLClassLoader, Pre ) \175do_klass(URL_klass, java_net_URL, Pre ) \176do_klass(Jar_Manifest_klass, java_util_jar_Manifest, Pre ) \177do_klass(sun_misc_Launcher_klass, sun_misc_Launcher, Pre ) \178do_klass(sun_misc_Launcher_AppClassLoader_klass, sun_misc_Launcher_AppClassLoader, Pre ) \179do_klass(sun_misc_Launcher_ExtClassLoader_klass, sun_misc_Launcher_ExtClassLoader, Pre ) \180do_klass(CodeSource_klass, java_security_CodeSource, Pre ) \181\182/* It's NULL in non-1.4 JDKs. */ \183do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \184/* Universe::is_gte_jdk14x_version() is not set up by this point. */ \185/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \186do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \187\188/* Preload boxing klasses */ \189do_klass(Boolean_klass, java_lang_Boolean, Pre ) \190do_klass(Character_klass, java_lang_Character, Pre ) \191do_klass(Float_klass, java_lang_Float, Pre ) \192do_klass(Double_klass, java_lang_Double, Pre ) \193do_klass(Byte_klass, java_lang_Byte, Pre ) \194do_klass(Short_klass, java_lang_Short, Pre ) \195do_klass(Integer_klass, java_lang_Integer, Pre ) \196do_klass(Long_klass, java_lang_Long, Pre ) \197/*end*/198199200class SystemDictionary : AllStatic {201friend class VMStructs;202friend class SystemDictionaryHandles;203204public:205enum WKID {206NO_WKID = 0,207208#define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),209WK_KLASSES_DO(WK_KLASS_ENUM)210#undef WK_KLASS_ENUM211212WKID_LIMIT,213214FIRST_WKID = NO_WKID + 1215};216217enum InitOption {218Pre, // preloaded; error if not present219Pre_JSR292, // preloaded if EnableInvokeDynamic220221// Order is significant. Options before this point require resolve_or_fail.222// Options after this point will use resolve_or_null instead.223224Opt, // preload tried; NULL if not present225Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection226Opt_Only_JDK15, // preload tried; use only with JDK1.5+227OPTION_LIMIT,228CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)229};230231232// Returns a class with a given class name and class loader. Loads the233// class if needed. If not found a NoClassDefFoundError or a234// ClassNotFoundException is thrown, depending on the value on the235// throw_error flag. For most uses the throw_error argument should be set236// to true.237238static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);239// Convenient call for null loader and protection domain.240static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);241protected:242// handle error translation for resolve_or_null results243static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, KlassHandle klass_h, TRAPS);244245public:246247// Returns a class with a given class name and class loader.248// Loads the class if needed. If not found NULL is returned.249static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);250// Version with null loader and protection domain251static Klass* resolve_or_null(Symbol* class_name, TRAPS);252253// Resolve a superclass or superinterface. Called from ClassFileParser,254// parse_interfaces, resolve_instance_class_or_null, load_shared_class255// "child_name" is the class whose super class or interface is being resolved.256static Klass* resolve_super_or_fail(Symbol* child_name,257Symbol* class_name,258Handle class_loader,259Handle protection_domain,260bool is_superclass,261TRAPS);262263// Parse new stream. This won't update the system dictionary or264// class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.265static Klass* parse_stream(Symbol* class_name,266Handle class_loader,267Handle protection_domain,268ClassFileStream* st,269TRAPS) {270KlassHandle nullHandle;271return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);272}273static Klass* parse_stream(Symbol* class_name,274Handle class_loader,275Handle protection_domain,276ClassFileStream* st,277KlassHandle host_klass,278GrowableArray<Handle>* cp_patches,279TRAPS);280281// Resolve from stream (called by jni_DefineClass and JVM_DefineClass)282static Klass* resolve_from_stream(Symbol* class_name, Handle class_loader,283Handle protection_domain,284ClassFileStream* st, bool verify, TRAPS);285286// Lookup an already loaded class. If not found NULL is returned.287static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);288289// Lookup an already loaded instance or array class.290// Do not make any queries to class loaders; consult only the cache.291// If not found NULL is returned.292static Klass* find_instance_or_array_klass(Symbol* class_name,293Handle class_loader,294Handle protection_domain,295TRAPS);296297// Lookup an instance or array class that has already been loaded298// either into the given class loader, or else into another class299// loader that is constrained (via loader constraints) to produce300// a consistent class. Do not take protection domains into account.301// Do not make any queries to class loaders; consult only the cache.302// Return NULL if the class is not found.303//304// This function is a strict superset of find_instance_or_array_klass.305// This function (the unchecked version) makes a conservative prediction306// of the result of the checked version, assuming successful lookup.307// If both functions return non-null, they must return the same value.308// Also, the unchecked version may sometimes be non-null where the309// checked version is null. This can occur in several ways:310// 1. No query has yet been made to the class loader.311// 2. The class loader was queried, but chose not to delegate.312// 3. ClassLoader.checkPackageAccess rejected a proposed protection domain.313// 4. Loading was attempted, but there was a linkage error of some sort.314// In all of these cases, the loader constraints on this type are315// satisfied, and it is safe for classes in the given class loader316// to manipulate strongly-typed values of the found class, subject317// to local linkage and access checks.318static Klass* find_constrained_instance_or_array_klass(Symbol* class_name,319Handle class_loader,320TRAPS);321322// Iterate over all klasses in dictionary323// Just the classes from defining class loaders324static void classes_do(void f(Klass*));325// Added for initialize_itable_for_klass to handle exceptions326static void classes_do(void f(Klass*, TRAPS), TRAPS);327// All classes, and their class loaders328static void classes_do(void f(Klass*, ClassLoaderData*));329330static void placeholders_do(void f(Symbol*));331332// Iterate over all methods in all klasses in dictionary333static void methods_do(void f(Method*));334335// Garbage collection support336337// This method applies "blk->do_oop" to all the pointers to "system"338// classes and loaders.339static void always_strong_oops_do(OopClosure* blk);340static void always_strong_classes_do(KlassClosure* closure);341342// Unload (that is, break root links to) all unmarked classes and343// loaders. Returns "true" iff something was unloaded.344static bool do_unloading(BoolObjectClosure* is_alive, bool clean_alive = true);345346// Used by DumpSharedSpaces only to remove classes that failed verification347static void remove_classes_in_error_state();348349static int calculate_systemdictionary_size(int loadedclasses);350351// Applies "f->do_oop" to all root oops in the system dictionary.352static void oops_do(OopClosure* f);353static void roots_oops_do(OopClosure* strong, OopClosure* weak);354355// System loader lock356static oop system_loader_lock() { return _system_loader_lock_obj; }357358protected:359// Extended Redefine classes support (tbi)360static void preloaded_classes_do(KlassClosure* f);361static void lazily_loaded_classes_do(KlassClosure* f);362public:363// Sharing support.364static void reorder_dictionary();365static void copy_buckets(char** top, char* end);366static void copy_table(char** top, char* end);367static void reverse();368static void set_shared_dictionary(HashtableBucket<mtClass>* t, int length,369int number_of_entries);370// Printing371static void print(bool details = true);372static void print_shared(bool details = true);373static void print_class_statistics() PRODUCT_RETURN;374static void print_method_statistics() PRODUCT_RETURN;375376// Number of contained klasses377// This is both fully loaded classes and classes in the process378// of being loaded379static int number_of_classes();380381// Monotonically increasing counter which grows as classes are382// loaded or modifications such as hot-swapping or setting/removing383// of breakpoints are performed384static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }385// Needed by evolution and breakpoint code386static inline void notice_modification() { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications; }387388// Verification389static void verify();390391#ifdef ASSERT392static bool is_internal_format(Symbol* class_name);393#endif394395// Initialization396static void initialize(TRAPS);397398// Fast access to commonly used classes (preloaded)399static Klass* check_klass(Klass* k) {400assert(k != NULL, "preloaded klass not initialized");401return k;402}403404static Klass* check_klass_Pre( Klass* k) { return check_klass(k); }405static Klass* check_klass_Pre_JSR292(Klass* k) { return EnableInvokeDynamic ? check_klass(k) : k; }406static Klass* check_klass_Opt( Klass* k) { return k; }407static Klass* check_klass_Opt_Only_JDK15(Klass* k) {408assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");409return k;410}411static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {412assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");413// despite the optional loading, if you use this it must be present:414return check_klass(k);415}416417static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);418static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);419static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {420int limit = (int)end_id + 1;421initialize_wk_klasses_until((WKID) limit, start_id, THREAD);422}423424public:425#define WK_KLASS_DECLARE(name, symbol, option) \426static Klass* name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \427static Klass** name##_addr() { \428return &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \429}430WK_KLASSES_DO(WK_KLASS_DECLARE);431#undef WK_KLASS_DECLARE432433static Klass* well_known_klass(WKID id) {434assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");435return _well_known_klasses[id];436}437438static Klass** well_known_klass_addr(WKID id) {439assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");440return &_well_known_klasses[id];441}442443// Local definition for direct access to the private array:444#define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]445446static Klass* box_klass(BasicType t) {447assert((uint)t < T_VOID+1, "range check");448return check_klass(_box_klasses[t]);449}450static BasicType box_klass_type(Klass* k); // inverse of box_klass451452// methods returning lazily loaded klasses453// The corresponding method to load the class must be called before calling them.454static Klass* abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }455456static void load_abstract_ownable_synchronizer_klass(TRAPS);457458protected:459// Tells whether ClassLoader.loadClassInternal is present460static bool has_loadClassInternal() { return _has_loadClassInternal; }461462// Returns the class loader data to be used when looking up/updating the463// system dictionary.464static ClassLoaderData *class_loader_data(Handle class_loader) {465return ClassLoaderData::class_loader_data(class_loader());466}467468public:469// Tells whether ClassLoader.checkPackageAccess is present470static bool has_checkPackageAccess() { return _has_checkPackageAccess; }471472static bool Parameter_klass_loaded() { return WK_KLASS(reflect_Parameter_klass) != NULL; }473static bool Class_klass_loaded() { return WK_KLASS(Class_klass) != NULL; }474static bool Cloneable_klass_loaded() { return WK_KLASS(Cloneable_klass) != NULL; }475static bool Object_klass_loaded() { return WK_KLASS(Object_klass) != NULL; }476static bool ClassLoader_klass_loaded() { return WK_KLASS(ClassLoader_klass) != NULL; }477478// Returns default system loader479static oop java_system_loader();480481// Compute the default system loader482static void compute_java_system_loader(TRAPS);483484// Register a new class loader485static ClassLoaderData* register_loader(Handle class_loader, TRAPS);486protected:487// Mirrors for primitive classes (created eagerly)488static oop check_mirror(oop m) {489assert(m != NULL, "mirror not initialized");490return m;491}492493public:494// Note: java_lang_Class::primitive_type is the inverse of java_mirror495496// Check class loader constraints497static bool add_loader_constraint(Symbol* name, Handle loader1,498Handle loader2, TRAPS);499static Symbol* check_signature_loaders(Symbol* signature, Handle loader1,500Handle loader2, bool is_method, TRAPS);501502// JSR 292503// find a java.lang.invoke.MethodHandle.invoke* method for a given signature504// (asks Java to compute it if necessary, except in a compiler thread)505static methodHandle find_method_handle_invoker(Symbol* name,506Symbol* signature,507KlassHandle accessing_klass,508Handle *appendix_result,509Handle *method_type_result,510TRAPS);511// for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)512// (does not ask Java, since this is a low-level intrinsic defined by the JVM)513static methodHandle find_method_handle_intrinsic(vmIntrinsics::ID iid,514Symbol* signature,515TRAPS);516// find a java.lang.invoke.MethodType object for a given signature517// (asks Java to compute it if necessary, except in a compiler thread)518static Handle find_method_handle_type(Symbol* signature,519KlassHandle accessing_klass,520TRAPS);521522// ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry523static Handle link_method_handle_constant(KlassHandle caller,524int ref_kind, //e.g., JVM_REF_invokeVirtual525KlassHandle callee,526Symbol* name,527Symbol* signature,528TRAPS);529530// ask Java to create a dynamic call site, while linking an invokedynamic op531static methodHandle find_dynamic_call_site_invoker(KlassHandle caller,532Handle bootstrap_method,533Symbol* name,534Symbol* type,535Handle *appendix_result,536Handle *method_type_result,537TRAPS);538539// Utility for printing loader "name" as part of tracing constraints540static const char* loader_name(oop loader) {541return ((loader) == NULL ? "<bootloader>" :542InstanceKlass::cast((loader)->klass())->name()->as_C_string() );543}544static const char* loader_name(ClassLoaderData* loader_data) {545return (loader_data->class_loader() == NULL ? "<bootloader>" :546InstanceKlass::cast((loader_data->class_loader())->klass())->name()->as_C_string() );547}548549// Record the error when the first attempt to resolve a reference from a constant550// pool entry to a class fails.551static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error,552Symbol* message);553static void delete_resolution_error(ConstantPool* pool);554static Symbol* find_resolution_error(constantPoolHandle pool, int which,555Symbol** message);556557protected:558559enum Constants {560_loader_constraint_size = 107, // number of entries in constraint table561_resolution_error_size = 107, // number of entries in resolution error table562_invoke_method_size = 139, // number of entries in invoke method table563_nof_buckets = 1009, // number of buckets in hash table for placeholders564_old_default_sdsize = 1009, // backward compat for system dictionary size565_prime_array_size = 8, // array of primes for system dictionary size566_average_depth_goal = 3 // goal for lookup length567};568569570// Static variables571572// hashtable sizes for system dictionary to allow growth573// prime numbers for system dictionary size574static int _sdgeneration;575static const int _primelist[_prime_array_size];576577// Hashtable holding loaded classes.578static Dictionary* _dictionary;579580// Hashtable holding placeholders for classes being loaded.581static PlaceholderTable* _placeholders;582583// Hashtable holding classes from the shared archive.584static Dictionary* _shared_dictionary;585586// Monotonically increasing counter which grows with587// _number_of_classes as well as hot-swapping and breakpoint setting588// and removal.589static int _number_of_modifications;590591// Lock object for system class loader592static oop _system_loader_lock_obj;593594// Constraints on class loaders595static LoaderConstraintTable* _loader_constraints;596597// Resolution errors598static ResolutionErrorTable* _resolution_errors;599600// Invoke methods (JSR 292)601static SymbolPropertyTable* _invoke_method_table;602603public:604// for VM_CounterDecay iteration support605friend class CounterDecay;606static Klass* try_get_next_class();607608protected:609static void validate_protection_domain(instanceKlassHandle klass,610Handle class_loader,611Handle protection_domain, TRAPS);612613friend class VM_PopulateDumpSharedSpace;614friend class TraversePlaceholdersClosure;615static Dictionary* dictionary() { return _dictionary; }616static Dictionary* shared_dictionary() { return _shared_dictionary; }617static PlaceholderTable* placeholders() { return _placeholders; }618static LoaderConstraintTable* constraints() { return _loader_constraints; }619static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }620static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }621622// Basic loading operations623static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);624static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);625static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);626// Wait on SystemDictionary_lock; unlocks lockObject before627// waiting; relocks lockObject with correct recursion count628// after waiting, but before reentering SystemDictionary_lock629// to preserve lock order semantics.630static void double_lock_wait(Handle lockObject, TRAPS);631static void define_instance_class(instanceKlassHandle k, TRAPS);632static instanceKlassHandle find_or_define_instance_class(Symbol* class_name,633Handle class_loader,634instanceKlassHandle k, TRAPS);635static instanceKlassHandle load_shared_class(instanceKlassHandle ik,636Handle class_loader,637Handle protection_domain,638TRAPS);639static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);640static Handle compute_loader_lock_object(Handle class_loader, TRAPS);641static void check_loader_lock_contention(Handle loader_lock, TRAPS);642static bool is_parallelCapable(Handle class_loader);643static bool is_parallelDefine(Handle class_loader);644645public:646static instanceKlassHandle load_shared_class(Symbol* class_name,647Handle class_loader,648TRAPS);649static bool is_ext_class_loader(Handle class_loader);650651protected:652static Klass* find_shared_class(Symbol* class_name);653654// Setup link to hierarchy655static void add_to_hierarchy(instanceKlassHandle k, TRAPS);656657// We pass in the hashtable index so we can calculate it outside of658// the SystemDictionary_lock.659660// Basic find on loaded classes661static Klass* find_class(int index, unsigned int hash,662Symbol* name, ClassLoaderData* loader_data);663static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);664665// Basic find on classes in the midst of being loaded666static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);667668// Updating entry in dictionary669// Add a completely loaded class670static void add_klass(int index, Symbol* class_name,671ClassLoaderData* loader_data, KlassHandle obj);672673// Add a placeholder for a class being loaded674static void add_placeholder(int index,675Symbol* class_name,676ClassLoaderData* loader_data);677static void remove_placeholder(int index,678Symbol* class_name,679ClassLoaderData* loader_data);680681// Performs cleanups after resolve_super_or_fail. This typically needs682// to be called on failure.683// Won't throw, but can block.684static void resolution_cleanups(Symbol* class_name,685ClassLoaderData* loader_data,686TRAPS);687688// Initialization689static void initialize_preloaded_classes(TRAPS);690691// Class loader constraints692static void check_constraints(int index, unsigned int hash,693instanceKlassHandle k, Handle loader,694bool defining, TRAPS);695static void update_dictionary(int d_index, unsigned int d_hash,696int p_index, unsigned int p_hash,697instanceKlassHandle k, Handle loader,698TRAPS);699700// Variables holding commonly used klasses (preloaded)701static Klass* _well_known_klasses[];702703// Lazily loaded klasses704static Klass* volatile _abstract_ownable_synchronizer_klass;705706// table of box klasses (int_klass, etc.)707static Klass* _box_klasses[T_VOID+1];708709static oop _java_system_loader;710711static bool _has_loadClassInternal;712static bool _has_checkPackageAccess;713};714715#endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP716717718