Skip to content

refactor: drop the java.logging module dependency and use System.Logger instead#1934

Merged
gnodet merged 1 commit into
jline:masterfrom
ingokegel:system_logger
Jun 15, 2026
Merged

refactor: drop the java.logging module dependency and use System.Logger instead#1934
gnodet merged 1 commit into
jline:masterfrom
ingokegel:system_logger

Conversation

@ingokegel

@ingokegel ingokegel commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Logging through java.util.logging forces the consumers to depend on the java.logging module. Switch all internal logging to System.Logger (in java.base) and drop "requires java.logging" from every module-info.

Level mapping: FINEST -> TRACE, FINE -> DEBUG, INFO and WARNING stay the same, SEVERE -> ERROR.

Runtime behavior is unchanged. When java.logging is present, System.Logger routes to the "org.jline" JUL logger as before, so existing logging.properties configuration keeps working.

DumbTerminalWarningTest still uses java.util.logging to capture and assert on log records. The unused
console-handler setup in the reader tests was removed.

Summary by CodeRabbit

Release Notes

  • Chores

    • Logging implementation updated from Java Util Logging to JDK System Logger API. Log levels adjusted accordingly (DEBUG, TRACE, ERROR mappings).
  • Documentation

    • Updated debug logging configuration guide to reflect System Logger implementation and routing through JUL on standard JDK installations.

…er instead

Logging through java.util.logging forces the consumers to depend on the java.logging module. Switch all internal logging to System.Logger (in java.base) and drop "requires java.logging" from every module-info.

Level mapping: FINEST -> TRACE, FINE -> DEBUG, INFO and WARNING stay the same, SEVERE -> ERROR.

Runtime behavior is unchanged. When java.logging is present, System.Logger routes to the "org.jline" JUL logger as before, so existing logging.properties configuration keeps working.

DumbTerminalWarningTest still uses java.util.logging to capture and assert on log records. The unused
  console-handler setup in the reader tests was removed.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

JLine migrates its entire logging infrastructure from java.util.logging to java.lang.System.Logger, removing direct module dependencies on java.logging while updating all log calls with level mappings (FINEST→TRACE, FINE→DEBUG, SEVERE→ERROR) and refactoring the core Log utility class.

Changes

System.Logger API Migration

Layer / File(s) Summary
Module descriptor cleanup
builtins/src/main/java/module-info.java, console-ui/src/main/java/module-info.java, console/src/main/java/module-info.java, jansi-core/src/main/java/module-info.java, native/src/main/java/module-info.java, prompt/src/main/java/module-info.java, reader/src/main/java/module-info.java, remote-telnet/src/main/java/module-info.java, style/src/main/java/module-info.java, terminal-ffm/src/main/java/module-info.java, terminal/src/main/java/module-info.java
Systematically remove requires java.logging; declarations across 11 module descriptors, decoupling JLine modules from the java.logging platform module.
Core logging infrastructure refactoring
terminal/src/main/java/org/jline/utils/Log.java
Migrate Log.java from java.util.logging to System.Logger, replacing LogRecord-based logging with direct logger.log(...) calls, updating level mapping to TRACE/DEBUG, and refactoring supplier and throwable handling.
Terminal utilities logging updates
terminal/src/main/java/org/jline/utils/NonBlockingInputStream.java, terminal/src/main/java/org/jline/utils/NonBlockingReader.java, terminal/src/main/java/org/jline/utils/StyleResolver.java
Update logger initialization and log calls to System.Logger with trace/debug/warning level mappings for stream I/O and style resolution debug/warning traces.
Native and terminal-FFM logging migration
native/src/main/java/org/jline/nativ/JLineNativeLoader.java, native/src/main/java/org/jline/nativ/OSInfo.java, terminal-ffm/src/main/java/org/jline/terminal/impl/ffm/CLibrary.java, terminal-ffm/src/main/java/org/jline/terminal/impl/ffm/FfmSignalHandler.java
Migrate native library loading and signal handling logging to System.Logger, updating level conditionals from FINE to DEBUG across initialization and error paths.
Style subsystem logging updates
style/src/main/java/org/jline/style/MemoryStyleSource.java, style/src/main/java/org/jline/style/StyleBundleInvocationHandler.java, style/src/main/java/org/jline/style/Styler.java
Update style source, bundle invocation handler, and styler logging from FINEST to TRACE level, using System.Logger for style operation and source-change tracing.
Remote connectivity logging migration
remote-ssh/src/main/java/org/jline/builtins/ssh/ShellCommand.java, remote-telnet/src/main/java/org/jline/builtins/telnet/Connection.java, remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionManager.java, remote-telnet/src/main/java/org/jline/builtins/telnet/PortListener.java, remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
Migrate SSH and telnet connection management, port listening, and protocol handling logs to System.Logger, updating exception logs from SEVERE to ERROR and debug logs from FINE to DEBUG throughout connection lifecycle and telnet state machine.
Test infrastructure updates
reader/src/test/java/org/jline/keymap/BindingReaderTest.java, reader/src/test/java/org/jline/keymap/KeyMapTest.java, reader/src/test/java/org/jline/reader/impl/ReaderTestSupport.java
Remove java.util.logging imports and ConsoleHandler setup code from test setUp() methods, eliminating obsolete logger initialization.
Maven test module configuration
terminal/pom.xml
Add --add-modules java.logging and --add-reads org.jline.terminal=java.logging to surefire and compiler plugin test configurations to maintain test-time access to java.logging despite removal from module requirements.
Documentation updates
website/docs/troubleshooting.md
Update debug logging documentation to explain System.Logger facade routing to JUL by default, include log level mappings, and document jlink behavior when java.logging is excluded from trimmed runtimes.

Sequence Diagram(s)

This PR does not contain control-flow changes or new component interactions that would benefit from sequence diagram visualization. The changes are primarily API-level migrations where logging statements route through a different backend without altering the execution order or business logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • jline/jline3#1828: Related to terminal subsystem refactoring and color parsing infrastructure that may interact with the logging layer.

Suggested labels

maintenance, java

Suggested reviewers

  • gnodet

Poem

🐰 Hops through logs with glee,
From JUL to System, set it free!
Newer API in every trace,
Debug hops with DEBUG grace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: refactoring the codebase to remove java.logging module dependency and use System.Logger instead.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@website/docs/troubleshooting.md`:
- Around line 815-817: Update the documentation mapping so JLine's `trace` level
maps to JUL `FINEST` (not `FINER`) to match the migration contract; change the
mapping line that currently reads "trace → FINER" to "trace → FINEST" and update
the recommendation text to suggest using `org.jline.level=FINEST` (or
`FINER`/`FINE` as alternatives) when describing how to enable trace-level output
for JLine-to-JUL configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 54534b41-dadb-41f0-af1d-8060d2e572ca

📥 Commits

Reviewing files that changed from the base of the PR and between 7f44a23 and 55e2096.

📒 Files selected for processing (32)
  • builtins/src/main/java/module-info.java
  • console-ui/src/main/java/module-info.java
  • console/src/main/java/module-info.java
  • jansi-core/src/main/java/module-info.java
  • native/src/main/java/module-info.java
  • native/src/main/java/org/jline/nativ/JLineNativeLoader.java
  • native/src/main/java/org/jline/nativ/OSInfo.java
  • prompt/src/main/java/module-info.java
  • reader/src/main/java/module-info.java
  • reader/src/test/java/org/jline/keymap/BindingReaderTest.java
  • reader/src/test/java/org/jline/keymap/KeyMapTest.java
  • reader/src/test/java/org/jline/reader/impl/ReaderTestSupport.java
  • remote-ssh/src/main/java/org/jline/builtins/ssh/ShellCommand.java
  • remote-telnet/src/main/java/module-info.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/Connection.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionManager.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/PortListener.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
  • style/src/main/java/module-info.java
  • style/src/main/java/org/jline/style/MemoryStyleSource.java
  • style/src/main/java/org/jline/style/StyleBundleInvocationHandler.java
  • style/src/main/java/org/jline/style/Styler.java
  • terminal-ffm/src/main/java/module-info.java
  • terminal-ffm/src/main/java/org/jline/terminal/impl/ffm/CLibrary.java
  • terminal-ffm/src/main/java/org/jline/terminal/impl/ffm/FfmSignalHandler.java
  • terminal/pom.xml
  • terminal/src/main/java/module-info.java
  • terminal/src/main/java/org/jline/utils/Log.java
  • terminal/src/main/java/org/jline/utils/NonBlockingInputStream.java
  • terminal/src/main/java/org/jline/utils/NonBlockingReader.java
  • terminal/src/main/java/org/jline/utils/StyleResolver.java
  • website/docs/troubleshooting.md
💤 Files with no reviewable changes (14)
  • remote-telnet/src/main/java/module-info.java
  • style/src/main/java/module-info.java
  • jansi-core/src/main/java/module-info.java
  • console/src/main/java/module-info.java
  • terminal/src/main/java/module-info.java
  • prompt/src/main/java/module-info.java
  • reader/src/test/java/org/jline/keymap/BindingReaderTest.java
  • console-ui/src/main/java/module-info.java
  • builtins/src/main/java/module-info.java
  • terminal-ffm/src/main/java/module-info.java
  • reader/src/main/java/module-info.java
  • reader/src/test/java/org/jline/reader/impl/ReaderTestSupport.java
  • native/src/main/java/module-info.java
  • reader/src/test/java/org/jline/keymap/KeyMapTest.java

Comment thread website/docs/troubleshooting.md

@gnodet gnodet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-executed migration. Dropping the java.logging module dependency is a meaningful improvement for consumers building trimmed jlink images — System.Logger (part of java.base since Java 9) is the right abstraction here.

What I verified:

  • Java version: System.Logger has been in java.base since Java 9. JLine targets Java 11+, so no compatibility concern.
  • Public API: Log.java's public interface (trace, debug, info, warn, error, isDebugEnabled) is unchanged. No downstream breakage.
  • Level mapping correctness: FINESTTRACE, FINEDEBUG, SEVEREERROR across all 32 files — verified consistent.
  • Module-info: All 11 requires java.logging declarations removed. Tests correctly add --add-modules java.logging --add-reads for test compilation.
  • Message format: Files using {0}, {1} JUL-style placeholders (e.g., FfmSignalHandler.java) continue to work because System.Logger's default JUL backend delegates to MessageFormat. If a user switches to a non-JUL LoggerFinder, these placeholders would need updating, but that's inherent to System.Logger and not a concern for this PR.
  • Documentation: Troubleshooting guide updated with level mapping table and jlink note — good.

Two minor observations:

  1. Log.java message rendering: The ByteArrayOutputStream/PrintStream allocation in log(Level, Object...) happens on every call that passes the level check. This was the same behavior before, so no regression — but for hot paths, Supplier<String> variants should be preferred by callers.

  2. Logger naming: The core Log.java uses "org.jline" while module-specific loggers (telnet, style, FFM) use class-name-based logger names (e.g., Connection.class.getName()). This is fine — it's the existing pattern — but worth noting that log configuration needs to account for both naming styles.

No blocking issues. Well done.

Review by Claude Code on behalf of Guillaume Nodet

Comment thread terminal/pom.xml

<properties>
<automatic.module.name>org.jline.terminal</automatic.module.name>
<surefire.argLine>--add-opens java.base/java.io=org.jline.nativ --add-opens java.base/java.io=org.jline.terminal --add-modules java.logging --add-reads org.jline.terminal=java.logging</surefire.argLine>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good: test compilation still gets java.logging via --add-modules/--add-reads, keeping the test infra working while the main code is free of the dependency.

Review by Claude Code on behalf of Guillaume Nodet

@gnodet gnodet added this to the 4.1.4 milestone Jun 15, 2026
@gnodet
gnodet merged commit 3c3da19 into jline:master Jun 15, 2026
15 checks passed
@gnodet gnodet modified the milestones: 4.1.4, 4.2.0 Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants