RFR: 8364361: [process] java.lang.Process should implement Closeable [v24]
Roger Riggs
rriggs at openjdk.org
Thu Oct 30 21:17:23 UTC 2025
On Thu, 30 Oct 2025 01:57:06 GMT, Jason Mehrens <duke at openjdk.org> wrote:
>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add \@implNote to recommend overriding close and calling `super.close()`.
>
> src/java.base/share/classes/java/lang/snippet-files/ProcessExamples.java line 31:
>
>> 29: public class ProcessExamples {
>> 30: // @start region=example
>> 31: void example() {
>
> Should there be another version of this that is involved with interruption set at top of method? That example would forever freeze which shows there is a problem with the example.
I don't see a hang in this example, it writes 3 lines to the child and flushes and closes the output stream.
`cat` will see end of file and exit.
Almost all processes started will exit when they've done what they are supposed to.
A more defensive example would give the impression that every use of a process should follow the same pattern.
It adds a lot of boilerplate to schedule an interrupt and then cancel when the process exits.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2479546092
More information about the core-libs-dev
mailing list