RFR: 8354872: Clarify java.lang.Process resource cleanup

Jaikiran Pai jpai at openjdk.org
Fri Jun 27 16:28:38 UTC 2025


On Wed, 18 Jun 2025 20:16:18 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Improve the documentation of Process use of system resources.
> 
> Describe the implementation closing streams when no longer referenced.
> Clarify the interactions between inputStream and inputReader and errorStream and errorReader.
> Add advice and example using try-with-resources to open and close streams.
> Recommend closing streams when no longer in use.

The copyright years on these files will need an update.

src/java.base/share/classes/java/lang/ProcessBuilder.java line 545:

> 543:          * {@snippet lang = "java" :
> 544:          *     Redirect.DISCARD.file() // is the filename appropriate for the operating system
> 545:          *     Redirect.DISCARD.type() == Redirect.Type.WRITE

With this use of snippet here I think it no longer conveys what the original `{@code}` block was trying to convey. I can't currently think of a better proposal either.

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

PR Comment: https://git.openjdk.org/jdk/pull/25884#issuecomment-3013634413
PR Review Comment: https://git.openjdk.org/jdk/pull/25884#discussion_r2172385878


More information about the core-libs-dev mailing list