Why can't JaCoCo simply use the class name to identify classes?
runtime — e.g. different method ordering or additional branches —
we would end-up with different probes. For example the probe at index
i would be in method a() and not in method
- b(). Obviously this will create random coverage results.
+ b(). Obviously this will create random coverage results.
Why do I get an error when I try to analyze multiple versions of the same
From 92628445bb5e0b88fadf6a1337969e9dced02336 Mon Sep 17 00:00:00 2001
From: "Marc R. Hoffmann"
Date: Fri, 28 May 2021 02:06:55 +0200
Subject: [PATCH 06/26] Add module for Java 16 validation tests (#1165)
Records and Pattern Matching for instanceof are finalized in Java 16,
so no need to test them as preview features in earlier versions.
---
.../pom.xml | 20 ----------
.../.classpath | 20 ++++++++++
.../.project | 30 ++++++++++++++
.../pom.xml | 39 +++++++++++++++++++
.../validation/java16}/InstanceofTest.java | 14 +------
.../test/validation/java16}/RecordsTest.java | 4 +-
.../java16}/targets/InstanceofTarget.java | 7 ++--
.../java16}/targets/RecordsTarget.java | 5 ++-
org.jacoco.core.test.validation/pom.xml | 1 +
org.jacoco.doc/docroot/doc/build.html | 15 +++++++
10 files changed, 116 insertions(+), 39 deletions(-)
create mode 100644 org.jacoco.core.test.validation.java16/.classpath
create mode 100644 org.jacoco.core.test.validation.java16/.project
create mode 100644 org.jacoco.core.test.validation.java16/pom.xml
rename {org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14 => org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16}/InstanceofTest.java (65%)
rename {org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14 => org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16}/RecordsTest.java (87%)
rename {org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14 => org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16}/targets/InstanceofTarget.java (77%)
rename {org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14 => org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16}/targets/RecordsTarget.java (88%)
diff --git a/org.jacoco.core.test.validation.java14/pom.xml b/org.jacoco.core.test.validation.java14/pom.xml
index 6ab698ea14..69ccfbc7a3 100644
--- a/org.jacoco.core.test.validation.java14/pom.xml
+++ b/org.jacoco.core.test.validation.java14/pom.xml
@@ -36,24 +36,4 @@
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- --enable-preview
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- --enable-preview
-
-
-
-
diff --git a/org.jacoco.core.test.validation.java16/.classpath b/org.jacoco.core.test.validation.java16/.classpath
new file mode 100644
index 0000000000..a91bd22121
--- /dev/null
+++ b/org.jacoco.core.test.validation.java16/.classpath
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.jacoco.core.test.validation.java16/.project b/org.jacoco.core.test.validation.java16/.project
new file mode 100644
index 0000000000..9a11aebf29
--- /dev/null
+++ b/org.jacoco.core.test.validation.java16/.project
@@ -0,0 +1,30 @@
+
+
+ org.jacoco.core.test.validation.java16
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.jdt.core.javanature
+
+
+
+ .settings
+ 2
+ PARENT-1-PROJECT_LOC/org.jacoco.core.test/.settings
+
+
+
diff --git a/org.jacoco.core.test.validation.java16/pom.xml b/org.jacoco.core.test.validation.java16/pom.xml
new file mode 100644
index 0000000000..025abc8cbb
--- /dev/null
+++ b/org.jacoco.core.test.validation.java16/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+ 4.0.0
+
+
+ org.jacoco
+ org.jacoco.core.test.validation
+ 0.8.8-SNAPSHOT
+ ../org.jacoco.core.test.validation
+
+
+ org.jacoco.core.test.validation.java16
+
+ JaCoCo :: Test :: Core :: Validation Java 16
+
+
+ 16
+
+
+
+
+ ${project.groupId}
+ org.jacoco.core.test
+ ${project.version}
+
+
+
+
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/InstanceofTest.java b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/InstanceofTest.java
similarity index 65%
rename from org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/InstanceofTest.java
rename to org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/InstanceofTest.java
index 09a7db34da..d7d2ad7b41 100644
--- a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/InstanceofTest.java
+++ b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/InstanceofTest.java
@@ -10,11 +10,10 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
-package org.jacoco.core.test.validation.java14;
+package org.jacoco.core.test.validation.java16;
-import org.jacoco.core.test.validation.Source.Line;
import org.jacoco.core.test.validation.ValidationTestBase;
-import org.jacoco.core.test.validation.java14.targets.InstanceofTarget;
+import org.jacoco.core.test.validation.java16.targets.InstanceofTarget;
/**
* Test of code coverage in {@link InstanceofTarget}.
@@ -25,13 +24,4 @@ public InstanceofTest() {
super(InstanceofTarget.class);
}
- public void assertInstanceof(final Line line) {
- if (isJDKCompiler && JAVA_VERSION.isBefore("15")) {
- // https://bugs.openjdk.java.net/browse/JDK-8237528
- assertFullyCovered(line, 1, 3);
- } else {
- assertFullyCovered(line, 0, 2);
- }
- }
-
}
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/RecordsTest.java b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/RecordsTest.java
similarity index 87%
rename from org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/RecordsTest.java
rename to org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/RecordsTest.java
index 7e93f50d19..c11731eec1 100644
--- a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/RecordsTest.java
+++ b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/RecordsTest.java
@@ -10,10 +10,10 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
-package org.jacoco.core.test.validation.java14;
+package org.jacoco.core.test.validation.java16;
import org.jacoco.core.test.validation.ValidationTestBase;
-import org.jacoco.core.test.validation.java14.targets.RecordsTarget;
+import org.jacoco.core.test.validation.java16.targets.RecordsTarget;
/**
* Test of code coverage for records.
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/InstanceofTarget.java b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/InstanceofTarget.java
similarity index 77%
rename from org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/InstanceofTarget.java
rename to org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/InstanceofTarget.java
index 3058295dce..1b44c3a46d 100644
--- a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/InstanceofTarget.java
+++ b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/InstanceofTarget.java
@@ -10,17 +10,18 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
-package org.jacoco.core.test.validation.java14.targets;
+package org.jacoco.core.test.validation.java16.targets;
import static org.jacoco.core.test.validation.targets.Stubs.nop;
/**
- * This target exercises pattern matching for instanceof (JEP 305).
+ * This target exercises pattern matching for instanceof
+ * (JEP 394).
*/
public class InstanceofTarget {
private static void ifInstanceof(Object e) {
- if (e instanceof String s) { // assertInstanceof()
+ if (e instanceof String s) { // assertFullyCovered(0, 2)
nop(s);
}
}
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/RecordsTarget.java b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/RecordsTarget.java
similarity index 88%
rename from org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/RecordsTarget.java
rename to org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/RecordsTarget.java
index 4667c5bb0d..37e60ecf6f 100644
--- a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/RecordsTarget.java
+++ b/org.jacoco.core.test.validation.java16/src/org/jacoco/core/test/validation/java16/targets/RecordsTarget.java
@@ -10,10 +10,11 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
-package org.jacoco.core.test.validation.java14.targets;
+package org.jacoco.core.test.validation.java16.targets;
/**
- * This target exercises records.
+ * This target exercises records
+ * (JEP 395).
*/
public class RecordsTarget {
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index 72ba3a23bb..f79d75e3e3 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -307,6 +307,7 @@
../org.jacoco.core.test.validation.java7../org.jacoco.core.test.validation.java8../org.jacoco.core.test.validation.java14
+ ../org.jacoco.core.test.validation.java16../org.jacoco.core.test.validation.groovy../org.jacoco.core.test.validation.scala
diff --git a/org.jacoco.doc/docroot/doc/build.html b/org.jacoco.doc/docroot/doc/build.html
index 5cd0aef3f8..f51d3823ba 100644
--- a/org.jacoco.doc/docroot/doc/build.html
+++ b/org.jacoco.doc/docroot/doc/build.html
@@ -96,6 +96,21 @@
Compilation and testing with different JDKs
+
+
org.jacoco.core.test.validation.java16
+
+
+
+
+
+
+
+
+
+
+
+
16
+
org.jacoco.core.test.validation.java14
From ec70eb541073805299c96f94c6d37d3778e8e4c8 Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Fri, 28 May 2021 06:30:39 +0200
Subject: [PATCH 07/26] Add org.jacoco.core.test.validation.java16 to profile
java17-bytecode (#1194)
---
org.jacoco.core.test.validation/pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index f79d75e3e3..b2a27109bd 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -335,6 +335,7 @@
../org.jacoco.core.test.validation.java7../org.jacoco.core.test.validation.java8../org.jacoco.core.test.validation.java14
+ ../org.jacoco.core.test.validation.java16../org.jacoco.core.test.validation.groovy../org.jacoco.core.test.validation.scala
From 5d24b063ba56dd62558a9998a46687a8e78274f4 Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Thu, 10 Jun 2021 10:45:28 +0200
Subject: [PATCH 08/26] Add filter for Java assert statement (#1196)
---
.../test/validation/java5/AssertTest.java | 27 ++++
.../java5/targets/AssertTarget.java | 29 ++++
.../analysis/filter/AbstractMatcherTest.java | 36 +++++
.../analysis/filter/AssertFilterTest.java | 145 ++++++++++++++++++
.../test/validation/ValidationTestBase.java | 1 +
.../analysis/filter/AbstractMatcher.java | 20 +++
.../analysis/filter/AssertFilter.java | 66 ++++++++
.../internal/analysis/filter/Filters.java | 2 +-
org.jacoco.doc/docroot/doc/changes.html | 7 +
9 files changed, 332 insertions(+), 1 deletion(-)
create mode 100644 org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/AssertTest.java
create mode 100644 org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/targets/AssertTarget.java
create mode 100644 org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AssertFilterTest.java
create mode 100644 org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AssertFilter.java
diff --git a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/AssertTest.java b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/AssertTest.java
new file mode 100644
index 0000000000..780b2fdb31
--- /dev/null
+++ b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/AssertTest.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java5;
+
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java5.targets.AssertTarget;
+
+/**
+ * Test of code coverage in {@link AssertTarget}.
+ */
+public class AssertTest extends ValidationTestBase {
+
+ public AssertTest() {
+ super(AssertTarget.class);
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/targets/AssertTarget.java b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/targets/AssertTarget.java
new file mode 100644
index 0000000000..316cfc7735
--- /dev/null
+++ b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/targets/AssertTarget.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java5.targets;
+
+import static org.jacoco.core.test.validation.targets.Stubs.t;
+
+/**
+ * This target exercises assert statement.
+ */
+public class AssertTarget { // assertFullyCovered()
+
+ private AssertTarget() {
+ }
+
+ public static void main(String[] args) {
+ assert t() : "msg"; // assertPartlyCovered(1, 1)
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
index be11d7e318..2aeb3d8e1a 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
@@ -137,6 +137,42 @@ public void nextIsVar() {
matcher.nextIsVar(Opcodes.ILOAD, "name");
}
+ @Test
+ public void nextIsField() {
+ m.visitInsn(Opcodes.NOP);
+ m.visitFieldInsn(Opcodes.PUTSTATIC, "owner", "name", "Z");
+
+ // should set cursor to null when opcode mismatch
+ matcher.cursor = m.instructions.getFirst();
+ matcher.nextIsField(Opcodes.GETSTATIC, "owner", "name", "Z");
+ assertNull(matcher.cursor);
+
+ // should set cursor to null when owner mismatch
+ matcher.cursor = m.instructions.getFirst();
+ matcher.nextIsField(Opcodes.PUTSTATIC, "another_owner", "name", "Z");
+ assertNull(matcher.cursor);
+
+ // should set cursor to null when name mismatch
+ matcher.cursor = m.instructions.getFirst();
+ matcher.nextIsField(Opcodes.PUTSTATIC, "owner", "another_name", "Z");
+ assertNull(matcher.cursor);
+
+ // should set cursor to null when descriptor mismatch
+ matcher.cursor = m.instructions.getFirst();
+ matcher.nextIsField(Opcodes.PUTSTATIC, "owner", "name",
+ "another_descriptor");
+ assertNull(matcher.cursor);
+
+ // should set cursor to next instruction when match
+ matcher.cursor = m.instructions.getFirst();
+ matcher.nextIsField(Opcodes.PUTSTATIC, "owner", "name", "Z");
+ assertSame(m.instructions.getLast(), matcher.cursor);
+
+ // should not do anything when cursor is null
+ matcher.cursor = null;
+ matcher.nextIsField(Opcodes.PUTSTATIC, "owner", "name", "Z");
+ }
+
@Test
public void nextIsInvoke() {
m.visitInsn(Opcodes.NOP);
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AssertFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AssertFilterTest.java
new file mode 100644
index 0000000000..52803c9a12
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AssertFilterTest.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.internal.analysis.filter;
+
+import org.jacoco.core.internal.instr.InstrSupport;
+import org.junit.Test;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.MethodNode;
+
+/**
+ * Unit tests for {@link AssertFilter}.
+ */
+public class AssertFilterTest extends FilterTestBase {
+
+ private final AssertFilter filter = new AssertFilter();
+
+ /**
+ *
+ * class Example {
+ * void example(boolean b) {
+ * ...
+ * assert b : "message";
+ * ...
+ * }
+ * }
+ *
+ */
+ @Test
+ public void should_filter_static_initializer() {
+ context.className = "Example";
+ final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION,
+ Opcodes.ACC_STATIC, "", "()V", null, null);
+
+ m.visitLdcInsn(Type.getType("LExample;"));
+ final Range range = new Range();
+ range.fromInclusive = m.instructions.getLast();
+ m.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Class",
+ "desiredAssertionStatus", "()Z", false);
+ final Label label1 = new Label();
+ final Label label2 = new Label();
+ m.visitJumpInsn(Opcodes.IFNE, label1);
+ m.visitInsn(Opcodes.ICONST_1);
+ m.visitJumpInsn(Opcodes.GOTO, label2);
+ m.visitLabel(label1);
+ m.visitInsn(Opcodes.ICONST_0);
+ m.visitLabel(label2);
+ m.visitFieldInsn(Opcodes.PUTSTATIC, "Example", "$assertionsDisabled",
+ "Z");
+ range.toInclusive = m.instructions.getLast();
+ m.visitInsn(Opcodes.RETURN);
+
+ filter.filter(m, context, output);
+
+ assertIgnored(range);
+ }
+
+ /**
+ *
+ * class Example {
+ * static final f;
+ *
+ * static {
+ * f = !Example.class.desiredAssertionStatus();
+ * }
+ * }
+ *
From 1c113ffbf7018962b8837719279ba0ca8c052de2 Mon Sep 17 00:00:00 2001
From: "Marc R. Hoffmann"
Date: Mon, 5 Jul 2021 23:06:00 +0200
Subject: [PATCH 12/26] Add `org.jacoco.core.test` to `dependencyManagement`
The module `org.jacoco.core.test` provides test tools for other tests
modules and is used as a dependency in several places.
---
org.jacoco.core.test.validation.groovy/pom.xml | 1 -
org.jacoco.core.test.validation.java14/pom.xml | 1 -
org.jacoco.core.test.validation.java5/pom.xml | 1 -
org.jacoco.core.test.validation.java7/pom.xml | 1 -
org.jacoco.core.test.validation.java8/pom.xml | 1 -
org.jacoco.core.test.validation.kotlin/pom.xml | 1 -
org.jacoco.core.test.validation.scala/pom.xml | 1 -
org.jacoco.tests/pom.xml | 10 ++++++++++
8 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/org.jacoco.core.test.validation.groovy/pom.xml b/org.jacoco.core.test.validation.groovy/pom.xml
index 53251d2a7c..a90dc05c55 100644
--- a/org.jacoco.core.test.validation.groovy/pom.xml
+++ b/org.jacoco.core.test.validation.groovy/pom.xml
@@ -34,7 +34,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}org.codehaus.groovy
diff --git a/org.jacoco.core.test.validation.java14/pom.xml b/org.jacoco.core.test.validation.java14/pom.xml
index 69ccfbc7a3..5cafab35fa 100644
--- a/org.jacoco.core.test.validation.java14/pom.xml
+++ b/org.jacoco.core.test.validation.java14/pom.xml
@@ -32,7 +32,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}
diff --git a/org.jacoco.core.test.validation.java5/pom.xml b/org.jacoco.core.test.validation.java5/pom.xml
index 6436d4da4b..e81022b97f 100644
--- a/org.jacoco.core.test.validation.java5/pom.xml
+++ b/org.jacoco.core.test.validation.java5/pom.xml
@@ -28,7 +28,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}
diff --git a/org.jacoco.core.test.validation.java7/pom.xml b/org.jacoco.core.test.validation.java7/pom.xml
index 5ab6494d70..071382a892 100644
--- a/org.jacoco.core.test.validation.java7/pom.xml
+++ b/org.jacoco.core.test.validation.java7/pom.xml
@@ -32,7 +32,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}
diff --git a/org.jacoco.core.test.validation.java8/pom.xml b/org.jacoco.core.test.validation.java8/pom.xml
index 039e9bfe60..7a838d5f58 100644
--- a/org.jacoco.core.test.validation.java8/pom.xml
+++ b/org.jacoco.core.test.validation.java8/pom.xml
@@ -32,7 +32,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}
diff --git a/org.jacoco.core.test.validation.kotlin/pom.xml b/org.jacoco.core.test.validation.kotlin/pom.xml
index fa64fc1bf2..533210c84a 100644
--- a/org.jacoco.core.test.validation.kotlin/pom.xml
+++ b/org.jacoco.core.test.validation.kotlin/pom.xml
@@ -32,7 +32,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}org.jetbrains.kotlin
diff --git a/org.jacoco.core.test.validation.scala/pom.xml b/org.jacoco.core.test.validation.scala/pom.xml
index c2bb537be4..d2be27710f 100644
--- a/org.jacoco.core.test.validation.scala/pom.xml
+++ b/org.jacoco.core.test.validation.scala/pom.xml
@@ -32,7 +32,6 @@
${project.groupId}org.jacoco.core.test
- ${project.version}org.scala-lang
diff --git a/org.jacoco.tests/pom.xml b/org.jacoco.tests/pom.xml
index 56636c427a..1f31ce9e71 100644
--- a/org.jacoco.tests/pom.xml
+++ b/org.jacoco.tests/pom.xml
@@ -44,6 +44,16 @@
true
+
+
+
+ ${project.groupId}
+ org.jacoco.core.test
+ ${project.version}
+
+
+
+
src
From 35b986af3bfe16ff26ea89ae478ed174e7b01e1f Mon Sep 17 00:00:00 2001
From: bpd0018 <17967090+bpd0018@users.noreply.github.com>
Date: Fri, 23 Jul 2021 09:22:48 -0500
Subject: [PATCH 13/26] Fix spelling in example build.xml (#1210)
---
org.jacoco.examples/build/build.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/org.jacoco.examples/build/build.xml b/org.jacoco.examples/build/build.xml
index d108f8e296..179b6943de 100644
--- a/org.jacoco.examples/build/build.xml
+++ b/org.jacoco.examples/build/build.xml
@@ -16,7 +16,7 @@
Example Ant build file that demonstrates how a JaCoCo coverage report
- can be itegrated into an existing build in three simple steps.
+ can be integrated into an existing build in three simple steps.
From 617f5399c0c1479ad0fae45468c7a5568289ac5e Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Thu, 9 Sep 2021 18:19:38 +0200
Subject: [PATCH 14/26] Use Maven 3.8.1 in Azure Pipelines (#1221)
Seems that Maven 3.8.2 contains bug, which prevents us from using it.
---
.azure-pipelines/azure-pipelines.yml | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml
index 483644ceb9..74a4954e13 100644
--- a/.azure-pipelines/azure-pipelines.yml
+++ b/.azure-pipelines/azure-pipelines.yml
@@ -59,26 +59,32 @@ jobs:
" > toolchains.xml
displayName: Setup JDK
+ - bash: |
+ set -e
+ mkdir .maven
+ curl -L "https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz" -o .maven/maven.tar.gz
+ tar -xzf .maven/maven.tar.gz -C .maven --strip-components 1
+ displayName: Setup Maven
- bash: |
if [[ "$JDK_VERSION" -ge "8" ]]; then
export JAVA_HOME=$PWD/.jdk
fi
if [[ "$BUILD_SOURCEBRANCH" == "refs/heads/master" && "$JDK_VERSION" == "5" ]]; then
- mvn -V -B -e -f org.jacoco.build \
+ .maven/bin/mvn -V -B -e -f org.jacoco.build \
verify -Djdk.version=$JDK_VERSION \
deploy:deploy -DdeployAtEnd \
--toolchains=toolchains.xml --settings=.azure-pipelines/maven-settings.xml
elif [[ "$JDK_VERSION" == "5" ]]; then
- mvn -V -B -e \
+ .maven/bin/mvn -V -B -e \
verify -Djdk.version=$JDK_VERSION \
--toolchains=toolchains.xml
elif [[ "$BUILD_SOURCEBRANCH" == "refs/heads/master" && "$JDK_VERSION" == "11" ]]; then
- mvn -V -B -e -f org.jacoco.build \
+ .maven/bin/mvn -V -B -e -f org.jacoco.build \
verify -Djdk.version=$JDK_VERSION -Dbytecode.version=$JDK_VERSION \
sonar:sonar \
--toolchains=toolchains.xml --settings=.azure-pipelines/maven-settings.xml
else
- mvn -V -B -e \
+ .maven/bin/mvn -V -B -e \
verify -Djdk.version=$JDK_VERSION -Dbytecode.version=$JDK_VERSION -Decj=${ECJ:-} \
--toolchains=toolchains.xml
fi
From 840b9bae72d5847e4457ce670560fc790c702f93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Silva?=
Date: Mon, 4 Oct 2021 10:07:45 +0100
Subject: [PATCH 15/26] Fix misleading FAQ (#1226)
A sequence of instructions between two probes may correspond to several lines.
In that case, as identified in #1223, an exception may "hide" the executed status of several lines, and not just one.
---
org.jacoco.doc/docroot/doc/faq.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/org.jacoco.doc/docroot/doc/faq.html b/org.jacoco.doc/docroot/doc/faq.html
index b24177d7e7..6a6ec1f253 100644
--- a/org.jacoco.doc/docroot/doc/faq.html
+++ b/org.jacoco.doc/docroot/doc/faq.html
@@ -65,7 +65,7 @@
Source code lines with exceptions show no coverage. Why?
into the control flow at certain positions. Code is considered as executed
when a subsequent probe has been executed. In case of exceptions such a
sequence of instructions is aborted somewhere in the middle and the
- corresponding line of source code is not marked as covered.
+ corresponding lines of source code are not marked as covered.
Why does the coverage report not show line coverage figures?
From 472be4e17700892918756583e4eb96778cc1a73c Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:53:29 +0200
Subject: [PATCH 16/26] Use Maven 3.8.3 in Azure Pipelines (#1229)
---
.azure-pipelines/azure-pipelines.yml | 2 +-
org.jacoco.build/pom.xml | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml
index 74a4954e13..347679ea1d 100644
--- a/.azure-pipelines/azure-pipelines.yml
+++ b/.azure-pipelines/azure-pipelines.yml
@@ -62,7 +62,7 @@ jobs:
- bash: |
set -e
mkdir .maven
- curl -L "https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz" -o .maven/maven.tar.gz
+ curl -L "https://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz" -o .maven/maven.tar.gz
tar -xzf .maven/maven.tar.gz -C .maven --strip-components 1
displayName: Setup Maven
- bash: |
diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml
index bb3ec1b7bb..f452cde6ac 100644
--- a/org.jacoco.build/pom.xml
+++ b/org.jacoco.build/pom.xml
@@ -551,7 +551,8 @@
1.8
- 3.3.9
+
+ [3.3.9,3.8.2),(3.8.2,)The rules for repo1.maven.org are that pom.xml files should not include repository definitions.
From 70d5b98d8c438126e9e95f186017ef972b031ef8 Mon Sep 17 00:00:00 2001
From: "Marc R. Hoffmann"
Date: Mon, 8 Nov 2021 17:08:51 +0100
Subject: [PATCH 17/26] Fix range for debug symbols of method parameters
(#1246)
By inserting the probe array access code at the beginning of the method
we accidently moved the range of the debug symbols of the method
parameters after the probe array access code. Actually the method
parameters are still valid from the very beginning of the method.
This offset in the method parameter's debug symbols may confuse tools
like Jandex.
---
.../internal/instr/ProbeInserterTest.java | 48 +++++++++++--------
.../core/internal/instr/ProbeInserter.java | 14 +++++-
org.jacoco.doc/docroot/doc/changes.html | 2 +
3 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
index fa42be8229..4f5c23e50a 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
@@ -59,7 +59,7 @@ public void verify() {
}
@Test
- public void testVariableStatic() {
+ public void probevar_should_be_at_position_0_for_static_method_without_parameters() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "()V",
actualVisitor, arrayStrategy);
pi.insertProbe(0);
@@ -71,7 +71,7 @@ public void testVariableStatic() {
}
@Test
- public void testVariableNonStatic() {
+ public void probevar_should_be_at_position_1_for_instance_method_without_parameters() {
ProbeInserter pi = new ProbeInserter(0, "m", "()V", actualVisitor,
arrayStrategy);
pi.insertProbe(0);
@@ -83,7 +83,7 @@ public void testVariableNonStatic() {
}
@Test
- public void testVariableNonStatic_IZObject() {
+ public void probevar_should_be_at_position_4_for_instance_method_with_3_parameters() {
ProbeInserter pi = new ProbeInserter(0, "m", "(IZLjava/lang/Object;)V",
actualVisitor, arrayStrategy);
pi.insertProbe(0);
@@ -95,7 +95,7 @@ public void testVariableNonStatic_IZObject() {
}
@Test
- public void testVariableNonStatic_JD() {
+ public void probevar_should_be_at_position_5_for_instance_method_with_2_wide_parameters() {
ProbeInserter pi = new ProbeInserter(0, "m", "(JD)V", actualVisitor,
arrayStrategy);
pi.insertProbe(0);
@@ -107,25 +107,27 @@ public void testVariableNonStatic_JD() {
}
@Test
- public void testVisitCode() {
+ public void visitCode_should_call_IProbeArrayStrategy_for_any_methods() {
ProbeInserter pi = new ProbeInserter(0, "m", "()V", actualVisitor,
arrayStrategy);
pi.visitCode();
+ expectedVisitor.visitLabel(new Label());
expectedVisitor.visitLdcInsn("init");
}
@Test
- public void testVisitClinit() {
+ public void visitCode_should_call_IProbeArrayStrategy_for_static_initializers() {
ProbeInserter pi = new ProbeInserter(0, "", "()V",
actualVisitor, arrayStrategy);
pi.visitCode();
+ expectedVisitor.visitLabel(new Label());
expectedVisitor.visitLdcInsn("clinit");
}
@Test
- public void testVisitVarIns() {
+ public void visitVarInsn_should_be_called_with_adjusted_variable_positions() {
ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor,
arrayStrategy);
@@ -146,7 +148,7 @@ public void testVisitVarIns() {
}
@Test
- public void testVisitIincInsn() {
+ public void visitIincInsn_should_be_called_with_adjusted_variable_positions() {
ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor,
arrayStrategy);
pi.visitIincInsn(0, 100);
@@ -166,7 +168,7 @@ public void testVisitIincInsn() {
}
@Test
- public void testVisitLocalVariable() {
+ public void visitLocalVariable_should_be_called_with_adjusted_variable_positions() {
ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor,
arrayStrategy);
@@ -176,10 +178,12 @@ public void testVisitLocalVariable() {
pi.visitLocalVariable(null, null, null, null, null, 3);
pi.visitLocalVariable(null, null, null, null, null, 4);
+ Label begin = new Label();
+
// Argument variables stay at the same position:
- expectedVisitor.visitLocalVariable(null, null, null, null, null, 0);
- expectedVisitor.visitLocalVariable(null, null, null, null, null, 1);
- expectedVisitor.visitLocalVariable(null, null, null, null, null, 2);
+ expectedVisitor.visitLocalVariable(null, null, null, begin, null, 0);
+ expectedVisitor.visitLocalVariable(null, null, null, begin, null, 1);
+ expectedVisitor.visitLocalVariable(null, null, null, begin, null, 2);
// Local variables are shifted by one:
expectedVisitor.visitLocalVariable(null, null, null, null, null, 4);
@@ -209,29 +213,31 @@ public void should_remap_LocalVariableAnnotation() {
}
@Test
- public void testVisitMaxs1() {
+ public void new_stack_size_should_be_big_enought_to_store_probe_array() {
ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor,
arrayStrategy);
pi.visitCode();
pi.visitMaxs(0, 8);
+ expectedVisitor.visitLabel(new Label());
expectedVisitor.visitLdcInsn("init");
expectedVisitor.visitMaxs(5, 9);
}
@Test
- public void testVisitMaxs2() {
+ public void new_stack_size_should_be_increased_for_probes() {
ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor,
arrayStrategy);
pi.visitCode();
pi.visitMaxs(10, 8);
+ expectedVisitor.visitLabel(new Label());
expectedVisitor.visitLdcInsn("init");
expectedVisitor.visitMaxs(13, 9);
}
@Test
- public void testVisitFrame() {
+ public void visitFrame_should_insert_probe_variable_between_arguments_and_local_variables() {
ProbeInserter pi = new ProbeInserter(0, "m", "(J)V", actualVisitor,
arrayStrategy);
@@ -245,7 +251,7 @@ public void testVisitFrame() {
}
@Test
- public void testVisitFrameNoLocals() {
+ public void visitFrame_should_only_insert_probe_variable_when_no_other_local_variables_exist() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "()V",
actualVisitor, arrayStrategy);
@@ -256,7 +262,7 @@ public void testVisitFrameNoLocals() {
}
@Test
- public void testVisitFrameProbeAt0() {
+ public void visitFrame_should_insert_probe_variable_first_when_no_parameters_exist() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "()V",
actualVisitor, arrayStrategy);
@@ -268,7 +274,7 @@ public void testVisitFrameProbeAt0() {
}
@Test
- public void testFillOneWord() {
+ public void visitFrame_should_fill_one_unused_slots_before_probe_variable_with_TOP() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "(I)V",
actualVisitor, arrayStrategy);
@@ -280,7 +286,7 @@ public void testFillOneWord() {
}
@Test
- public void testFillTwoWord() {
+ public void visitFrame_should_fill_two_unused_slots_before_probe_variable_with_TOP_TOP() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "(J)V",
actualVisitor, arrayStrategy);
@@ -293,7 +299,7 @@ public void testFillTwoWord() {
}
@Test
- public void testFillPartly() {
+ public void visitFrame_should_fill_three_unused_slots_before_probe_variable_with_TOP_TOP_TOP() {
ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "m", "(DIJ)V",
actualVisitor, arrayStrategy);
@@ -309,7 +315,7 @@ public void testFillPartly() {
}
@Test(expected = IllegalArgumentException.class)
- public void testVisitFrame_invalidType() {
+ public void visitFrame_must_only_support_resolved_frames() {
ProbeInserter pi = new ProbeInserter(0, "m", "()V", actualVisitor,
arrayStrategy);
pi.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
index 0f5b99ff55..dfa7df0f93 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
@@ -38,6 +38,9 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
/** Position of the inserted variable. */
private final int variable;
+ /** Label for the new beginning of the method */
+ private final Label beginLabel;
+
/** Maximum stack usage of the code to access the probe array. */
private int accessorStackSize;
@@ -66,6 +69,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
pos += t.getSize();
}
variable = pos;
+ beginLabel = new Label();
}
public void insertProbe(final int id) {
@@ -93,6 +97,7 @@ public void insertProbe(final int id) {
@Override
public void visitCode() {
+ mv.visitLabel(beginLabel);
accessorStackSize = arrayStrategy.storeInstance(mv, clinit, variable);
mv.visitCode();
}
@@ -111,7 +116,14 @@ public final void visitIincInsn(final int var, final int increment) {
public final void visitLocalVariable(final String name, final String desc,
final String signature, final Label start, final Label end,
final int index) {
- mv.visitLocalVariable(name, desc, signature, start, end, map(index));
+ if (index < variable) {
+ // Method parameters are still valid from the very beginning
+ mv.visitLocalVariable(name, desc, signature, beginLabel, end,
+ index);
+ } else {
+ mv.visitLocalVariable(name, desc, signature, start, end,
+ map(index));
+ }
}
@Override
diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html
index 128455ffda..873039ab62 100644
--- a/org.jacoco.doc/docroot/doc/changes.html
+++ b/org.jacoco.doc/docroot/doc/changes.html
@@ -33,6 +33,8 @@
Fixed bugs
Fixed NullPointerException during filtering
(GitHub #1189).
+
Fix range for debug symbols of method parameters
+ (GitHub #1246).
Non-functional Changes
From 024de66740f7308ce98b6ce895a4ae1d049d282d Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Wed, 17 Nov 2021 18:30:50 +0100
Subject: [PATCH 18/26] Fix build for JDK 18 >= EA b21 (#1249)
Ant task `java` with parameter `fork="false"` calls
`java.lang.System.setSecurityManager`,
however tests should not call it,
because as part of work on JEP 411
in JDK 17 it was marked as deprecated
(see https://bugs.openjdk.java.net/browse/JDK-8264713)
and in JDK 18 throws UnsupportedOperationException
unless system property `java.security.manager` set to `allow`
(see https://bugs.openjdk.java.net/browse/JDK-8270380).
---
org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml | 2 +-
org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml
index de7cb09970..01c3689ad6 100644
--- a/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/CoverageTaskTest.xml
@@ -152,7 +152,7 @@
-
+
diff --git a/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
index 0481c21825..2ffa9694be 100644
--- a/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
+++ b/org.jacoco.ant.test/src/org/jacoco/ant/ReportTaskTest.xml
@@ -71,7 +71,7 @@
-
+
@@ -89,7 +89,7 @@
-
+
From a0cf1e6c0ce9bbfeda705201278689a01b3d274b Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Thu, 18 Nov 2021 10:58:56 +0100
Subject: [PATCH 19/26] Upgrade gmavenplus-plugin to 1.13.0 (#1253)
---
org.jacoco.core.test.validation.groovy/pom.xml | 2 +-
org.jacoco.core.test.validation/pom.xml | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/org.jacoco.core.test.validation.groovy/pom.xml b/org.jacoco.core.test.validation.groovy/pom.xml
index a90dc05c55..f1857fb98d 100644
--- a/org.jacoco.core.test.validation.groovy/pom.xml
+++ b/org.jacoco.core.test.validation.groovy/pom.xml
@@ -26,7 +26,7 @@
JaCoCo :: Test :: Core :: Validation Groovy
- 1.12.1
+ 1.13.03.0.8
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index 79e98a0bb6..46041095b2 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -324,8 +324,7 @@
16
-
- 16
+ 171717
From ac756b60c029d0acf5e1202c9966b2c5a79b6b8c Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com>
Date: Tue, 14 Dec 2021 11:15:09 +0100
Subject: [PATCH 20/26] Add experimental support for Java 19 class files
(#1264)
---
.azure-pipelines/azure-pipelines.yml | 2 ++
org.jacoco.build/pom.xml | 14 +++++++++
org.jacoco.core.test.validation/pom.xml | 30 +++++++++++++++++++
.../jacoco/core/analysis/AnalyzerTest.java | 10 +++----
.../jacoco/core/instr/InstrumenterTest.java | 10 +++----
.../core/internal/instr/InstrSupportTest.java | 15 +++++-----
.../core/internal/instr/InstrSupport.java | 4 +--
org.jacoco.doc/docroot/doc/changes.html | 2 ++
8 files changed, 68 insertions(+), 19 deletions(-)
diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml
index 347679ea1d..4a622bd104 100644
--- a/.azure-pipelines/azure-pipelines.yml
+++ b/.azure-pipelines/azure-pipelines.yml
@@ -33,6 +33,8 @@ jobs:
JDK_VERSION: 17
JDK 18:
JDK_VERSION: 18
+ JDK 19:
+ JDK_VERSION: 19
pool:
vmImage: 'ubuntu-18.04'
steps:
diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml
index f452cde6ac..29dad3a560 100644
--- a/org.jacoco.build/pom.xml
+++ b/org.jacoco.build/pom.xml
@@ -894,6 +894,20 @@
+
+ java19-bytecode
+
+
+ bytecode.version
+ 19
+
+
+
+ 13
+ 13
+
+
+
ecj
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index 46041095b2..9df1529001 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -369,6 +369,36 @@
../org.jacoco.core.test.validation.scala
+
+
+ java19-bytecode
+
+
+ bytecode.version
+ 19
+
+
+
+
+ 16
+
+ 16
+
+ 19
+ 19
+
+
+ ../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.java16
+
+ ../org.jacoco.core.test.validation.scala
+
+
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 00b0aebba5..cbc357bd0a 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
@@ -108,7 +108,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.V17 + 1);
+ final byte[] originalBytes = createClass(Opcodes.V18 + 1);
final byte[] bytes = new byte[originalBytes.length];
System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length);
final long expectedClassId = CRC64.classId(bytes);
@@ -131,14 +131,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.V17 + 2);
+ final byte[] bytes = createClass(Opcodes.V18 + 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 63",
+ assertEquals("Unsupported class file major version 64",
e.getCause().getMessage());
}
}
@@ -218,7 +218,7 @@ public void testAnalyzeClass_BrokenStream() throws IOException {
*/
@Test
public void analyzeAll_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V17 + 2);
+ final byte[] bytes = createClass(Opcodes.V18 + 2);
try {
analyzer.analyzeAll(new ByteArrayInputStream(bytes),
"UnsupportedVersion");
@@ -226,7 +226,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 63",
+ assertEquals("Unsupported class file major version 64",
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 44d16d36e7..e745ce8de9 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
@@ -99,7 +99,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.V17 + 1);
+ final byte[] originalBytes = createClass(Opcodes.V18 + 1);
final byte[] bytes = new byte[originalBytes.length];
System.arraycopy(originalBytes, 0, bytes, 0, originalBytes.length);
final long expectedClassId = CRC64.classId(bytes);
@@ -122,14 +122,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.V17 + 2);
+ final byte[] bytes = createClass(Opcodes.V18 + 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 63",
+ assertEquals("Unsupported class file major version 64",
e.getCause().getMessage());
}
}
@@ -224,7 +224,7 @@ public void testSerialization() throws Exception {
*/
@Test
public void instrumentAll_should_throw_exception_for_unsupported_class_file_version() {
- final byte[] bytes = createClass(Opcodes.V17 + 2);
+ final byte[] bytes = createClass(Opcodes.V18 + 2);
try {
instrumenter.instrumentAll(new ByteArrayInputStream(bytes),
new ByteArrayOutputStream(), "UnsupportedVersion");
@@ -232,7 +232,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 63",
+ assertEquals("Unsupported class file major version 64",
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 4db19bf51c..d98a25616a 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
@@ -43,8 +43,8 @@ public void setup() {
}
@Test
- public void classReaderFor_should_read_java_18_class() {
- final byte[] bytes = createJava18Class();
+ public void classReaderFor_should_read_java_19_class() {
+ final byte[] bytes = createJava19Class();
final ClassReader classReader = InstrSupport.classReaderFor(bytes);
@@ -53,16 +53,16 @@ public void classReaderFor_should_read_java_18_class() {
public void visit(final int version, final int access,
final String name, final String signature,
final String superName, final String[] interfaces) {
- assertEquals(Opcodes.V17 + 1, version);
+ assertEquals(Opcodes.V18 + 1, version);
}
}, 0);
- assertArrayEquals(createJava18Class(), bytes);
+ assertArrayEquals(createJava19Class(), bytes);
}
- private static byte[] createJava18Class() {
+ private static byte[] createJava19Class() {
final ClassWriter cw = new ClassWriter(0);
- cw.visit(Opcodes.V17 + 1, 0, "Foo", null, "java/lang/Object", null);
+ cw.visit(Opcodes.V18 + 1, 0, "Foo", null, "java/lang/Object", null);
cw.visitEnd();
return cw.toByteArray();
}
@@ -129,7 +129,8 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_
assertTrue(InstrSupport.needsFrames(Opcodes.V15));
assertTrue(InstrSupport.needsFrames(Opcodes.V16));
assertTrue(InstrSupport.needsFrames(Opcodes.V17));
- assertTrue(InstrSupport.needsFrames(Opcodes.V17 + 1));
+ assertTrue(InstrSupport.needsFrames(Opcodes.V18));
+ assertTrue(InstrSupport.needsFrames(Opcodes.V18 + 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 003efabea5..88e25944d6 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.V17 + 1) {
+ if (originalVersion == Opcodes.V18 + 1) {
// temporarily downgrade version to bypass check in ASM
- setMajorVersion(Opcodes.V17, b);
+ setMajorVersion(Opcodes.V18, 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 873039ab62..392763f7b0 100644
--- a/org.jacoco.doc/docroot/doc/changes.html
+++ b/org.jacoco.doc/docroot/doc/changes.html
@@ -24,6 +24,8 @@
New Features
Experimental support for Java 18 class files
(GitHub #1198).
+
Experimental support for Java 19 class files
+ (GitHub #1264).
Part of bytecode generated by the Java compilers for assert
statement is filtered out during generation of report
(GitHub #1196).