This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.9.x by this push:
new eeddfa2a58 [MNG-8248] Add enable-native-access to startup scripts
eeddfa2a58 is described below
commit eeddfa2a58e1486b181bce54e2481702439b8e8f
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Thu Mar 20 23:45:02 2025 +0100
[MNG-8248] Add enable-native-access to startup scripts
In order to avoid
WARNING A restricted method in java.lang.System has been called
---
apache-maven/src/bin/mvn | 5 +++++
apache-maven/src/bin/mvn.cmd | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn
index 38b036af1d..954af15e00 100755
--- a/apache-maven/src/bin/mvn
+++ b/apache-maven/src/bin/mvn
@@ -196,6 +196,11 @@ export MAVEN_PROJECTBASEDIR
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
+# MNG-8248
+if "$JAVACMD" --enable-native-access=ALL-UNNAMED -version >/dev/null 2>&1; then
+ MAVEN_OPTS="--enable-native-access=ALL-UNNAMED $MAVEN_OPTS"
+fi
+
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd
index 666656ccd2..972c39eaf2 100644
--- a/apache-maven/src/bin/mvn.cmd
+++ b/apache-maven/src/bin/mvn.cmd
@@ -172,6 +172,12 @@ if "_%MAVEN_PROJECTBASEDIR:~-1%"=="_\" set
"MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTB
for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set
CLASSWORLDS_JAR="%%i"
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+@REM MNG-8248
+"%JAVACMD%" --enable-native-access=ALL-UNNAMED -version >nul 2>&1
+if ERRORLEVEL 1 goto skipEnableNativeAccess
+set "MAVEN_OPTS=--enable-native-access=ALL-UNNAMED %MAVEN_OPTS%"
+:skipEnableNativeAccess
+
"%JAVACMD%" ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^