JDK-8294817 : Define and specify Runtime shutdown sequence
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Draft
  • Resolution: Unresolved
  • Fix Versions: 20
  • Submitted: 2022-10-05
  • Updated: 2022-10-05
Related Reports
CSR :  
Description
Summary
-------

Update the `java.lang.Runtime` class specification to describe the *shutdown sequence*.

Problem
-------

The *shutdown hooks* mechanism was added in JDK 1.3. This allowed some special "hooks"
(really, threads) to be run after `System.exit` was called but before the JVM actually
terminated. Unfortunately, documentation of the exact behavior of hooks with respect to the actual
shutdown and exit of the JVM was piecemeal, and there were several places in the specifications
that had misleading or out-of-date information, such as statements that "The System.exit() method
terminates the JVM." Similarly out-of-date information was present in the JLS, the JVMS, and the
JNI Specifications.

Solution
--------

Update the `java.lang.Runtime` class specification to define the *shutdown sequence*, what
causes it to start, and what happens when it finishes (or not). Also make minor adjustments
to various places in `Thread` and `System`.

Note that corresponding changes to other specifications are also being made:

 * [JDK-8290388](https://bugs.openjdk.org/browse/JDK-8290388) - JVMS changes
 * [JDK-8290196](https://bugs.openjdk.org/browse/JDK-8290196) - JLS changes
 * [JDK-8290482](https://bugs.openjdk.org/browse/JDK-8290482) - JNI Specification changes

Specification
-------------

See attached specdiff.