diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 9ce49b71734..40a7d178f75 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -1030,17 +1030,14 @@ static ClassPathEntry* find_first_module_cpe(ModuleEntry* mod_entry, } -// Search either the patch-module or exploded build entries for class. +// Search the module list for the class file stream based on the file name and java package ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, const GrowableArray* const module_list, - const char* const class_name, + PackageEntry* pkg_entry, // Java package entry derived from the class name const char* const file_name) { ClassFileStream* stream = nullptr; - // Find the class' defining module in the boot loader's module entry table - TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name); - TempNewSymbol pkg_name = package_from_class_name(class_name_symbol); - PackageEntry* pkg_entry = get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()); + // Find the defining module in the boot loader's module entry table ModuleEntry* mod_entry = (pkg_entry != nullptr) ? pkg_entry->module() : nullptr; // If the module system has not defined java.base yet, then @@ -1085,7 +1082,7 @@ ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, } // Called by the boot classloader to load classes -InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) { +InstanceKlass* ClassLoader::load_class(Symbol* name, PackageEntry* pkg_entry, bool search_append_only, TRAPS) { assert(name != nullptr, "invariant"); ResourceMark rm(THREAD); @@ -1132,7 +1129,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR // is not supported with UseSharedSpaces, we can never come here during dynamic dumping. assert(!CDSConfig::is_dumping_dynamic_archive(), "sanity"); if (!CDSConfig::is_dumping_static_archive()) { - stream = search_module_entries(THREAD, _patch_mod_entries, class_name, file_name); + stream = search_module_entries(THREAD, _patch_mod_entries, pkg_entry, file_name); } } @@ -1144,7 +1141,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR } else { // Exploded build - attempt to locate class in its defining module's location. assert(_exploded_entries != nullptr, "No exploded build entries present"); - stream = search_module_entries(THREAD, _exploded_entries, class_name, file_name); + stream = search_module_entries(THREAD, _exploded_entries, pkg_entry, file_name); } } diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index 10373dbcf9f..c8ea47435dd 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -292,14 +292,14 @@ class ClassLoader: AllStatic { // Add a module's exploded directory to the boot loader's exploded module build list static void add_to_exploded_build_list(JavaThread* current, Symbol* module_name); - // Attempt load of individual class from either the patched or exploded modules build lists + // Search the module list for the class file stream based on the file name and java package static ClassFileStream* search_module_entries(JavaThread* current, const GrowableArray* const module_list, - const char* const class_name, + PackageEntry* pkg_entry, // Java package entry derived from the class name const char* const file_name); // Load individual .class file - static InstanceKlass* load_class(Symbol* class_name, bool search_append_only, TRAPS); + static InstanceKlass* load_class(Symbol* class_name, PackageEntry* pkg_entry, bool search_append_only, TRAPS); // If the specified package has been loaded by the system, then returns // the name of the directory or ZIP file that the package was loaded from. diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index f2a88f00e0d..30538926b41 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1276,7 +1276,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha if (k == nullptr) { // Use VM class loader PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); - k = ClassLoader::load_class(class_name, search_only_bootloader_append, CHECK_NULL); + k = ClassLoader::load_class(class_name, pkg_entry, search_only_bootloader_append, CHECK_NULL); } // find_or_define_instance_class may return a different InstanceKlass