summaryrefslogtreecommitdiff
path: root/jvmfwk
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-04-09 14:51:54 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-04-09 22:31:17 +0200
commit3d27b2fa9c5a03f78e5145377402f8a88e3da1be (patch)
treebe09d47208ad2f3f4564987a25d5d6d875744792 /jvmfwk
parentd38f9934f08939032cca64a32de58fa3901a88d5 (diff)
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon Corretto" to our hard-coded list, there is now reports that at least Debian and Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set to string like "Debian" or "Ubuntu". Instead of trying to catch up with an ever-growing hard-coded list, it is probably better to stop relying exclusively on such a hard-coded list, and for unknown vendor values, try out whether the SunInfo backend (which supports the "generic" OpenJDK) would be able to handle the given JRE. (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. If this turns out to be problematic, we could include information about problematic vendors after all, or add a general check that JREs from unknown vendors are at least Java 6.) Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to take a vendorSettings parameter instead, and VendorSettings::getVersionInformation has been changed to return a boost::optional, so that unknown vendors can be handled gracefully. Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9 Reviewed-on: https://gerrit.libreoffice.org/70460 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'jvmfwk')
-rw-r--r--jvmfwk/inc/fwkbase.hxx (renamed from jvmfwk/source/fwkbase.hxx)11
-rw-r--r--jvmfwk/inc/libxmlutil.hxx (renamed from jvmfwk/source/libxmlutil.hxx)4
-rw-r--r--jvmfwk/inc/vendorplugin.hxx94
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx109
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx7
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx18
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx5
-rw-r--r--jvmfwk/source/elements.cxx4
-rw-r--r--jvmfwk/source/framework.cxx273
-rw-r--r--jvmfwk/source/fwkbase.cxx18
-rw-r--r--jvmfwk/source/libxmlutil.cxx2
11 files changed, 189 insertions, 356 deletions
diff --git a/jvmfwk/source/fwkbase.hxx b/jvmfwk/inc/fwkbase.hxx
index b3779cda96b6..8fe077b79a28 100644
--- a/jvmfwk/source/fwkbase.hxx
+++ b/jvmfwk/inc/fwkbase.hxx
@@ -16,10 +16,15 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_JVMFWK_SOURCE_FWKBASE_HXX
-#define INCLUDED_JVMFWK_SOURCE_FWKBASE_HXX
+#ifndef INCLUDED_JVMFWK_INC_FWKBASE_HXX
+#define INCLUDED_JVMFWK_INC_FWKBASE_HXX
+
+#include <sal/config.h>
+
+#include <boost/optional.hpp>
#include <rtl/ustring.hxx>
+#include "elements.hxx"
#include "libxmlutil.hxx"
namespace jfw
@@ -34,7 +39,7 @@ class VendorSettings
public:
VendorSettings();
- VersionInfo getVersionInformation(const OUString & sVendor) const;
+ boost::optional<VersionInfo> getVersionInformation(const OUString & sVendor) const;
::std::vector< OUString> getSupportedVendors() const;
};
diff --git a/jvmfwk/source/libxmlutil.hxx b/jvmfwk/inc/libxmlutil.hxx
index 8a58280b406d..078d285ac78f 100644
--- a/jvmfwk/source/libxmlutil.hxx
+++ b/jvmfwk/inc/libxmlutil.hxx
@@ -16,8 +16,8 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_JVMFWK_SOURCE_LIBXMLUTIL_HXX
-#define INCLUDED_JVMFWK_SOURCE_LIBXMLUTIL_HXX
+#ifndef INCLUDED_JVMFWK_INC_LIBXMLUTIL_HXX
+#define INCLUDED_JVMFWK_INC_LIBXMLUTIL_HXX
#include <libxml/parser.h>
#include <libxml/xpath.h>
diff --git a/jvmfwk/inc/vendorplugin.hxx b/jvmfwk/inc/vendorplugin.hxx
index f370f1123375..0aa6d84276e3 100644
--- a/jvmfwk/inc/vendorplugin.hxx
+++ b/jvmfwk/inc/vendorplugin.hxx
@@ -28,10 +28,10 @@
#include <memory>
#include <vector>
-#include <utility>
-#include "elements.hxx"
#include "vendorbase.hxx"
+namespace jfw { class VendorSettings; }
+
/**
@file
<p>
@@ -56,7 +56,6 @@ enum class javaPluginError
WrongVersionFormat,
FailedVersion,
NoJre,
- WrongVendor,
WrongArch,
VmCreationFailed
};
@@ -64,26 +63,14 @@ enum class javaPluginError
/** obtains information about installations of Java Runtime Environments (JREs).
- <p>The function gathers information about available JREs which have the same
- vendor as determined by the <code>sVendor</code> parameter. Only information
+ <p>The function gathers information about available JREs. Only information
about those JREs which match the version requirements are returned. These
- requirements are specified by the parameters <code>sMinVersion</code>,
- <code>sMaxVersion</code> and <code>arExcludeList</code>.
+ requirements are specified by the parameter <code>vendorSettings</code>.
</p>
<p>
The JavaInfo structures returned in <code>parJavaInfo</code> should be ordered
according to their version. The one, representing a JRE with the highest
version should be the first in the array. </p>
- @param sVendor
- [in] only JREs from this vendor are examined. This parameter always contains
- a vendor string. That is, the string it is not empty.
- @param sMinVersion
- [in] represents the minimum version of a JRE. The string can be empty.
- @param sMaxVersion
- [in] represents the maximum version of a JRE. The string can be empty.
- @param arExcludeList
- [in] contains a list of &quot;bad&quot; versions. JREs which have one of these
- versions must not be returned by this function.
@param parJavaInfo
[out] if the function runs successfully then <code>parJavaInfo</code> contains
on return a vector of pointers to <code>JavaInfo</code> objects.
@@ -91,40 +78,25 @@ enum class javaPluginError
@return
javaPluginError::NONE the function ran successfully.</br>
javaPluginError::Error an error occurred during execution.</br>
- javaPluginError::InvalidArg an argument was not valid.</br>
javaPluginError::WrongVersionFormat the version strings in
- <code>sMinVersion,sMaxVersion,arExcludeList</code> are not recognized as valid
+ <code>vendorSettings</code> are not recognized as valid
version strings.
*/
javaPluginError jfw_plugin_getAllJavaInfos(
bool checkJavaHomeAndPath,
- OUString const& sVendor,
- OUString const& sMinVersion,
- OUString const& sMaxVersion,
- std::vector<OUString> const & arExcludeList,
+ jfw::VendorSettings const & vendorSettings,
std::vector<std::unique_ptr<JavaInfo>> * parJavaInfo,
std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos);
/** obtains information for a JRE at a given location.
- <p>If the given location belongs to a JRE whoose vendor matches the
- sVendor argument and the JRE has a version which meets the requirements as
- specified by <code>sMinVersion, sMaxVersion, arExcludeList</code> then
- this function shall return a JavaInfo object for this JRE if this implementation
- supports this vendor.</p>
+ <p>If the given location belongs to a JRE
+ and the JRE has a version which meets the requirements as
+ specified by <code>vendorSettings</code> then
+ this function shall return a JavaInfo object for this JRE.</p>
@param sLocation
[in] a file URL to the directory of the JRE.
- @param sVendor
- [in] a name of a vendor. This parameter always contains
- a vendor string. That is, the string it is not empty.
- @param sMinVersion
- [in] represents the minimum version of a JRE.
- @param sMaxVersion
- [in] represents the maximum version of a JRE.
- @param arExcludeList
- [in] contains a list of &quot;bad&quot; versions. JREs which have one of these
- versions must not be returned by this function.
@param ppInfo
[out] if the function runs successfully then <code>ppInfo</code> contains
on return a pointer to a <code>JavaInfo</code> object.
@@ -134,37 +106,23 @@ javaPluginError jfw_plugin_getAllJavaInfos(
javaPluginError::Error an error occurred during execution.</br>
javaPluginError::InvalidArg an argument was not valid. For example, sLocation
is an empty string.</br>
- javaPluginError::WrongVersionFormat the version strings in
- <code>sMinVersion,sMaxVersion,arExcludeList</code> are not recognized as valid
- version strings.
javaPluginError::FailedVersion there is a JRE at the given location but it does not
meet the version requirements.
- javaPluginError::NoJre no JRE could be detected at the given location. However, that
- does not mean necessarily that there is no JRE. There could be a JRE but it has
- a vendor which is not supported by this API implementation.
+ javaPluginError::NoJre no JRE could be detected at the given location.
*/
javaPluginError jfw_plugin_getJavaInfoByPath(
OUString const& sLocation,
- OUString const& sVendor,
- OUString const& sMinVersion,
- OUString const& sMaxVersion,
- std::vector<OUString> const &arExcludeList,
+ jfw::VendorSettings const & vendorSettings,
std::unique_ptr<JavaInfo> * ppInfo);
/** obtains information for a JRE referenced by the JAVA_HOME environment variable.
- <p>If the JAVA_HOME environment variable is set and points to a JRE whoose vendor
- matches the requirements given by vecVendorInfos (i.e. it has a vendor that is
- given in vecVendorInfos and the version requirements for the vendor are met),
+ <p>If the JAVA_HOME environment variable is set and points to a JRE that
+ matches the requirements given by vendorSettings (i.e.
+ the version requirements, if any, for the vendor are met),
then this function shall return a JavaInfo object for this JRE.</p>
- @param vecVendorInfos
- [in] vector specifying the vendor and version requirements that the JRE must fulfill.
- The vector contains pairs of vendors and the respective version requirements
- for those vendors. The JRE must support the requirements of one given pair in the
- vector (i.e. it must be of one of the vendors and meet the version requirements
- - minVersion, maxVersion, excludeVersions - for that specific vendor).
@param ppInfo
[out] if the JAVA_HOME environment variable is set and points to a suitable
JRE, then <code>ppInfo</code> contains
@@ -173,12 +131,12 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
@return
javaPluginError::NONE the function ran successfully.</br>
javaPluginError::NoJre no suitable JRE could be detected at the given location. However, that
- does not mean necessarily that there is no JRE. There could be a JRE but it has
- a vendor which is not supported by this API implementation or it does not
+ does not mean necessarily that there is no JRE. There could be a JRE but
+ it does not
meet the version requirements.
*/
javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
- std::vector<std::pair<OUString, jfw::VersionInfo>> const& vecVendorInfos,
+ jfw::VendorSettings const & vendorSettings,
std::unique_ptr<JavaInfo> * ppInfo,
std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos);
@@ -187,20 +145,14 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
whose executable is in the PATH.
<p>The function gathers information about available JREs which are on the PATH
- (PATH environment variable) and meet the vendor and version requirements given by
- <code>vecVendorInfos</code> (i.e. they have a vendor that is given in
- <code>vecVendorInfos</code> and the version requirements for the vendor are met).
+ (PATH environment variable) and meet the version requirements given by
+ <code>vendorSettings</code> (i.e.
+ the version requirements, if any, for the vendor are met).
</p>
<p>
The JavaInfo structures returned in <code>vecJavaInfosFromPath</code> should be ordered
according to their occurrence in the PATH. The one that is the first one on the PATH
is also the first element in the vector.</p>
- @param vecVendorInfos
- [in] vector specifying the vendor and version requirements that the JRE must fulfill.
- The vector contains pairs of vendors and the respective version requirements
- for those vendors. The JRE must support the requirements of one given pair in the
- vector (i.e. it must be of one of the vendors and meet the version requirements
- - minVersion, maxVersion, excludeVersions - for that specific vendor).
@param vecJavaInfosFromPath
[out] if the function runs successfully then <code>vecJavaInfosFromPath</code>
contains on return a vector of pointers to <code>JavaInfo</code> objects.
@@ -216,7 +168,7 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
*/
javaPluginError jfw_plugin_getJavaInfosFromPath(
- std::vector<std::pair<OUString, jfw::VersionInfo>> const& vecVendorInfos,
+ jfw::VendorSettings const & vendorSettings,
std::vector<std::unique_ptr<JavaInfo>> & vecJavaInfosFromPath,
std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos);
@@ -256,8 +208,6 @@ javaPluginError jfw_plugin_getJavaInfosFromPath(
@return
javaPluginError::NONE the function ran successfully.</br>
javaPluginError::Error an error occurred during execution.</br>
- javaPluginError::WrongVendor the <code>JavaInfo</code> object was not created
- in by this library and the VM cannot be started.</br>
JFW_PLUGIN_E_VM_CREATION_FAILED a VM could not be created. The error was caused
by the JRE.
*/
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index b2cc8ed40803..395ef332e0e8 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -57,6 +57,7 @@
#include <jni.h>
#include <rtl/byteseq.hxx>
+#include <fwkbase.hxx>
#include <vendorplugin.hxx>
#include "util.hxx"
#include "sunversion.hxx"
@@ -296,19 +297,12 @@ javaPluginError checkJavaVersionRequirements(
javaPluginError jfw_plugin_getAllJavaInfos(
bool checkJavaHomeAndPath,
- OUString const& sVendor,
- OUString const& sMinVersion,
- OUString const& sMaxVersion,
- std::vector<OUString> const &arExcludeList,
+ jfw::VendorSettings const & vendorSettings,
std::vector<std::unique_ptr<JavaInfo>>* parJavaInfo,
std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos)
{
assert(parJavaInfo);
- OSL_ASSERT(!sVendor.isEmpty());
- if (sVendor.isEmpty())
- return javaPluginError::InvalidArg;
-
//Find all JREs
vector<rtl::Reference<VendorBase> > vecInfos =
addAllJREInfos(checkJavaHomeAndPath, infos);
@@ -316,17 +310,16 @@ 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);
- if (sVendor != vecInfo->getVendor())
- continue;
-
- javaPluginError err = checkJavaVersionRequirements(
- vecInfo, sMinVersion, sMaxVersion, arExcludeList);
-
- 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);
}
@@ -343,10 +336,7 @@ javaPluginError jfw_plugin_getAllJavaInfos(
javaPluginError jfw_plugin_getJavaInfoByPath(
OUString const& sPath,
- OUString const& sVendor,
- OUString const& sMinVersion,
- OUString const& sMaxVersion,
- std::vector<OUString> const &arExcludeList,
+ jfw::VendorSettings const & vendorSettings,
std::unique_ptr<JavaInfo> * ppInfo)
{
assert(ppInfo != nullptr);
@@ -354,19 +344,17 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
if (sPath.isEmpty())
return javaPluginError::InvalidArg;
- OSL_ASSERT(!sVendor.isEmpty());
- if (sVendor.isEmpty())
- return javaPluginError::InvalidArg;
-
rtl::Reference<VendorBase> aVendorInfo = getJREInfoByPath(sPath);
if (!aVendorInfo.is())
return javaPluginError::NoJre;
//Check if the detected JRE matches the version requirements
- if (sVendor != aVendorInfo->getVendor())
- return javaPluginError::NoJre;
- javaPluginError errorcode = checkJavaVersionRequirements(
- aVendorInfo, sMinVersion, sMaxVersion, arExcludeList);
+ javaPluginError errorcode = javaPluginError::NONE;
+ if (auto const versionInfo = vendorSettings.getVersionInformation(aVendorInfo->getVendor()))
+ {
+ errorcode = checkJavaVersionRequirements(
+ aVendorInfo, versionInfo->sMinVersion, versionInfo->sMaxVersion, versionInfo->vecExcludeVersions);
+ }
if (errorcode == javaPluginError::NONE)
*ppInfo = createJavaInfo(aVendorInfo);
@@ -375,7 +363,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
}
javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
- std::vector<pair<OUString, jfw::VersionInfo>> const& vecVendorInfos,
+ jfw::VendorSettings const & vendorSettings,
std::unique_ptr<JavaInfo> * ppInfo,
std::vector<rtl::Reference<VendorBase>> & infos)
{
@@ -389,32 +377,24 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome(
assert(infoJavaHome.size() == 1);
//Check if the detected JRE matches the version requirements
- for (auto const& vendorInfo : vecVendorInfos)
- {
- const OUString& vendor = vendorInfo.first;
- jfw::VersionInfo versionInfo = vendorInfo.second;
-
- if (vendor == infoJavaHome[0]->getVendor())
- {
- javaPluginError errorcode = checkJavaVersionRequirements(
+ auto const versionInfo = vendorSettings.getVersionInformation(infoJavaHome[0]->getVendor());
+ if (!versionInfo
+ || (checkJavaVersionRequirements(
infoJavaHome[0],
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions);
-
- if (errorcode == javaPluginError::NONE)
- {
- *ppInfo = createJavaInfo(infoJavaHome[0]);
- return javaPluginError::NONE;
- }
- }
+ versionInfo->sMinVersion,
+ versionInfo->sMaxVersion,
+ versionInfo->vecExcludeVersions)
+ == javaPluginError::NONE))
+ {
+ *ppInfo = createJavaInfo(infoJavaHome[0]);
+ return javaPluginError::NONE;
}
return javaPluginError::NoJre;
}
javaPluginError jfw_plugin_getJavaInfosFromPath(
- std::vector<std::pair<OUString, jfw::VersionInfo>> const& vecVendorInfos,
+ jfw::VendorSettings const & vendorSettings,
std::vector<std::unique_ptr<JavaInfo>> & javaInfosFromPath,
std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos)
{
@@ -427,24 +407,16 @@ javaPluginError jfw_plugin_getJavaInfosFromPath(
// copy infos of JREs that meet version requirements to vecVerifiedInfos
for (auto const& infosFromPath : vecInfosFromPath)
{
- for (auto const& vendorInfo : vecVendorInfos)
- {
- const OUString& vendor = vendorInfo.first;
- jfw::VersionInfo const & versionInfo = vendorInfo.second;
-
- if (vendor == infosFromPath->getVendor())
- {
- javaPluginError errorcode = checkJavaVersionRequirements(
+ auto const versionInfo = vendorSettings.getVersionInformation(infosFromPath->getVendor());
+ if (!versionInfo
+ || (checkJavaVersionRequirements(
infosFromPath,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions);
-
- if (errorcode == javaPluginError::NONE)
- {
- vecVerifiedInfos.push_back(createJavaInfo(infosFromPath));
- }
- }
+ versionInfo->sMinVersion,
+ versionInfo->sMaxVersion,
+ versionInfo->vecExcludeVersions)
+ == javaPluginError::NONE))
+ {
+ vecVerifiedInfos.push_back(createJavaInfo(infosFromPath));
}
}
@@ -621,9 +593,6 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
// unless errorcode is volatile the following warning occurs on gcc:
// warning: variable 'errorcode' might be clobbered by `longjmp' or `vfork'
volatile javaPluginError errorcode = javaPluginError::NONE;
- //Check if the Vendor (pInfo->sVendor) is supported by this plugin
- if ( ! isVendorSupported(pInfo->sVendor))
- return javaPluginError::WrongVendor;
#ifdef MACOSX
rtl::Reference<VendorBase> aVendorInfo = getJREInfoByPath( pInfo->sLocation );
if ( !aVendorInfo.is() || aVendorInfo->compareVersions( pInfo->sVersion ) < 0 )
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 249deeaf304c..a21aa4ff933f 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -1032,6 +1032,7 @@ rtl::Reference<VendorBase> getJREInfoByPath(
}
}
+ auto knownVendor = false;
if (!sVendorName.isEmpty())
{
//find the creator func for the respective vendor name
@@ -1043,10 +1044,16 @@ rtl::Reference<VendorBase> getJREInfoByPath(
if (sNameMap == sVendorName)
{
ret = createInstance(gVendorMap[c].createFunc, props);
+ knownVendor = true;
break;
}
}
}
+ // For unknown vendors, try SunInfo as fallback:
+ if (!knownVendor)
+ {
+ ret = createInstance(SunInfo::createInstance, props);
+ }
if (!ret.is())
{
vecBadPaths.push_back(sFilePath);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
index 60911f8a63ca..cc3088fbc683 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.cxx
@@ -22,10 +22,6 @@
#include "gnujre.hxx"
#include "sunjre.hxx"
#include "otherjre.hxx"
-#include <osl/thread.h>
-#include <stdio.h>
-#include <sal/log.hxx>
-
namespace jfw_plugin
{
@@ -54,20 +50,6 @@ VendorSupportMapEntry const gVendorMap[] ={
VENDOR_MAP_ENTRY<OtherInfo>("Azul Systems, Inc."),
{nullptr, nullptr, nullptr} };
-
-bool isVendorSupported(const OUString& sVendor)
-{
- const size_t count = SAL_N_ELEMENTS(gVendorMap) - 1;
- for ( size_t pos = 0; pos < count; ++pos )
- {
- if (sVendor.equalsAscii(gVendorMap[pos].sVendorName))
- return true;
- }
- SAL_INFO(
- "jfw.level2", "sunjavaplugin does not support vendor: " << sVendor);
- return false;
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
index 10e3cec10518..a0e682a9e09b 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
@@ -41,11 +41,6 @@ template<typename y> constexpr VendorSupportMapEntry VENDOR_MAP_ENTRY(char const
return {x, & y::getJavaExePaths, & y::createInstance};
}
-/* Examines if the vendor supplied in parameter sVendor is part of the
- list of supported vendors. That is the arry of VendorSupportMapEntry
- is search for an respective entry.
-*/
-bool isVendorSupported(const OUString & sVendor);
}
#endif
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index ec77f7ab1cae..4a9477c41db1 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -27,9 +27,9 @@
#include <osl/mutex.hxx>
#include <osl/file.hxx>
#include <fwkutil.hxx>
-#include "fwkbase.hxx"
+#include <fwkbase.hxx>
#include "framework.hxx"
-#include "libxmlutil.hxx"
+#include <libxmlutil.hxx>
#include <osl/thread.hxx>
#include <algorithm>
#include <libxml/parser.h>
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index a748d77cff37..8d870fd335ae 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -35,7 +35,7 @@
#include "framework.hxx"
#include <fwkutil.hxx>
#include <elements.hxx>
-#include "fwkbase.hxx"
+#include <fwkbase.hxx>
namespace {
@@ -59,8 +59,6 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI
osl::MutexGuard guard(jfw::FwkMutex::get());
jfw::VendorSettings aVendorSettings;
- std::vector<OUString> vecVendors =
- aVendorSettings.getSupportedVendors();
//Add the JavaInfos found by jfw_plugin_getAllJavaInfos to the vector
std::vector<std::unique_ptr<JavaInfo>> vecInfo;
//get the list of paths to jre locations which have been
@@ -68,69 +66,47 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI
const jfw::MergedSettings settings;
const std::vector<OUString>& vecJRELocations =
settings.getJRELocations();
- //Use every plug-in library to get Java installations.
- for (auto const & vendor: vecVendors)
- {
- jfw::VersionInfo versionInfo =
- aVendorSettings.getVersionInformation(vendor);
+ //Use all plug-in libraries to get Java installations.
+ std::vector<std::unique_ptr<JavaInfo>> arInfos;
+ std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos;
+ javaPluginError plerr = jfw_plugin_getAllJavaInfos(
+ true,
+ aVendorSettings,
+ & arInfos,
+ infos);
- //get all installations of one vendor according to minVersion,
- //maxVersion and excludeVersions
- std::vector<std::unique_ptr<JavaInfo>> arInfos;
- std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos;
- javaPluginError plerr = jfw_plugin_getAllJavaInfos(
- true,
- vendor,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions,
- & arInfos,
- infos);
+ if (plerr != javaPluginError::NONE)
+ return JFW_E_ERROR;
- if (plerr != javaPluginError::NONE)
- return JFW_E_ERROR;
+ for (auto & j: arInfos)
+ vecInfo.push_back(std::move(j));
- for (auto & j: arInfos)
- vecInfo.push_back(std::move(j));
+ //Check if any plugin can detect JREs at the location
+ // of the paths added by jfw_addJRELocation
+ //Check every manually added location
+ for (auto const & ii: vecJRELocations)
+ {
+ std::unique_ptr<JavaInfo> aInfo;
+ plerr = jfw_plugin_getJavaInfoByPath(
+ ii,
+ aVendorSettings,
+ &aInfo);
+ if (plerr == javaPluginError::NoJre)
+ continue;
+ if (plerr == javaPluginError::FailedVersion)
+ continue;
+ else if (plerr != javaPluginError::NONE)
+ return JFW_E_ERROR;
- //Check if the current plugin can detect JREs at the location
- // of the paths added by jfw_addJRELocation
- //Check every manually added location
- for (auto const & ii: vecJRELocations)
+ // Was this JRE already added?
+ if (std::none_of(
+ vecInfo.begin(), vecInfo.end(),
+ [&aInfo](std::unique_ptr<JavaInfo> const & info) {
+ return areEqualJavaInfo(
+ info.get(), aInfo.get());
+ }))
{
- std::unique_ptr<JavaInfo> aInfo;
- plerr = jfw_plugin_getJavaInfoByPath(
- ii,
- vendor,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions,
- &aInfo);
- if (plerr == javaPluginError::NoJre)
- continue;
- if (plerr == javaPluginError::FailedVersion)
- continue;
- else if (plerr != javaPluginError::NONE)
- return JFW_E_ERROR;
-
- // Was this JRE already added? Different plugins could detect
- // the same JRE. Also make sure vecInfo contains only JavaInfos
- // for the vendors for which there is a javaSelection/plugins/
- // library entry in the javavendors.xml; jfw_getJavaInfoByPath
- // can return a JavaInfo of any vendor:
- if ((std::none_of(
- vecInfo.begin(), vecInfo.end(),
- [&aInfo](std::unique_ptr<JavaInfo> const & info) {
- return areEqualJavaInfo(
- info.get(), aInfo.get());
- }))
- && (std::find(
- vecVendors.begin(), vecVendors.end(),
- aInfo->sVendor)
- != vecVendors.end()))
- {
- vecInfo.push_back(std::move(aInfo));
- }
+ vecInfo.push_back(std::move(aInfo));
}
}
@@ -304,7 +280,6 @@ javaFrameworkError jfw_startVM(
g_pJavaVM = pVm;
*ppVM = pVm;
}
- OSL_ASSERT(plerr != javaPluginError::WrongVendor);
}
catch (const jfw::FrameworkException& e)
{
@@ -343,25 +318,13 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
// get list of vendors for Java installations
jfw::VendorSettings aVendorSettings;
- std::vector<OUString> vecVendors =
- aVendorSettings.getSupportedVendors();
-
- // save vendors and respective version requirements pair-wise in a vector
- std::vector<std::pair<OUString, jfw::VersionInfo>> versionInfos;
- for (auto const & vendor : vecVendors)
- {
- jfw::VersionInfo versionInfo =
- aVendorSettings.getVersionInformation(vendor);
-
- versionInfos.emplace_back(vendor, versionInfo);
- }
std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos;
// first inspect Java installation that the JAVA_HOME
// environment variable points to (if it is set)
if (jfw_plugin_getJavaInfoFromJavaHome(
- versionInfos, &aCurrentInfo, infos)
+ aVendorSettings, &aCurrentInfo, infos)
== javaPluginError::NONE)
{
// compare features
@@ -379,7 +342,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
{
std::vector<std::unique_ptr<JavaInfo>> vecJavaInfosFromPath;
if (jfw_plugin_getJavaInfosFromPath(
- versionInfos, vecJavaInfosFromPath, infos)
+ aVendorSettings, vecJavaInfosFromPath, infos)
== javaPluginError::NONE)
{
for (auto & pJInfo: vecJavaInfosFromPath)
@@ -405,31 +368,20 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
// if no suitable Java installation has been found yet:
- // first iterate over all vendors to find a suitable Java installation,
+ // first use jfw_plugin_getAllJavaInfos to find a suitable Java installation,
// then try paths that have been added manually
if (!bInfoFound)
{
- //Use every vendor to get Java installations. At the first usable
- //Java the loop will break
- for (auto const & vendor : vecVendors)
+ //get all installations
+ std::vector<std::unique_ptr<JavaInfo>> arInfos;
+ javaPluginError plerr = jfw_plugin_getAllJavaInfos(
+ false,
+ aVendorSettings,
+ & arInfos,
+ infos);
+
+ if (plerr == javaPluginError::NONE)
{
- jfw::VersionInfo versionInfo =
- aVendorSettings.getVersionInformation(vendor);
-
- //get all installations of one vendor according to minVersion,
- //maxVersion and excludeVersions
- std::vector<std::unique_ptr<JavaInfo>> arInfos;
- javaPluginError plerr = jfw_plugin_getAllJavaInfos(
- false,
- vendor,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions,
- & arInfos,
- infos);
-
- if (plerr != javaPluginError::NONE)
- continue;
//iterate over all installations to find the best which has
//all features
for (auto & pJInfo: arInfos)
@@ -442,7 +394,6 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
//the just found Java implements all required features
//currently there is only accessibility!!!
aCurrentInfo = std::move(pJInfo);
- bInfoFound = true;
break;
}
else if (!aCurrentInfo)
@@ -452,12 +403,8 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
aCurrentInfo = std::move(pJInfo);
}
}
-
- if (bInfoFound)
- break;
- //All Java installations found by the current plug-in lib
- //do not provide the required features. Try the next plug-in
}
+
if (!aCurrentInfo)
{//The plug-ins did not find a suitable Java. Now try the paths which have been
//added manually.
@@ -466,53 +413,41 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
//node.loadFromSettings();
const std::vector<OUString> & vecJRELocations =
settings.getJRELocations();
- //use every plug-in to determine the JavaInfo objects
- for (auto const & vendor : vecVendors)
+ //use all plug-ins to determine the JavaInfo objects
+ for (auto const & JRELocation : vecJRELocations)
{
- jfw::VersionInfo versionInfo =
- aVendorSettings.getVersionInformation(vendor);
-
- for (auto const & JRELocation : vecJRELocations)
+ std::unique_ptr<JavaInfo> aInfo;
+ javaPluginError err = jfw_plugin_getJavaInfoByPath(
+ JRELocation,
+ aVendorSettings,
+ &aInfo);
+ if (err == javaPluginError::NoJre)
+ continue;
+ if (err == javaPluginError::FailedVersion)
+ continue;
+ else if (err !=javaPluginError::NONE)
+ return JFW_E_ERROR;
+
+ if (aInfo)
{
- std::unique_ptr<JavaInfo> aInfo;
- javaPluginError err = jfw_plugin_getJavaInfoByPath(
- JRELocation,
- vendor,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions,
- &aInfo);
- if (err == javaPluginError::NoJre)
- continue;
- if (err == javaPluginError::FailedVersion)
- continue;
- else if (err !=javaPluginError::NONE)
- return JFW_E_ERROR;
-
- if (aInfo)
+ // compare features
+ // If the user does not require any features (nFeatureFlags = 0)
+ // then the first installation is used
+ if ((aInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
{
- // compare features
- // If the user does not require any features (nFeatureFlags = 0)
- // then the first installation is used
- if ((aInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
- {
- //the just found Java implements all required features
- //currently there is only accessibility!!!
- aCurrentInfo = std::move(aInfo);
- bInfoFound = true;
- break;
- }
- else if (!aCurrentInfo)
- {
- // We remember the very first installation in
- // aCurrentInfo:
- aCurrentInfo = std::move(aInfo);
- }
+ //the just found Java implements all required features
+ //currently there is only accessibility!!!
+ aCurrentInfo = std::move(aInfo);
+ break;
}
- }//end iterate over paths
- if (bInfoFound)
- break;
- }// end iterate plug-ins
+ else if (!aCurrentInfo)
+ {
+ // We remember the very first installation in
+ // aCurrentInfo:
+ aCurrentInfo = std::move(aInfo);
+ }
+ }
+ }//end iterate over paths
}
}
if (aCurrentInfo)
@@ -623,43 +558,21 @@ javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr
osl::MutexGuard guard(jfw::FwkMutex::get());
jfw::VendorSettings aVendorSettings;
- std::vector<OUString> vecVendors =
- aVendorSettings.getSupportedVendors();
- //Use every plug-in library to determine if the path represents a
- //JRE. If a plugin recognized it then the loop will break
- for (auto const & vendor : vecVendors)
- {
- jfw::VersionInfo versionInfo =
- aVendorSettings.getVersionInformation(vendor);
-
- //ask the plugin if this is a JRE.
- //If so check if it meets the version requirements.
- //Only if it does return a JavaInfo
- javaPluginError plerr = jfw_plugin_getJavaInfoByPath(
- pPath,
- vendor,
- versionInfo.sMinVersion,
- versionInfo.sMaxVersion,
- versionInfo.vecExcludeVersions,
- ppInfo);
+ //ask all plugins if this is a JRE.
+ //If so check if it meets the version requirements.
+ //Only if it does return a JavaInfo
+ javaPluginError plerr = jfw_plugin_getJavaInfoByPath(
+ pPath,
+ aVendorSettings,
+ ppInfo);
- if (plerr == javaPluginError::NONE)
- {
- break;
- }
- else if(plerr == javaPluginError::FailedVersion)
- {//found JRE but it has the wrong version
- ppInfo->reset();
- errcode = JFW_E_FAILED_VERSION;
- break;
- }
- else if (plerr == javaPluginError::NoJre)
- {// plugin does not recognize this path as belonging to JRE
- continue;
- }
- OSL_ASSERT(false);
+ if(plerr == javaPluginError::FailedVersion)
+ {//found JRE but it has the wrong version
+ ppInfo->reset();
+ errcode = JFW_E_FAILED_VERSION;
}
+ OSL_ASSERT(plerr == javaPluginError::NONE || plerr == javaPluginError::NoJre);
if (!*ppInfo && errcode != JFW_E_FAILED_VERSION)
errcode = JFW_E_NOT_RECOGNIZED;
}
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index db91bdeb38f4..73d7925f8707 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -29,7 +29,7 @@
#include "framework.hxx"
#include <fwkutil.hxx>
#include <elements.hxx>
-#include "fwkbase.hxx"
+#include <fwkbase.hxx>
using namespace osl;
@@ -116,11 +116,23 @@ VendorSettings::VendorSettings():
}
}
-VersionInfo VendorSettings::getVersionInformation(const OUString & sVendor) const
+boost::optional<VersionInfo> VendorSettings::getVersionInformation(const OUString & sVendor) const
{
OSL_ASSERT(!sVendor.isEmpty());
- VersionInfo aVersionInfo;
OString osVendor = OUStringToOString(sVendor, RTL_TEXTENCODING_UTF8);
+ CXPathObjectPtr pathObject;
+ pathObject = xmlXPathEvalExpression(
+ reinterpret_cast<xmlChar const *>(
+ OString(
+ "/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"" + osVendor
+ + "\"]/jf:minVersion").getStr()),
+ m_xmlPathContextVendorSettings);
+ if (xmlXPathNodeSetIsEmpty(pathObject->nodesetval))
+ {
+ return {};
+ }
+
+ VersionInfo aVersionInfo;
//Get minVersion
OString sExpression = OString(
"/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=\"") +
diff --git a/jvmfwk/source/libxmlutil.cxx b/jvmfwk/source/libxmlutil.cxx
index d2fe64e391a5..5f1ec5784eb5 100644
--- a/jvmfwk/source/libxmlutil.cxx
+++ b/jvmfwk/source/libxmlutil.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "libxmlutil.hxx"
+#include <libxmlutil.hxx>
namespace jfw
{