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

8295857: Clarify that cleanup code can be skipped when the JVM terminates (e.g. when calling halt()) #11218

Closed
wants to merge 10 commits into from
12 changes: 7 additions & 5 deletions src/java.base/share/classes/java/lang/Runtime.java
Expand Up @@ -90,9 +90,10 @@
*
* <p>When the JVM terminates, all threads are immediately prevented from executing any further
* Java code. This includes shutdown hooks as well as daemon and non-daemon threads. The
* threads' current methods do not complete normally or abruptly; no {@code finally} clause
* of any method is executed, nor is any {@linkplain Thread.UncaughtExceptionHandler
* uncaught exception handler}.
* threads' current methods do not complete normally or abruptly.
* {@linkplain Thread.UncaughtExceptionHandler Uncaught exception handlers} are not run,
* no {@code finally} clause of any method is executed, and try-with-resources
* blocks do not {@linkplain AutoCloseable close} their resources.
*
* @implNote
* Native code typically uses the
Expand Down Expand Up @@ -277,8 +278,9 @@ public boolean removeShutdownHook(Thread hook) {
*
* @apiNote
* This method should be used with extreme caution. Using it may circumvent or disrupt
* any cleanup actions intended to be performed by shutdown hooks, possibly leading to
* data corruption.
* any cleanup actions intended to be performed by shutdown hooks,
* {@linkplain Thread.UncaughtExceptionHandler uncaught exception handlers},
* finally blocks, or try-with-resources blocks. This can lead to data corruption.
bchristi-git marked this conversation as resolved.
Show resolved Hide resolved
*
* @param status
* Termination status. By convention, a nonzero status code
Expand Down