< 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);
+ // 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()) {
record_hidden_class(ik);
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
< prev index next >