RFR: 8364361: [process] java.lang.Process should implement close and be AutoCloseable [v6]
David Lloyd
dmlloyd at openjdk.org
Thu Sep 4 12:30:44 UTC 2025
On Wed, 3 Sep 2025 21:38:14 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> `DestroyForcibly` is an escalation that should only be used with a known poorly behaved process; and that's up to the programmer. It is the equivalent of `kill -9`. It should not be used in the normal case. Unfortunately, Windows does not have a polite, please terminate API so `destroy` has the same behavior as `destroyForcibly`.
This is my point exactly; the behavior will differ between Windows and non-Windows. (I didn't want to name-and-shame any particular OS though.) :-)
> If the caller uses `process.waitFor()` within the try-catch, the process will have terminated, possibly based on the stream closings, and `destroy()` will not be called. If emphasis is needed, the javadoc can elaborate.
OK. Clarifying in the javadoc would be option three then (the other two options being the two ways mentioned to make the behavior equitable between platforms).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2321933225
More information about the core-libs-dev
mailing list