diff --git a/test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigTest.java b/test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigTest.java index 9274f9d7eaff4..0506872cf44aa 100644 --- a/test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigTest.java +++ b/test/jdk/java/time/nontestng/java/time/chrono/HijrahConfigTest.java @@ -34,7 +34,11 @@ * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) * @library /tools/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jimage * jdk.compiler * @build HijrahConfigCheck tests.* diff --git a/test/jdk/tools/jimage/JImageNonAsciiNameTest.java b/test/jdk/tools/jimage/JImageNonAsciiNameTest.java index 4d1e5ba94ad82..5e478f15bec7c 100644 --- a/test/jdk/tools/jimage/JImageNonAsciiNameTest.java +++ b/test/jdk/tools/jimage/JImageNonAsciiNameTest.java @@ -38,7 +38,11 @@ * @library ../lib * /test/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jimage * @build tests.* * @run main/othervm JImageNonAsciiNameTest diff --git a/test/jdk/tools/jimage/JImageTest.java b/test/jdk/tools/jimage/JImageTest.java index e6165a2c33e1e..8c0c1a48bded6 100644 --- a/test/jdk/tools/jimage/JImageTest.java +++ b/test/jdk/tools/jimage/JImageTest.java @@ -48,7 +48,11 @@ * @bug 8222100 * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.jlink/jdk.tools.jlink.internal diff --git a/test/jdk/tools/jlink/DefaultProviderTest.java b/test/jdk/tools/jlink/DefaultProviderTest.java index 85dca4829fc26..62cca19e937c4 100644 --- a/test/jdk/tools/jlink/DefaultProviderTest.java +++ b/test/jdk/tools/jlink/DefaultProviderTest.java @@ -43,7 +43,11 @@ * @requires vm.compMode != "Xcomp" * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/ExplodedModuleNameTest.java b/test/jdk/tools/jlink/ExplodedModuleNameTest.java index bcbc1ffd86c67..7cbdc93bf0e2e 100644 --- a/test/jdk/tools/jlink/ExplodedModuleNameTest.java +++ b/test/jdk/tools/jlink/ExplodedModuleNameTest.java @@ -39,7 +39,11 @@ * @summary Inconsistent handling of exploded modules in jlink * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/IntegrationTest.java b/test/jdk/tools/jlink/IntegrationTest.java index f62be0278a8f1..9d92c2042ef75 100644 --- a/test/jdk/tools/jlink/IntegrationTest.java +++ b/test/jdk/tools/jlink/IntegrationTest.java @@ -61,7 +61,11 @@ * @author Jean-Francois Denise * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.builder * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins diff --git a/test/jdk/tools/jlink/JLink100Modules.java b/test/jdk/tools/jlink/JLink100Modules.java index 926a6adaf4f98..bbcba94b51fe6 100644 --- a/test/jdk/tools/jlink/JLink100Modules.java +++ b/test/jdk/tools/jlink/JLink100Modules.java @@ -36,7 +36,11 @@ * @bug 8240567 * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/JLink2Test.java b/test/jdk/tools/jlink/JLink2Test.java index 5c0f7f3357192..47cc9bafc4f3b 100644 --- a/test/jdk/tools/jlink/JLink2Test.java +++ b/test/jdk/tools/jlink/JLink2Test.java @@ -27,7 +27,11 @@ * @author Jean-Francois Denise * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/JLinkDedupTestBatchSizeOne.java b/test/jdk/tools/jlink/JLinkDedupTestBatchSizeOne.java index 3a52f6b32c493..45ab9bf41f258 100644 --- a/test/jdk/tools/jlink/JLinkDedupTestBatchSizeOne.java +++ b/test/jdk/tools/jlink/JLinkDedupTestBatchSizeOne.java @@ -37,7 +37,11 @@ * @library /test/lib * ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/JLinkNegativeTest.java b/test/jdk/tools/jlink/JLinkNegativeTest.java index edfdfbb43ea9f..493d7a370ddf1 100644 --- a/test/jdk/tools/jlink/JLinkNegativeTest.java +++ b/test/jdk/tools/jlink/JLinkNegativeTest.java @@ -33,7 +33,11 @@ * java.base/jdk.internal.classfile.constantpool * java.base/jdk.internal.jimage * java.base/jdk.internal.module - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/JLinkOptionsTest.java b/test/jdk/tools/jlink/JLinkOptionsTest.java index 5fcadd6d59846..e1f84c0872a09 100644 --- a/test/jdk/tools/jlink/JLinkOptionsTest.java +++ b/test/jdk/tools/jlink/JLinkOptionsTest.java @@ -37,7 +37,11 @@ * @author Jean-Francois Denise * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/JLinkPluginsTest.java b/test/jdk/tools/jlink/JLinkPluginsTest.java index 6076cfa40435f..b90f9d4db26fa 100644 --- a/test/jdk/tools/jlink/JLinkPluginsTest.java +++ b/test/jdk/tools/jlink/JLinkPluginsTest.java @@ -36,7 +36,11 @@ * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/JLinkTest.java b/test/jdk/tools/jlink/JLinkTest.java index 39cf311a33000..0226caf47ccae 100644 --- a/test/jdk/tools/jlink/JLinkTest.java +++ b/test/jdk/tools/jlink/JLinkTest.java @@ -52,7 +52,11 @@ * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/ModuleNamesOrderTest.java b/test/jdk/tools/jlink/ModuleNamesOrderTest.java index 37041da4c06be..a2c6f0cfe3e7d 100644 --- a/test/jdk/tools/jlink/ModuleNamesOrderTest.java +++ b/test/jdk/tools/jlink/ModuleNamesOrderTest.java @@ -42,7 +42,11 @@ * @summary MODULES property should be topologically ordered and space-separated list * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/NativeTest.java b/test/jdk/tools/jlink/NativeTest.java index b147617be8bee..38bc87faabbe5 100644 --- a/test/jdk/tools/jlink/NativeTest.java +++ b/test/jdk/tools/jlink/NativeTest.java @@ -27,7 +27,11 @@ * @author Andrei Eremeev * @library ../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java b/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java index afcf4b38b2fc9..0979edd1af4ca 100644 --- a/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java +++ b/test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java @@ -31,7 +31,11 @@ * @library ../../lib * @library /test/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/plugins/CDSPluginTest.java b/test/jdk/tools/jlink/plugins/CDSPluginTest.java index c57c10f9e611e..d96c2eb8b7ecf 100644 --- a/test/jdk/tools/jlink/plugins/CDSPluginTest.java +++ b/test/jdk/tools/jlink/plugins/CDSPluginTest.java @@ -38,7 +38,11 @@ * @library ../../lib * @library /test/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/plugins/GenerateJLIClassesPluginTest.java b/test/jdk/tools/jlink/plugins/GenerateJLIClassesPluginTest.java index d4413f629af8d..2a8ea451865a3 100644 --- a/test/jdk/tools/jlink/plugins/GenerateJLIClassesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/GenerateJLIClassesPluginTest.java @@ -43,7 +43,11 @@ * @library ../../lib * @summary Test --generate-jli-classes plugin * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins * jdk.jlink/jdk.tools.jmod diff --git a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java index ce758915f41e0..08a4bd1a129e9 100644 --- a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -48,7 +48,11 @@ * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) * @library ../../lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins * jdk.jlink/jdk.tools.jlink.plugin diff --git a/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java b/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java index c9eed4745776c..fe26f7e6bbbe1 100644 --- a/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java @@ -28,7 +28,11 @@ * @library ../../lib * @library /test/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/jlink/plugins/StringSharingPluginTest.java b/test/jdk/tools/jlink/plugins/StringSharingPluginTest.java index 1ffef172f11ae..306974781306f 100644 --- a/test/jdk/tools/jlink/plugins/StringSharingPluginTest.java +++ b/test/jdk/tools/jlink/plugins/StringSharingPluginTest.java @@ -33,7 +33,11 @@ * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.compiler * @run build tests.* * @run main StringSharingPluginTest diff --git a/test/jdk/tools/jlink/plugins/StripJavaDebugAttributesPluginTest.java b/test/jdk/tools/jlink/plugins/StripJavaDebugAttributesPluginTest.java index 8d081d25dc466..5c66ccedbbab4 100644 --- a/test/jdk/tools/jlink/plugins/StripJavaDebugAttributesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/StripJavaDebugAttributesPluginTest.java @@ -33,7 +33,11 @@ * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jimage * jdk.jlink/jdk.tools.jmod - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.compiler * @run main StripJavaDebugAttributesPluginTest */ @@ -42,19 +46,11 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Stream; -import com.sun.tools.classfile.Attribute; -import com.sun.tools.classfile.ClassFile; -import com.sun.tools.classfile.Code_attribute; -import com.sun.tools.classfile.ConstantPoolException; -import com.sun.tools.classfile.Method; - +import jdk.internal.classfile.*; +import jdk.internal.classfile.attribute.CodeAttribute; import jdk.tools.jlink.internal.ResourcePoolManager; import jdk.tools.jlink.internal.plugins.StripJavaDebugAttributesPlugin; import jdk.tools.jlink.plugin.Plugin; @@ -141,21 +137,22 @@ private ResourcePoolEntry stripDebug(Plugin debug, ResourcePoolEntry classResour return resPool.findEntry(classResource.path()).get(); } - private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException { - ClassFile classFile = ClassFile.read(new ByteArrayInputStream(strippedClassFile)); - String[] debugAttributes = new String[]{ - Attribute.LineNumberTable, - Attribute.LocalVariableTable, - Attribute.LocalVariableTypeTable - }; - for (Method method : classFile.methods) { - String methodName = method.getName(classFile.constant_pool); - Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); - for (String attr : debugAttributes) { - if (code.attributes.get(attr) != null) { - throw new AssertionError("Debug attribute was not removed: " + attr + - " from method " + classFile.getName() + "#" + methodName); - } + private > void checkDebugAttributes(byte[] strippedClassFile) { + ClassModel classFile = Classfile.of().parse(strippedClassFile); + for (MethodModel method : classFile.methods()) { + String methodName = method.methodName().stringValue(); + CodeAttribute code = method.findAttribute(Attributes.CODE).orElseThrow(); + if (code.findAttribute(Attributes.LINE_NUMBER_TABLE).orElse(null) != null) { + throw new AssertionError("Debug attribute was not removed: " + "LINE_NUMBER_TABLE" + + " from method " + classFile.thisClass().asInternalName() + "#" + methodName); + } + if (code.findAttribute(Attributes.LOCAL_VARIABLE_TABLE).orElse(null) != null) { + throw new AssertionError("Debug attribute was not removed: " + "LOCAL_VARIABLE_TABLE" + + " from method " + classFile.thisClass().asInternalName() + "#" + methodName); + } + if (code.findAttribute(Attributes.LOCAL_VARIABLE_TYPE_TABLE).orElse(null) != null) { + throw new AssertionError("Debug attribute was not removed: " + "LOCAL_VARIABLE_TYPE_TABLE" + + " from method " + classFile.thisClass().asInternalName() + "#" + methodName); } } } diff --git a/test/jdk/tools/jlink/plugins/VendorInfoPluginsTest.java b/test/jdk/tools/jlink/plugins/VendorInfoPluginsTest.java index 8eee849851b54..73bc3fab7e4c7 100644 --- a/test/jdk/tools/jlink/plugins/VendorInfoPluginsTest.java +++ b/test/jdk/tools/jlink/plugins/VendorInfoPluginsTest.java @@ -31,7 +31,11 @@ * @library ../../lib * @library /test/lib * @modules java.base/jdk.internal.jimage - * jdk.jdeps/com.sun.tools.classfile + * java.base/jdk.internal.classfile + * java.base/jdk.internal.classfile.attribute + * java.base/jdk.internal.classfile.constantpool + * java.base/jdk.internal.classfile.instruction + * java.base/jdk.internal.classfile.components * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage diff --git a/test/jdk/tools/lib/tests/JImageValidator.java b/test/jdk/tools/lib/tests/JImageValidator.java index 69c6761b5862f..41f75a480f7bd 100644 --- a/test/jdk/tools/lib/tests/JImageValidator.java +++ b/test/jdk/tools/lib/tests/JImageValidator.java @@ -22,19 +22,16 @@ */ package tests; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import com.sun.tools.classfile.ClassFile; -import com.sun.tools.classfile.ConstantPoolException; +import jdk.internal.classfile.Classfile; import jdk.internal.jimage.BasicImageReader; import jdk.internal.jimage.ImageLocation; @@ -224,11 +221,13 @@ public long getModuleLauncherExecutionTime() { return moduleExecutionTime; } - public static void readClass(byte[] clazz) throws IOException { - try (InputStream stream = new ByteArrayInputStream(clazz)) { - ClassFile.read(stream); - } catch (ConstantPoolException e) { - throw new IOException(e); + public static void readClass(byte[] clazz) throws IOException{ + var errors = Classfile.of().parse(clazz).verify(null); + if (!errors.isEmpty()) { + var itr = errors.iterator(); + var thrown = itr.next(); + itr.forEachRemaining(thrown::addSuppressed); + throw new IOException(thrown); } } }