changeset 46322:25836096c89d

8172514: Stop checking for duplicate packages in the JVM_DefineModule() package list Summary: Use GrowableArray append() instead of append_if_missing() to stop searching for duplicates Reviewed-by: redestad, coleenp, dholmes, gtriantafill
author hseigel
date Fri, 10 Mar 2017 08:04:17 -0500
parents 640277633c23
children d41bb2dcaeb8
files hotspot/src/share/vm/classfile/modules.cpp hotspot/src/share/vm/classfile/modules.hpp hotspot/test/runtime/modules/JVMDefineModule.java
diffstat 3 files changed, 3 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/classfile/modules.cpp	Thu Mar 09 15:00:23 2017 -0800
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Fri Mar 10 08:04:17 2017 -0500
@@ -162,8 +162,7 @@
   }
 
 
-  // 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 @@
                 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 @@
     }
 
     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);
--- a/hotspot/src/share/vm/classfile/modules.hpp	Thu Mar 09 15:00:23 2017 -0800
+++ b/hotspot/src/share/vm/classfile/modules.hpp	Fri Mar 10 08:04:17 2017 -0500
@@ -45,7 +45,6 @@
   // * 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
--- a/hotspot/test/runtime/modules/JVMDefineModule.java	Thu Mar 09 15:00:23 2017 -0800
+++ b/hotspot/test/runtime/modules/JVMDefineModule.java	Fri Mar 10 08:04:17 2017 -0500
@@ -105,17 +105,6 @@
             }
         }
 
-        // 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 {