Skip to content

Commit 0c8e87b

Browse files
committed
Fix JLine module loading to eliminate native access warnings
Added --add-modules org.jline.terminal.ffm flag to ensure JLine modules are properly loaded as named modules before applying --enable-native-access. This eliminates the 'Unknown module' warnings that occurred when JLine modules were loaded as automatic modules. Key changes: - Added --add-modules org.jline.terminal.ffm to both Unix and Windows launchers - Moved MODULE_PATH definition earlier in scripts for version checking - Now mvn --version runs without any native access warnings - JLine FFM module is properly recognized for native access permissions The implementation now provides clean JPMS module support with targeted native access control and no warning messages.
1 parent b4e8e1b commit 0c8e87b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

apache-maven/src/assembly/maven/bin/mvn

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ else
107107
fi
108108
fi
109109

110-
if ! "$JAVACMD" --enable-native-access=org.jline.terminal.ffm -version >/dev/null 2>&1; then
110+
MODULE_PATH="$MAVEN_HOME/modules"
111+
112+
if ! "$JAVACMD" --module-path "$MODULE_PATH" --add-modules org.jline.terminal.ffm --enable-native-access=org.jline.terminal.ffm -version >/dev/null 2>&1; then
111113
echo "Error: Apache Maven 4.x requires Java 17 or newer to run." >&2
112114
"$JAVACMD" -version >&2
113115
echo "Please upgrade your Java installation or set JAVA_HOME to point to a compatible JDK." >&2
@@ -192,7 +194,6 @@ MAVEN_PROJECTBASEDIR="`find_maven_basedir "$@"`"
192194
MAVEN_OPTS="$MAVEN_OPTS `concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"`"
193195
LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/maven-classworlds-*.jar`
194196
LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
195-
MODULE_PATH="$MAVEN_HOME/modules"
196197

197198
# For Cygwin and MinGW, switch paths to Windows format before running java(1) command
198199
if $cygwin || $mingw ; then
@@ -244,6 +245,7 @@ cmd="\"$JAVACMD\" \
244245
$MAVEN_OPTS \
245246
$MAVEN_DEBUG_OPTS \
246247
--module-path \"$MODULE_PATH\" \
248+
--add-modules org.jline.terminal.ffm \
247249
--enable-native-access=org.jline.terminal.ffm \
248250
-classpath \"$LAUNCHER_JAR\" \
249251
\"-Dclassworlds.conf=$CLASSWORLDS_CONF\" \

apache-maven/src/assembly/maven/bin/mvn.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ if not exist "%JAVACMD%" (
7474
goto error
7575
)
7676

77+
set MODULE_PATH="%MAVEN_HOME%\modules"
78+
7779
@REM Check Java version by testing the Java 17+ flag
78-
"%JAVACMD%" --enable-native-access=org.jline.terminal.ffm -version >nul 2>&1
80+
"%JAVACMD%" --module-path %MODULE_PATH% --add-modules org.jline.terminal.ffm --enable-native-access=org.jline.terminal.ffm -version >nul 2>&1
7981
if ERRORLEVEL 1 (
8082
echo Error: Apache Maven 4.x requires Java 17 or newer to run. >&2
8183
"%JAVACMD%" -version >&2
@@ -249,7 +251,6 @@ call :processArgs %*
249251

250252
for %%i in ("%MAVEN_HOME%"\boot\maven-classworlds-*) do set LAUNCHER_JAR="%%i"
251253
set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
252-
set MODULE_PATH="%MAVEN_HOME%\modules"
253254
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling
254255

255256
"%JAVACMD%" ^
@@ -258,6 +259,7 @@ if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCl
258259
%JVM_CONFIG_MAVEN_OPTS% ^
259260
%MAVEN_DEBUG_OPTS% ^
260261
--module-path %MODULE_PATH% ^
262+
--add-modules org.jline.terminal.ffm ^
261263
--enable-native-access=org.jline.terminal.ffm ^
262264
-classpath %LAUNCHER_JAR% ^
263265
"-Dclassworlds.conf=%CLASSWORLDS_CONF%" ^

0 commit comments

Comments
 (0)