aboutsummaryrefslogtreecommitdiff
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
parentfbd009930c38344d08fcfe966165afa11412bf25 (diff)
downloadjacoco-b5f1b5d911b4cc21c460b129b895e2a957954f05.tar.gz
Add experimental support for Java 15 class files (#992)
-rwxr-xr-x.travis.sh7
-rw-r--r--.travis.yml1
-rw-r--r--org.jacoco.build/pom.xml16
-rw-r--r--org.jacoco.core.test.validation/pom.xml25
-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
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java4
-rw-r--r--org.jacoco.doc/docroot/doc/changes.html2
10 files changed, 77 insertions, 21 deletions
diff --git a/.travis.sh b/.travis.sh
index 7183debc..19bb743e 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 6821a0a2..a52886cd 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
diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml
index f234af7c..b2bf811f 100644
--- a/org.jacoco.build/pom.xml
+++ b/org.jacoco.build/pom.xml
@@ -807,7 +807,7 @@
</profile>
<!--
- Following profile enables compilation into bytecode version 13
+ Following profiles enable compilation into bytecode version 13
when requested "bytecode.version" greater than 13,
because this is maximum that can be processed by
maven-shade-plugin and maven-plugin-plugin.
@@ -827,6 +827,20 @@
</properties>
</profile>
+ <profile>
+ <id>java15-bytecode</id>
+ <activation>
+ <property>
+ <name>bytecode.version</name>
+ <value>15</value>
+ </property>
+ </activation>
+ <properties>
+ <maven.compiler.source>13</maven.compiler.source>
+ <maven.compiler.target>13</maven.compiler.target>
+ </properties>
+ </profile>
+
<!-- This profile enables use of ECJ -->
<profile>
<id>ecj</id>
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index 2634773e..1aa6a207 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -221,6 +221,31 @@
<module>../org.jacoco.core.test.validation.scala</module>
</modules>
</profile>
+
+ <profile>
+ <id>java15-bytecode</id>
+ <activation>
+ <property>
+ <name>bytecode.version</name>
+ <value>15</value>
+ </property>
+ </activation>
+ <properties>
+ <!-- see respective profile in org.jacoco.build about this override -->
+ <maven.compiler.source>15</maven.compiler.source>
+ <maven.compiler.target>15</maven.compiler.target>
+ </properties>
+ <modules>
+ <module>../org.jacoco.core.test.validation.kotlin</module>
+ <module>../org.jacoco.core.test.validation.java7</module>
+ <module>../org.jacoco.core.test.validation.java8</module>
+ <module>../org.jacoco.core.test.validation.java14</module>
+ <!-- Groovy 2.5.8 doesn't support bytecode version 15
+ <module>../org.jacoco.core.test.validation.groovy</module>
+ -->
+ <module>../org.jacoco.core.test.validation.scala</module>
+ </modules>
+ </profile>
</profiles>
</project>
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));
}
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 75eed02b..a9b6f882 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 final class InstrSupport {
*/
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);
diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html
index 430b23cb..8049067a 100644
--- a/org.jacoco.doc/docroot/doc/changes.html
+++ b/org.jacoco.doc/docroot/doc/changes.html
@@ -22,6 +22,8 @@
<h3>New Features</h3>
<ul>
+ <li>Experimental support for Java 15 class files
+ (GitHub <a href="https://github.com/jacoco/jacoco/issues/992">#992</a>).</li>
<li>Methods <code>toString</code>, <code>hashCode</code> and <code>equals</code>
generated by compiler for records are filtered out during generation of report
(GitHub <a href="https://github.com/jacoco/jacoco/issues/990">#990</a>).</li>