RFR: 8191441: (Process) add Readers and Writer access to java.lang.Process streams [v3]

Roger Riggs rriggs at openjdk.java.net
Mon May 24 01:24:24 UTC 2021


On Mon, 24 May 2021 00:33:06 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Methods are added to java.lang.Process to read and write characters and lines from and to a spawned Process.
>> The Charset used to encode and decode characters to bytes can be specified or use the
>> operating system native encoding as is available from the "native.encoding" system property.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added throws for NPE, delegated zero-arg methods that use native.encoding to
>   the 1-arg method with a charset, added tests for Redirect cases where the streams are null-input or null-output streams.

Thanks for the comments, most are addressed.

> The updated proposal looks reasonable, as does the names of the methods.
> 
> I think the javadoc will need to specify how malformed or unmappable byte sequence are handled. The implNote does document that it uses InputStreamReader so this means that erroneous input is replaced but this isn't normative text.
> 
> It may be useful to specify how these methods are intended to work when the process has terminated. I realise the existing getXXXX aren't clear on this point and maybe they should.
> 
> The API note that warns about unpredictable behavior then trying to use both the byte and character stream probably needs to go into the existing methods too.
> 
> NPE will need to be documented as I don't think the Process class description has a statement to avoid clutter in the method descriptions. You will eventually need to add the @SInCE javadoc tag too.
> 
> Is there more test coverage to come? I don't see tests that exercise the redirect cases or NPE. The test updates includes an adjustment to how SerialFilterTest is run - is that meant to be included?
> 
> A formatting nit is that the line lengths are very really long compared to the rest of the source file.

On the question of process termination behavior, I'm not sure what can be said that could be specification.
The implementations vary between Mac, Linux, and Windows; with the common thread 
to avoid losing process output. But this may have to be included in the unspecified implementation behavior
or just an API note.  Suggestions?

I need to address what happens when these methods are called more than once.
They should return the same instance as the previous call.

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

PR: https://git.openjdk.java.net/jdk/pull/4134


More information about the core-libs-dev mailing list