RFR: 8357993: Use "stdin.encoding" for reading System.in with InputStreamReader/Scanner [hotspot] [v2]

Chris Plummer cjplummer at openjdk.org
Mon Jun 2 19:02:53 UTC 2025


On Mon, 2 Jun 2025 18:39:33 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-8357993 this PR is addressing is a sub-task of JDK-8356893 and is concerned with only areas related to Hotspot.
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Provide fallback for `stdin.encoding`

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CLHSDB.java line 111:

> 109: 
> 110:         Charset charset = Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset());
> 111:         BufferedReader in = new BufferedReader(new InputStreamReader(System.in, charset));

Why in some cases are you special casing the the default charset as you do here, but in other cases you are not? Also, the CharSet.forName() API you are using here is new in 18, which means backports will need to address that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25542#discussion_r2121939764


More information about the serviceability-dev mailing list