RFR: 8366261: Provide utility methods for sun.security.util.Password [v5]

Stuart Marks smarks at openjdk.org
Thu Sep 4 23:49:27 UTC 2025


On Tue, 2 Sep 2025 16:29:32 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> Providing a couple of utility methods using the "built-in" `Console` implementation to support tools that require password input, such as `keytool`, ensuring they work even when std0ut is redirected.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Refining comments

src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java line 133:

> 131:                         Charset.forName(StaticProperty.stdinEncoding(), UTF_8.INSTANCE),
> 132:                         Charset.forName(StaticProperty.stdoutEncoding(), UTF_8.INSTANCE))) :
> 133:                 Optional.empty();

(Finally getting back to this.)

The code returns an Optional containing a JdkConsoleImpl instance, or an empty Optional. However the comment above says it returns a JdkConsoleImpl instance or null. Which do we want it to be? Either is OK, but the comment should agree with the code.

I think @wangweij might want to weigh in here since his code will be calling this.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26973#discussion_r2323743307


More information about the security-dev mailing list