On Mon, 4 Jul 2022 01:59:37 GMT, Kim Barrett <kbarr...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Runtime.java line 89: >> >>> 87: * of the first invocation will be used; the status codes from >>> other invocations >>> 88: * will be ignored. If this method is invoked from a shutdown hook >>> the system >>> 89: * will deadlock. >> >> Expressing this accurately is tricky - what is "first" here? I suggest the >> following: >> >>> Invocations of this method are serialized such that only one invocation >>> will actually proceed with the shutdown sequence and terminate the VM with >>> the given status code. All other invocations will block indefinitely. If >>> this method is invoked from a shutdown hook the system will deadlock. > > +1 - except for the "deadlock" part (see other comment). I think the old > paragraph is at least confusing, and perhaps even just wrong. Let's say > we've run `shutdown` so run all the hooks but not halted. Then someone calls > `exit(0)`. That seems to suggest the call will block indefinitely, which is > neither desirable nor what was actually implemented. David's refinement looks good. The sentence on deadlock is accurate as shutdown hooks run on other threads, not the thread calling System.ext. ------------- PR: https://git.openjdk.org/jdk/pull/9351