config_host.mk.in             |    1 +
 configure.ac                  |   20 +++++++++++++++-----
 ridljar/Jar_libreoffice.mk    |    6 +++---
 ridljar/Jar_unoloader.mk      |    8 ++++----
 solenv/gbuild/JavaClassSet.mk |    6 +++---
 5 files changed, 26 insertions(+), 15 deletions(-)

New commits:
commit 4267c7124876b9213b3169a55731d260c8c63f7c
Author:     Fridrich Štrba <fridrich.st...@bluewin.ch>
AuthorDate: Fri Mar 1 13:36:42 2024 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Mar 2 06:29:50 2024 +0100

    Allow building with Java 8
    
    Change-Id: Ib1af1a98993aabb8a03f4ef19d8da4d9a71fdbc0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164226
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/config_host.mk.in b/config_host.mk.in
index 04745d508fc3..00dc7aa1f898 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -483,6 +483,7 @@ export MERGELIBS_MORE=@MERGELIBS_MORE@
 export ML_EXE=@ML_EXE@
 export MOC5=@MOC5@
 export MOC6=@MOC6@
+MODULAR_JAVA=@MODULAR_JAVA@
 export MPL_SUBSET=@MPL_SUBSET@
 export MSGFMT=@MSGFMT@
 export MSGUNIQ=@MSGUNIQ@
diff --git a/configure.ac b/configure.ac
index dd4ed7107aa8..b218120773d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2570,7 +2570,7 @@ AC_ARG_WITH(linker-hash-style,
 
 AC_ARG_WITH(jdk-home,
     AS_HELP_STRING([--with-jdk-home=<absolute path to JDK home>],
-        [If you have installed JDK 17 or later on your system please supply the
+        [If you have installed JDK 8 or later on your system please supply the
          path here. Note that this is not the location of the java command but 
the
          location of the entire distribution. In case of cross-compiling, this
          is the JDK of the host os. Use --with-build-platform-configure-options
@@ -8647,7 +8647,7 @@ if test "$ENABLE_JAVA" != ""; then
         fi
 
         if ! test -f "$with_jdk_home/lib/jvm.lib" -a -f 
"$with_jdk_home/bin/java.exe"; then
-            AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option (or 
fix the path) pointing to a $WIN_HOST_BITS-bit JDK >= 17])
+            AC_MSG_ERROR([No JDK found, pass the --with-jdk-home option (or 
fix the path) pointing to a $WIN_HOST_BITS-bit JDK >= 8])
         fi
     fi
 
@@ -8712,6 +8712,7 @@ dnl 
===================================================================
 # Whether all the complexity here actually is needed any more or not, no idea.
 
 JDK_SECURITYMANAGER_DISALLOWED=
+MODULAR_JAVA=
 if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != "yes"; then
     _gij_longver=0
     AC_MSG_CHECKING([the installed JDK])
@@ -8732,8 +8733,8 @@ if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != 
"yes"; then
             _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' 
| $SED '/^$/d' | $SED s/[[-A-Za-z]]*//`
             _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 
+ $3;}'`
 
-            if test "$_jdk_ver" -lt 170000; then
-                AC_MSG_ERROR([JDK is too old, you need at least 17 ($_jdk_ver 
< 170000)])
+            if test "$_jdk_ver" -lt 10800; then
+                AC_MSG_ERROR([JDK is too old, you need at least 8 ($_jdk_ver < 
10800)])
             fi
             dnl TODO: Presumably, the Security Manager will not merely be 
disallowed, but be
             dnl completely removed in some Java version > 18 (see
@@ -8748,13 +8749,21 @@ if test "$ENABLE_JAVA" != "" -a "$cross_compiling" != 
"yes"; then
             fi
             AC_MSG_RESULT([found $JAVA_HOME (JDK $_jdk)])
 
+            dnl Check whether the build Java supports modules
+            if test "$_jdk_ver" -ge 90000; then
+                MODULAR_JAVA=TRUE
+            else
+                AC_MSG_WARN([Modular jars will not be built. They need at 
least Java 9 ($_jdk_ver < 90000)])
+                add_warning "Modular jars will not be built. They need at 
least Java 9 ($_jdk_ver < 90000)"
+            fi
+
             # set to limit VM usage for JunitTests
             JAVAIFLAGS=-Xmx64M
             # set to limit VM usage for javac
             JAVACFLAGS=-J-Xmx128M
         fi
     else
-        AC_MSG_ERROR([Java not found. You need at least JDK 17])
+        AC_MSG_ERROR([Java not found. You need at least JDK 8])
     fi
 else
     if test -z "$ENABLE_JAVA"; then
@@ -9058,6 +9067,7 @@ AC_SUBST(JDK_FOR_BUILD)
 AC_SUBST(JDK_SECURITYMANAGER_DISALLOWED_FOR_BUILD)
 AC_SUBST(JAVA_SOURCE_VER)
 AC_SUBST(JAVA_TARGET_VER)
+AC_SUBST(MODULAR_JAVA)
 
 
 dnl ===================================================================
diff --git a/ridljar/Jar_libreoffice.mk b/ridljar/Jar_libreoffice.mk
index 76a56eedc078..77397bc246ee 100644
--- a/ridljar/Jar_libreoffice.mk
+++ b/ridljar/Jar_libreoffice.mk
@@ -36,12 +36,12 @@ $(eval $(call gb_Jar_add_manifest_classpath,libreoffice, \
 $(eval $(call gb_Jar_add_packagedirs,libreoffice,\
     $(call gb_CustomTarget_get_workdir,ridljar/javamaker)/com \
     $(call gb_CustomTarget_get_workdir,unoil/javamaker)/com \
-       $(call gb_JavaClassSet_get_classdir,$(call 
gb_Jar_get_classsetname,libreoffice))/module-info.class \
+       $(if $(MODULAR_JAVA),$(call gb_JavaClassSet_get_classdir,$(call 
gb_Jar_get_classsetname,libreoffice))/module-info.class) \
 ))
 
-$(eval $(call gb_Jar_add_sourcefiles_java9,libreoffice,\
+$(if $(MODULAR_JAVA),$(eval $(call gb_Jar_add_sourcefiles_java9,libreoffice,\
     ridljar/source/libreoffice/module-info \
-))
+)))
 
 $(eval $(call gb_Jar_add_sourcefiles,libreoffice,\
     ridljar/com/sun/star/comp/bridgefactory/BridgeFactory \
diff --git a/ridljar/Jar_unoloader.mk b/ridljar/Jar_unoloader.mk
index 2acf20b5b289..b7fcbc105dc1 100644
--- a/ridljar/Jar_unoloader.mk
+++ b/ridljar/Jar_unoloader.mk
@@ -14,13 +14,13 @@ $(eval $(call gb_Jar_set_packageroot,unoloader,com))
 $(eval $(call 
gb_Jar_set_manifest,unoloader,$(SRCDIR)/ridljar/source/unoloader/com/sun/star/lib/unoloader/manifest))
 
 # the module-info.class is manually added here since it's not in "com" dir
-$(eval $(call gb_Jar_add_packagedirs,unoloader,\
+$(if $(MODULAR_JAVA),$(eval $(call gb_Jar_add_packagedirs,unoloader,\
        $(call gb_JavaClassSet_get_classdir,$(call 
gb_Jar_get_classsetname,unoloader))/module-info.class \
-))
+)))
 
-$(eval $(call gb_Jar_add_sourcefiles_java9,unoloader,\
+$(if $(MODULAR_JAVA),$(eval $(call gb_Jar_add_sourcefiles_java9,unoloader,\
     ridljar/source/unoloader/module-info \
-))
+)))
 
 $(eval $(call gb_Jar_add_sourcefiles,unoloader,\
     ridljar/source/unoloader/com/sun/star/lib/unoloader/UnoClassLoader \
diff --git a/solenv/gbuild/JavaClassSet.mk b/solenv/gbuild/JavaClassSet.mk
index 84fbcc13c32d..8acf120dd615 100644
--- a/solenv/gbuild/JavaClassSet.mk
+++ b/solenv/gbuild/JavaClassSet.mk
@@ -19,7 +19,7 @@
 
 gb_JavaClassSet_JAVACCOMMAND = $(ICECREAM_RUN) $(JAVACOMPILER) $(JAVACFLAGS) \
     -encoding utf8 \
-    --release $(1) \
+    $(if $(MODULAR_JAVA),--release $(1),-source $(1) -target $(1)) \
     -Xlint:-options \
     -Xlint:unchecked
 
@@ -51,7 +51,7 @@ $(call gb_Helper_abbreviate_dirs,\
                        -d $(call gb_JavaClassSet_get_classdir,$(2)) \
                        @$$RESPONSEFILE &&) \
                rm -f $$RESPONSEFILE &&) \
-               $(if $(T_MODULENAME),\
+               $(if $(MODULAR_JAVA),$(if $(T_MODULENAME),\
                        RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),\
                                $(T_JAVA9FILES)) && \
                        $(if $(3),$(call gb_JavaClassSet_JAVACCOMMAND,9) \
@@ -61,7 +61,7 @@ $(call gb_Helper_abbreviate_dirs,\
                                $(if $(T_MODULENAME),--patch-module 
$(T_MODULENAME)="$(subst $(WHITESPACE),$(gb_CLASSPATHSEP),$(strip $(dir 
$(PACKAGEDIRS))))") \
                                -d $(call gb_JavaClassSet_get_classdir,$(2)) \
                                @$$RESPONSEFILE &&) \
-                       rm -f $$RESPONSEFILE &&) \
+                       rm -f $$RESPONSEFILE &&)) \
        touch $(1))
 
 endef

Reply via email to