RFR: 8357995: Use "stdin.encoding" for reading System.in with InputStreamReader/Scanner [core] [v2]
Chris Plummer
cjplummer at openjdk.org
Mon Jun 2 19:29:50 UTC 2025
On Mon, 2 Jun 2025 19:27:08 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.
>
> Volkan Yazici has updated the pull request incrementally with two additional commits since the last revision:
>
> - Provide fallback for `stdin.encoding`
> - Revert changes to `Application` and `JavaChild`
>
> There stdin is connected to the parent process rather than the console.
test/jdk/com/sun/jdi/MultiBreakpointsTest.java line 141:
> 139: Thread console(final int num, final int nhits) {
> 140: final InputStreamReader isr = new InputStreamReader(
> 141: System.in, Charset.forName(System.getProperty("stdin.encoding")));
`isr` is not really needed. It is used to create `br`, which is never used. It is also synchronized on, but since there is a unique `isr` for each thread, the synchronization does nothing. I suggest just deleting `isr`, `br`, and the `synchronized` below.
Note there is a hint in a comment as to why it is like this:
// This is a tendril from the original jdb test.
// It could probably be deleted.
I think this test once used jdb (and had to deal with the jdb console), but no longer does.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25544#discussion_r2121984300
More information about the security-dev
mailing list