From 03b6942c6cced1ecaff743e53ce721adb931dba5 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 18 Jun 2019 11:38:47 +0200 Subject: [PATCH 1/2] (WIP) implement --- .../org/jacoco/core/analysis/AnalyzerTest.java | 2 +- .../jacoco/core/instr/ClassFileVersionsTest.java | 8 +++++++- .../org/jacoco/core/instr/InstrumenterTest.java | 2 +- .../core/internal/ContentTypeDetectorTest.java | 14 ++++++++++++++ .../core/internal/instr/InstrSupportTest.java | 15 ++++++++------- .../jacoco/core/internal/ContentTypeDetector.java | 6 ++++-- .../jacoco/core/internal/instr/InstrSupport.java | 4 ++-- 7 files changed, 37 insertions(+), 14 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 1e95a5d144..b93508582f 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 @@ -106,7 +106,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.V12 + 1); + final byte[] originalBytes = createClass(Opcodes.V13 + 1); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); 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 9a9bd557de..ee5250769c 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 @@ -26,6 +26,7 @@ import static org.objectweb.asm.Opcodes.V10; import static org.objectweb.asm.Opcodes.V11; import static org.objectweb.asm.Opcodes.V12; +import static org.objectweb.asm.Opcodes.V13; import static org.objectweb.asm.Opcodes.V1_1; import static org.objectweb.asm.Opcodes.V1_2; import static org.objectweb.asm.Opcodes.V1_3; @@ -116,7 +117,12 @@ public void test_12() throws IOException { @Test public void test_13() throws IOException { - testVersion(V12 + 1, true); + testVersion(V13, true); + } + + @Test + public void test_14() throws IOException { + testVersion(V13 + 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 d5104bcc89..9fc7056958 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 @@ -98,7 +98,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.V12 + 1); + final byte[] originalBytes = createClass(Opcodes.V13 + 1); final byte[] bytes = new byte[originalBytes.length]; System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length); final long expectedClassId = CRC64.classId(bytes); diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java index a631b52ecf..e21e463354 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java @@ -165,6 +165,20 @@ public void should_detect_java_13_with_preview_features() throws IOException { assertContent(); } + @Test + public void should_detect_java_14() throws IOException { + initData(0xCA, 0xFE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x3A); + assertEquals(ContentTypeDetector.CLASSFILE, detector.getType()); + assertContent(); + } + + @Test + public void should_detect_java_14_with_preview_features() throws IOException { + initData(0xCA, 0xFE, 0xBA, 0xBE, 0xFF, 0xFF, 0x00, 0x3A); + assertEquals(ContentTypeDetector.CLASSFILE, detector.getType()); + assertContent(); + } + @Test public void testMachObjectFile() throws IOException { initData(0xCA, 0xFE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x02); 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 8345ac1b63..d9c707b338 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 @@ -46,8 +46,8 @@ public void setup() { } @Test - public void classReaderFor_should_read_java_13_class() { - final byte[] bytes = createJava13Class(); + public void classReaderFor_should_read_java_14_class() { + final byte[] bytes = createJava14Class(); final ClassReader classReader = InstrSupport.classReaderFor(bytes); @@ -56,16 +56,16 @@ public void classReaderFor_should_read_java_13_class() { public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { - assertEquals(Opcodes.V12 + 1, version); + assertEquals(Opcodes.V13 + 1, version); } }, 0); - assertArrayEquals(createJava13Class(), bytes); + assertArrayEquals(createJava14Class(), bytes); } - private static byte[] createJava13Class() { + private static byte[] createJava14Class() { final ClassWriter cw = new ClassWriter(0); - cw.visit(Opcodes.V12 + 1, 0, "Foo", null, "java/lang/Object", null); + cw.visit(Opcodes.V13 + 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.V10)); assertTrue(InstrSupport.needsFrames(Opcodes.V11)); assertTrue(InstrSupport.needsFrames(Opcodes.V12)); - assertTrue(InstrSupport.needsFrames(Opcodes.V12 + 1)); + assertTrue(InstrSupport.needsFrames(Opcodes.V13)); + assertTrue(InstrSupport.needsFrames(Opcodes.V13 + 1)); assertTrue(InstrSupport.needsFrames(0x0100)); } diff --git a/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java b/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java index 74574ecc81..4e5641f959 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/ContentTypeDetector.java @@ -88,8 +88,10 @@ private static int determineType(final InputStream in) throws IOException { case Opcodes.V11 | Opcodes.V_PREVIEW: case Opcodes.V12: case Opcodes.V12 | Opcodes.V_PREVIEW: - case (Opcodes.V12 + 1): - case (Opcodes.V12 + 1) | Opcodes.V_PREVIEW: + case Opcodes.V13: + case Opcodes.V13 | Opcodes.V_PREVIEW: + case (Opcodes.V13 + 1): + case (Opcodes.V13 + 1) | Opcodes.V_PREVIEW: return CLASSFILE; } } 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 85e83a3a81..b06d3473f4 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 @@ -272,9 +272,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.V12 + 1) { + if (originalVersion == Opcodes.V13 + 1) { // temporarily downgrade version to bypass check in ASM - setMajorVersion(Opcodes.V12, b); + setMajorVersion(Opcodes.V13, b); } final ClassReader classReader = new ClassReader(b); setMajorVersion(originalVersion, b); From 3787486cbe5229a034e10de4af3d137e1b48cc3b Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 18 Jun 2019 12:00:03 +0200 Subject: [PATCH 2/2] (WIP) update changelog --- org.jacoco.doc/docroot/doc/changes.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 979fd74785..9211acd2ac 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -22,6 +22,8 @@

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

New Features