Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of java.specification.version #195

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/script/ant
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,18 @@ else
fi
fi
# Run "java -XshowSettings:properties" and check the output for "java.specification.version" value
JAVA_SPEC_VERSION=$("$JAVACMD" -XshowSettings:properties 2>&1 | grep "java.specification.version = " | tr -d '[:space:]java.specification.version=')
if [ "$JAVA_SPEC_VERSION" -ge 18 ]; then
# set security manager property to allow calls to System.setSecurityManager() at runtime
ANT_OPTS="$ANT_OPTS -Djava.security.manager=allow"
fi
JAVA_SPEC_VERSION=$("$JAVACMD" -XshowSettings:properties 2>&1 | sed -n -e 's/[[:space:]]//g' -e 's/^java\.specification\.version=//p')
case "$JAVA_SPEC_VERSION" in
1.*)
# Up to and including Java 8, versions are reported as 1.N.
;;
*)
if [ "$JAVA_SPEC_VERSION" -ge 18 ]; then
# set security manager property to allow calls to System.setSecurityManager() at runtime
ANT_OPTS="$ANT_OPTS -Djava.security.manager=allow"
fi
;;
esac
ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" -Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\""
if $ant_exec_debug; then
# using printf to avoid echo line continuation and escape interpretation confusion
Expand Down