From 82f56d678f30169be087acda01d4d6490012390b Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 14:16:19 +0100 Subject: [PATCH 1/6] (WIP) build using JDK 15 Early Access in Travis CI --- .travis.sh | 7 +++++++ .travis.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/.travis.sh b/.travis.sh index 7183debca6..19bb743e01 100755 --- a/.travis.sh +++ b/.travis.sh @@ -72,6 +72,9 @@ case "$JDK" in 14-ea) install_jdk $JDK14_EA_URL ;; +15-ea) + install_jdk $JDK15_EA_URL + ;; esac # Do not use "~/.mavenrc" set by Travis (https://github.com/travis-ci/travis-ci/issues/3893), @@ -107,6 +110,10 @@ case "$JDK" in mvn -V -B -e verify -Dbytecode.version=14 \ --settings=./.travis/settings.xml ;; +15-ea) + mvn -V -B -e verify -Dbytecode.version=15 \ + --settings=./.travis/settings.xml + ;; *) echo "Incorrect JDK [$JDK]" exit 1; diff --git a/.travis.yml b/.travis.yml index 6821a0a2e5..a52886cd6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,5 +30,6 @@ env: - JDK=12 - JDK=13 - JDK=14-ea + - JDK=15-ea script: ./.travis.sh From 5dd2beff2f1421e0a48a16b1f314c064601c92a3 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 14:16:52 +0100 Subject: [PATCH 2/6] (WIP) add Maven profile for compilation into Java 15 bytecode --- org.jacoco.build/pom.xml | 16 +++++++++++++++- org.jacoco.core.test.validation/pom.xml | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml index f234af7c07..b2bf811f26 100644 --- a/org.jacoco.build/pom.xml +++ b/org.jacoco.build/pom.xml @@ -807,7 +807,7 @@ ecj diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml index 2634773efb..1aa6a20715 100644 --- a/org.jacoco.core.test.validation/pom.xml +++ b/org.jacoco.core.test.validation/pom.xml @@ -221,6 +221,31 @@ ../org.jacoco.core.test.validation.scala + + + java15-bytecode + + + bytecode.version + 15 + + + + + 15 + 15 + + + ../org.jacoco.core.test.validation.kotlin + ../org.jacoco.core.test.validation.java7 + ../org.jacoco.core.test.validation.java8 + ../org.jacoco.core.test.validation.java14 + + ../org.jacoco.core.test.validation.scala + + From 96ec5c0ab676a7ca40e69e718c25b7ccb7f3803a Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 15:20:53 +0100 Subject: [PATCH 3/6] (WIP) add unit tests --- .../core/instr/ClassFileVersionsTest.java | 6 +++++ .../core/internal/instr/InstrSupportTest.java | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) 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 941be00821..c1d0360ad3 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.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; @@ -126,6 +127,11 @@ public void test_14() throws IOException { testVersion(V13 + 1, true); } + @Test + public void test_15() throws IOException { + testVersion(V14 + 1, true); + } + private void testVersion(int version, boolean frames) throws IOException { final byte[] original = createClass(version, frames); 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 e9a714c484..ba39c65f14 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,6 +46,31 @@ public void setup() { trace = new TraceMethodVisitor(printer); } + @Test + public void classReaderFor_should_read_java_15_class() { + final byte[] bytes = createJava15Class(); + + final ClassReader classReader = InstrSupport.classReaderFor(bytes); + + classReader.accept(new ClassVisitor(InstrSupport.ASM_API_VERSION) { + @Override + public void visit(final int version, final int access, + final String name, final String signature, + final String superName, final String[] interfaces) { + assertEquals(Opcodes.V14 + 1, version); + } + }, 0); + + assertArrayEquals(createJava15Class(), bytes); + } + + private static byte[] createJava15Class() { + final ClassWriter cw = new ClassWriter(0); + cw.visit(Opcodes.V14 + 1, 0, "Foo", null, "java/lang/Object", null); + cw.visitEnd(); + return cw.toByteArray(); + } + @Test public void classReaderFor_should_read_java_14_class() { final byte[] bytes = createJava14Class(); @@ -130,6 +155,7 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_ assertTrue(InstrSupport.needsFrames(Opcodes.V12)); assertTrue(InstrSupport.needsFrames(Opcodes.V13)); assertTrue(InstrSupport.needsFrames(Opcodes.V13 + 1)); + assertTrue(InstrSupport.needsFrames(Opcodes.V14 + 1)); assertTrue(InstrSupport.needsFrames(0x0100)); } From d3d8b4b1c77b5b7427ffa84a2595d978b70dbe61 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 15:32:24 +0100 Subject: [PATCH 4/6] (WIP) implement --- .../src/org/jacoco/core/analysis/AnalyzerTest.java | 10 +++++----- .../src/org/jacoco/core/instr/InstrumenterTest.java | 10 +++++----- .../org/jacoco/core/internal/instr/InstrSupport.java | 4 ++-- 3 files changed, 12 insertions(+), 12 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 d90d2d55eb..6acb8f5e8e 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.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 @@ private static byte[] createClass(final int version) { */ @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 void testAnalyzeClass_BrokenStream() throws IOException { */ @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 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 59", + assertEquals("Unsupported class file major version 60", e.getCause().getMessage()); } } 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 2639d924fb..e0bdf8614a 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.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 @@ private static byte[] createClass(final int version) { */ @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 void testSerialization() throws Exception { */ @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 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 59", + assertEquals("Unsupported class file major version 60", e.getCause().getMessage()); } } 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 75eed02b43..a9b6f8825b 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.V13 + 1) { + if (originalVersion == Opcodes.V14 + 1) { // temporarily downgrade version to bypass check in ASM - setMajorVersion(Opcodes.V13, b); + setMajorVersion(Opcodes.V14, b); } final ClassReader classReader = new ClassReader(b); setMajorVersion(originalVersion, b); From 7ebbbff391ac1426d134bffb35fc0814076dc38a Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 16:23:05 +0100 Subject: [PATCH 5/6] (WIP) cleanup --- .../core/instr/ClassFileVersionsTest.java | 2 +- .../core/internal/instr/InstrSupportTest.java | 27 +------------------ 2 files changed, 2 insertions(+), 27 deletions(-) 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 c1d0360ad3..b735b467c8 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 @@ -124,7 +124,7 @@ public void test_13() throws IOException { @Test public void test_14() throws IOException { - testVersion(V13 + 1, true); + testVersion(V14, true); } @Test 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 ba39c65f14..c0bd3732e0 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 @@ -71,31 +71,6 @@ private static byte[] createJava15Class() { return cw.toByteArray(); } - @Test - public void classReaderFor_should_read_java_14_class() { - final byte[] bytes = createJava14Class(); - - final ClassReader classReader = InstrSupport.classReaderFor(bytes); - - classReader.accept(new ClassVisitor(InstrSupport.ASM_API_VERSION) { - @Override - 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); - } - }, 0); - - assertArrayEquals(createJava14Class(), bytes); - } - - private static byte[] createJava14Class() { - final ClassWriter cw = new ClassWriter(0); - cw.visit(Opcodes.V13 + 1, 0, "Foo", null, "java/lang/Object", null); - cw.visitEnd(); - return cw.toByteArray(); - } - @Test public void getMajorVersion_should_read_unsigned_two_bytes_at_offset_6() { final byte[] bytes = new byte[] { // @@ -154,7 +129,7 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_ 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)); From 8253065279a01c2a1aa869371a78e1038f61e25d Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 10 Jan 2020 16:48:49 +0100 Subject: [PATCH 6/6] (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 430b23cb7e..8049067ac3 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

    +
  • Experimental support for Java 15 class files + (GitHub #992).
  • Methods toString, hashCode and equals generated by compiler for records are filtered out during generation of report (GitHub #990).