Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.


Browse files Browse the repository at this point in the history
8295857: Clarify that cleanup code can be skipped when the JVM termin…
…ates (e.g. when calling halt())

Reviewed-by: iris
Backport-of: c7aca73
  • Loading branch information
Brent Christian committed Dec 13, 2022
1 parent 04b8d0c commit bf78f71
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/java.base/share/classes/java/lang/
Expand Up @@ -89,10 +89,14 @@
* shutdown sequence.
* <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}.
* Java code. This includes shutdown hooks as well as daemon and non-daemon threads.
* This means, for example, that:
* <ul>
* <li>threads' current methods do not complete normally or abruptly;</li>
* <li>{@code finally} clauses are not executed;</li>
* <li>{@linkplain Thread.UncaughtExceptionHandler uncaught exception handlers} are not run; and</li>
* <li>resources opened with try-with-resources are not {@linkplain AutoCloseable closed};</li>
* </ul>
* @implNote
* Native code typically uses the
Expand Down Expand Up @@ -278,7 +282,8 @@ 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.
* data corruption. See the <a href="#termination">termination</a> section above
* for other possible consequences of halting the Java Virtual Machine.
* @param status
* Termination status. By convention, a nonzero status code
Expand Down

1 comment on commit bf78f71

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.