mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8178604: JVM does not allow defining boot loader modules in exploded build after module system initialization
Allow defining of boot loader modules after initialization but add locks to synchronize access to exploded build list Reviewed-by: dholmes, lfoltan
This commit is contained in:
parent
dd55dfc914
commit
09d3f0e43d
2 changed files with 58 additions and 37 deletions
|
@ -822,11 +822,7 @@ void ClassLoader::setup_search_path(const char *class_path, bool bootstrap_searc
|
|||
// will be added to the ClassLoader::_exploded_entries array.
|
||||
void ClassLoader::add_to_exploded_build_list(Symbol* module_sym, TRAPS) {
|
||||
assert(!ClassLoader::has_jrt_entry(), "Exploded build not applicable");
|
||||
|
||||
// Set up the boot loader's _exploded_entries list
|
||||
if (_exploded_entries == NULL) {
|
||||
_exploded_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(EXPLODED_ENTRY_SIZE, true);
|
||||
}
|
||||
assert(_exploded_entries != NULL, "_exploded_entries was not initialized");
|
||||
|
||||
// Find the module's symbol
|
||||
ResourceMark rm(THREAD);
|
||||
|
@ -850,7 +846,10 @@ void ClassLoader::add_to_exploded_build_list(Symbol* module_sym, TRAPS) {
|
|||
if (new_entry != NULL) {
|
||||
ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
|
||||
module_cpl->add_to_list(new_entry);
|
||||
{
|
||||
MutexLocker ml(Module_lock, THREAD);
|
||||
_exploded_entries->push(module_cpl);
|
||||
}
|
||||
log_info(class, load)("path: %s", path);
|
||||
}
|
||||
}
|
||||
|
@ -1351,9 +1350,30 @@ const char* ClassLoader::file_name_for_class_name(const char* class_name,
|
|||
return file_name;
|
||||
}
|
||||
|
||||
// Search either the patch-module or exploded build entries for class
|
||||
ClassPathEntry* find_first_module_cpe(ModuleEntry* mod_entry,
|
||||
const GrowableArray<ModuleClassPathList*>* const module_list) {
|
||||
int num_of_entries = module_list->length();
|
||||
const Symbol* class_module_name = mod_entry->name();
|
||||
|
||||
// Loop through all the modules in either the patch-module or exploded entries looking for module
|
||||
for (int i = 0; i < num_of_entries; i++) {
|
||||
ModuleClassPathList* module_cpl = module_list->at(i);
|
||||
Symbol* module_cpl_name = module_cpl->module_name();
|
||||
|
||||
if (module_cpl_name->fast_compare(class_module_name) == 0) {
|
||||
// Class' module has been located.
|
||||
return module_cpl->module_first_entry();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// Search either the patch-module or exploded build entries for class.
|
||||
ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleClassPathList*>* const module_list,
|
||||
const char* const class_name, const char* const file_name, TRAPS) {
|
||||
const char* const class_name,
|
||||
const char* const file_name,
|
||||
TRAPS) {
|
||||
ClassFileStream* stream = NULL;
|
||||
|
||||
// Find the class' defining module in the boot loader's module entry table
|
||||
|
@ -1372,19 +1392,20 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
|
|||
}
|
||||
|
||||
// The module must be a named module
|
||||
ClassPathEntry* e = NULL;
|
||||
if (mod_entry != NULL && mod_entry->is_named()) {
|
||||
int num_of_entries = module_list->length();
|
||||
const Symbol* class_module_name = mod_entry->name();
|
||||
if (module_list == _exploded_entries) {
|
||||
// The exploded build entries can be added to at any time so a lock is
|
||||
// needed when searching them.
|
||||
assert(!ClassLoader::has_jrt_entry(), "Must be exploded build");
|
||||
MutexLocker ml(Module_lock, THREAD);
|
||||
e = find_first_module_cpe(mod_entry, module_list);
|
||||
} else {
|
||||
e = find_first_module_cpe(mod_entry, module_list);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all the modules in either the patch-module or exploded entries looking for module
|
||||
for (int i = 0; i < num_of_entries; i++) {
|
||||
ModuleClassPathList* module_cpl = module_list->at(i);
|
||||
Symbol* module_cpl_name = module_cpl->module_name();
|
||||
|
||||
if (module_cpl_name->fast_compare(class_module_name) == 0) {
|
||||
// Class' module has been located, attempt to load
|
||||
// the class from the module's ClassPathEntry list.
|
||||
ClassPathEntry* e = module_cpl->module_first_entry();
|
||||
// Try to load the class from the module's ClassPathEntry list.
|
||||
while (e != NULL) {
|
||||
stream = e->open_stream(file_name, CHECK_NULL);
|
||||
// No context.check is required since CDS is not supported
|
||||
|
@ -1399,11 +1420,6 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
|
|||
// There will not be another valid entry for that module.
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) {
|
||||
assert(name != NULL, "invariant");
|
||||
|
@ -1679,6 +1695,12 @@ void ClassLoader::classLoader_init2(TRAPS) {
|
|||
if (!has_jrt_entry()) {
|
||||
assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with exploded module builds");
|
||||
assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds");
|
||||
// Set up the boot loader's _exploded_entries list. Note that this gets
|
||||
// done before loading any classes, by the same thread that will
|
||||
// subsequently do the first class load. So, no lock is needed for this.
|
||||
assert(_exploded_entries == NULL, "Should only get initialized once");
|
||||
_exploded_entries = new (ResourceObj::C_HEAP, mtModule)
|
||||
GrowableArray<ModuleClassPathList*>(EXPLODED_ENTRY_SIZE, true);
|
||||
add_to_exploded_build_list(vmSymbols::java_base(), CHECK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -449,9 +449,8 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version,
|
|||
}
|
||||
|
||||
// If the module is defined to the boot loader and an exploded build is being
|
||||
// used, prepend <java.home>/modules/modules_name, if it exists, to the system boot class path.
|
||||
if (loader == NULL &&
|
||||
!ClassLoader::has_jrt_entry()) {
|
||||
// used, prepend <java.home>/modules/modules_name to the system boot class path.
|
||||
if (loader == NULL && !ClassLoader::has_jrt_entry()) {
|
||||
ClassLoader::add_to_exploded_build_list(module_symbol, CHECK);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue