RFR: 8295857: Clarify that cleanup code can be skipped when the JVM terminates (e.g. when calling halt()) [v4]
Stuart Marks
smarks at openjdk.org
Wed Nov 23 17:37:16 UTC 2022
On Tue, 22 Nov 2022 00:50:51 GMT, Brent Christian <bchristi at openjdk.org> wrote:
>> [JDK-8290036](https://bugs.openjdk.org/browse/JDK-8290036) documented the shutdown sequence, noting that calling Runtime.halt() skips the shutdown sequence and immediately terminates the VM. Thus, "threads' current methods do not complete normally or abruptly; no finally clause of any method is executed".
>>
>> One ramification of this is that resources within try-with-resource blocks will not be released. It would be good to state this explicitly.
>
> Brent Christian has updated the pull request incrementally with one additional commit since the last revision:
>
> Update Runtime class doc re: other unexpected behaviors
src/java.base/share/classes/java/lang/Runtime.java line 285:
> 283: * actions intended to be performed by shutdown hooks,
> 284: * {@linkplain Thread.UncaughtExceptionHandler uncaught exception handlers},
> 285: * finally blocks, or try-with-resources blocks. This can lead to data corruption.
Since the examples of the consequences of halting are covered above in "JVM Termination" and are getting a bit involved, I'd suggest not trying to list the concrete consequences here, and referring the reader (again) to the "JVM Termination" section.
-------------
PR: https://git.openjdk.org/jdk/pull/11218
More information about the core-libs-dev
mailing list