diff options
author | Evgeny Mandrikov <138671+Godin@users.noreply.github.com> | 2019-06-20 22:56:53 +0200 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2019-06-20 22:56:53 +0200 |
commit | 6be65643ccd83d9cb5f87274a192c8296cda8d7f (patch) | |
tree | 2418f56d436dcb2fa7da3af17697eaa4f96ff275 /org.jacoco.core.test/src | |
parent | d32e5b1225fd12d41e75487ee5f9ba0fe8cf288e (diff) | |
download | jacoco-6be65643ccd83d9cb5f87274a192c8296cda8d7f.tar.gz |
Add experimental support for Java 14 class files (#897)
Diffstat (limited to 'org.jacoco.core.test/src')
5 files changed, 31 insertions, 10 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 1e95a5d1..b9350858 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 class AnalyzerTest { @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 9a9bd557..ee525076 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.RETURN; 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 class ClassFileVersionsTest { @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 d5104bcc..9fc70569 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 class InstrumenterTest { @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 a631b52e..e21e4633 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 @@ -166,6 +166,20 @@ public class ContentTypeDetectorTest { } @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); assertEquals(ContentTypeDetector.UNKNOWN, detector.getType()); 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 8345ac1b..d9c707b3 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 class InstrSupportTest { } @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 class InstrSupportTest { 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 class InstrSupportTest { 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)); } |