Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
JDK_VERSION: 23
JDK 24:
JDK_VERSION: 24
JDK 25:
JDK_VERSION: 25
pool:
vmImage: 'ubuntu-20.04'
steps:
Expand Down
14 changes: 14 additions & 0 deletions org.jacoco.build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,20 @@
</properties>
</profile>

<profile>
<id>java25-bytecode</id>
<activation>
<property>
<name>bytecode.version</name>
<value>25</value>
</property>
</activation>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</profile>

<!-- This profile enables use of ECJ -->
<profile>
<id>ecj</id>
Expand Down
33 changes: 33 additions & 0 deletions org.jacoco.core.test.validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,39 @@
</modules>
</profile>

<profile>
<id>java25-bytecode</id>
<activation>
<property>
<name>bytecode.version</name>
<value>25</value>
</property>
</activation>
<properties>
<!-- Kotlin 2.1.0 doesn't support compilation into 25 -->
<kotlin.compiler.jvmTarget>23</kotlin.compiler.jvmTarget>
<!-- Groovy 3.0.22 does not support compilation into 25 -->
<groovy.targetBytecode>16</groovy.targetBytecode>
<!-- see respective profile in org.jacoco.build about this override -->
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
</properties>
<modules>
<!-- Kotlin compiler does not yet support Java 25 as runtime
<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>
<module>../org.jacoco.core.test.validation.java16</module>
<module>../org.jacoco.core.test.validation.java21</module>
<!-- Groovy 3.0.22 does not support Java 25
<module>../org.jacoco.core.test.validation.groovy</module>
-->
<module>../org.jacoco.core.test.validation.scala</module>
</modules>
</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ private static byte[] createClass(final int version) {
*/
@Test
public void analyzeClass_should_throw_exception_for_unsupported_class_file_version() {
final byte[] bytes = createClass(Opcodes.V23 + 2);
final byte[] bytes = createClass(Opcodes.V24 + 2);
try {
analyzer.analyzeClass(bytes, "UnsupportedVersion");
fail("exception expected");
} catch (IOException e) {
assertExceptionMessage("UnsupportedVersion", e);
assertEquals("Unsupported class file major version 69",
assertEquals("Unsupported class file major version 70",
e.getCause().getMessage());
}
}
Expand Down Expand Up @@ -218,14 +218,14 @@ public void testAnalyzeClass_BrokenStream() throws IOException {
*/
@Test
public void analyzeAll_should_throw_exception_for_unsupported_class_file_version() {
final byte[] bytes = createClass(Opcodes.V23 + 2);
final byte[] bytes = createClass(Opcodes.V24 + 2);
try {
analyzer.analyzeAll(new ByteArrayInputStream(bytes),
"UnsupportedVersion");
fail("exception expected");
} catch (IOException e) {
assertExceptionMessage("UnsupportedVersion", e);
assertEquals("Unsupported class file major version 69",
assertEquals("Unsupported class file major version 70",
e.getCause().getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import static org.objectweb.asm.Opcodes.V14;
import static org.objectweb.asm.Opcodes.V15;
import static org.objectweb.asm.Opcodes.V16;
import static org.objectweb.asm.Opcodes.V17;
import static org.objectweb.asm.Opcodes.V18;
import static org.objectweb.asm.Opcodes.V19;
import static org.objectweb.asm.Opcodes.V1_1;
import static org.objectweb.asm.Opcodes.V1_2;
import static org.objectweb.asm.Opcodes.V1_3;
Expand All @@ -39,6 +42,11 @@
import static org.objectweb.asm.Opcodes.V1_6;
import static org.objectweb.asm.Opcodes.V1_7;
import static org.objectweb.asm.Opcodes.V1_8;
import static org.objectweb.asm.Opcodes.V20;
import static org.objectweb.asm.Opcodes.V21;
import static org.objectweb.asm.Opcodes.V22;
import static org.objectweb.asm.Opcodes.V23;
import static org.objectweb.asm.Opcodes.V24;
import static org.objectweb.asm.Opcodes.V9;

import java.io.IOException;
Expand Down Expand Up @@ -139,6 +147,51 @@ public void test_16() throws IOException {
testVersion(V16, true);
}

@Test
public void test_17() throws IOException {
testVersion(V17, true);
}

@Test
public void test_18() throws IOException {
testVersion(V18, true);
}

@Test
public void test_19() throws IOException {
testVersion(V19, true);
}

@Test
public void test_20() throws IOException {
testVersion(V20, true);
}

@Test
public void test_21() throws IOException {
testVersion(V21, true);
}

@Test
public void test_22() throws IOException {
testVersion(V22, true);
}

@Test
public void test_23() throws IOException {
testVersion(V23, true);
}

@Test
public void test_24() throws IOException {
testVersion(V24, true);
}

@Test
public void test_25() throws IOException {
testVersion(V24 + 1, true);
}

private void testVersion(int version, boolean frames) throws IOException {
final byte[] original = createClass(version, frames);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ private static byte[] createClass(final int version) {
*/
@Test
public void instrument_should_throw_exception_for_unsupported_class_file_version() {
final byte[] bytes = createClass(Opcodes.V23 + 2);
final byte[] bytes = createClass(Opcodes.V24 + 2);
try {
instrumenter.instrument(bytes, "UnsupportedVersion");
fail("exception expected");
} catch (final IOException e) {
assertExceptionMessage("UnsupportedVersion", e);
assertEquals("Unsupported class file major version 69",
assertEquals("Unsupported class file major version 70",
e.getCause().getMessage());
}
}
Expand Down Expand Up @@ -221,14 +221,14 @@ public void testSerialization() throws Exception {
*/
@Test
public void instrumentAll_should_throw_exception_for_unsupported_class_file_version() {
final byte[] bytes = createClass(Opcodes.V23 + 2);
final byte[] bytes = createClass(Opcodes.V24 + 2);
try {
instrumenter.instrumentAll(new ByteArrayInputStream(bytes),
new ByteArrayOutputStream(), "UnsupportedVersion");
fail("exception expected");
} catch (final IOException e) {
assertExceptionMessage("UnsupportedVersion", e);
assertEquals("Unsupported class file major version 69",
assertEquals("Unsupported class file major version 70",
e.getCause().getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void setup() {
}

@Test
public void classReaderFor_should_read_java_24_class() {
final byte[] bytes = createJava24Class();
public void classReaderFor_should_read_java_25_class() {
final byte[] bytes = createJava25Class();

final ClassReader classReader = InstrSupport.classReaderFor(bytes);

Expand All @@ -53,16 +53,16 @@ public void classReaderFor_should_read_java_24_class() {
public void visit(final int version, final int access,
final String name, final String signature,
final String superName, final String[] interfaces) {
assertEquals(Opcodes.V23 + 1, version);
assertEquals(Opcodes.V24 + 1, version);
}
}, 0);

assertArrayEquals(createJava24Class(), bytes);
assertArrayEquals(createJava25Class(), bytes);
}

private static byte[] createJava24Class() {
private static byte[] createJava25Class() {
final ClassWriter cw = new ClassWriter(0);
cw.visit(Opcodes.V23 + 1, 0, "Foo", null, "java/lang/Object", null);
cw.visit(Opcodes.V24 + 1, 0, "Foo", null, "java/lang/Object", null);
cw.visitEnd();
return cw.toByteArray();
}
Expand Down Expand Up @@ -135,7 +135,8 @@ public void needFrames_should_return_true_for_versions_greater_than_or_equal_to_
assertTrue(InstrSupport.needsFrames(Opcodes.V21));
assertTrue(InstrSupport.needsFrames(Opcodes.V22));
assertTrue(InstrSupport.needsFrames(Opcodes.V23));
assertTrue(InstrSupport.needsFrames(Opcodes.V23 + 1));
assertTrue(InstrSupport.needsFrames(Opcodes.V24));
assertTrue(InstrSupport.needsFrames(Opcodes.V24 + 1));

assertTrue(InstrSupport.needsFrames(0x0100));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.jacoco.core.data.ExecutionDataStore;
import org.jacoco.core.data.SessionInfo;
import org.jacoco.core.internal.analysis.CounterImpl;
import org.jacoco.core.internal.instr.InstrSupport;
import org.jacoco.core.test.InstrumentingLoader;
import org.jacoco.core.test.TargetLoader;
import org.jacoco.core.test.validation.Source.Line;
Expand All @@ -44,7 +45,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runners.model.MultipleFailureException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.util.ASMifier;
import org.objectweb.asm.util.Textifier;
import org.objectweb.asm.util.TraceClassVisitor;
Expand Down Expand Up @@ -124,9 +124,10 @@ private void saveBytecodeRepresentations(final byte[] classBytes,
new File(outputDir, fileName + ".txt"));
final PrintWriter asmWriter = new PrintWriter(
new File(outputDir, fileName + ".java"));
new ClassReader(classBytes).accept(new TraceClassVisitor(
new TraceClassVisitor(null, new Textifier(), textWriter),
new ASMifier(), asmWriter), 0);
InstrSupport.classReaderFor(classBytes)
.accept(new TraceClassVisitor(new TraceClassVisitor(null,
new Textifier(), textWriter), new ASMifier(),
asmWriter), 0);
textWriter.close();
asmWriter.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.V23 + 1) {
if (originalVersion == Opcodes.V24 + 1) {
// temporarily downgrade version to bypass check in ASM
setMajorVersion(Opcodes.V23, b);
setMajorVersion(Opcodes.V24, b);
}
final ClassReader classReader = new ClassReader(b);
setMajorVersion(originalVersion, b);
Expand Down
2 changes: 2 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ <h3>New Features</h3>
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1700">#1700</a>).</li>
<li>Experimental support for Java 24 class files
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1631">#1631</a>).</li>
<li>Experimental support for Java 25 class files
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1807">#1807</a>).</li>
<li>Part of bytecode generated by the Kotlin Compose compiler plugin is
filtered out during generation of report
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1616">#1616</a>).</li>
Expand Down
9 changes: 5 additions & 4 deletions org.jacoco.doc/docroot/doc/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ <h3>Does JaCoCo have a plug-in for [Eclipse|Netbeans|Whatever...]?</h3>

<h3>What Java versions are supported by JaCoCo?</h3>
<p>
JaCoCo supports Java class files from version 1.0 to 23. However the minimum
JRE version required by the JaCoCo runtime (e.g. the agent) and the JaCoCo
tools is 1.5. Also note that class files under test from version 1.6 and above
have to contain valid stackmap frames.
JaCoCo officially supports Java class files from version 1.0 to 23. Also
experimental support for class files of versions 24 and 25 is provided.
However the minimum JRE version required by the JaCoCo runtime
(e.g. the agent) and the JaCoCo tools is 1.5. Also note that class files under
test from version 1.6 and above have to contain valid stackmap frames.
</p>

<h3>Why do I get the error "Can't add different class with same name"?</h3>
Expand Down