JDK-8361613 : System.console() should only be available for interactive terminal
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 26
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-07-08
  • Updated: 2025-09-03
  • Resolved: 2025-08-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b13Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Description
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.
Comments
Changeset: ae0dac43 Branch: master Author: Naoto Sato <naoto@openjdk.org> Date: 2025-08-22 17:50:22 +0000 URL: https://git.openjdk.org/jdk/commit/ae0dac43c09377c87e9b0452618a5b32c8568150
22-08-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26273 Date: 2025-07-11 18:46:14 +0000
11-07-2025