8170120: jimage throws IOException when the given file is not a jimage file
authoralanb
Mon, 19 Feb 2018 13:26:41 +0000
changeset 48913 7f9c3cd11e97
parent 48912 01237b276b8b
child 48914 0a185d6fafa1
8170120: jimage throws IOException when the given file is not a jimage file Reviewed-by: alanb Contributed-by: mvala@redhat.com
src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java
src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties
test/jdk/ProblemList.txt
--- a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Mon Feb 19 10:57:05 2018 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Mon Feb 19 13:26:41 2018 +0000
@@ -386,7 +386,7 @@
 
         for (File file : options.jimages) {
             if (!file.exists() || !file.isFile()) {
-                throw TASK_HELPER.newBadArgs("err.not.a.jimage", file.getName());
+                throw TASK_HELPER.newBadArgs("err.not.a.jimage", file);
             }
 
             try (BasicImageReader reader = BasicImageReader.open(file.toPath())) {
@@ -431,6 +431,8 @@
                         }
                     }
                 }
+            } catch (IOException ioe) {
+                throw TASK_HELPER.newBadArgs("err.invalid.jimage", file, ioe.getMessage());
             }
         }
     }
--- a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Mon Feb 19 10:57:05 2018 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Mon Feb 19 13:26:41 2018 +0000
@@ -95,6 +95,7 @@
 err.missing.arg=no value given for {0}
 err.not.a.dir=not a directory: {0}
 err.not.a.jimage=not a jimage file: {0}
+err.invalid.jimage=Unable to open {0}: {1}
 err.no.jimage=no jimage provided
 err.option.unsupported={0} not supported: {1}
 err.unknown.option=unknown option: {0}
--- a/test/jdk/ProblemList.txt	Mon Feb 19 10:57:05 2018 +0100
+++ b/test/jdk/ProblemList.txt	Mon Feb 19 13:26:41 2018 +0000
@@ -466,7 +466,6 @@
 
 tools/jimage/JImageExtractTest.java                             8170120 generic-all
 tools/jimage/JImageListTest.java                                8170120 generic-all
-tools/jimage/JImageVerifyTest.java                              8170120 generic-all
 
 ############################################################################