Skip to content

Commit

Permalink
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: lancea, bpb, naoto, dholmes, smarks
  • Loading branch information
Brent Christian committed Dec 12, 2022
1 parent 781a2e0 commit c7aca73
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/java.base/share/classes/java/lang/Runtime.java
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

3 comments on commit c7aca73

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@bchristi-git
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk20

@openjdk
Copy link

@openjdk openjdk bot commented on c7aca73 Dec 12, 2022

Choose a reason for hiding this comment

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

@bchristi-git the backport was successfully created on the branch bchristi-git-backport-c7aca731 in my personal fork of openjdk/jdk20. To create a pull request with this backport targeting openjdk/jdk20:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c7aca731 from the openjdk/jdk repository.

The commit being backported was authored by Brent Christian on 12 Dec 2022 and was reviewed by Lance Andersen, Brian Burkhalter, Naoto Sato, David Holmes and Stuart Marks.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk20:

$ git fetch https://github.com/openjdk-bots/jdk20 bchristi-git-backport-c7aca731:bchristi-git-backport-c7aca731
$ git checkout bchristi-git-backport-c7aca731
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk20 bchristi-git-backport-c7aca731

Please sign in to comment.