RFR: 8356985: Use "stdin.encoding" in Console's read*() methods [v5]
Stuart Marks
smarks at openjdk.org
Fri May 23 03:49:51 UTC 2025
On Thu, 22 May 2025 17:46:33 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> `java.io.Console` uses the charset specified by the `stdout.encoding` system property for both input and output. While this is generally sufficient, since Console is intended for interactive terminal use, some platforms allow different encodings to be configured for input and output. In such cases, using a single encoding may lead to incorrect behavior when reading from the terminal. To address this, the newly introduced system property, `stdin.encoding`, should be used specifically for input where appropriate.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>
> Reflects wording change suggestions
I may be overthinking this, but let me just toss this out there to get people's opinions.
This changes the API of `jdk.internal.io.JdkConsoleProvider`. OK, this is an internal interface, so strictly speaking we can change it at will. But... do the IDEs use this to interface to implement their in-IDE terminal emulator? I'm not sure; maybe we should ask @lahodaj .
Well, the IDEs can probably easily adapt based on the JDK version. Or, if we want to be nice, we can leave the two-arg `console` method in place and have a default implementation for the three-arg `console` method that just calls the two-arg method with one of the charsets. Might not be worth it though.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25271#issuecomment-2903161425
More information about the core-libs-dev
mailing list