From 5ee736cc156861f22b4057e5926340190ddb70d8 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Fri, 11 Sep 2020 08:53:59 +0200 Subject: [PATCH 1/4] Upgrade to ASM 9.0 Also use ASM for Java 16 class files directly. --- .../licenses/{asm-8.0.1.html => asm-9.0.html} | 2 +- org.jacoco.build/pom.xml | 4 ++-- .../org/jacoco/core/analysis/AnalyzerTest.java | 10 +++++----- .../jacoco/core/instr/ClassFileVersionsTest.java | 8 +++++++- .../org/jacoco/core/instr/InstrumenterTest.java | 10 +++++----- .../core/internal/instr/InstrSupportTest.java | 15 ++++++++------- .../jacoco/core/internal/instr/InstrSupport.java | 4 ++-- 7 files changed, 30 insertions(+), 23 deletions(-) rename org.jacoco.build/licenses/{asm-8.0.1.html => asm-9.0.html} (96%) diff --git a/org.jacoco.build/licenses/asm-8.0.1.html b/org.jacoco.build/licenses/asm-9.0.html similarity index 96% rename from org.jacoco.build/licenses/asm-8.0.1.html rename to org.jacoco.build/licenses/asm-9.0.html index 1ba58e514c..7e6d1d7b7f 100644 --- a/org.jacoco.build/licenses/asm-8.0.1.html +++ b/org.jacoco.build/licenses/asm-9.0.html @@ -1,7 +1,7 @@

ASM

- ASM 7.2 is subject to the terms and + ASM 9.0 is subject to the terms and conditions of the following license:

diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml index 078b4e73ec..8f79e8ad36 100644 --- a/org.jacoco.build/pom.xml +++ b/org.jacoco.build/pom.xml @@ -139,7 +139,7 @@ ${jvm.args} - 8.0.1 + 9.0 1.7.1 2.0.28 4.13 @@ -740,7 +740,7 @@ org.jacoco.*;version="${range;[===,==+);${Bundle-Version}}", - org.objectweb.asm.*;version="${range;[===,=+);${asm.version}}" + org.objectweb.asm.*;version="[9.0.0,10.0)" J2SE-1.5 scm:git:git://github.com/jacoco/jacoco.git;path="${project.artifactId}";commitId=${buildNumber} diff --git a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java index 120ddb9244..3a0be5db6e 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java @@ -107,7 +107,7 @@ public void should_ignore_synthetic_classes() throws Exception { @Test public void should_not_modify_class_bytes_to_support_next_version() throws Exception { - final byte[] originalBytes = createClass(Opcodes.V15 + 1); + final byte[] originalBytes = createClass(Opcodes.V16 + 1); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); @@ -130,14 +130,14 @@ private static byte[] createClass(final int version) { */ @Test public void analyzeClass_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V15 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 2); try { analyzer.analyzeClass(bytes, "UnsupportedVersion"); fail("exception expected"); } catch (IOException e) { assertEquals("Error while analyzing UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 61", + assertEquals("Unsupported class file major version 62", e.getCause().getMessage()); } } @@ -217,7 +217,7 @@ public void testAnalyzeClass_BrokenStream() throws IOException { */ @Test public void analyzeAll_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V15 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 2); try { analyzer.analyzeAll(new ByteArrayInputStream(bytes), "UnsupportedVersion"); @@ -225,7 +225,7 @@ public void analyzeAll_should_throw_exception_for_unsupported_class_file_version } catch (IOException e) { assertEquals("Error while analyzing UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 61", + assertEquals("Unsupported class file major version 62", e.getCause().getMessage()); } } diff --git a/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java index f1d21db210..95b3e6e423 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java @@ -30,6 +30,7 @@ import static org.objectweb.asm.Opcodes.V13; import static org.objectweb.asm.Opcodes.V14; import static org.objectweb.asm.Opcodes.V15; +import static org.objectweb.asm.Opcodes.V16; import static org.objectweb.asm.Opcodes.V1_1; import static org.objectweb.asm.Opcodes.V1_2; import static org.objectweb.asm.Opcodes.V1_3; @@ -135,7 +136,12 @@ public void test_15() throws IOException { @Test public void test_16() throws IOException { - testVersion(V15 + 1, true); + testVersion(V16 + 1, true); + } + + @Test + public void test_17() throws IOException { + testVersion(V16 + 1, true); } private void testVersion(int version, boolean frames) throws IOException { diff --git a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java index 5d29429a91..e22be15a2f 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java @@ -99,7 +99,7 @@ public void setup() throws Exception { @Test public void should_not_modify_class_bytes_to_support_next_version() throws Exception { - final byte[] originalBytes = createClass(Opcodes.V15 + 1); + final byte[] originalBytes = createClass(Opcodes.V16 + 1); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); @@ -122,14 +122,14 @@ private static byte[] createClass(final int version) { */ @Test public void instrument_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V15 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 2); try { instrumenter.instrument(bytes, "UnsupportedVersion"); fail("exception expected"); } catch (final IOException e) { assertEquals("Error while instrumenting UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 61", + assertEquals("Unsupported class file major version 62", e.getCause().getMessage()); } } @@ -224,7 +224,7 @@ public void testSerialization() throws Exception { */ @Test public void instrumentAll_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V15 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 2); try { instrumenter.instrumentAll(new ByteArrayInputStream(bytes), new ByteArrayOutputStream(), "UnsupportedVersion"); @@ -232,7 +232,7 @@ public void instrumentAll_should_throw_exception_for_unsupported_class_file_vers } catch (final IOException e) { assertEquals("Error while instrumenting UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 61", + assertEquals("Unsupported class file major version 62", e.getCause().getMessage()); } } diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java index b6ddb29336..c5387fea9d 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java @@ -43,8 +43,8 @@ public void setup() { } @Test - public void classReaderFor_should_read_java_16_class() { - final byte[] bytes = createJava16Class(); + public void classReaderFor_should_read_java_17_class() { + final byte[] bytes = createJava17Class(); final ClassReader classReader = InstrSupport.classReaderFor(bytes); @@ -53,16 +53,16 @@ public void classReaderFor_should_read_java_16_class() { public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { - assertEquals(Opcodes.V15 + 1, version); + assertEquals(Opcodes.V16 + 1, version); } }, 0); - assertArrayEquals(createJava16Class(), bytes); + assertArrayEquals(createJava17Class(), bytes); } - private static byte[] createJava16Class() { + private static byte[] createJava17Class() { final ClassWriter cw = new ClassWriter(0); - cw.visit(Opcodes.V15 + 1, 0, "Foo", null, "java/lang/Object", null); + cw.visit(Opcodes.V16 + 1, 0, "Foo", null, "java/lang/Object", null); cw.visitEnd(); return cw.toByteArray(); } @@ -127,7 +127,8 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_ assertTrue(InstrSupport.needsFrames(Opcodes.V13)); assertTrue(InstrSupport.needsFrames(Opcodes.V14)); assertTrue(InstrSupport.needsFrames(Opcodes.V15)); - assertTrue(InstrSupport.needsFrames(Opcodes.V15 + 1)); + assertTrue(InstrSupport.needsFrames(Opcodes.V16)); + assertTrue(InstrSupport.needsFrames(Opcodes.V16 + 1)); assertTrue(InstrSupport.needsFrames(0x0100)); } diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java index bf91e6d051..f8ce15039d 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java @@ -273,9 +273,9 @@ public static void push(final MethodVisitor mv, final int value) { */ public static ClassReader classReaderFor(final byte[] b) { final int originalVersion = getMajorVersion(b); - if (originalVersion == Opcodes.V15 + 1) { + if (originalVersion == Opcodes.V16 + 1) { // temporarily downgrade version to bypass check in ASM - setMajorVersion(Opcodes.V15, b); + setMajorVersion(Opcodes.V16, b); } final ClassReader classReader = new ClassReader(b); setMajorVersion(originalVersion, b); From 5819d7a67c24284213660f493e9c2cb8687493cc Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Wed, 23 Sep 2020 08:19:30 +0200 Subject: [PATCH 2/4] Update change log --- org.jacoco.doc/docroot/doc/changes.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 67769e4646..8558948b83 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -20,6 +20,19 @@

Change History

Snapshot Build @qualified.bundle.version@ (@build.date@)

+

New Features

+ + +

Non-functional Changes

+ + +

Release 0.8.6 (2020/09/15)

New Features

From f0f9fef6838f8b35041e2317fb552948f5c715c3 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Mon, 28 Sep 2020 17:53:11 +0200 Subject: [PATCH 3/4] Review: Revert temp change to version rule --- org.jacoco.build/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml index 8f79e8ad36..89acca23d6 100644 --- a/org.jacoco.build/pom.xml +++ b/org.jacoco.build/pom.xml @@ -740,7 +740,7 @@ org.jacoco.*;version="${range;[===,==+);${Bundle-Version}}", - org.objectweb.asm.*;version="[9.0.0,10.0)" + org.objectweb.asm.*;version="${range;[===,=+);${asm.version}}" J2SE-1.5 scm:git:git://github.com/jacoco/jacoco.git;path="${project.artifactId}";commitId=${buildNumber} From 362064b48b8ee023918d47571a486ed7df57510b Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Mon, 28 Sep 2020 19:09:26 +0200 Subject: [PATCH 4/4] Review: do not downgrade Java 17 class files --- .../src/org/jacoco/core/analysis/AnalyzerTest.java | 10 +++++----- .../jacoco/core/instr/ClassFileVersionsTest.java | 7 +------ .../src/org/jacoco/core/instr/InstrumenterTest.java | 10 +++++----- .../core/internal/instr/InstrSupportTest.java | 13 ++++++------- .../jacoco/core/internal/instr/InstrSupport.java | 2 +- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java index 3a0be5db6e..33d1ea5a11 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java @@ -107,7 +107,7 @@ public void should_ignore_synthetic_classes() throws Exception { @Test public void should_not_modify_class_bytes_to_support_next_version() throws Exception { - final byte[] originalBytes = createClass(Opcodes.V16 + 1); + final byte[] originalBytes = createClass(Opcodes.V16); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); @@ -130,14 +130,14 @@ private static byte[] createClass(final int version) { */ @Test public void analyzeClass_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V16 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 1); try { analyzer.analyzeClass(bytes, "UnsupportedVersion"); fail("exception expected"); } catch (IOException e) { assertEquals("Error while analyzing UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 62", + assertEquals("Unsupported class file major version 61", e.getCause().getMessage()); } } @@ -217,7 +217,7 @@ public void testAnalyzeClass_BrokenStream() throws IOException { */ @Test public void analyzeAll_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V16 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 1); try { analyzer.analyzeAll(new ByteArrayInputStream(bytes), "UnsupportedVersion"); @@ -225,7 +225,7 @@ public void analyzeAll_should_throw_exception_for_unsupported_class_file_version } catch (IOException e) { assertEquals("Error while analyzing UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 62", + assertEquals("Unsupported class file major version 61", e.getCause().getMessage()); } } diff --git a/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java index 95b3e6e423..3afa8103b0 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java @@ -136,12 +136,7 @@ public void test_15() throws IOException { @Test public void test_16() throws IOException { - testVersion(V16 + 1, true); - } - - @Test - public void test_17() throws IOException { - testVersion(V16 + 1, true); + testVersion(V16, true); } private void testVersion(int version, boolean frames) throws IOException { diff --git a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java index e22be15a2f..b7500cb122 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java @@ -99,7 +99,7 @@ public void setup() throws Exception { @Test public void should_not_modify_class_bytes_to_support_next_version() throws Exception { - final byte[] originalBytes = createClass(Opcodes.V16 + 1); + final byte[] originalBytes = createClass(Opcodes.V16); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); @@ -122,14 +122,14 @@ private static byte[] createClass(final int version) { */ @Test public void instrument_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V16 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 1); try { instrumenter.instrument(bytes, "UnsupportedVersion"); fail("exception expected"); } catch (final IOException e) { assertEquals("Error while instrumenting UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 62", + assertEquals("Unsupported class file major version 61", e.getCause().getMessage()); } } @@ -224,7 +224,7 @@ public void testSerialization() throws Exception { */ @Test public void instrumentAll_should_throw_exception_for_unsupported_class_file_version() { - final byte[] bytes = createClass(Opcodes.V16 + 2); + final byte[] bytes = createClass(Opcodes.V16 + 1); try { instrumenter.instrumentAll(new ByteArrayInputStream(bytes), new ByteArrayOutputStream(), "UnsupportedVersion"); @@ -232,7 +232,7 @@ public void instrumentAll_should_throw_exception_for_unsupported_class_file_vers } catch (final IOException e) { assertEquals("Error while instrumenting UnsupportedVersion.", e.getMessage()); - assertEquals("Unsupported class file major version 62", + assertEquals("Unsupported class file major version 61", e.getCause().getMessage()); } } diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java index c5387fea9d..a66b5ebd3d 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java @@ -43,8 +43,8 @@ public void setup() { } @Test - public void classReaderFor_should_read_java_17_class() { - final byte[] bytes = createJava17Class(); + public void classReaderFor_should_read_java_16_class() { + final byte[] bytes = createJava16Class(); final ClassReader classReader = InstrSupport.classReaderFor(bytes); @@ -53,16 +53,16 @@ public void classReaderFor_should_read_java_17_class() { public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { - assertEquals(Opcodes.V16 + 1, version); + assertEquals(Opcodes.V16, version); } }, 0); - assertArrayEquals(createJava17Class(), bytes); + assertArrayEquals(createJava16Class(), bytes); } - private static byte[] createJava17Class() { + private static byte[] createJava16Class() { final ClassWriter cw = new ClassWriter(0); - cw.visit(Opcodes.V16 + 1, 0, "Foo", null, "java/lang/Object", null); + cw.visit(Opcodes.V16, 0, "Foo", null, "java/lang/Object", null); cw.visitEnd(); return cw.toByteArray(); } @@ -128,7 +128,6 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_ assertTrue(InstrSupport.needsFrames(Opcodes.V14)); assertTrue(InstrSupport.needsFrames(Opcodes.V15)); assertTrue(InstrSupport.needsFrames(Opcodes.V16)); - assertTrue(InstrSupport.needsFrames(Opcodes.V16 + 1)); assertTrue(InstrSupport.needsFrames(0x0100)); } diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java index f8ce15039d..a4de1f227e 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java @@ -273,7 +273,7 @@ public static void push(final MethodVisitor mv, final int value) { */ public static ClassReader classReaderFor(final byte[] b) { final int originalVersion = getMajorVersion(b); - if (originalVersion == Opcodes.V16 + 1) { + if (originalVersion == Opcodes.V16) { // temporarily downgrade version to bypass check in ASM setMajorVersion(Opcodes.V16, b); }