This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 00a90ea2c35aa0d62b41963f97bc10041530f5d1 Author: Jim Jagielski <[email protected]> AuthorDate: Wed Jul 1 14:26:50 2026 -0400 Support building with modern JDKs while keeping Java 8 runtime compatibility The bundled Java externals and the core Java build assumed old JDKs and emitted pre-8 bytecode at pre-8 source/target levels. Modern JDKs (11+) reject -source/-target 1.4/1.5/6/7 outright, and even where compilation succeeds a new JDK silently emits bytecode that will not load on the minimum supported Java 8 runtime. Establish a tree-wide Java 8 bytecode floor and fix the bundled externals so the tree builds on any JDK from 8 through 21 while all artifacts remain loadable on a Java 8 JRE. --- .../java/lang/commons-lang3-java-version.patch | 17 +++++++++++++++++ main/apache-commons/java/lang/makefile.mk | 1 + main/hsqldb/makefile.mk | 12 ++++++++---- main/hsqldb/patches/runfinalizers.patch | 22 ++++++++++++++++++++++ main/javainstaller2/build.xml | 2 +- main/lucene/lucene-java-version.patch | 12 ++++++------ main/rhino/makefile.mk | 2 +- main/rhino/rhino1_7R3-java-version.patch | 13 +++++++++++++ main/saxon/saxon-9.0.0.7-bj.patch | 8 ++++---- main/solenv/ant/aoo-ant.xml | 5 ++++- main/solenv/inc/antsettings.mk | 9 +++++++++ main/solenv/inc/settings.mk | 11 +++++++++++ main/stax/makefile.mk | 4 +++- 13 files changed, 100 insertions(+), 18 deletions(-) diff --git a/main/apache-commons/java/lang/commons-lang3-java-version.patch b/main/apache-commons/java/lang/commons-lang3-java-version.patch new file mode 100644 index 0000000000..95f2e9dfcf --- /dev/null +++ b/main/apache-commons/java/lang/commons-lang3-java-version.patch @@ -0,0 +1,17 @@ +--- misc/build/commons-lang3-3.3-src/default.properties ++++ misc/build/commons-lang3-3.3-src/default.properties +@@ -73,12 +73,12 @@ + # In particular, if you use JDK 1.4+ the generated classes will not be usable + # for a 1.1 Java VM unless you explicitly set this attribute to the value 1.1 + # (which is the default value for JDK 1.1 to 1.3). +-compile.target = 1.6 ++compile.target = 1.8 + + # Specifies the source version for the Java compiler. + # Corresponds to the source attribute for the ant javac task. + # Valid values are 1.3, 1.4, 1.5. +-compile.source = 1.6 ++compile.source = 1.8 + + # Specifies the source encoding. + compile.encoding = ISO-8859-1 diff --git a/main/apache-commons/java/lang/makefile.mk b/main/apache-commons/java/lang/makefile.mk index df400aecfa..88b67fabd9 100644 --- a/main/apache-commons/java/lang/makefile.mk +++ b/main/apache-commons/java/lang/makefile.mk @@ -49,6 +49,7 @@ TARFILE_MD5=4c8c505cc3cba4c467c479e3e0f09ba4 TARFILE_ROOTDIR=commons-lang3-3.3-src #PATCH_FILES=$(PRJ)$/patches$/logging.patch +PATCH_FILES=commons-lang3-java-version.patch #CONVERTFILES=build.xml diff --git a/main/hsqldb/makefile.mk b/main/hsqldb/makefile.mk index e2f14404b8..fd77dde950 100644 --- a/main/hsqldb/makefile.mk +++ b/main/hsqldb/makefile.mk @@ -49,17 +49,21 @@ CONVERTFILES=build$/build.xml \ src$/org$/hsqldb$/persist$/HsqlDatabaseProperties.java \ src$/org$/hsqldb$/Library.java -PATCH_FILES=patches$/i121754.patch patches$/script.patch +PATCH_FILES=patches$/i121754.patch patches$/script.patch patches$/runfinalizers.patch + +# hsqldb's build.xml javac tasks specify no source/target; pin them so bytecode +# stays Java 8 compatible regardless of the (possibly much newer) build JDK. +JAVAC_SRCTGT=-Dant.build.javac.source=1.8 -Dant.build.javac.target=1.8 .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar .ELSE .IF "$(debug)"!="" -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.debug="on" -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.debug="on" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar +BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" $(JAVAC_SRCTGT) -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF diff --git a/main/hsqldb/patches/runfinalizers.patch b/main/hsqldb/patches/runfinalizers.patch new file mode 100644 index 0000000000..dfeafdfee2 --- /dev/null +++ b/main/hsqldb/patches/runfinalizers.patch @@ -0,0 +1,22 @@ +--- misc/build/hsqldb/src/org/hsqldb/lib/java/JavaSystem.java ++++ misc/build/hsqldb/src/org/hsqldb/lib/java/JavaSystem.java +@@ -160,7 +160,7 @@ + public static void runFinalizers() { + + //#ifdef JAVA2FULL +- System.runFinalizersOnExit(true); ++ // System.runFinalizersOnExit(boolean) was removed in Java 11+; dropped for modern JDK compatibility + + //#endif + } +--- misc/build/hsqldb/src/org/hsqldb/lib/HsqlArrayList.java ++++ misc/build/hsqldb/src/org/hsqldb/lib/HsqlArrayList.java +@@ -57,7 +57,7 @@ + Reporter() { + + try { +- System.runFinalizersOnExit(true); ++ // System.runFinalizersOnExit(boolean) was removed in Java 11+; dropped for modern JDK compatibility + } catch (SecurityException e) {} + } + diff --git a/main/javainstaller2/build.xml b/main/javainstaller2/build.xml index 4ad58dbea7..6dcad32532 100644 --- a/main/javainstaller2/build.xml +++ b/main/javainstaller2/build.xml @@ -77,7 +77,7 @@ </target> <target name="compile-javainstaller" depends="prepare" unless="jarFile.uptodate"> - <javac srcdir="${source.dir}" source="1.4" target="1.4" + <javac srcdir="${source.dir}" source="1.8" target="1.8" destdir="${build.dir}/${classes.dir}/${name}" debug="${compile.debug}" optimize="${compile.optimize}"> diff --git a/main/lucene/lucene-java-version.patch b/main/lucene/lucene-java-version.patch index c22e7fc94a..b674733d1e 100644 --- a/main/lucene/lucene-java-version.patch +++ b/main/lucene/lucene-java-version.patch @@ -6,8 +6,8 @@ <property name="javac.debug" value="on"/> - <property name="javac.source" value="1.4"/> - <property name="javac.target" value="1.4"/> -+ <property name="javac.source" value="1.6"/> -+ <property name="javac.target" value="1.6"/> ++ <property name="javac.source" value="1.8"/> ++ <property name="javac.target" value="1.8"/> <property name="javadoc.link" value="http://java.sun.com/j2se/1.4/docs/api/"/> <property name="javadoc.access" value="protected"/> @@ -19,8 +19,8 @@ - <property name="javac.source" value="1.4" /> - <property name="javac.target" value="1.4" /> -+ <property name="javac.source" value="1.6" /> -+ <property name="javac.target" value="1.6" /> ++ <property name="javac.source" value="1.8" /> ++ <property name="javac.target" value="1.8" /> <property name="build.dir" location="../../../build/contrib/analyzers/common" /> <property name="dist.dir" location="../../../dist/contrib/analyzers/common" /> @@ -32,8 +32,8 @@ - <property name="javac.source" value="1.4" /> - <property name="javac.target" value="1.4" /> -+ <property name="javac.source" value="1.6" /> -+ <property name="javac.target" value="1.6" /> ++ <property name="javac.source" value="1.8" /> ++ <property name="javac.target" value="1.8" /> <property name="build.dir" location="../../../build/contrib/analyzers/smartcn" /> <property name="dist.dir" location="../../../dist/contrib/analyzers/smartcn" /> diff --git a/main/rhino/makefile.mk b/main/rhino/makefile.mk index 5104695816..9bed5ae846 100644 --- a/main/rhino/makefile.mk +++ b/main/rhino/makefile.mk @@ -51,7 +51,7 @@ TARFILE_ROOTDIR=rhino1_7R3 ADDITIONAL_FILES= \ toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java -PATCH_FILES=rhino1_7R3.patch +PATCH_FILES=rhino1_7R3.patch rhino1_7R3-java-version.patch .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= diff --git a/main/rhino/rhino1_7R3-java-version.patch b/main/rhino/rhino1_7R3-java-version.patch new file mode 100644 index 0000000000..921be10617 --- /dev/null +++ b/main/rhino/rhino1_7R3-java-version.patch @@ -0,0 +1,13 @@ +--- misc/build/rhino1_7R3/build.properties ++++ misc/build/rhino1_7R3/build.properties +@@ -53,8 +53,8 @@ + + # compilation settings + debug: on +-target-jvm: 1.5 +-source-level: 1.5 ++target-jvm: 1.8 ++source-level: 1.8 + + # jar generation settings + jar-compression: true diff --git a/main/saxon/saxon-9.0.0.7-bj.patch b/main/saxon/saxon-9.0.0.7-bj.patch index 157ed004c2..bf2ed0fa48 100644 --- a/main/saxon/saxon-9.0.0.7-bj.patch +++ b/main/saxon/saxon-9.0.0.7-bj.patch @@ -144,10 +144,10 @@ + <property name="build.debuglevel" value="source,lines,vars"/> + <property name="build.deprecation" value="true"/> + <property name="build.optimize" value="true"/> -+ <property name="build.compiler.source" value="1.4"/> -+ <property name="build.compiler.target" value="1.4"/> -+ <property name="build.s9api.compiler.source" value="1.5"/> -+ <property name="build.s9api.compiler.target" value="1.5"/> ++ <property name="build.compiler.source" value="1.8"/> ++ <property name="build.compiler.target" value="1.8"/> ++ <property name="build.s9api.compiler.source" value="1.8"/> ++ <property name="build.s9api.compiler.target" value="1.8"/> + <property name="build.compress" value="false"/> + + <!-- following properties can be switched to determine whether to build from patch source diff --git a/main/solenv/ant/aoo-ant.xml b/main/solenv/ant/aoo-ant.xml index 4a42c7e5c9..7ed043bf6a 100644 --- a/main/solenv/ant/aoo-ant.xml +++ b/main/solenv/ant/aoo-ant.xml @@ -51,7 +51,10 @@ <property name="test-idl.classes.build.dir" location="${build.base.dir}/test-idl/classes"/> <property name="test.reports.dir" location="${build.base.dir}/test-reports"/> - <property name="java.baseline.version" value="1.7"/> + <!-- Java bytecode baseline: source/target level for all aoo-ant.xml driven + modules. 1.8 is the minimum supported JRE; must not exceed what modern + build JDKs still accept as -source/-target (JDK 21 dropped 1.7). --> + <property name="java.baseline.version" value="1.8"/> <property name="jar.dir" location="${WORKDIR}/Ant"/> <property name="main.debug" value="true"/> diff --git a/main/solenv/inc/antsettings.mk b/main/solenv/inc/antsettings.mk index a809bdb92f..4f7a661c7a 100644 --- a/main/solenv/inc/antsettings.mk +++ b/main/solenv/inc/antsettings.mk @@ -80,3 +80,12 @@ ANT_FLAGS= .IF "$(WITH_LANG)"!="" ANT_FLAGS+=-Dsolar.langs="$(WITH_LANG)" -Dsolar.localized="true" .ENDIF # "$(WITH_LANG)"!="" + +# Tree-wide Java bytecode floor for ant-driven builds: ant.build.javac.source/ +# target is Ant's global default for any <javac> task that does not set its own +# source/target, so bytecode stays Java 8 compatible on newer build JDKs. Tasks +# that specify their own source/target (e.g. patched saxon/lucene) are not +# overridden. gcj does not accept these, so skip that path. +.IF "$(SOLAR_JAVA)"!="" && "$(JAVACISGCJ)"!="yes" +ANT_FLAGS+=-Dant.build.javac.source=1.8 -Dant.build.javac.target=1.8 +.ENDIF # "$(SOLAR_JAVA)"!="" && "$(JAVACISGCJ)"!="yes" diff --git a/main/solenv/inc/settings.mk b/main/solenv/inc/settings.mk index ea088be714..258e081a3b 100644 --- a/main/solenv/inc/settings.mk +++ b/main/solenv/inc/settings.mk @@ -150,6 +150,17 @@ JAVARESPONSE= .ENDIF .ENDIF +# Tree-wide Java bytecode floor: compile all Java to a fixed source/target level +# so artifacts run on the minimum supported JRE (Java 8) regardless of how new +# the build JDK is. Without this, building on a modern JDK (e.g. 21) emits +# bytecode that will not load on Java 8. gcj does not accept -source/-target, +# so skip it there. Can be overridden by setting JAVA_TARGET_FLAG in the env. +.IF "$(JAVA_TARGET_FLAG)"=="" +.IF "$(JAVACISGCJ)"!="yes" +JAVA_TARGET_FLAG=-source 1.8 -target 1.8 +.ENDIF # "$(JAVACISGCJ)"!="yes" +.ENDIF # "$(JAVA_TARGET_FLAG)"=="" + JAVAFLAGS+=$(JAVA_TARGET_FLAG) #END JAVA diff --git a/main/stax/makefile.mk b/main/stax/makefile.mk index 57c74831b8..ed5955d0e5 100644 --- a/main/stax/makefile.mk +++ b/main/stax/makefile.mk @@ -55,7 +55,9 @@ TARFILE_NAME=stax-src-1.2.0 TARFILE_MD5=980143f96b3f6ce45d2e4947da21a5e9 TARFILE_ROOTDIR=src -BUILD_ACTION=$(JAVAC) javax$/xml$/stream$/*.java && jar -cf stax-1.2.0.jar javax$/xml$/stream$/*.class javax$/xml$/stream$/events$/*.class javax$/xml$/stream$/util$/*.class +# $(JAVA_TARGET_FLAG) pins bytecode to the Java 8 floor (settings.mk); this raw +# javac call would otherwise emit bytecode for whatever the build JDK defaults to. +BUILD_ACTION=$(JAVAC) $(JAVA_TARGET_FLAG) javax$/xml$/stream$/*.java && jar -cf stax-1.2.0.jar javax$/xml$/stream$/*.class javax$/xml$/stream$/events$/*.class javax$/xml$/stream$/util$/*.class OUT2CLASS=stax-1.2.0.jar .ENDIF # "$(BUILD_STAX)" != "YES"
