--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Wed Jul 20 20:47:42 2016 +0200
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java Thu Jul 21 10:34:59 2016 -0300
@@ -39,6 +39,8 @@
import jdk.internal.jimage.BasicImageReader;
import jdk.internal.jimage.ImageHeader;
import jdk.internal.jimage.ImageLocation;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.tree.ClassNode;
import jdk.tools.jlink.internal.ImageResourcesTree;
import jdk.tools.jlink.internal.TaskHelper;
import jdk.tools.jlink.internal.TaskHelper.BadArgs;
@@ -354,16 +356,14 @@
}
void verify(BasicImageReader reader, String name, ImageLocation location) {
- if (name.endsWith(".class")) {
- byte[] bytes = reader.getResource(location);
-
- if (bytes == null || bytes.length <= 4 ||
- (bytes[0] & 0xFF) != 0xCA ||
- (bytes[1] & 0xFF) != 0xFE ||
- (bytes[2] & 0xFF) != 0xBA ||
- (bytes[3] & 0xFF) != 0xBE) {
- log.print(" NOT A CLASS: ");
- print(reader, name);
+ if (name.endsWith(".class") && !name.endsWith("module-info.class")) {
+ try {
+ byte[] bytes = reader.getResource(location);
+ ClassReader cr =new ClassReader(bytes);
+ ClassNode cn = new ClassNode();
+ cr.accept(cn, ClassReader.EXPAND_FRAMES);
+ } catch (Exception ex) {
+ log.println("Error(s) in Class: " + name);
}
}
}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties Wed Jul 20 20:47:42 2016 +0200
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties Thu Jul 21 10:34:59 2016 -0300
@@ -63,7 +63,7 @@
\ --dir Target directory for extract directive
main.opt.include=\
-\ --include <pattern-list> Pattern list for filtering list or extract entries.
+\ --include <pattern-list> Pattern list for filtering entries.
main.opt.footer=\
\n\
--- a/jdk/test/tools/jimage/JImageToolTest.java Wed Jul 20 20:47:42 2016 +0200
+++ b/jdk/test/tools/jimage/JImageToolTest.java Thu Jul 21 10:34:59 2016 -0300
@@ -63,6 +63,8 @@
String jimage = jimagePath.toAbsolutePath().toString();
String bootimage = modulesimagePath.toAbsolutePath().toString();
String extractDir = Paths.get(".", "extract").toAbsolutePath().toString();
+ jimage("list", bootimage);
+ jimage("verify", bootimage);
jimage("extract", "--dir", extractDir, bootimage);
System.out.println("Test successful");
} else {