RFR: 8361613: System.console() should only be available for interactive terminal [v3]
Naoto Sato
naoto at openjdk.org
Mon Jul 14 20:23:25 UTC 2025
> In prior JDK releases, `System.console()` could return a `Console` instance even when the JVM was not attached to an interactive terminal. This could lead to confusion, particularly when input was not from a keyboard or output was redirected, such as to or from a file or pipe, especially when using methods like `readPassword()`. Starting with JDK 25, the default behavior has changed: `System.console()` now returns `null` if standard input and/or output is redirected. However, if a JLine-based Console implementation is explicitly specified via the system property `-Djdk.console=jdk.internal.le`, the previous behavior may still occur.
> This PR aims to align the behavior of the JLine-based `Console` implementation with the default `System.console()` behavior. The actual code change is a one-liner in `JdkConsoleProviderImpl.java`; the rest of the changes are adjustments to test cases to reflect the updated behavior. A corresponding CSR has also been drafted.
Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
Reflects review comments
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26273/files
- new: https://git.openjdk.org/jdk/pull/26273/files/82773085..5a4114c7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26273&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26273&range=01-02
Stats: 12 lines in 2 files changed: 4 ins; 3 del; 5 mod
Patch: https://git.openjdk.org/jdk/pull/26273.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26273/head:pull/26273
PR: https://git.openjdk.org/jdk/pull/26273
More information about the compiler-dev
mailing list