< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
*** 1226,1252 ****
--- 1226,1292 ----
// 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;
}
+ // Check if
+ // 1) -Xbootclasspath/a: specified or
+ // 2) --module-path at runtime
+ // so avoid checking class visibility for builtin loaders.
+ bool continue_check_shared_class_visibility() {
+ static int check_continue = -1;
+ if (check_continue == -1) {
+ const char *classpath_append = Arguments::get_jdk_boot_class_path_append();
+ const char *module_path = Arguments::get_property("jdk.module.path");
+ log_info(cds)("-Xbootclasspath/a: = %s", classpath_append != NULL ? classpath_append : "nil");
+ log_info(cds)("--module-path = %s", module_path != NULL ? module_path : "nil");
+ if ((classpath_append == NULL || strlen(classpath_append) == 0) &&
+ (module_path == NULL || strlen(module_path) == 0)) {
+ check_continue = 0;
+ } else {
+ check_continue = 1;
+ }
+ }
+ return check_continue == 1;
+ }
+
+
// Check if a shared class can be loaded by the specific classloader:
//
// NULL classloader:
// - Module class from "modules" jimage. ModuleEntry must be defined in the classloader.
// - Class from -Xbootclasspath/a. The class has no defined PackageEntry, or must
// be defined in an unnamed module.
bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
InstanceKlass* ik,
PackageEntry* pkg_entry,
Handle class_loader, TRAPS) {
+ bool cont = continue_check_shared_class_visibility();
+ #ifdef ASSERT
+ if (!cont) {
+ assert(SystemDictionary::is_shared_class_visible_impl(class_name, ik, pkg_entry, class_loader, THREAD), "Sanity check");
+ }
+ #endif
+ if (!cont) {
+ 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) {
+
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);
*** 1554,1569 ****
!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
PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
k = load_shared_boot_class(class_name, pkg_entry, THREAD);
- #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);
--- 1594,1611 ----
!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
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 >