RFR: 8295803: Console should be usable in jshell and other environments [v2]

Alan Bateman alanb at openjdk.org
Thu Dec 1 15:18:39 UTC 2022


On Wed, 30 Nov 2022 20:44:30 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> This is to allow Console to be used even when it is not attached to the platform provided terminal, such as the case when the standard input is redirected. `System.console()` now returns a Console implementation based on `jdk.internal.le` terminal by default, or jshell implementation if available. A corresponding CSR has been drafted.
>
> Naoto Sato has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Adds a test
>  - Removed JavaIOAccess.charset() which is no longer needed

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

> 2131:     }
> 2132: 
> 2133:     private static InputStream initIn = null;

I think it would be helpful to rename this to `initialIn` and move this to be with `in` and `out`. It might also be helpful to have a  comment to say that it's the initial value of `in`, set in initPhase1.  It doesn't need to be initialized to null as that it's default value anyway.

src/java.base/share/classes/sun/security/util/Password.java line 63:

> 61:                 // readPassword returns "" if you just press ENTER with the built-in Console,
> 62:                 // to be compatible with old Password class, change to null
> 63:                 if (consoleEntered == null || consoleEntered.length == 0) {

@wangweij Would you have cycles to build with this change to see that keytool is okay?

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

PR: https://git.openjdk.org/jdk/pull/11421


More information about the core-libs-dev mailing list