RFR: 8361972: Clarify the condition of System.console() about standard input/output [v3]
Stuart Marks
smarks at openjdk.org
Thu Aug 21 00:19:54 UTC 2025
On Mon, 14 Jul 2025 20:58:56 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - Wording change, isTerminal() always returns true
>> - Merge branch 'master' into JDK-8361972-System-console-condition
>> - Wording modification
>> - initial commit
>
> src/java.base/share/classes/java/io/Console.java line 47:
>
>> 45: * output streams then its console will exist and will typically be
>> 46: * connected to the keyboard and display from which the virtual machine
>> 47: * was launched. If the virtual machine is started automatically, for
>
> I think it might read easier if we reword the structure of the sentence to make it more concise.
>
> E.g.
>
>> The virtual machine may not have a console if started automatically, (e.g., by a background scheduler) or if either the standard input or output has been redirected.
I took another look at this and I agree that some rewording is necessary. There are several inconsistencies in the wording here, e.g., between "exists / does not exist" or "the virtual machine has a console / does not have a console" or "a console / a console device". I rewrote the first couple paragraphs here to unify the wording around a console as a noun (that is, no "console device") and to use "exists / does not exist" consistently. I also made some areas a bit more definite.
* <p> Whether a virtual machine's console exists is dependent upon the
* underlying platform and also upon the manner in which the virtual
* machine is invoked. If the virtual machine is started from an
* interactive command line without redirecting the standard input and
* output streams, then its console will generally exist and will be
* connected to the keyboard and display from which the virtual machine
* was launched. If the standard input or standard output have been
* redirected (for example, to a file or to a pipe), or if the virtual
* machine was started from a background job scheduler, the console
* will not exist.
* <p>
* If the console exists, then it is represented by a unique instance of this
* class which can be obtained by invoking the {@link System#console()} method.
* If the console does not exist, that method will return {@code null}.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26299#discussion_r2289573821
More information about the core-libs-dev
mailing list