Skip to content
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

Java 22 Support #404

Closed
dwarakaprasad opened this issue Mar 28, 2024 · 11 comments · Fixed by #407
Closed

Java 22 Support #404

dwarakaprasad opened this issue Mar 28, 2024 · 11 comments · Fixed by #407
Assignees
Labels
type/bug A general bug
Milestone

Comments

@dwarakaprasad
Copy link

Expected Behavior

The following error is thrown when using the java 22 runtime,

OpenJDK 64-Bit Server VM warning: Option AllowRedefinitionToAddDeleteMethods was deprecated in version 13.0 and will likely be removed in a future release.
WARNING: A Java agent has been loaded dynamically (/tmp/byteBuddyAgent15882293150021270014.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[Byte Buddy] ERROR java.lang.ProcessImpl [null, module java.base, Thread[#1,main,5,main], loaded=true]
java.lang.IllegalArgumentException: Java 22 (66) is not supported by the current version of Byte Buddy which officially supports Java 21 (65) - update Byte Buddy or set reactor.blockhound.shaded.net.bytebuddy.experimental as a VM property
	at reactor.blockhound.shaded.net.bytebuddy.utility.OpenedClassReader.of(OpenedClassReader.java:96)
	at reactor.blockhound.shaded.net.bytebuddy.pool.TypePool$Default.parse(TypePool.java:879)
	at reactor.blockhound.shaded.net.bytebuddy.pool.TypePool$Default.doDescribe(TypePool.java:865)
	at reactor.blockhound.shaded.net.bytebuddy.pool.TypePool$AbstractBase.describe(TypePool.java:598)
	at reactor.blockhound.shaded.net.bytebuddy.pool.TypePool$AbstractBase$Hierarchical.describe(TypePool.java:681)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$DescriptionStrategy$Default$3.apply(AgentBuilder.java:4243)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$RedefinitionStrategy$Collector.consider(AgentBuilder.java:7956)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$RedefinitionStrategy.apply(AgentBuilder.java:5741)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$Default.doInstall(AgentBuilder.java:11237)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$Default.installOn(AgentBuilder.java:11155)
	at reactor.blockhound.shaded.net.bytebuddy.agent.builder.AgentBuilder$Default$Delegator.installOn(AgentBuilder.java:12927)
	at reactor.blockhound.BlockHound$Builder.instrument(BlockHound.java:581)
	at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:484)
	at reactor.blockhound.BlockHound.install(BlockHound.java:91)
	at reactor.blockhound.junit.platform.BlockHoundTestExecutionListener.<clinit>(BlockHoundTestExecutionListener.java:19)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:340)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:173)
	at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:785)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:725)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1397)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:611)
	at org.junit.platform.launcher.core.LauncherFactory.registerTestExecutionListeners(LauncherFactory.java:195)
	at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:142)
	at org.junit.platform.launcher.core.LauncherFactory.lambda$openSession$1(LauncherFactory.java:101)
	at org.junit.platform.launcher.core.DefaultLauncherSession.<init>(DefaultLauncherSession.java:53)
	at org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:100)
	at org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:82)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:125)
	at org.apache.maven.surefire.api.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:62)
	at org.apache.maven.surefire.junitplatform.LazyLauncher.launcher(LazyLauncher.java:68)
	at org.apache.maven.surefire.junitplatform.LazyLauncher.discover(LazyLauncher.java:50)
	at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:52)
	at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:87)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:142)
	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](https://github.com/jhipster/generator-jhipster/actions/runs/8472839537/job/23215829498?pr=25658#step:17:508))
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)

was able to move forward with using -Dreactor.blockhound.shaded.net.bytebuddy.experimental=true

Actual Behavior

Steps to Reproduce

@Test
void reproCase() {

}

Possible Solution

Work-around
use -Dreactor.blockhound.shaded.net.bytebuddy.experimental=true

Based on the response from byte-buddy -1.14.13 supports Java 22

Your Environment

  • Reactor version(s) used:
    reactor-core: 3.6.4
  • Other relevant libraries versions (eg. netty, ...):
    spring-boot: 3.2.4
    reactor-netty-core: 1.1.17
  • JVM version (java -version):
    openjdk version "22" 2024-03-19
    OpenJDK Runtime Environment Temurin-22+36 (build 22+36)
    OpenJDK 64-Bit Server VM Temurin-22+36 (build 22+36, mixed mode, sharing)
  • OS and version (eg uname -a):
  • Distributor ID: Ubuntu
    Description: Ubuntu 22.04.3 LTS
    Release: 22.04
    Codename: jammy
@pderop pderop self-assigned this Mar 29, 2024
@pderop
Copy link
Contributor

pderop commented Mar 29, 2024

@dwarakaprasad ,

Can you test with the snapshot version 1.0.9.BUILD-SNAPSHOT of BlockHound that is available from https://repo.spring.io/snapshot ?

the snapshot is now using the latest byte buddy version.
can you please confirm ? if it works, then let's release 1.0.9 version (but before, I will need to check #403).

thanks

@dwarakaprasad
Copy link
Author

@dwarakaprasad ,

Can you test with the snapshot version 1.0.9.BUILD-SNAPSHOT of BlockHound that is available from https://repo.spring.io/snapshot ?

the snapshot is now using the latest byte buddy version. can you please confirm ? if it works, then let's release 1.0.9 version (but before, I will need to check #403).

thanks

Awesome, yup will do...
thank you!

@dwarakaprasad
Copy link
Author

dwarakaprasad commented Mar 29, 2024

the above error doesn't happen, but getting the instrumentation error...

VM arg - -XX:+AllowRedefinitionToAddDeleteMethods is set as part of the Surefire plugin configuration. I tried running the test in eclipse and debugged the incoming VM args and found the above arg.

[-Xmx3489m, -XX:+ShowCodeDetailsInExceptionMessages, -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:40797, -ea, -XX:+AllowRedefinitionToAddDeleteMethods, -XX:+EnableDynamicAgentLoading, -Dspring.profiles.active=testprod, -Ddamo=damo, -javaagent:/workspace/eclipse/configuration/org.eclipse.osgi/414/0/.cp/lib/javaagent-shaded.jar, -Dfile.encoding=UTF-8]

Couldn't find anything related to the argument in JDK 22 docs (on the surface...). Before I go any further, wanted to validate my findings.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-test) on project jup: 
[ERROR] 
[ERROR] Please refer to /workspace/code/jup/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider reactor.blockhound.junit.platform.BlockHoundTestExecutionListener could not be instantiated
[ERROR] org.apache.maven.surefire.api.util.SurefireReflectionException: java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider reactor.blockhound.junit.platform.BlockHoundTestExecutionListener could not be instantiated
[ERROR]         at org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:129)
[ERROR]         at org.apache.maven.surefire.api.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:62)
[ERROR]         at org.apache.maven.surefire.junitplatform.LazyLauncher.launcher(LazyLauncher.java:68)
[ERROR]         at org.apache.maven.surefire.junitplatform.LazyLauncher.discover(LazyLauncher.java:50)
[ERROR]         at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:52)
[ERROR]         at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:87)
[ERROR]         at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:142)
[ERROR]         at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
[ERROR] Caused by: java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider reactor.blockhound.junit.platform.BlockHoundTestExecutionListener could not be instantiated
[ERROR]         at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
[ERROR]         at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:809)
[ERROR]         at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:725)
[ERROR]         at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1397)
[ERROR]         at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
[ERROR]         at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
[ERROR]         at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
[ERROR]         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
[ERROR]         at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:611)
[ERROR]         at org.junit.platform.launcher.core.LauncherFactory.registerTestExecutionListeners(LauncherFactory.java:195)
[ERROR]         at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:142)
[ERROR]         at org.junit.platform.launcher.core.LauncherFactory.lambda$openSession$1(LauncherFactory.java:101)
[ERROR]         at org.junit.platform.launcher.core.DefaultLauncherSession.<init>(DefaultLauncherSession.java:53)
[ERROR]         at org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:100)
[ERROR]         at org.junit.platform.launcher.core.LauncherFactory.openSession(LauncherFactory.java:82)
[ERROR]         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[ERROR]         at org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:125)
[ERROR]         ... 11 more
[ERROR] Caused by: java.lang.ExceptionInInitializerError
[ERROR]         at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
[ERROR]         at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unknown Source)
[ERROR]         at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:340)
[ERROR]         at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
[ERROR]         at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:173)
[ERROR]         at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
[ERROR]         at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
[ERROR]         at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
[ERROR]         at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:785)
[ERROR]         ... 30 more
[ERROR] Caused by: java.lang.IllegalStateException: The instrumentation have failed.
[ERROR] It looks like you're running on JDK 13+.
[ERROR] You need to add '-XX:+AllowRedefinitionToAddDeleteMethods' JVM flag.
[ERROR] See https://github.com/reactor/BlockHound/issues/33 for more info.
[ERROR]         at reactor.blockhound.BlockHound$Builder.testInstrumentation(BlockHound.java:538)
[ERROR]         at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:501)
[ERROR]         at reactor.blockhound.BlockHound.install(BlockHound.java:91)
[ERROR]         at reactor.blockhound.junit.platform.BlockHoundTestExecutionListener.<clinit>(BlockHoundTestExecutionListener.java:19)
[ERROR]         ... 39 more

@pderop
Copy link
Contributor

pderop commented Mar 31, 2024

Hi @dwarakaprasad ,

I also reproduced the issue, I'm trying to figure out.
Have uploaded a reproducer sample in raphw/byte-buddy#1609, let's see if Rafael can help on this.

thanks.

@pderop
Copy link
Contributor

pderop commented Apr 3, 2024

based on discussions from raphw/byte-buddy#1609 (comment), it's likely that there is a bug in OpenJDK 22 around the AllowRedefinitionToAddDeleteMethodsoption allowing to redefine native methods.

I will first isolate the problem in a reproducer sample code outside of BlockHound and will submit it to OpenJDK for version 22.
And for the long term, another way to instrument native methods should be investigated in order to not depend on the AllowRedefinitionToAddDeleteMethodsoption anymore.

for the moment, I'm attaching here a reproducer based on BlockHound here:
blockhound-issue-410.tgz

(see raphw/byte-buddy#1609 (comment) on how to run the blockhound-issue-410.tgz reproducer test).

I'm now working on doing a standalone reproducer sample code in order to submit it to OpenJDK 22.

@pderop
Copy link
Contributor

pderop commented Apr 4, 2024

@dwarakaprasad ,

Actually, there was a problem in BlockHound because in JDK22, the Thred.sleep() method is now internally calling Thread.sleepNanos0 instead of Thread.sleep0 native method.

The PR #407 for this problem has been merged and has been pushed to the snapshot repo.
Can you try again the 1.0.9.BUILD-SNAPSHOT version available from https://repo.spring.io/snapshot ?

thanks.

@dwarakaprasad
Copy link
Author

@dwarakaprasad ,

Actually, there was a problem in BlockHound because in JDK22, the Thred.sleep() method is now internally calling Thread.sleepNanos0 instead of Thread.sleep0 native method.

The PR #407 for this problem has been merged and has been pushed to the snapshot repo. Can you try again the 1.0.9.BUILD-SNAPSHOT version available from https://repo.spring.io/snapshot ?

thanks.

Yeah sure, will keep you posted.

@pderop
Copy link
Contributor

pderop commented Apr 15, 2024

Hi @dwarakaprasad,

We may release BlockHound this week; but I just wonder if you had a chance to validate the 1.0.9.BUILD-SNAPSHOT version which has the fix for jdk22 support ?

thanks.

@dwarakaprasad
Copy link
Author

We may release BlockHound this week; but I just wonder if you had a chance to validate the 1.0.9.BUILD-SNAPSHOT version which has the fix for jdk22 support ?

Hi @pderop, Sorry for the delayed reply. I was able to add your changes to my project and was able to successful move past the issue. Thank you so much.

@pderop
Copy link
Contributor

pderop commented Apr 17, 2024

thanks a lot for having verified the PR, then let's release all this 🚀

@pderop
Copy link
Contributor

pderop commented Apr 18, 2024

The BlockHound 1.0.9.RELEASE version has been released and includes the fix.

@pderop pderop added this to the 1.0.9.RELEASE milestone Apr 18, 2024
@pderop pderop added the type/bug A general bug label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants