8170120: jimage throws IOException when the given file is not a jimage file
Reviewed-by: alanb
Contributed-by: mvala@redhat.com
--- 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
############################################################################