--- a/jdk/test/tools/jlink/JLinkTest.java Wed Sep 28 19:21:42 2016 +0300
+++ b/jdk/test/tools/jlink/JLinkTest.java Wed Sep 28 22:13:14 2016 +0530
@@ -150,6 +150,43 @@
}
{
+ String moduleName = "m_8165735"; // JDK-8165735
+ helper.generateDefaultJModule(moduleName+"dependency").assertSuccess();
+ Path jmod = helper.generateDefaultJModule(moduleName, moduleName+"dependency").assertSuccess();
+ JImageGenerator.getJLinkTask()
+ .modulePath(helper.defaultModulePath())
+ .repeatedModulePath(".") // second --module-path overrides the first one
+ .output(helper.createNewImageDir(moduleName))
+ .addMods(moduleName)
+ // second --module-path does not have that module
+ .call().assertFailure("Error: Module m_8165735 not found");
+
+ JImageGenerator.getJLinkTask()
+ .modulePath(".") // first --module-path overridden later
+ .repeatedModulePath(helper.defaultModulePath())
+ .output(helper.createNewImageDir(moduleName))
+ .addMods(moduleName)
+ // second --module-path has that module
+ .call().assertSuccess();
+
+ JImageGenerator.getJLinkTask()
+ .modulePath(helper.defaultModulePath())
+ .output(helper.createNewImageDir(moduleName))
+ .limitMods(moduleName)
+ .repeatedLimitMods("java.base") // second --limit-modules overrides first
+ .addMods(moduleName)
+ .call().assertFailure("Error: Module m_8165735dependency not found, required by m_8165735");
+
+ JImageGenerator.getJLinkTask()
+ .modulePath(helper.defaultModulePath())
+ .output(helper.createNewImageDir(moduleName))
+ .limitMods("java.base")
+ .repeatedLimitMods(moduleName) // second --limit-modules overrides first
+ .addMods(moduleName)
+ .call().assertSuccess();
+ }
+
+ {
// Help
StringWriter writer = new StringWriter();
jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));