JDK-8296454 : System.console() shouldn't return null in jshell
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 11,17,19,20
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2022-11-06
  • Updated: 2023-01-06
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 21
21Unresolved
Related Reports
CSR :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

$ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment (build 19.0.1+10-21)
OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

$ jshell --version
jshell 19.0.1


A DESCRIPTION OF THE PROBLEM :
When running jshell, System.console() should not return null.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Launch jshell (without any redirection)
2. In jshell, enter System.console()

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result is for jshell to behave, apart from its REPL capabilities, as similar to java as possible. That includes the provision of a Console through System.console() to use jshell's REPL to tinker with java.io.Console.
ACTUAL -
The actual result is that in jshell, System.console() returns null, which makes using jshell's REPL to tinker with java.io.Console impossible.

CUSTOMER SUBMITTED WORKAROUND :
* One could write their own Java shell that doesn't have this defect.
* One could use java to tinker with Console.log()
Both workaround defeat the purpose of existence of jshell in this context.


Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11695 Date: 2022-12-15 15:30:12 +0000
06-01-2023

System.console() returns null in jshell. Therefore no console operations possible subsequently.
07-11-2022