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.
$ 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.
- csr for
-
JDK-8299680 System.console() shouldn't return null in jshell
-
- Closed
-
- relates to
-
JDK-8298425 System.console().readLine() hangs in jshell
-
- Resolved
-