RFR: 8361972: Clarify the condition of System.console() about standard input/output [v2]
Naoto Sato
naoto at openjdk.org
Thu Jul 17 16:50:51 UTC 2025
On Thu, 17 Jul 2025 07:40:28 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Wording modification
>
> src/java.base/share/classes/java/io/Console.java line 51:
>
>> 49: * console. Regardless of how the virtual machine was created, it may not
>> 50: * have a console if either the standard input or output stream is
>> 51: * redirected.
>
> Can you clarify what the intent of "it may not have a console" is? Initially I though the intention was that there is no Console when either stdout or stdin is redirected. However, the sentence suggests there may or may not be a Console.
I was considering the case for `jshell`, where its `System.console()` returns a `Console` instance regardless of the `isTTY` state:
https://github.com/openjdk/jdk/blob/bd55d7a49514da9fa4de0d4a372956e21deab4d2/src/jdk.jshell/share/classes/jdk/jshell/execution/impl/ConsoleImpl.java#L70
That led me to use `may` in the updated spec. I'd appreciate your suggestions on wording.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26299#discussion_r2213837754
More information about the core-libs-dev
mailing list