RFR: 8361972: Clarify the condition of System.console() about standard input/output [v2]

Naoto Sato naoto at openjdk.org
Tue Jul 22 18:17:55 UTC 2025


On Sun, 20 Jul 2025 06:46:01 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> 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?

For the jshell case, I think it can return `true` from its `isTerminal()` as it is infact interactive environment. That means all the Console implementations return `true` so that we can replace that "may not have a Console" with "will not have a Console", which is clearer.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26299#discussion_r2223438918


More information about the core-libs-dev mailing list