< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
@@ -1230,10 +1230,11 @@
// Load a class for boot loader from the shared spaces. This also
// forces the super class and all interfaces to be loaded.
InstanceKlass* SystemDictionary::load_shared_boot_class(Symbol* class_name,
PackageEntry* pkg_entry,
TRAPS) {
+ assert(UseSharedSpaces, "Sanity check");
InstanceKlass* ik = SystemDictionaryShared::find_builtin_class(class_name);
if (ik != NULL && ik->is_shared_boot_class()) {
return load_shared_class(ik, Handle(), Handle(), NULL, pkg_entry, THREAD);
}
return NULL;
@@ -1249,22 +1250,34 @@
InstanceKlass* ik,
PackageEntry* pkg_entry,
Handle class_loader, TRAPS) {
assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(),
"Cannot use sharing if java.base is patched");
- ResourceMark rm(THREAD);
- int path_index = ik->shared_classpath_index();
- ClassLoaderData* loader_data = class_loader_data(class_loader);
- if (path_index < 0) {
+ if (ik->shared_classpath_index() < 0) {
// path_index < 0 indicates that the class is intended for a custom loader
// and should not be loaded by boot/platform/app loaders
- if (loader_data->is_builtin_class_loader_data()) {
+ if (is_builtin_class_loader(class_loader())) {
return false;
} else {
return true;
}
}
+
+ // skip class visibility check
+ if (MetaspaceShared::use_optimized_module_handling()) {
+ assert(SystemDictionary::is_shared_class_visible_impl(class_name, ik, pkg_entry, class_loader, THREAD), "Optimizing module handling failed.");
+ return true;
+ }
+ return is_shared_class_visible_impl(class_name, ik, pkg_entry, class_loader, THREAD);
+}
+
+bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name,
+ InstanceKlass* ik,
+ PackageEntry* pkg_entry,
+ Handle class_loader, TRAPS) {
+ int path_index = ik->shared_classpath_index();
+ ClassLoaderData* loader_data = class_loader_data(class_loader);
SharedClassPathEntry* ent =
(SharedClassPathEntry*)FileMapInfo::shared_path(path_index);
if (!Universe::is_module_initialized()) {
assert(ent != NULL && ent->is_modules_image(),
"Loading non-bootstrap classes before the module system is initialized");
@@ -1558,16 +1571,18 @@
!search_only_bootloader_append,
"Attempt to load a class outside of boot loader's module path");
// Search for classes in the CDS archive.
InstanceKlass* k = NULL;
- {
+
#if INCLUDE_CDS
+ if (UseSharedSpaces)
+ {
PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
k = load_shared_boot_class(class_name, pkg_entry, THREAD);
-#endif
}
+#endif
if (k == NULL) {
// Use VM class loader
PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time());
k = ClassLoader::load_class(class_name, search_only_bootloader_append, CHECK_NULL);
< prev index next >