RFR: 8356420: Provide examples on wrapping System.in [v4]

Stuart Marks smarks at openjdk.org
Tue May 13 00:57:52 UTC 2025


On Mon, 12 May 2025 21:59:29 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> With the introduction of `stdin.encoding` ([JDK-8350703](https://bugs.openjdk.org/browse/JDK-8350703)), some guidance for users to decode `System.in` would be desirable. Adding examples in the field description would help.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Reflects more comments

src/java.base/share/classes/java/lang/System.java line 129:

> 127:      * within the object that handles character encoding. After this is done,
> 128:      * subsequent reading should use only the wrapper object; operating directly
> 129:      * on {@code System.in} results in unspecified behavior.

Sorry, I think I suggested this wording initially, but I now think it needs to be changed. I'd suggest changing the text after the semicolon to

> continuing to operate directly on {@code System.in} results in unspecified behavior.

src/java.base/share/classes/javax/security/auth/callback/CallbackHandler.java line 116:

> 114:      *          System.err.flush();
> 115:      *          nc.setName((new BufferedReader
> 116:      *                  (new InputStreamReader(System.in, "stdin.encoding"))).readLine());

Needs to be `System.getProperty("stdin.encoding"))`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25155#discussion_r2085741488
PR Review Comment: https://git.openjdk.org/jdk/pull/25155#discussion_r2085739806


More information about the core-libs-dev mailing list