RFR: 8352693: Use a simpler console reader instead of JLine for System.console()

Jan Lahoda jlahoda at openjdk.org
Wed Mar 26 10:32:13 UTC 2025


On Wed, 26 Mar 2025 08:59:39 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> The `java.io.Console` has several backends: a simple on in `java.base`, a more convenient one in `jdk.internal.le` (with line-reading based on JLine) and one for JShell.
>> 
>> The backend based on JLine is proving to be a somewhat problematic - JLine is very powerful, possibly too powerful and complex for the simple task of editing a line with no completion, no history, no variables, no commands, etc. As a consequence, there are inevitable sharp edges in this backend.
>> 
>> The idea in this PR is to replace the use of JLine in the `jdk.internal.le` backend with a simple escape code interpreter, that only handles a handful of keys/codes (left/right arrow, home, end, delete, backspace, enter), and ignores the rest. The goal is to have something simple with less surprising behavior.
>
> src/java.base/share/classes/module-info.java line 172:
> 
>> 170:         java.rmi,
>> 171:         jdk.charsets,
>> 172:         jdk.internal.le,
> 
> What code in JLine is using shared secrets? I wonder what we need to change to avoid this.

Oops, sorry. I forgot to remove these (qualified export of `jdk.internal.access` and `sun.nio.cs`) after a refactoring. Will remove them in a next update.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24242#discussion_r2013832440


More information about the core-libs-dev mailing list