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

Joe Darcy darcy at openjdk.org
Mon Oct 27 18:22:37 UTC 2025


On Mon, 27 Oct 2025 17:32:20 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/Process.java line 212:
>> 
>>> 210:      * The {@code outputWriter} and {@code outputStream} to the process are closed.
>>> 211:      * The {@code inputReader} and {@code inputStream} from the process are closed.
>>> 212:      * The {@code errorReader} and {@code errorStream} from the process are closed.
>> 
>> The implSpec is quite verbose as it lists all 6 streams and character streams. Maybe shorten to say that the method first closes all I/O streams, then waits for the process to terminate?
>
> I expect the implSpec to be specific as to the order and enumerate the actions.
> Given the detail in the rest of the javadoc, perhaps the @implSpec is redundant and unnecessary.

The `Process.close()` method is not only overridable by subclasses, it is supposed to be overridden. An `@implSpec` tag is the proper mechanism to document in detail the operational semantics of `Process.close()`, including the other method of `Process` that it calls. Some of the other text describing that could be moved here.

In additional, perhaps an `@apiNote` should be added to this method "hey, if you're overriding this method, make sure to call super, etc." to supplement the statement to that effect at the class-level.

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

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


More information about the core-libs-dev mailing list