RFR: 8264208: Console charset API [v11]

Naoto Sato naoto at openjdk.java.net
Thu Apr 22 15:45:32 UTC 2021


On Thu, 22 Apr 2021 15:18:11 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 13 additional commits since the last revision:
>> 
>>  - Refined the test case.
>>  - Merge branch 'master' into JDK-8264208
>>  - Changed shell based test into java based
>>  - Added link to Charset#defaultChaset() in InputStreamReader.
>>  - Modified javadocs per suggestions.
>>  - Added @see links.
>>  - Added Console::charset() relation with System.in
>>  - Added comment to System.out/err init.
>>  - Reflected further review comments.
>>  - Reverted PrintStream changes
>>  - ... and 3 more: https://git.openjdk.java.net/jdk/compare/51627555...e585d16f
>
> src/java.base/share/classes/java/io/Console.java line 597:
> 
>> 595:                 return null;
>> 596:             }
>> 597:         });
> 
> Please keep the charset() method and return CHARSET.
> 
> I'm looking at a use case that needs to know the platform charset regardless of whether the console exists.
> When a process is launched it may be redirected to /dev/tty or a pseudo tty and in that case
> a Reader from that stream should be able to use the encoding of the platform.
> Its still a work in progress, but it would save some refactoring or duplication later.

Would the singleton `Console.cons` be instantiated in your use case? It is created only when isatty() (or Windows' equivalent) in the native code returns true.

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

PR: https://git.openjdk.java.net/jdk/pull/3419



More information about the security-dev mailing list