8163382: ResourcePoolManager.findEntry has a bug in startsWith call
Reviewed-by: jlaskey, redestad
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java Mon Aug 08 13:58:14 2016 -0700
+++ b/jdk/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/jdk/test/tools/jlink/JLinkTest.java Mon Aug 08 13:58:14 2016 -0700
+++ b/jdk/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));