Read the Java release from $JAVA_HOME/release so the first mc-image-helper call gets the same options (#4292)

This commit is contained in:
u9g
2026-09-25 08:28:15 -05:00
committed by GitHub
parent c469eadc36
commit 79a5346182
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ if isTrue "$PREFER_IPV6"; then
export JVM_DD_OPTS
fi
if (( $(mc-image-helper java-release) >= 17 )); then
if (( $(getJavaRelease) >= 17 )); then
MC_IMAGE_HELPER_OPTS+=" --enable-native-access=ALL-UNNAMED"
export MC_IMAGE_HELPER_OPTS
fi
+17
View File
@@ -646,6 +646,23 @@ function getDistro() {
grep -E "^ID=" /etc/os-release | cut -d= -f2 | sed -e 's/"//g'
}
function getJavaRelease() {
# Read the major version from the JDK's release file so no JVM has to start;
# the helper is the fallback when the file is missing.
local version
if [[ ${JAVA_HOME:-} && -f "$JAVA_HOME/release" ]]; then
version=$(sed -n -e 's/^JAVA_VERSION="\(.*\)"$/\1/p' "$JAVA_HOME/release")
# Java 8 and earlier report 1.8.0_312 and so on
version=${version#1.}
version=${version%%[._-]*}
fi
if isNumeric "${version:-}"; then
echo "$version"
else
mc-image-helper java-release
fi
}
function checkSum() {
local sum_file=${1?}