RFR: 8361972: Clarify the condition of System.console() about standard input/output
Justin Lu
jlu at openjdk.org
Mon Jul 14 20:53:40 UTC 2025
On Mon, 14 Jul 2025 19:38:04 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> src/java.base/share/classes/java/io/Console.java line 49:
>>
>>> 47: * was launched. If the virtual machine is started automatically, for
>>> 48: * example by a background job scheduler, or if one or both of the
>>> 49: * standard input or output has been redirected, then it may not have a
>>
>> If we are claiming that `System.console()` should **only** return a "Console instance only when both standard input and output are connected to a terminal." then is the _may_ wording not restrictive enough? Or is that nuance negligible?
>
> Intention here is that, we do want to restirct to not return JLine based Console when either/both of stdin/out is redirected, I think we would not want to restrict them as the spec. For example, `System.console()` in jshell returns non-null, even if the remote JVM is not-attached to a terminal. I will describe this sublety in the CSR
OK, I see your point. It is a hint as to what the behavior of this implementation does, but not enforced in the specification by any means as indicated by the _may_ wording. Nit: if that is the case, then shouldn't there technically be minimal compatibility risk in the CSR, since nothing is being "enforced" specification wise.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26299#discussion_r2205797490
More information about the core-libs-dev
mailing list