< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
@@ -1487,12 +1487,11 @@
// of the boot loader's module path
assert(Universe::is_module_initialized() ||
!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
PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
k = load_shared_class(class_name, class_loader, THREAD);
@@ -1956,11 +1955,11 @@
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
// 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:
static const short wk_init_info[] = {
#define WK_KLASS_INIT_INFO(name, symbol) \
@@ -1969,10 +1968,26 @@
WK_KLASSES_DO(WK_KLASS_INIT_INFO)
#undef WK_KLASS_INIT_INFO
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];
Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
InstanceKlass** klassp = &_well_known_klasses[id];
@@ -2000,12 +2015,12 @@
// move the starting value forward to the limit:
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.
ClassLoader::classLoader_init2(CHECK);
@@ -2069,11 +2084,12 @@
// JSR 292 classes
WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
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);
_box_klasses[T_FLOAT] = WK_KLASS(Float_klass);
_box_klasses[T_DOUBLE] = WK_KLASS(Double_klass);
@@ -2086,10 +2102,19 @@
{ // Compute whether we should use checkPackageAccess or NOT
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; i<last; i++) {
+ InstanceKlass* k = _well_known_klasses[i];
+ assert(k->is_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).
// If so, returns the basic type it holds. If not, returns T_OBJECT.
BasicType SystemDictionary::box_klass_type(Klass* k) {
< prev index next >