jvmfwk/inc/fwkbase.hxx                              |    3 -
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |   46 ++++++++------------
 jvmfwk/source/fwkbase.cxx                           |    4 -
 3 files changed, 23 insertions(+), 30 deletions(-)

New commits:
commit 3460c16d7f749d8d2a59d8b927df5ec31f64a083
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Oct 21 10:14:38 2021 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Thu Oct 21 12:42:03 2021 +0200

    Make getVersionInformation always return a VersionInfo
    
    ...even for JREs not listed in javavendors.xml, making it default to a
    VersionInfo with sMinVersion = "1.8.0".
    
    3d27b2fa9c5a03f78e5145377402f8a88e3da1be "tdf#124503: Support JRE 
installations
    with unknown java.vendor property", which had changed getVersionInformation 
to
    return an optional<VersionInfo>,  said in the commit message:  "For 
simplicity,
    assume that any versions of such JREs are supported.  Our baseline is Java 
6,
    and there are unlikely any older versions of JREs from unknown vendors out
    there."  Our baseline is Java 8 by now, and there are still unlikely any 
older
    JREs out there, but for macOS ARM64 we may want to restrict to at least 
Java 17
    implementing <http://openjdk.java.net/jeps/391> "JEP 391: macOS/AArch64 
Port",
    and this commit is a prerequisite for such a change (where we would then 
e.g.
    change the hardcoded "1.8.0" to "17" for just that one platform).
    
    (OtherInfo::compareVersions in 
jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
    unconditionally returns 0, meaning "versions compare equal", so introducing 
a
    default version of "1.8.0" should have no negative effect on any JREs that 
use
    OtherInfo.)
    
    Change-Id: I34dc5f2b755c2254a91d42c262786ceec70c746e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123958
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/jvmfwk/inc/fwkbase.hxx b/jvmfwk/inc/fwkbase.hxx
index 5f989cc08cee..61c3fa500138 100644
--- a/jvmfwk/inc/fwkbase.hxx
+++ b/jvmfwk/inc/fwkbase.hxx
@@ -21,7 +21,6 @@
 
 #include <sal/config.h>
 
-#include <optional>
 #include <string_view>
 #include <vector>
 
@@ -40,7 +39,7 @@ class VendorSettings
 public:
     VendorSettings();
 
-    std::optional<VersionInfo> getVersionInformation(std::u16string_view 
sVendor) const;
+    VersionInfo getVersionInformation(std::u16string_view sVendor) const;
 };
 
 /* The class offers functions to retrieve verified bootstrap parameters.
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx 
b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index d3b9b92a5b5e..70d6e7888097 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -348,16 +348,14 @@ javaPluginError jfw_plugin_getAllJavaInfos(
 
     for (auto const& vecInfo : vecInfos)
     {
-        if (auto const versionInfo = 
vendorSettings.getVersionInformation(vecInfo->getVendor()))
-        {
-            javaPluginError err = checkJavaVersionRequirements(
-                vecInfo, versionInfo->sMinVersion, versionInfo->sMaxVersion, 
versionInfo->vecExcludeVersions);
+        auto const versionInfo = 
vendorSettings.getVersionInformation(vecInfo->getVendor());
+        javaPluginError err = checkJavaVersionRequirements(
+            vecInfo, versionInfo.sMinVersion, versionInfo.sMaxVersion, 
versionInfo.vecExcludeVersions);
 
-            if (err == javaPluginError::FailedVersion || err == 
javaPluginError::WrongArch)
-                continue;
-            else if (err == javaPluginError::WrongVersionFormat)
-                return err;
-        }
+        if (err == javaPluginError::FailedVersion || err == 
javaPluginError::WrongArch)
+            continue;
+        else if (err == javaPluginError::WrongVersionFormat)
+            return err;
 
         vecVerifiedInfos.push_back(vecInfo);
     }
@@ -388,11 +386,9 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
 
     //Check if the detected JRE matches the version requirements
     javaPluginError errorcode = javaPluginError::NONE;
-    if (auto const versionInfo = 
vendorSettings.getVersionInformation(aVendorInfo->getVendor()))
-    {
-        errorcode = checkJavaVersionRequirements(
-            aVendorInfo, versionInfo->sMinVersion, versionInfo->sMaxVersion, 
versionInfo->vecExcludeVersions);
-    }
+    auto const versionInfo = 
vendorSettings.getVersionInformation(aVendorInfo->getVendor());
+    errorcode = checkJavaVersionRequirements(
+        aVendorInfo, versionInfo.sMinVersion, versionInfo.sMaxVersion, 
versionInfo.vecExcludeVersions);
 
     if (errorcode == javaPluginError::NONE)
         *ppInfo = createJavaInfo(aVendorInfo);
@@ -416,13 +412,12 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
 
     //Check if the detected JRE matches the version requirements
     auto const versionInfo = 
vendorSettings.getVersionInformation(infoJavaHome[0]->getVendor());
-    if (!versionInfo
-        || (checkJavaVersionRequirements(
+    if (checkJavaVersionRequirements(
                 infoJavaHome[0],
-                versionInfo->sMinVersion,
-                versionInfo->sMaxVersion,
-                versionInfo->vecExcludeVersions)
-            == javaPluginError::NONE))
+                versionInfo.sMinVersion,
+                versionInfo.sMaxVersion,
+                versionInfo.vecExcludeVersions)
+            == javaPluginError::NONE)
     {
         *ppInfo = createJavaInfo(infoJavaHome[0]);
         return javaPluginError::NONE;
@@ -446,13 +441,12 @@ javaPluginError jfw_plugin_getJavaInfosFromPath(
     for (auto const& infosFromPath : vecInfosFromPath)
     {
         auto const versionInfo = 
vendorSettings.getVersionInformation(infosFromPath->getVendor());
-        if (!versionInfo
-            || (checkJavaVersionRequirements(
+        if (checkJavaVersionRequirements(
                     infosFromPath,
-                    versionInfo->sMinVersion,
-                    versionInfo->sMaxVersion,
-                    versionInfo->vecExcludeVersions)
-                == javaPluginError::NONE))
+                    versionInfo.sMinVersion,
+                    versionInfo.sMaxVersion,
+                    versionInfo.vecExcludeVersions)
+                == javaPluginError::NONE)
         {
             vecVerifiedInfos.push_back(createJavaInfo(infosFromPath));
         }
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index dc7a8a153a5c..8de3f0c4d00c 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -119,7 +119,7 @@ VendorSettings::VendorSettings()
                 "[Java framework] Error in constructor 
VendorSettings::VendorSettings() (fwkbase.cxx)");
 }
 
-std::optional<VersionInfo> 
VendorSettings::getVersionInformation(std::u16string_view sVendor) const
+VersionInfo VendorSettings::getVersionInformation(std::u16string_view sVendor) 
const
 {
     OSL_ASSERT(!sVendor.empty());
     OString osVendor = OUStringToOString(sVendor, RTL_TEXTENCODING_UTF8);
@@ -131,7 +131,7 @@ std::optional<VersionInfo> 
VendorSettings::getVersionInformation(std::u16string_
         m_xmlPathContextVendorSettings);
     if (xmlXPathNodeSetIsEmpty(pathObject->nodesetval))
     {
-        return {};
+        return {{}, "1.8.0", ""};
     }
 
     VersionInfo aVersionInfo;

Reply via email to