From 4db1950e7af7779e156e98db0730f4cd12fbf979 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Mon, 14 Jul 2025 10:02:47 -0700 Subject: [PATCH 1/3] initial commit --- src/java.base/share/classes/java/io/Console.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index 838334a0901fe..c3acb58e3ec0b 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -45,8 +45,9 @@ * output streams then its console will exist and will typically be * connected to the keyboard and display from which the virtual machine * was launched. If the virtual machine is started automatically, for - * example by a background job scheduler, then it may not - * have a console. + * example by a background job scheduler, or if one or both of the + * standard input or output has been redirected, then it may not have a + * console. *

* If this virtual machine has a console then it is represented by a * unique instance of this class which can be obtained by invoking the From e2a64c959a03946a8388b5a95c583cdffcfa57d8 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Mon, 14 Jul 2025 15:01:26 -0700 Subject: [PATCH 2/3] Wording modification --- src/java.base/share/classes/java/io/Console.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index c3acb58e3ec0b..bd528913f90fc 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -45,9 +45,10 @@ * output streams then its console will exist and will typically be * connected to the keyboard and display from which the virtual machine * was launched. If the virtual machine is started automatically, for - * example by a background job scheduler, or if one or both of the - * standard input or output has been redirected, then it may not have a - * console. + * example by a background job scheduler, then it may not have a + * console. Regardless of how the virtual machine was created, it may not + * have a console if either the standard input or output stream is + * redirected. *

* If this virtual machine has a console then it is represented by a * unique instance of this class which can be obtained by invoking the From a3b390492753c17d1c9112ee75c2604021427864 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 22 Jul 2025 11:04:20 -0700 Subject: [PATCH 3/3] Wording change, isTerminal() always returns true --- .../share/classes/java/io/Console.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index bd528913f90fc..39578cfd86380 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -42,17 +42,17 @@ * 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 exist and will typically be + * output streams, then its console will exist and will typically be * connected to the keyboard and display from which the virtual machine * was launched. If the virtual machine is started automatically, for - * example by a background job scheduler, then it may not have a - * console. Regardless of how the virtual machine was created, it may not - * have a console if either the standard input or output stream is - * redirected. + * example by a background job scheduler, then it may not + * have a console. Regardless of how the virtual machine was created, + * it will not have a console if either the standard input or output + * stream is redirected. *

* If this virtual machine has a console then it is represented by a * unique instance of this class which can be obtained by invoking the - * {@link java.lang.System#console()} method. If no console device is + * {@link System#console()} method. If no console device is * available then an invocation of that method will return {@code null}. *

* Read and write operations are synchronized to guarantee the atomic @@ -537,18 +537,14 @@ public Charset charset() { /** * {@return {@code true} if the {@code Console} instance is a terminal} *

- * This method returns {@code true} if the console device, associated with the current - * Java virtual machine, is a terminal, typically an interactive command line - * connected to a keyboard and display. - * - * @implNote The default implementation returns the value equivalent to calling - * {@code isatty(stdin/stdout)} on POSIX platforms, or whether standard in/out file - * descriptors are character devices or not on Windows. + * This method always returns {@code true}, since {@link System#console()} + * provides a {@code Console} instance only when both standard input and + * output are unredirected, that is, when running in an interactive terminal. * * @since 22 */ public boolean isTerminal() { - return istty; + return true; } private static UnsupportedOperationException newUnsupportedOperationException() {