RFR: 8288984: Simplification in Shutdown.exit [v2]
Kim Barrett
kbarrett at openjdk.org
Mon Jul 4 07:50:47 UTC 2022
On Sat, 2 Jul 2022 21:21:37 GMT, Ryan Ernst <duke at openjdk.org> wrote:
>> This is a followup to simplify Shutdown.exit after the removal of
>> finalizers (https://bugs.openjdk.org/browse/JDK-8198250). Once agreement
>> on the approach has been reached in this PR, a CSR will be filed to
>> propose the spec change to Runtime.exit.
>
> Ryan Ernst has updated the pull request incrementally with one additional commit since the last revision:
>
> better clarify multiple threads behavior
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.
Is "deadlock" accurate? I thought Java monitors were reentrant, with the result that a shutdown hook calling `exit` would lead to a recursive `runHooks` which would run all the hooks, including *rerunning* hooks before the one that called exit (which could be bad), and then rerunning the hook that called exit (possibly leading to infinite recursion), then running later hooks, then returning to rerun those later hooks. This situation could be made perhaps less bad by having runHooks null out each entry in the hooks table before it runs that hook, or using currentRunningHook to determine which hooks to run in runHooks. Or something else, like immediate exit in this case. (That would be spec change.)
-------------
PR: https://git.openjdk.org/jdk/pull/9351
More information about the core-libs-dev
mailing list