RFR: 8361972: Clarify the condition of System.console() about standard input/output [v2]
Alan Bateman
alanb at openjdk.org
Sun Jul 20 06:48:38 UTC 2025
On Thu, 17 Jul 2025 17:39:01 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> 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.
>
> Since the decision of whether a console exists is dependent on the implementation as specified,
>
>> Whether a virtual machine has a console is dependent upon the underlying platform
>
> And the existing wording in this paragraph uses open-ended words such as "may" and "typically", it makes sense to me that this change would follow the same style of wording. If you wanted to concretely define what this implementation does, using one of the `@impl` tags to describe the behavior could be an option?
Okay, so the intent is to specify that it is implementation or configuration specific as to whether there is a Console when standard input or output, but not both, are redirected, is that right? What should users expect isTerminal to return in this case?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26299#discussion_r2217642624
More information about the core-libs-dev
mailing list