On Mon, 5 Dec 2022 19:52:59 GMT, Naoto Sato <na...@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 one additional 
> commit since the last revision:
> 
>   Fixed the copyright year

Hello Naoto, the class level javadoc of `java.io.Console` currently specifies 
synchronization expectations in the context of multithreaded use:

>  Read and write operations are synchronized to guarantee the atomic
>  completion of critical operations; therefore invoking methods
>  {@link #readLine()}, {@link #readPassword()}, {@link #format format()},
>  {@link #printf printf()} as well as the read, format and write operations
>  on the objects returned by {@link #reader()} and {@link #writer()} may
>  block in multithreaded scenarios.

So the `Console` instance returned from `System.console()`, thus far, follows 
these semantics. However, with the change proposed in this PR, the default 
implementation will now be the jline backed `JdkConsoleImpl` implementation. 
From what I can see there, we don't seem to have any similar guarantees around 
multithreaded access. Do we need similar locking constructs in that 
implementation to guarantee/verify it works as per the expectations of 
`java.io.Console` API?

While we are at it, the Console class level javadoc also states:

> If the virtual machine is started from an
> interactive command line without redirecting the standard input and
> output streams then its console will exist and will typically be
> connected to the keyboard and display from which the virtual machine
> was launched.

With this proposed change, to by default use the jline backed implementation, 
would we need to reword/update that javadoc?

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

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

Reply via email to