Skip to content

8361613: System.console() should only be available for interactive terminal #26273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

naotoj
Copy link
Member

@naotoj naotoj commented Jul 11, 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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Change requires CSR request JDK-8361911 to be approved
  • Commit message must refer to an issue

Issues

  • JDK-8361613: System.console() should only be available for interactive terminal (Bug - P4)
  • JDK-8361911: System.console() should only be available for interactive terminal (CSR)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26273/head:pull/26273
$ git checkout pull/26273

Update a local copy of the PR:
$ git checkout pull/26273
$ git pull https://git.openjdk.org/jdk.git pull/26273/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26273

View PR using the GUI difftool:
$ git pr show -t 26273

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26273.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 11, 2025

👋 Welcome back naoto! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 11, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels Jul 11, 2025
@openjdk
Copy link

openjdk bot commented Jul 11, 2025

@naotoj The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Jul 11, 2025

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler [email protected] core-libs [email protected] csr Pull request needs approved CSR before integration rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants