Skip to content

chore: use jline ffm terminal implementation#1441

Merged
derklaro merged 2 commits into
nightly-jdk22from
use-jline-ffm-terminal
Jul 9, 2024
Merged

chore: use jline ffm terminal implementation#1441
derklaro merged 2 commits into
nightly-jdk22from
use-jline-ffm-terminal

Conversation

@derklaro
Copy link
Copy Markdown
Member

@derklaro derklaro commented Jul 9, 2024

Motivation

JLine includes a FFM terminal implementation, which became a permantent feature in JDK 22. As we're now requring java 22, we can use the FFM terminal instead of some jni-based implementation.

Modification

  • Replaced the usages of org.jline:jline: that is a complete bundle containing all jline dependencies, which is not nessacary at all. We're now including only the line reader and terminal dependencies.
  • Enable native access: while java itself has no requirement for this yet, some steps were already made into that direction coming to java 24 (see JEP 472). JLine has an explicit check that verifies that native access is enabled, so setting the flag is mandatory in order to use the FFM terminal implementation.
  • Replaced usages of AnsiConsole.systemInstall/systemUninstall: the ansi handling is already baked into JLine itself, these methods are only overriding the systems streams nowadays. No native lib is required for ansi anymore, so the color support detection becomes useless as well. If I understood the code correctly, ansi color codes are stripped from the output by JLine if it detects a terminal without color support.

This change was tested on Debian 12 and Windows using cmd and PowerShell 5 & 7. All animations, tab completion & typing works as expected.

Result

We're now using the FFM-based terminal implementaton of JLine and are no longer relying on JNI libraries to do the job.

@derklaro derklaro added v: 4.X This pull should be included in the 4.0 release in: node An issue/pull request releated to the node module code t: fix A pull request introducing a fix for a bug. t: improvement The pull request improves existing code labels Jul 9, 2024
@derklaro derklaro added this to the 4.0.0-RC11 milestone Jul 9, 2024
@derklaro derklaro requested a review from 0utplay July 9, 2024 13:42
@derklaro derklaro self-assigned this Jul 9, 2024
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 9, 2024

Test Results

 47 files  ±0   47 suites  ±0   1m 55s ⏱️ -26s
420 tests ±0  420 ✅ ±0  0 💤 ±0  0 ❌ ±0 
751 runs  ±0  751 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 6c31e8e. ± Comparison against base commit 442f3d3.

@derklaro derklaro merged commit 44536cc into nightly-jdk22 Jul 9, 2024
@derklaro derklaro deleted the use-jline-ffm-terminal branch July 9, 2024 20:36
derklaro added a commit that referenced this pull request Jul 12, 2024
### Motivation
JLine includes a FFM terminal implementation, which became a permantent
feature in JDK 22. As we're now requring java 22, we can use the FFM
terminal instead of some jni-based implementation.

### Modification
* Replaced the usages of `org.jline:jline`: that is a complete bundle
containing all jline dependencies, which is not nessacary at all. We're
now including only the line reader and terminal dependencies.
* Enable native access: while java itself has no requirement for this
*yet*, some steps were already made into that direction coming to java
24 (see JEP 472). JLine has an explicit check that verifies that native
access is enabled, so setting the flag is mandatory in order to use the
FFM terminal implementation.
* Replaced usages of `AnsiConsole.systemInstall/systemUninstall`: the
ansi handling is already baked into JLine itself, these methods are only
overriding the systems streams nowadays. No native lib is required for
ansi anymore, so the color support detection becomes useless as well. If
I understood the code correctly, ansi color codes are stripped from the
output by JLine if it detects a terminal without color support.

This change was tested on Debian 12 and Windows using cmd and PowerShell
5 & 7. All animations, tab completion & typing works as expected.

### Result
We're now using the FFM-based terminal implementaton of JLine and are no
longer relying on JNI libraries to do the job.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: node An issue/pull request releated to the node module code t: fix A pull request introducing a fix for a bug. t: improvement The pull request improves existing code v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants