You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the program using OpenJ9. The program will throw java.lang.IllegalStateException.
path/to/openj9/bin/java Test
java.lang.IllegalStateException: Shutdown in progress
at java.base/java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:67)
at java.base/java.lang.Runtime.addShutdownHook(Runtime.java:250)
at Test.main(Test.java:16)
Here are the source file and corresponding class file.
@hzongaro seems like a JIT issue.
Hotspot is able to run all the operations in less than 1 sec (real 0m0.652s), but OpenJ9 usually cannot so the IllegalStateException occurs.
Do you really want to add multiple shutdown hooks? If not, the call should be before the loop. Either way,it should be before scheduling the task that will call System.exit().
I think it is the point: depending on how long it takes to get from the (first) schedule() call to the check within each addShutdownHook() call is the fundamental issue with the sample code. Reorder those calls, and that timing is no longer an issue.
To clarify, the loop just makes it worse; increase the limit to something higher than 282 and Hotspot will also fail.
Java -version output
Hotspot
OpenJ9
OS
Summary of problem
When compiling and running the test case below with JDK21 using Hotspot and OpenJ9, the program behaves differently.
java.lang.IllegalStateException
.Reproduce Steps
java.lang.IllegalStateException
.Here are the source file and corresponding class file.
testcase.zip
The text was updated successfully, but these errors were encountered: