changeset 17376:f1ff866fd512

8163382: ResourcePoolManager.findEntry has a bug in startsWith call Reviewed-by: jlaskey, redestad
author sundar
date Tue, 09 Aug 2016 09:44:25 +0530
parents eebdcae9af85
children 3a850cd34e59
files src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java test/tools/jlink/JLinkTest.java
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Mon Aug 08 13:58:14 2016 -0700
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Tue Aug 09 09:44:25 2016 +0530
@@ -83,8 +83,8 @@
             if (!path.startsWith("/")) {
                 path = "/" + path;
             }
-            if (!path.startsWith("/" + name)) {
-                path = "/" + name + path;
+            if (!path.startsWith("/" + name + "/")) {
+                path = "/" + name + path; // path already starts with '/'
             }
             return Optional.ofNullable(moduleContent.get(path));
         }
--- a/test/tools/jlink/JLinkTest.java	Mon Aug 08 13:58:14 2016 -0700
+++ b/test/tools/jlink/JLinkTest.java	Tue Aug 09 09:44:25 2016 +0530
@@ -131,6 +131,25 @@
         }
 
         {
+            String moduleName = "m"; // 8163382
+            Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
+            JImageGenerator.getJLinkTask()
+                    .modulePath(helper.defaultModulePath())
+                    .output(helper.createNewImageDir(moduleName))
+                    .addMods("m")
+                    .option("")
+                    .call().assertSuccess();
+            moduleName = "mod";
+            jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
+            JImageGenerator.getJLinkTask()
+                    .modulePath(helper.defaultModulePath())
+                    .output(helper.createNewImageDir(moduleName))
+                    .addMods("m")
+                    .option("")
+                    .call().assertSuccess();
+        }
+
+        {
             // Help
             StringWriter writer = new StringWriter();
             jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));