Closed dwarakaprasad closed 1 month ago
Java 22 is supported in the latest version. You would need to ask the library for an update.
Java 22 is supported in the latest version. You would need to ask the library for an update.
Awesome thank you!
@raphw ,
Hi Rafael,
I'm currently maintaining BlockHound, and I have upgraded BlockHound 1.0.9 snapshot with latest bytebuddy version (1.14.13). But it seems that there are still problems with JDK22 (only). I managed to do a simple reproducer project that I'm attaching here:
For the moment, I cannot say from where the problem is. Can you please give a try to the reproducer ?
It's a simple project that is using BlockHound.
The junit test verifies that if a blocking task is scheduled in the com.example.NonBlockingThread
, then BlockingOperationError exception is thrown.
it works well with all jdk versions, except with jdk 22.
1) Trying with JDK 21:
install JDK 21
build and run tests (should be successful): ./gradlew build -i
try to run the sample application with blockhound agent:
wget https://repo.spring.io/artifactory/snapshot/io/projectreactor/tools/blockhound/1.0.9.BUILD-SNAPSHOT/blockhound-1.0.9.BUILD-SNAPSHOT.jar
java -javaagent:blockhound-1.0.9.BUILD-SNAPSHOT.jar -XX:+AllowRedefinitionToAddDeleteMethods -jar build/libs/blockhound-example-1.0.0-SNAPSHOT.jar
then the exception is correctly thrown by BlockHound:
Exception in thread "Thread-1" reactor.blockhound.BlockingOperationError: Blocking call! java.lang.Thread.sleep0
at java.base/java.lang.Thread.sleep0(Thread.java)
at java.base/java.lang.Thread.sleep(Thread.java:509)
at com.example.Example.lambda$main$0(Example.java:14)
at com.example.NonBlockingThread.run(NonBlockingThread.java:11)
2) now trying with JDK 22:
install jdk 22 I'm using :
openjdk version "22" 2024-03-19
OpenJDK Runtime Environment Zulu22.28+91-CA (build 22+36)
OpenJDK 64-Bit Server VM Zulu22.28+91-CA (build 22+36, mixed mode, sharing)
BlockHoundTest > testBlockHound() STANDARD_ERROR
WARNING: A Java agent has been loaded dynamically (/var/folders/jx/l0tprgfx2pnbzkghx4rrx6t80000gq/T/byteBuddyAgent7953852419399146968.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
BlockHoundTest > testBlockHound() FAILED java.lang.IllegalStateException: The instrumentation have failed. It looks like you're running on JDK 13+. You need to add '-XX:+AllowRedefinitionToAddDeleteMethods' JVM flag. See https://github.com/reactor/BlockHound/issues/33 for more info. at reactor.blockhound.BlockHound$Builder.testInstrumentation(BlockHound.java:538) at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:501) at reactor.blockhound.BlockHound.install(BlockHound.java:91) at com.example.BlockHoundTest.testBlockHound(BlockHoundTest.java:15)
actually, it's the BlockHound installation that fails, because when it is installing, it tries to verify if instrumentation is working, see [here](https://github.com/reactor/BlockHound/blob/master/agent/src/main/java/reactor/blockhound/BlockHound.java#L526).
(the test is using the special '-XX:+AllowRedefinitionToAddDeleteMethods option, see build.gradle).
- now interestingly, try to execute the application with blockhound agent (it also fails, but this times with some assert jdk errors):
java -javaagent:blockhound-1.0.9.BUILD-SNAPSHOT.jar -XX:+AllowRedefinitionToAddDeleteMethods -jar build/libs/blockhound-example-1.0.0-SNAPSHOT.jar OpenJDK 64-Bit Server VM warning: Option AllowRedefinitionToAddDeleteMethods was deprecated in version 13.0 and will likely be removed in a future release. OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:560) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:572) Caused by: java.lang.IllegalStateException: The instrumentation have failed. It looks like you're running on JDK 13+. You need to add '-XX:+AllowRedefinitionToAddDeleteMethods' JVM flag. See https://github.com/reactor/BlockHound/issues/33 for more info. at reactor.blockhound.BlockHound$Builder.testInstrumentation(BlockHound.java:538) at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:501) at reactor.blockhound.BlockHound.premain(BlockHound.java:106) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ... 3 more java.lang.instrument ASSERTION FAILED : "!errorOutstanding" with message Outstanding error when calling method in invokeJavaAgentMainMethod at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 627 java.lang.instrument ASSERTION FAILED : "success" with message invokeJavaAgentMainMethod failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 466 java.lang.instrument ASSERTION FAILED : "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 429 FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0x52cc44] jni_FatalError+0x7c V [libjvm.dylib+0x699990] JvmtiExport::post_vm_initialized()+0x2b8 V [libjvm.dylib+0xa20a08] Threads::create_vm(JavaVMInitArgs, bool)+0x6c4 V [libjvm.dylib+0x54b69c] JNI_CreateJavaVM+0x74 C [libjli.dylib+0xa510] JavaMain+0x100 C [libjli.dylib+0xd5e0] ThreadJavaMain+0xc C [libsystem_pthread.dylib+0x6fa8] _pthread_start+0x94 Abort trap: 6
I'm investigating, but that would be nice if you could play with the reproducer , maybe you will figure out somethikng ? (the assertions errors from the jdk are very strange ?)
thanks !
Quite honestly, this looks like a JVM bug to me that is related to AllowRedefinitionToAddDeleteMethods
. On the long run you need to find a way around this option as it will be removed anyways, so I might be looking into that while also reporting the bug to OpenJDK.
Thank you Rafael;
in fact, I tend to do agree, because I managed to hack BlockHound in order to instrument only one single non-native method, and in this case, it works well with JDK 22. Now, looking into JDK 22, the AllowRedefinitionToAddDeleteMethods
seems to be still there, so it sounds like a OpenJDK 22 bug, I will manage to isolate the issue and submit them a bug.
Then, for the long term, I'll start to investigate another way to instrument native methods (I have no ideas for the moment).
Thank you.
Any idea for Java 22 support.
jHipster uses Blockhound for unit testing, which in turn uses byte-buddy. Tests are failing with,
was able to move forward with the vm argument (reactor.blockhound.shaded.net.bytebuddy.experimental).
Also found a similar issue related to Java 21