RFR: 8357995: Use "stdin.encoding" for reading System.in with InputStreamReader/Scanner [core]

Alan Bateman alanb at openjdk.org
Fri May 30 14:27:51 UTC 2025


On Fri, 30 May 2025 11:07:30 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

> Passes the `Charset` read from the `stdin.encoding` system property while creating `InputStreamReader` or `Scanner` instances for `System.in`.
> 
> `stdin.encoding` is a recently added property for Java 25 in [JDK-8350703](https://bugs.openjdk.org/browse/JDK-8350703). Employing it throughout the entire code base is addressed by the parent ticket [JDK-8356893](https://bugs.openjdk.org/browse/JDK-8356893). JDK-8357995 this PR is addressing is a sub-task of JDK-8356893 and is concerned with only areas related to core libraries.

test/jdk/com/sun/tools/attach/Application.java line 40:

> 38: 
> 39:         try (BufferedReader br = new BufferedReader(new InputStreamReader(
> 40:                 System.in, System.getProperty("stdin.encoding")))) {

This "application" is launched by the test so connected to the parent process rather than the console.

test/jdk/java/lang/ProcessHandle/JavaChild.java line 315:

> 313:                         // children and wait for each to exit
> 314:                         sendResult(action, "start");
> 315:                         try (Reader reader = new InputStreamReader(System.in, System.getProperty("stdin.encoding"));

I didn't study the test closely but I think this is another case where a child process is launched so System.in is connected to the parent rather than the console.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25544#discussion_r2116027806
PR Review Comment: https://git.openjdk.org/jdk/pull/25544#discussion_r2116031061


More information about the nio-dev mailing list