RFR: 8364361: [process] java.lang.Process should implement Closeable [v13]

Jason Mehrens duke at openjdk.org
Wed Oct 1 17:01:18 UTC 2025


On Wed, 1 Oct 2025 13:00:41 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/Process.java line 205:
>> 
>>> 203:      * On some platforms, {@linkplain #supportsNormalTermination() normal termination}
>>> 204:      * is not available and the process is forcibly terminated.
>>> 205:      * The {@linkplain #waitFor() waitFor} method SHOULD NOT be called after
>> 
>> Calling waitFor with a timeout is a must for escalation of process termination.  E.G. TWR + finally waitFor with timeout. Then destroy with force. Optionally waitFor again if we need to know process is terminated.
>> 
>> It is not waitFor that should not be used. It is the result of exitValue or waitFor may or may not be a normal value from the process after any destroy method.
>
> @jmehrens I think I understand your point. Does this capture it:
> 
>      * Calling {@linkplain #waitFor() waitFor} after
>      * {@linkplain #close() close} or after the try-with-resources block exits
>      * can verify that the process has been terminated.
>      * The status returned may be from normal termination or the result of
>      * {@link #destroy() destroying the process}.

Looks good. Thanks for update.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2395260463


More information about the core-libs-dev mailing list