changeset 16208:685512caa8bf

8167328: jar -d m.jar hangs Reviewed-by: alanb, mchung, chegar
author sherman
date Thu, 01 Dec 2016 15:42:22 -0800
parents 7b997de570ba
children b1b62e236357
files src/jdk.jartool/share/classes/sun/tools/jar/Main.java src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties test/tools/jar/modularJar/Basic.java
diffstat 3 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Dec 01 21:39:49 2016 +0000
+++ b/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/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Dec 01 21:39:49 2016 +0000
+++ b/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/test/tools/jar/modularJar/Basic.java	Thu Dec 01 21:39:49 2016 +0000
+++ b/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();
         }
     }