8167328: jar -d m.jar hangs
authorsherman
Thu, 01 Dec 2016 15:42:22 -0800
changeset 42345 cead5ce4ca27
parent 42344 a2378998a8fd
child 42346 c0c6d5d20c35
8167328: jar -d m.jar hangs Reviewed-by: alanb, mchung, chegar
jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java
jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties
jdk/test/tools/jar/modularJar/Basic.java
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Dec 01 21:39:49 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Dec 01 15:42:22 2016 -0800
@@ -774,6 +774,12 @@
         /* 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];
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Dec 01 21:39:49 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Dec 01 15:42:22 2016 -0800
@@ -44,6 +44,8 @@
 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=\
--- a/jdk/test/tools/jar/modularJar/Basic.java	Thu Dec 01 21:39:49 2016 +0000
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Thu Dec 01 15:42:22 2016 -0800
@@ -46,6 +46,7 @@
 
 /*
  * @test
+ * @bug 8167328
  * @library /lib/testlibrary
  * @modules jdk.compiler
  *          jdk.jartool
@@ -756,6 +757,14 @@
                                "Expected to find ", FOO.moduleName + "@" + FOO.version,
                                " in [", r.output, "]")
                 );
+
+            jar(option,
+                "--file=" + modularJar.toString(),
+                modularJar.toString())
+            .assertFailure();
+
+            jar(option, modularJar.toString())
+            .assertFailure();
         }
     }