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".

3d27b2fa9c "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 <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2021-10-21 10:14:38 +02:00
parent 9bf469e6e4
commit 3460c16d7f
3 changed files with 23 additions and 30 deletions

View file

@ -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.

View file

@ -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));
}

View file

@ -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;