RFR: 8338281: jshell does not run shutdown hooks

Jan Lahoda jlahoda at openjdk.org
Thu Aug 15 16:11:59 UTC 2024


JShell normally runs user's snippets in a separate VM. And JShell is shutting down, it will send a CLOSE command to the remote agent, and then destroy the remote process. But, the remote process, after receiving the CLOSE command will not finish on its own, run until it is destroyed by `Process.destroy`.

And `Process.destroy` may or may not run any shutdown hooks installed, which is the main point of this bug.

This patch does the following:
 - the remote agent now exits when receiving the CLOSE event (the command loop is stopped, and then the `main` method finishes)
 - the JShell's close will wait for a moment for the remote process to finish

-------------

Commit messages:
 - Fixing synchronization.
 - Introducing a constant for the shutdown.
 - Fixing the test on Windows.
 - Fixing tests.
 - 8338281: jshell does not run shutdown hooks

Changes: https://git.openjdk.org/jdk/pull/20599/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20599&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8338281
  Stats: 74 lines in 3 files changed: 72 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/20599.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20599/head:pull/20599

PR: https://git.openjdk.org/jdk/pull/20599


More information about the kulla-dev mailing list