aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Mandrikov <Godin@users.noreply.github.com>2016-08-01 09:25:51 +0200
committerGitHub <noreply@github.com>2016-08-01 09:25:51 +0200
commitc6f2b6b7e887eb645b8aba928ff0134cfe66ec28 (patch)
treea7fa83baa5313ec0660e8b2856e6bda21568ac61
parent8f05e7c58610d31ae322e82f34e55722a6c47bd4 (diff)
downloadjacoco-c6f2b6b7e887eb645b8aba928ff0134cfe66ec28.tar.gz
Execute core tests with bytecode version 9 (#411)
And build using two different versions of JDK 9 EA in Travis: * `9-ea` - currently under testing and hence failures are allowed while we investigate them * `9-ea-stable` - tested previously and hence failures are not allowed, so that to verify that new changes do not introduce regressions For example fixes on our side were required for the changes introduced in JDK 9 EA b119 and b122 and still required for b127.
-rwxr-xr-x.travis.sh7
-rw-r--r--.travis.yml1
-rw-r--r--org.jacoco.build/pom.xml31
-rw-r--r--org.jacoco.core.test/pom.xml6
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java6
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/CyclomaticComplexityTest.java15
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/FramesTest.java4
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java4
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java24
9 files changed, 72 insertions, 26 deletions
diff --git a/.travis.sh b/.travis.sh
index aaa26e73..d75ce17d 100755
--- a/.travis.sh
+++ b/.travis.sh
@@ -52,6 +52,9 @@ case "$JDK" in
9-ea)
install_jdk $JDK9_EA_URL
;;
+9-ea-stable)
+ install_jdk $JDK9_EA_STABLE_URL
+ ;;
esac
# Do not use "~/.mavenrc" set by Travis (https://github.com/travis-ci/travis-ci/issues/3893),
@@ -81,9 +84,9 @@ case "$JDK" in
8 | 8-ea)
mvn -V -B -e verify -Dbytecode.version=1.8
;;
-9-ea)
+9-ea | 9-ea-stable)
# see https://bugs.openjdk.java.net/browse/JDK-8131041 about "java.locale.providers"
- mvn -V -B -e verify -Dbytecode.version=1.8 \
+ mvn -V -B -e verify -Dbytecode.version=1.9 \
-DargLine=-Djava.locale.providers=JRE,SPI
;;
*)
diff --git a/.travis.yml b/.travis.yml
index 11a0f9a5..36ea75d0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,7 @@ env:
- JDK=8
- JDK=8-ea
- JDK=9-ea
+ - JDK=9-ea-stable
matrix:
allow_failures:
diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml
index cf6a2abc..667b32ec 100644
--- a/org.jacoco.build/pom.xml
+++ b/org.jacoco.build/pom.xml
@@ -654,6 +654,24 @@
<maven.compiler.target>${bytecode.version}</maven.compiler.target>
</properties>
</profile>
+ <profile>
+ <id>java9-validation</id>
+ <activation>
+ <property>
+ <name>bytecode.version</name>
+ <value>1.9</value>
+ </property>
+ </activation>
+ <properties>
+ <!--
+ Compile into bytecode version 8 by default,
+ because maven-shade-plugin and maven-plugin-plugin are unable to proceess bytecode version 9,
+ this is overridden for tests
+ -->
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+ </profile>
<profile>
<id>jdk16</id>
@@ -695,6 +713,19 @@
</profile>
<profile>
+ <id>jdk9</id>
+ <activation>
+ <property>
+ <name>jdk.version</name>
+ <value>1.9</value>
+ </property>
+ </activation>
+ <properties>
+ <jvm.args>-XX:-FailOverToOldVerifier -Xverify:all</jvm.args>
+ </properties>
+ </profile>
+
+ <profile>
<id>sign</id>
<activation>
<property>
diff --git a/org.jacoco.core.test/pom.xml b/org.jacoco.core.test/pom.xml
index 4b0a23c0..d72a22eb 100644
--- a/org.jacoco.core.test/pom.xml
+++ b/org.jacoco.core.test/pom.xml
@@ -37,7 +37,7 @@
<artifactId>junit</artifactId>
</dependency>
</dependencies>
-
+
<profiles>
<profile>
<id>java8-validation</id>
@@ -73,11 +73,15 @@
<profile>
<id>java9-validation</id>
<activation>
+ <!-- for some reason activation should be presented here, even if already defined in parent -->
<property>
<name>bytecode.version</name>
<value>1.9</value>
</property>
</activation>
+ <properties>
+ <maven.compiler.target>1.9</maven.compiler.target>
+ </properties>
<build>
<plugins>
<plugin>
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 89ed34b4..f834810a 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
@@ -36,6 +36,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.jacoco.core.data.ExecutionDataStore;
+import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.internal.data.CRC64;
import org.jacoco.core.test.TargetLoader;
import org.junit.Before;
@@ -91,8 +92,9 @@ public class AnalyzerTest {
@Test
public void testAnalyzeClassIdMatch() throws IOException {
- final byte[] bytes = TargetLoader
- .getClassDataAsBytes(AnalyzerTest.class);
+ // class IDs are always calculated after downgrade of the version
+ final byte[] bytes = Java9Support.downgradeIfRequired(
+ TargetLoader.getClassDataAsBytes(AnalyzerTest.class));
executionData.get(Long.valueOf(CRC64.checksum(bytes)),
"org/jacoco/core/analysis/AnalyzerTest", 200);
analyzer.analyzeClass(bytes, "Test");
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/CyclomaticComplexityTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/CyclomaticComplexityTest.java
index bfa28146..db631823 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/CyclomaticComplexityTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/CyclomaticComplexityTest.java
@@ -14,6 +14,7 @@ package org.jacoco.core.test.validation;
import static org.jacoco.core.test.validation.targets.Stubs.nop;
import static org.junit.Assert.assertEquals;
+import java.io.IOException;
import java.util.Collection;
import org.jacoco.core.analysis.Analyzer;
@@ -32,7 +33,6 @@ import org.jacoco.core.test.TargetLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.objectweb.asm.ClassReader;
/**
* Various tests for cyclomatic complexity of methods.
@@ -45,7 +45,7 @@ public class CyclomaticComplexityTest {
private RuntimeData data;
private IRuntime runtime;
- private ClassReader reader;
+ private byte[] bytes;
private Target target;
@Before
@@ -253,18 +253,19 @@ public class CyclomaticComplexityTest {
private void instrument(final Class<? extends Target> clazz)
throws Exception {
- reader = new ClassReader(TargetLoader.getClassData(clazz));
- final byte[] bytes = new Instrumenter(runtime).instrument(reader);
+ bytes = TargetLoader.getClassDataAsBytes(clazz);
+ final byte[] instrumented = new Instrumenter(runtime).instrument(bytes,
+ "TestTarget");
final TargetLoader loader = new TargetLoader();
- target = (Target) loader.add(clazz, bytes).newInstance();
+ target = (Target) loader.add(clazz, instrumented).newInstance();
}
- private ICounter analyze() {
+ private ICounter analyze() throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final ExecutionDataStore store = new ExecutionDataStore();
data.collect(store, new SessionInfoStore(), false);
final Analyzer analyzer = new Analyzer(store, builder);
- analyzer.analyzeClass(reader);
+ analyzer.analyzeClass(bytes, "TestTarget");
final Collection<IClassCoverage> classes = builder.getClasses();
assertEquals(1, classes.size(), 0.0);
final IClassCoverage classCoverage = classes.iterator().next();
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/FramesTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/FramesTest.java
index cc8d6c97..cf3f7b0a 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/FramesTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/FramesTest.java
@@ -19,6 +19,7 @@ import java.io.StringWriter;
import org.jacoco.core.JaCoCo;
import org.jacoco.core.instr.Instrumenter;
+import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.jacoco.core.test.TargetLoader;
@@ -87,7 +88,8 @@ public class FramesTest {
}
private byte[] calculateFrames(byte[] source) {
- ClassReader rc = new ClassReader(source);
+ ClassReader rc = new ClassReader(
+ Java9Support.downgradeIfRequired(source));
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
// Adjust Version to 1.6 to enable frames:
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java
index eb2083f0..071b7f2e 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StructuredLockingTest.java
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Set;
import org.jacoco.core.instr.Instrumenter;
+import org.jacoco.core.internal.Java9Support;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.jacoco.core.test.TargetLoader;
@@ -63,7 +64,8 @@ public class StructuredLockingTest {
byte[] instrumented = instrumenter.instrument(source, "TestTarget");
ClassNode cn = new ClassNode();
- new ClassReader(instrumented).accept(cn, 0);
+ new ClassReader(Java9Support.downgradeIfRequired(instrumented))
+ .accept(cn, 0);
for (MethodNode mn : cn.methods) {
assertStructuredLocking(cn.name, mn);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
index a3ecabea..5216a057 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
@@ -13,6 +13,7 @@ package org.jacoco.core.test.validation;
import static org.junit.Assert.assertEquals;
+import java.io.IOException;
import java.util.Collection;
import org.jacoco.core.analysis.Analyzer;
@@ -30,7 +31,6 @@ import org.jacoco.core.runtime.RuntimeData;
import org.jacoco.core.runtime.SystemPropertiesRuntime;
import org.jacoco.core.test.TargetLoader;
import org.junit.Before;
-import org.objectweb.asm.ClassReader;
/**
* Base class for validation tests. It executes the given class under code
@@ -71,20 +71,20 @@ public abstract class ValidationTestBase {
@Before
public void setup() throws Exception {
loader = new TargetLoader();
- final ClassReader reader = new ClassReader(
- TargetLoader.getClassData(target));
- final ExecutionDataStore store = execute(reader);
- analyze(reader, store);
+ final byte[] bytes = TargetLoader.getClassDataAsBytes(target);
+ final ExecutionDataStore store = execute(bytes);
+ analyze(bytes, store);
source = Source.getSourceFor(srcFolder, target);
}
- private ExecutionDataStore execute(final ClassReader reader)
- throws Exception {
+ private ExecutionDataStore execute(final byte[] bytes) throws Exception {
RuntimeData data = new RuntimeData();
IRuntime runtime = new SystemPropertiesRuntime();
runtime.startup(data);
- final byte[] bytes = new Instrumenter(runtime).instrument(reader);
- run(loader.add(target, bytes));
+
+ final byte[] instrumented = new Instrumenter(runtime).instrument(bytes,
+ "TestTarget");
+ run(loader.add(target, instrumented));
final ExecutionDataStore store = new ExecutionDataStore();
data.collect(store, new SessionInfoStore(), false);
runtime.shutdown();
@@ -93,11 +93,11 @@ public abstract class ValidationTestBase {
protected abstract void run(final Class<?> targetClass) throws Exception;
- private void analyze(final ClassReader reader,
- final ExecutionDataStore store) {
+ private void analyze(final byte[] bytes, final ExecutionDataStore store)
+ throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(store, builder);
- analyzer.analyzeClass(reader);
+ analyzer.analyzeClass(bytes, "TestTarget");
final Collection<IClassCoverage> classes = builder.getClasses();
assertEquals(1, classes.size(), 0.0);
classCoverage = classes.iterator().next();