--- old/src/hotspot/share/classfile/systemDictionary.cpp 2018-10-21 17:55:03.071145403 -0700 +++ new/src/hotspot/share/classfile/systemDictionary.cpp 2018-10-21 17:55:02.791134641 -0700 @@ -1489,8 +1489,7 @@ !search_only_bootloader_append, "Attempt to load a class outside of boot loader's module path"); - // Search the shared system dictionary for classes preloaded into the - // shared spaces. + // Search for classes in the CDS archive. InstanceKlass* k = NULL; { #if INCLUDE_CDS @@ -1958,7 +1957,7 @@ // Allocate private object used as system class loader lock _system_loader_lock_obj = oopFactory::new_intArray(0, CHECK); // Initialize basic classes - resolve_preloaded_classes(CHECK); + resolve_well_known_classes(CHECK); } // Compact table of directions on the initialization of klasses: @@ -1971,6 +1970,22 @@ 0 }; +#ifdef ASSERT +bool SystemDictionary::is_well_known_klass(Symbol* class_name) { + for (int i = 0; ; i++) { + int sid = wk_init_info[i]; + if (sid == 0) { + break; + } + Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid); + if (class_name == symbol) { + return true; + } + } + return false; +} +#endif + bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) { assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); int sid = wk_init_info[id - FIRST_WKID]; @@ -2002,8 +2017,8 @@ start_id = limit_id; } -void SystemDictionary::resolve_preloaded_classes(TRAPS) { - assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once"); +void SystemDictionary::resolve_well_known_classes(TRAPS) { + assert(WK_KLASS(Object_klass) == NULL, "well-known classes should only be initialized once"); // Create the ModuleEntry for java.base. This call needs to be done here, // after vmSymbols::initialize() is called but before any classes are pre-loaded. @@ -2071,7 +2086,8 @@ WKID jsr292_group_end = WK_KLASS_ENUM_NAME(VolatileCallSite_klass); resolve_wk_klasses_until(jsr292_group_start, scan, CHECK); resolve_wk_klasses_through(jsr292_group_end, scan, CHECK); - resolve_wk_klasses_until(NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID), scan, CHECK); + WKID last = NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID); + resolve_wk_klasses_until(last, scan, CHECK); _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass); _box_klasses[T_CHAR] = WK_KLASS(Character_klass); @@ -2088,6 +2104,15 @@ Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); _has_checkPackageAccess = (method != NULL); } + + if (UseSharedSpaces) { + assert(JvmtiEnvBase::get_phase() <= JVMTI_PHASE_PRIMORDIAL, + "All well known classes must be resolved in JVMTI_PHASE_PRIMORDIAL or before"); + for (int i=FIRST_WKID; iis_shared(), "must not be replaced by JVMTI class file load hook"); + } + } } // Tells if a given klass is a box (wrapper class, such as java.lang.Integer).