|
38 | 38 | * Methods to access the character-based console device, if any, associated |
39 | 39 | * with the current Java virtual machine. |
40 | 40 | * |
41 | | - * <p> Whether a virtual machine has a console is dependent upon the |
| 41 | + * <p> Whether a virtual machine's console exists is dependent upon the |
42 | 42 | * underlying platform and also upon the manner in which the virtual |
43 | 43 | * machine is invoked. If the virtual machine is started from an |
44 | 44 | * interactive command line without redirecting the standard input and |
45 | | - * output streams then its console will exist and will typically be |
| 45 | + * output streams, then its console will generally exist and will be |
46 | 46 | * connected to the keyboard and display from which the virtual machine |
47 | | - * was launched. If the virtual machine is started automatically, for |
48 | | - * example by a background job scheduler, then it may not |
49 | | - * have a console. |
| 47 | + * was launched. If the standard input or standard output have been |
| 48 | + * redirected (for example, to a file or to a pipe), or if the virtual |
| 49 | + * machine was started from a background job scheduler, the console |
| 50 | + * will not exist. |
50 | 51 | * <p> |
51 | | - * If this virtual machine has a console then it is represented by a |
52 | | - * unique instance of this class which can be obtained by invoking the |
53 | | - * {@link java.lang.System#console()} method. If no console device is |
54 | | - * available then an invocation of that method will return {@code null}. |
| 52 | + * If the console exists, then it is represented by a unique instance of this |
| 53 | + * class which can be obtained by invoking the {@link System#console()} method. |
| 54 | + * If the console does not exist, that method will return {@code null}. |
55 | 55 | * <p> |
56 | 56 | * Read and write operations are synchronized to guarantee the atomic |
57 | 57 | * completion of critical operations; therefore invoking methods |
@@ -535,18 +535,14 @@ public Charset charset() { |
535 | 535 | /** |
536 | 536 | * {@return {@code true} if the {@code Console} instance is a terminal} |
537 | 537 | * <p> |
538 | | - * This method returns {@code true} if the console device, associated with the current |
539 | | - * Java virtual machine, is a terminal, typically an interactive command line |
540 | | - * connected to a keyboard and display. |
541 | | - * |
542 | | - * @implNote The default implementation returns the value equivalent to calling |
543 | | - * {@code isatty(stdin/stdout)} on POSIX platforms, or whether standard in/out file |
544 | | - * descriptors are character devices or not on Windows. |
| 538 | + * This method always returns {@code true}, since {@link System#console()} |
| 539 | + * provides a {@code Console} instance only when both standard input and |
| 540 | + * output are unredirected, that is, when running in an interactive terminal. |
545 | 541 | * |
546 | 542 | * @since 22 |
547 | 543 | */ |
548 | 544 | public boolean isTerminal() { |
549 | | - return istty; |
| 545 | + return true; |
550 | 546 | } |
551 | 547 |
|
552 | 548 | private static UnsupportedOperationException newUnsupportedOperationException() { |
|
0 commit comments