Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add experimental support for Java 24 class files #1631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Conversation

Godin
Copy link
Member

@Godin Godin commented Jun 8, 2024

No description provided.

@Godin Godin added this to the 0.8.13 milestone Jun 8, 2024
@Godin Godin self-assigned this Jun 8, 2024
@Godin Godin marked this pull request as ready for review June 8, 2024 19:11
@Godin Godin marked this pull request as draft June 8, 2024 19:19
@Godin Godin marked this pull request as ready for review June 10, 2024 08:49
@Godin Godin requested a review from marchof June 10, 2024 08:49
@marchof marchof merged commit 859da1c into jacoco:master Jun 11, 2024
29 checks passed
@Godin Godin deleted the java24 branch June 11, 2024 07:57
@garydgregory
Copy link

garydgregory commented Oct 3, 2024

Hi All,

Could we get a release (0.8.13?) pushed to Maven Central? I'd like to get all of our Apache Commons builds on Java 24-ea passing; for example: https://github.com/apache/commons-collections/actions/runs/11168739466/job/31047838820

TY!

@Godin
Copy link
Member Author

Godin commented Oct 9, 2024

@garydgregory in https://github.com/apache/commons-collections/actions/runs/11168739466/job/31047838820 you have

[INFO] Results:
[INFO] 
Error:  Errors: 
Error:    IteratorUtilsTest.testGetIterator:781 » IllegalArgument Could not create type
[INFO] 
Error:  Tests run: 8214, Failures: 0, Errors: 1, Skipped: 66

and

[INFO] Running org.apache.commons.collections4.IteratorUtilsTest
Error:  Tests run: 48, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.587 s <<< FAILURE! -- in org.apache.commons.collections4.IteratorUtilsTest
Error:  org.apache.commons.collections4.IteratorUtilsTest.testGetIterator -- Time elapsed: 0.547 s <<< ERROR!
java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:170)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at org.easymock.internal.ClassProxyFactory.doCreateProxy(ClassProxyFactory.java:171)
	at org.easymock.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:154)
	at org.easymock.internal.MocksControl.createMock(MocksControl.java:110)
	at org.easymock.internal.MocksControl.createMock(MocksControl.java:83)
	at org.easymock.IMocksControl.mock(IMocksControl.java:44)
	at org.easymock.EasyMock.mock(EasyMock.java:70)
	at org.easymock.EasyMock.createMock(EasyMock.java:322)
	at org.apache.commons.collections4.IteratorUtilsTest.testGetIterator(IteratorUtilsTest.java:781)
	at java.base/java.lang.reflect.Method.invoke(Method.java:573)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
Caused by: java.lang.IllegalArgumentException: java.util.Dictionary$$$EasyMock$2 must be defined in the same package as org.easymock.internal.ClassProxyFactory
	at net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.injectRaw(ClassInjector.java:1635)
	at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:118)
	at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$UsingLookup.load(ClassLoadingStrategy.java:519)
	at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
	at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:[632](https://github.com/apache/commons-collections/actions/runs/11168739466/job/31047838820#step:5:633)5)
	at org.easymock.internal.ClassProxyFactory.lambda$doCreateProxy$0(ClassProxyFactory.java:181)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	... 12 more

so I don't think that your build fails because of JaCoCo.

@garydgregory
Copy link

Hello @Godin

You're not looking in the right place 😉

[INFO] Running org.apache.commons.collections4.properties.EmptyPropertiesTest
java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/provider/NonBaseLocaleDataMetaInfo with JaCoCo 0.8.12.202403310830/dbfb6f2.
	at org.jacoco.agent.rt.internal_aeaf9ab.CoverageTransformer.transform(CoverageTransformer.java:94)
	at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:259)
	at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
	at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:611)
	at java.base/java.lang.ClassLoader.defineClass2(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1116)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:741)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:621)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:640)
	at java.base/java.lang.Class.forName(Class.java:672)
	at java.base/java.lang.Class.forName(Class.java:647)
	at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:855)
	at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.hasNext(ServiceLoader.java:1080)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1305)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
	at java.base/sun.util.locale.provider.JRELocaleProviderAdapter.lambda$createSupportedLocaleString$0(JRELocaleProviderAdapter.java:469)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
	at java.base/sun.util.locale.provider.JRELocaleProviderAdapter.createSupportedLocaleString(JRELocaleProviderAdapter.java:466)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:160)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:146)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:144)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:100)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:160)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:146)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:144)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:100)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:198)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:169)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:93)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:58)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:141)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:57)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:103)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:85)
	at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
	at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:56)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:184)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:148)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.io.IOException: Error while instrumenting sun/util/resources/provider/NonBaseLocaleDataMetaInfo with JaCoCo 0.8.12.202403310830/dbfb6f2.
	at org.jacoco.agent.rt.internal_aeaf9ab.core.instr.Instrumenter.instrumentError(Instrumenter.java:161)
	at org.jacoco.agent.rt.internal_aeaf9ab.core.instr.Instrumenter.instrument(Instrumenter.java:111)
	at org.jacoco.agent.rt.internal_aeaf9ab.CoverageTransformer.transform(CoverageTransformer.java:92)
	... 108 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 68
	at org.jacoco.agent.rt.internal_aeaf9ab.asm.ClassReader.<init>(ClassReader.java:200)
	at org.jacoco.agent.rt.internal_aeaf9ab.asm.ClassReader.<init>(ClassReader.java:180)
	at org.jacoco.agent.rt.internal_aeaf9ab.asm.ClassReader.<init>(ClassReader.java:166)
	at org.jacoco.agent.rt.internal_aeaf9ab.core.internal.instr.InstrSupport.classReaderFor(InstrSupport.java:280)
	at org.jacoco.agent.rt.internal_aeaf9ab.core.instr.Instrumenter.instrument(Instrumenter.java:77)
	at org.jacoco.agent.rt.internal_aeaf9ab.core.instr.Instrumenter.instrument(Instrumenter.java:109)
	... 109 more

@Godin
Copy link
Member Author

Godin commented Oct 9, 2024

I saw

[INFO] Running org.apache.commons.collections4.properties.EmptyPropertiesTest
java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/provider/NonBaseLocaleDataMetaInfo with JaCoCo 0.8.12.202403310830/dbfb6f2.
	at org.jacoco.agent.rt.internal_aeaf9ab.CoverageTransformer.transform(CoverageTransformer.java:94)

but I seriously doubt that this is the cause of your build failure - according to

final IllegalClassFormatException wrapper = new IllegalClassFormatException(
ex.getMessage());
wrapper.initCause(ex);
// Report this, as the exception is ignored by the JVM:
logger.logExeption(wrapper);
throw wrapper;

inability to instrument/transform class is ignored by JVM and class should remain uninstrumented, ie JaCoCo simply won't be able to record coverage for it. And I doubt that sun/util classes are classes of your application and you want to compute coverage for them.

And that's why IMO #1631 (comment) is

the right place

to look at.

Also have you tried suggestion from #1742 (comment)

test latest build of master branch (Maven SNAPSHOT)

??? According to the above IMO even with SNAPSHOT you'll have build failure and hence even if we'll release it.

@Godin
Copy link
Member Author

Godin commented Oct 9, 2024

@garydgregory I just tried locally

$ git clone [email protected]:apache/commons-collections.git
$ git rev-parse HEAD
e1016b78664c78ed91f84119066cd7018c029139

then added

index 0057f179f..1cc25ac71 100644
--- i/pom.xml
+++ w/pom.xml
@@ -32,6 +32,12 @@
     <system>jira</system>
     <url>https://issues.apache.org/jira/browse/COLLECTIONS</url>
   </issueManagement>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>jacoco-snapshot</id>
+      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+    </pluginRepository>
+  </pluginRepositories>
   <scm>
     <connection>scm:git:http://gitbox.apache.org/repos/asf/commons-collections.git</connection>
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-collections.git</developerConnection>

and then executed

mvn verify -Dcommons.jacoco.version=0.8.13-SNAPSHOT

using

openjdk version "24-ea" 2025-03-18
OpenJDK Runtime Environment (build 24-ea+18-2073)
OpenJDK 64-Bit Server VM (build 24-ea+18-2073, mixed mode, sharing)

and

java.lang.instrument.IllegalClassFormatException: Error while instrumenting ... with JaCoCo

are gone, but #1631 (comment) remains 😉

@Godin
Copy link
Member Author

Godin commented Oct 9, 2024

Another proof that does not require JaCoCo SNAPSHOT: execution of

mvn verify -Djacoco.skip

with JDK 24-ea also fails with the same #1631 (comment)

@Godin
Copy link
Member Author

Godin commented Oct 9, 2024

And one more proof: execution of

mvn verify -Dnet.bytebuddy.experimental=true

succeeds with JaCoCo 0.8.12 and JDK 24-ea 😉

@garydgregory
Copy link

garydgregory commented Oct 10, 2024

Hello @Godin

Thank you for taking the time to experiment and provide guidance.

I was able to get past the ASM error using 0.13.0-SNAPSHOT. This is now in git master under a Maven profile for Java 24.

It looks like the IteratorUtilsTest is an EasyMock issue and unrelated to JaCoCo.

TY again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants