mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-14 07:29:51 +00:00
8172514: Stop checking for duplicate packages in the JVM_DefineModule() package list
Use GrowableArray append() instead of append_if_missing() to stop searching for duplicates Reviewed-by: redestad, coleenp, dholmes, gtriantafill
This commit is contained in:
parent
ade6d7cd18
commit
8a5f33bd16
@ -162,8 +162,7 @@ static void define_javabase_module(jobject module, jstring version,
|
||||
}
|
||||
|
||||
|
||||
// Check that the list of packages has no duplicates and that the
|
||||
// packages are syntactically ok.
|
||||
// Check that the packages are syntactically ok.
|
||||
GrowableArray<Symbol*>* pkg_list = new GrowableArray<Symbol*>(num_packages);
|
||||
for (int x = 0; x < num_packages; x++) {
|
||||
const char *package_name = packages[x];
|
||||
@ -172,12 +171,7 @@ static void define_javabase_module(jobject module, jstring version,
|
||||
err_msg("Invalid package name: %s for module: " JAVA_BASE_NAME, package_name));
|
||||
}
|
||||
Symbol* pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
|
||||
// append_if_missing() returns FALSE if entry already exists.
|
||||
if (!pkg_list->append_if_missing(pkg_symbol)) {
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
err_msg("Duplicate package name: %s for module " JAVA_BASE_NAME,
|
||||
package_name));
|
||||
}
|
||||
pkg_list->append(pkg_symbol);
|
||||
}
|
||||
|
||||
// Validate java_base's loader is the boot loader.
|
||||
@ -340,12 +334,7 @@ void Modules::define_module(jobject module, jstring version,
|
||||
}
|
||||
|
||||
Symbol* pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
|
||||
// append_if_missing() returns FALSE if entry already exists.
|
||||
if (!pkg_list->append_if_missing(pkg_symbol)) {
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
err_msg("Duplicate package name: %s for module %s",
|
||||
package_name, module_name));
|
||||
}
|
||||
pkg_list->append(pkg_symbol);
|
||||
}
|
||||
|
||||
ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
|
||||
|
||||
@ -45,7 +45,6 @@ public:
|
||||
// * Module's Class loader has already defined types for any of the module's packages
|
||||
// * Module_name is syntactically bad
|
||||
// * Packages contains an illegal package name
|
||||
// * Packages contains a duplicate package name
|
||||
// * A package already exists in another module for this class loader
|
||||
// * Module is an unnamed module
|
||||
// * num_packages is negative
|
||||
|
||||
@ -105,17 +105,6 @@ public class JVMDefineModule {
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicates in package list, expect an IAE
|
||||
m = ModuleHelper.ModuleObject("module.x", cl, new String[] { "mypackage4", "mypackage5" });
|
||||
try {
|
||||
ModuleHelper.DefineModule(m, "9.0", "mymodule/here", new String[] { "mypackage4", "mypackage5", "mypackage4" });
|
||||
throw new RuntimeException("Failed to get IAE for duplicate packages");
|
||||
} catch(IllegalArgumentException e) {
|
||||
if (!e.getMessage().contains("Duplicate package name")) {
|
||||
throw new RuntimeException("Failed to get expected IAE message for duplicate package: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Empty entry in package list, expect an IAE
|
||||
m = ModuleHelper.ModuleObject("module.y", cl, new String[] { "mypackageX", "mypackageY" });
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user