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

Alan Bateman alanb at openjdk.org
Thu Jul 17 07:42:48 UTC 2025


On Mon, 14 Jul 2025 22:39:56 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> This accompanies the fix for [JDK-8361613](https://bugs.openjdk.org/browse/JDK-8361613), which restricts `System.console()` to return a `Console` instance only when both standard input and output are connected to a terminal. The change here is solely a specification clarification and tightening of the `java.io.Console` javadoc to reflect this behavior. We are separating the spec clarification because the fix itself may be backported to prior LTS releases without requiring a Maintenance Review process.
>
> 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.

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

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


More information about the core-libs-dev mailing list