< prev index next > src/hotspot/share/classfile/classLoader.cpp
Print this page
// Lookup stream for parsing .class file
ClassFileStream* stream = nullptr;
s2 classpath_index = 0;
ClassPathEntry* e = nullptr;
+ bool is_patched = false;
// If search_append_only is true, boot loader visibility boundaries are
// set to be _first_append_entry to the end. This includes:
// [-Xbootclasspath/a]; [jvmti appended entries]
//
// that are part of the overall module definition. So if a particular class is not
// found within its module specification, the search should continue to Load Attempt #2.
// Note: The --patch-module entries are never searched if the boot loader's
// visibility boundary is limited to only searching the append entries.
if (_patch_mod_entries != nullptr && !search_append_only) {
! assert(!CDSConfig::is_dumping_archive(), "CDS doesn't support --patch-module during dumping");
! stream = search_module_entries(THREAD, _patch_mod_entries, pkg_entry, file_name);
}
// Load Attempt #2: [jimage | exploded build]
if (!search_append_only && (nullptr == stream)) {
if (has_jrt_entry()) {
// that are part of the overall module definition. So if a particular class is not
// found within its module specification, the search should continue to Load Attempt #2.
// Note: The --patch-module entries are never searched if the boot loader's
// visibility boundary is limited to only searching the append entries.
if (_patch_mod_entries != nullptr && !search_append_only) {
! // At CDS dump time, the --patch-module entries are ignored. That means a
! // class is still loaded from the runtime image even if it might
+ // appear in the _patch_mod_entries. The runtime shared class visibility
+ // check will determine if a shared class is visible based on the runtime
+ // environment, including the runtime --patch-module setting.
+ if (!CDSConfig::is_valhalla_preview()) {
+ // Dynamic dumping requires UseSharedSpaces to be enabled. Since --patch-module
+ // is not supported with UseSharedSpaces, we can never come here during dynamic dumping.
+ assert(!CDSConfig::is_dumping_archive(), "CDS doesn't support --patch-module during dumping");
+ }
+ if (CDSConfig::is_valhalla_preview() || !CDSConfig::is_dumping_static_archive()) {
+ stream = search_module_entries(THREAD, _patch_mod_entries, pkg_entry, file_name);
+ if (stream != nullptr) {
+ is_patched = true;
+ }
+ }
}
// Load Attempt #2: [jimage | exploded build]
if (!search_append_only && (nullptr == stream)) {
if (has_jrt_entry()) {
name,
loader_data,
cl_info,
CHECK_NULL);
result->set_classpath_index(classpath_index);
+ if (is_patched) {
+ result->set_shared_classpath_index(0);
+ result->set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
+ }
return result;
}
#if INCLUDE_CDS
static const char* skip_uri_protocol(const char* source) {
if (ik->is_hidden()) {
// We do not archive hidden classes.
return;
}
+ if (ik->shared_classpath_index() == 0 && ik->is_shared_boot_class()) {
+ return;
+ }
+
oop loader = ik->class_loader();
char* src = (char*)stream->source();
if (src == nullptr) {
if (loader == nullptr) {
// JFR classes
}
} else {
// The shared path table is set up after module system initialization.
// The path table contains no entry before that. Any classes loaded prior
// to the setup of the shared path table must be from the modules image.
! assert(stream->from_boot_loader_modules_image(), "stream must be loaded by boot loader from modules image");
assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup");
classpath_index = 0;
}
const char* const class_name = ik->name()->as_C_string();
}
} else {
// The shared path table is set up after module system initialization.
// The path table contains no entry before that. Any classes loaded prior
// to the setup of the shared path table must be from the modules image.
! if (!CDSConfig::is_valhalla_preview()) {
+ assert(stream->from_boot_loader_modules_image(), "stream must be loaded by boot loader from modules image");
+ }
assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup");
classpath_index = 0;
}
const char* const class_name = ik->name()->as_C_string();
< prev index next >