aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2020-01-13 17:56:01 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2020-01-13 16:56:01 +0100
commitb5f1b5d911b4cc21c460b129b895e2a957954f05 (patch)
treebb271b55d1df383dd281ea4529e560d1967f4bbe /org.jacoco.core.test/src/org/jacoco/core
parentfbd009930c38344d08fcfe966165afa11412bf25 (diff)
downloadjacoco-b5f1b5d911b4cc21c460b129b895e2a957954f05.tar.gz
Add experimental support for Java 15 class files (#992)
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java10
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/instr/ClassFileVersionsTest.java8
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java10
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java15
4 files changed, 25 insertions, 18 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 d90d2d55..6acb8f5e 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 class AnalyzerTest {
@Test
public void should_not_modify_class_bytes_to_support_next_version()
throws Exception {
- final byte[] originalBytes = createClass(Opcodes.V13 + 1);
+ final byte[] originalBytes = createClass(Opcodes.V14 + 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 @@ public class AnalyzerTest {
*/
@Test
public void analyzeClass_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V14 + 1);
+ final byte[] bytes = createClass(Opcodes.V14 + 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 59",
+ assertEquals("Unsupported class file major version 60",
e.getCause().getMessage());
}
}
@@ -217,7 +217,7 @@ public class AnalyzerTest {
*/
@Test
public void analyzeAll_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V14 + 1);
+ final byte[] bytes = createClass(Opcodes.V14 + 2);
try {
analyzer.analyzeAll(new ByteArrayInputStream(bytes),
"UnsupportedVersion");
@@ -225,7 +225,7 @@ public class AnalyzerTest {
} catch (IOException e) {
assertEquals("Error while analyzing UnsupportedVersion.",
e.getMessage());
- assertEquals("Unsupported class file major version 59",
+ assertEquals("Unsupported class file major version 60",
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 941be008..b735b467 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
@@ -28,6 +28,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.V14;
import static org.objectweb.asm.Opcodes.V1_1;
import static org.objectweb.asm.Opcodes.V1_2;
import static org.objectweb.asm.Opcodes.V1_3;
@@ -123,7 +124,12 @@ public class ClassFileVersionsTest {
@Test
public void test_14() throws IOException {
- testVersion(V13 + 1, true);
+ testVersion(V14, true);
+ }
+
+ @Test
+ public void test_15() throws IOException {
+ testVersion(V14 + 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 2639d924..e0bdf861 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.V13 + 1);
+ final byte[] originalBytes = createClass(Opcodes.V14 + 1);
final byte[] bytes = new byte[originalBytes.length];
System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length);
final long expectedClassId = CRC64.classId(bytes);
@@ -121,14 +121,14 @@ public class InstrumenterTest {
*/
@Test
public void instrument_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V14 + 1);
+ final byte[] bytes = createClass(Opcodes.V14 + 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 59",
+ assertEquals("Unsupported class file major version 60",
e.getCause().getMessage());
}
}
@@ -223,7 +223,7 @@ public class InstrumenterTest {
*/
@Test
public void instrumentAll_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V14 + 1);
+ final byte[] bytes = createClass(Opcodes.V14 + 2);
try {
instrumenter.instrumentAll(new ByteArrayInputStream(bytes),
new ByteArrayOutputStream(), "UnsupportedVersion");
@@ -231,7 +231,7 @@ public class InstrumenterTest {
} catch (final IOException e) {
assertEquals("Error while instrumenting UnsupportedVersion.",
e.getMessage());
- assertEquals("Unsupported class file major version 59",
+ assertEquals("Unsupported class file major version 60",
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 e9a714c4..c0bd3732 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
@@ -47,8 +47,8 @@ public class InstrSupportTest {
}
@Test
- public void classReaderFor_should_read_java_14_class() {
- final byte[] bytes = createJava14Class();
+ public void classReaderFor_should_read_java_15_class() {
+ final byte[] bytes = createJava15Class();
final ClassReader classReader = InstrSupport.classReaderFor(bytes);
@@ -57,16 +57,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.V13 + 1, version);
+ assertEquals(Opcodes.V14 + 1, version);
}
}, 0);
- assertArrayEquals(createJava14Class(), bytes);
+ assertArrayEquals(createJava15Class(), bytes);
}
- private static byte[] createJava14Class() {
+ private static byte[] createJava15Class() {
final ClassWriter cw = new ClassWriter(0);
- cw.visit(Opcodes.V13 + 1, 0, "Foo", null, "java/lang/Object", null);
+ cw.visit(Opcodes.V14 + 1, 0, "Foo", null, "java/lang/Object", null);
cw.visitEnd();
return cw.toByteArray();
}
@@ -129,7 +129,8 @@ public class InstrSupportTest {
assertTrue(InstrSupport.needsFrames(Opcodes.V11));
assertTrue(InstrSupport.needsFrames(Opcodes.V12));
assertTrue(InstrSupport.needsFrames(Opcodes.V13));
- assertTrue(InstrSupport.needsFrames(Opcodes.V13 + 1));
+ assertTrue(InstrSupport.needsFrames(Opcodes.V14));
+ assertTrue(InstrSupport.needsFrames(Opcodes.V14 + 1));
assertTrue(InstrSupport.needsFrames(0x0100));
}