Add JPMS module support for JLine native access #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements clean JPMS module support for JLine native access, moving away from
--enable-native-access=ALL-UNNAMED
to specific module-based permissions.Key Changes
1. Updated Launcher Scripts
mvn
andmvn.cmd
to use:--module-path
pointing tomodules/
directory--add-modules org.jline.nativ
to ensure proper module loading--enable-native-access=org.jline.nativ
for targeted permissions2. Created Modules Directory
modules/
directory in distribution assemblylib/
tomodules/
for proper JPMS handling:jline-native
,jline-terminal-jni
,jline-terminal
jline-reader
,jline-style
,jline-builtins
jline-console
,jline-console-ui
,jansi-core
3. Updated Dependencies
jline-terminal-ffm
withjline-native
in apache-maven POM4. Enhanced Classworlds Configuration
m2.conf
to load JARs from bothlib/
andmodules/
directoriesWhy Separate Modules Directory?
🚨 Critical JPMS Insight: Cannot use
lib/
directory as module path because multiple Maven JARs export the same packages, causing module resolution conflicts.Example conflict discovered during testing:
JPMS requires that only one module can export a package. Maven's
lib/
directory contains many JARs with overlapping package exports, making it unsuitable as a module path.Solution: Separate
modules/
directory containing only JLine JARs avoids conflicts while providing clean JPMS module resolution.Benefits
✅ Enhanced Security: Native access limited to specific
org.jline.nativ
module instead ofALL-UNNAMED
✅ Proper JPMS Support: JLine modules are properly loaded on module path without conflicts
✅ Clean Architecture: Separates JPMS modules from regular classpath dependencies
✅ Backward Compatibility: Maintains all existing Maven functionality
✅ Foundation for Future: Provides clean foundation for broader JPMS migration
Technical Details
--add-modules
to ensure JLine modules are in the resolved module graphorg.jline.nativ
module gets native access permissionsTesting
The implementation successfully:
Scope
This PR focuses solely on JLine JPMS support and does not include broader classworlds module changes. It provides a clean, isolated improvement that can be merged independently.
Related to: Issue apache#11028 - JPMS module support for
--enable-native-access