From 689077a9da2ebbca05fd2603c459c40b8819a5db Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 1 Dec 2016 15:42:22 -0800 Subject: [PATCH] 8167328: jar -d m.jar hangs Reviewed-by: alanb, mchung, chegar --- .../jdk.jartool/share/classes/sun/tools/jar/Main.java | 6 ++++++ .../share/classes/sun/tools/jar/resources/jar.properties | 2 ++ jdk/test/tools/jar/modularJar/Basic.java | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index 566b99ba0f3..f9b32761f05 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -774,6 +774,12 @@ class Main { /* parse file arguments */ int n = args.length - count; if (n > 0) { + if (printModuleDescriptor) { + // "--print-module-descriptor/-d" does not require file argument(s) + error(formatMsg("error.bad.dflag", args[count])); + usageError(); + return false; + } int version = BASE_VERSION; int k = 0; String[] nameBuf = new String[n]; diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties index 7e2f6e6a164..f1e281619ef 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties @@ -44,6 +44,8 @@ error.bad.uflag=\ error.bad.eflag=\ 'e' flag and manifest with the 'Main-Class' attribute cannot be specified \n\ together! +error.bad.dflag=\ + '-d, --print-module-descriptor' option requires no input file(s) to be specified: {0} error.nosuch.fileordir=\ {0} : no such file or directory error.write.file=\ diff --git a/jdk/test/tools/jar/modularJar/Basic.java b/jdk/test/tools/jar/modularJar/Basic.java index 45ef7897b43..df38b6cc584 100644 --- a/jdk/test/tools/jar/modularJar/Basic.java +++ b/jdk/test/tools/jar/modularJar/Basic.java @@ -46,6 +46,7 @@ import static java.lang.System.out; /* * @test + * @bug 8167328 * @library /lib/testlibrary * @modules jdk.compiler * jdk.jartool @@ -756,6 +757,14 @@ public class Basic { "Expected to find ", FOO.moduleName + "@" + FOO.version, " in [", r.output, "]") ); + + jar(option, + "--file=" + modularJar.toString(), + modularJar.toString()) + .assertFailure(); + + jar(option, modularJar.toString()) + .assertFailure(); } }