config_host.mk.in | 1 + configure.ac | 10 ++++++++++ external/hsqldb/ExternalProject_hsqldb.mk | 7 +++++++ 3 files changed, 18 insertions(+)
New commits: commit 19de5d97efbb80e9767bc6b873bcc2c263a721de Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Apr 5 08:09:59 2022 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Tue Apr 5 17:50:48 2022 +0200 Allow building against JDK 18 ...where ExternalProject_hsqldb failed with > [java] java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release > [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194) > [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:891) > [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:231) > [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) > [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) > [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299) > [java] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) > [java] at java.base/java.lang.reflect.Method.invoke(Method.java:577) > [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) > [java] at org.apache.tools.ant.Task.perform(Task.java:350) > [java] at org.apache.tools.ant.Target.execute(Target.java:449) > [java] at org.apache.tools.ant.Target.performTasks(Target.java:470) > [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401) > [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1374) > [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) > [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1264) > [java] at org.apache.tools.ant.Main.runBuild(Main.java:818) > [java] at org.apache.tools.ant.Main.startAnt(Main.java:223) > [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284) > [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101) > [java] Caused by: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release > [java] at java.base/java.lang.System.setSecurityManager(System.java:416) > [java] at org.apache.tools.ant.types.Permissions.setSecurityManager(Permissions.java:103) > [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:216) > [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:155) > [java] ... 19 more while building target switchtojdk17 (but then unfortunately carried on, without the source modifications that should have been done by that target, leading to confusing errors like > [javac] workdir/UnpackedTarball/hsqldb/src/org/hsqldb/jdbc/jdbcConnection.java:426: error: jdbcConnection is not abstract and does not override abstract method createStruct(String,Object[]) in Connection that should have been under control at least ever since 7dbfc0012cc75e7dac9a416b53149ad8ec33f071 "make hsqldb build with java 1.7".) Unconditionally passing ANT_OPTS -Djava.security.manager=allow would cause older JDK versions (like Java 11) to fail with a java.lang.Error "Could not create SecurityManager" caused by a java.lang.ClassNotFoundException "allow", so introduce JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD. This should allow us to keep building against at least JDK 18, even though later versions of Java may remove the Security Manager completely, but in which case hopefully an updated version of Apache Ant will become available. Change-Id: I9d143d8bcfff67870017bb1c874eec53e0ff9672 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132558 Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Jenkins diff --git a/config_host.mk.in b/config_host.mk.in index ee5d0326c981..c412a0b99895 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -353,6 +353,7 @@ export JAVA_TARGET_VER=@JAVA_TARGET_VER@ export JAWTLIB=@JAWTLIB@ export JDK=@JDK@ export JDK_FOR_BUILD=@JDK_FOR_BUILD@ +export JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD=@JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD@ export JFREEREPORT_JAR=@JFREEREPORT_JAR@ export JITC_PROCESSOR_TYPE=@JITC_PROCESSOR_TYPE@ export JVM_ONE_PATH_CHECK=@JVM_ONE_PATH_CHECK@ diff --git a/configure.ac b/configure.ac index 91fb52cb1a2c..af0c9937d865 100644 --- a/configure.ac +++ b/configure.ac @@ -5774,6 +5774,7 @@ if test "$cross_compiling" = "yes"; then JAVA_HOME JAVAIFLAGS JDK + JDK_SECURITYMANAGER_DISALLOWED LIBO_BIN_FOLDER LIBO_LIB_FOLDER LIBO_URE_LIB_FOLDER @@ -8594,6 +8595,7 @@ dnl =================================================================== # Whether all the complexity here actually is needed any more or not, no idea. +JDK_SECURITYMANAGER_DISALLOWED= if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then _gij_longver=0 AC_MSG_CHECKING([the installed JDK]) @@ -8620,6 +8622,12 @@ if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then if test "$_jdk_ver" -gt 10900; then JAVA_CLASSPATH_NOT_SET=TRUE fi + dnl TODO: Presumably, the Security Manager will not merely be disallowed, but be + dnl completely removed in some Java version > 18 (see + dnl <https://openjdk.java.net/jeps/411> "Deprecate the Security Manager for Removal"): + if test "$_jdk_ver" -ge 180000; then + JDK_SECURITYMANAGER_DISALLOWED=TRUE + fi JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"` if test "$_os" = "WINNT"; then @@ -8928,6 +8936,7 @@ if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then JAVA_HOME_FOR_BUILD=$JAVA_HOME JAVAIFLAGS_FOR_BUILD=$JAVAIFLAGS JDK_FOR_BUILD=$JDK + JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD=$JDK_SECURITYMANAGER_DISALLOWED fi AC_SUBST(JAVACFLAGS) @@ -8940,6 +8949,7 @@ AC_SUBST(JAVA_HOME) AC_SUBST(JAVA_HOME_FOR_BUILD) AC_SUBST(JDK) AC_SUBST(JDK_FOR_BUILD) +AC_SUBST(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD) AC_SUBST(JAVA_SOURCE_VER) AC_SUBST(JAVA_TARGET_VER) diff --git a/external/hsqldb/ExternalProject_hsqldb.mk b/external/hsqldb/ExternalProject_hsqldb.mk index 4d5f5f8786f0..67ae75106bc2 100644 --- a/external/hsqldb/ExternalProject_hsqldb.mk +++ b/external/hsqldb/ExternalProject_hsqldb.mk @@ -13,10 +13,17 @@ $(eval $(call gb_ExternalProject_register_targets,hsqldb,\ build \ )) +# ANT_OPTS -Djava.security.manager=allow allows latest Apache Ant 1.10.12 to still run under +# Java 18, where java.lang.System.setSecurityManager (as called from +# org.apache.tools.ant.types.Permissions.setSecurityManager) would otherwise throw an +# UnsupportedOperationException (see <https://openjdk.java.net/jeps/411> "Deprecate the Security +# Manager for Removal"): $(call gb_ExternalProject_get_state_target,hsqldb,build) : $(call gb_Trace_StartRange,hsqldb,EXTERNAL) $(call gb_ExternalProject_run,build,\ JAVA_HOME=$(JAVA_HOME_FOR_BUILD) \ + $(if $(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD), \ + ANT_OPTS="$$ANT_OPTS -Djava.security.manager=allow") \ $(ICECREAM_RUN) "$(ANT)" \ $(if $(verbose),-v,-q) \ -f build/build.xml \