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

Jan Lahoda jlahoda at openjdk.org
Mon Mar 31 14:36:16 UTC 2025


On Mon, 31 Mar 2025 12:43:26 GMT, Magnus Ihse Bursie <ihse 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.
>
> make/modules/jdk.internal.le/Lib.gmk line 36:
> 
>> 34:       TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
>> 35:       OPTIMIZATION := LOW, \
>> 36:       JDK_LIBS := java.base:libjava, \
> 
> A quick glance through the native code revealed no obvious calls to libjava functions. Are you sure this dependency is needed?

`CHECK_NULL` is used by the native code, originating in `jni_util.h`. But, looking at other libraries, seems that 

EXTRA_HEADER_DIRS := java.base:libjava,


should be enough (i.e. replacing `JDK_LIBS` with `EXTRA_HEADER_DIRS`). Is there some even better way?

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

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


More information about the build-dev mailing list