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

Naoto Sato naoto at openjdk.java.net
Thu May 20 20:50:30 UTC 2021


On Thu, 20 May 2021 19:57:22 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.

Good to see `native.encoding` is utilized. Some comments follow.

src/java.base/share/classes/java/lang/Process.java line 25:

> 23:  * questions.
> 24:  */
> 25: 

Copyright year -> 2021

src/java.base/share/classes/java/lang/Process.java line 181:

> 179:      * @return a {@link BufferedReader BufferedReader} using the {@code native.encoding} if supported,
> 180:      *          otherwise, the {@link Charset#defaultCharset()}
> 181:      */

`@since 17` is needed (and for other public methods)

src/java.base/share/classes/java/lang/Process.java line 771:

> 769: 
> 770:         /**
> 771:          * {@return Charset for the native encoding or {@link Charset#defaultCharset()}

Need some edit here?

test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java line 64:

> 62:         return new Object[][] {
> 63:                 {"UTF-8"},
> 64:                 {"ISO8859-1"},

`ISO8859-1` may not be available on all underlying OSes.

test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java line 111:

> 109:     @Test(dataProvider = "CharsetCases", enabled = true)
> 110:     void testCase(String nativeEncoding) throws IOException {
> 111:         String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT);

Not used anywhere else.

test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java line 122:

> 120:                 "ReaderWriterTest$ChildWithCharset");
> 121:         var env = pb.environment();
> 122:         env.put("LANG", "en_US." + cleanCSName);

Does this work on Windows?

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

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


More information about the core-libs-dev mailing list