diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2020-10-21 10:23:29 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2020-10-22 07:40:07 +0200 |
commit | 903a5aca86b41cd6c3d814af8bdd60b6885d300b (patch) | |
tree | 92eddcec6d6b1749ad1f1821604525ddf28d1879 /jvmfwk/source | |
parent | 9c7b02852fce033b008f2ccd1703fc10276cfb4e (diff) |
Only read Java settings files in application mode
The 'javasettings_${_OS}_${_ARCH}.xml' files are only
meant to be used when the application mode of the
Java framework is used, not in direct mode.
From ure/source/README:
> You can also use the
> UNO_JAVA_JFW_JREHOME deployment variable to specify the location of a JDK/JRE
> installation. For more information on this variable, see
> http://udk.openoffice.org/common/man/spec/javavendorextension.sxw.
From that http://udk.openoffice.org/common/man/spec/javavendorextension.sxw :
> The direct mode of the framework is used within the build environment.
> Java is needed there in order to register Java UNO components with the
> regcomp tool. Direct mode means that no settings are written or read.
> That is the parameters UNO_JAVA_JFW_USER_DATA and
> UNO_JAVA_JFW_SHARED_DATA are not used.
> [...]
> Another example for using the direct mode is the SDK. The SDK uses the
> libraries from the office installation. When an SDK is configured then
> one specifies what Java is to be used. This Java shall then be used for
> all task which require Java including registration of UNO components. In
> order to override the java settings of the office the script which
> prepares the SDK environment sets these environment variables:
> UNO_JAVA_JFW_JREHOME=<file_URL_to_selected_Java>
> UNO_JAVA_JFW_ENV_CLASSPATH=true
> UNO_JAVA_JFW_VENDOR_SETTINGS=<file_URL_to_javavendors.xml_from_OOo>
> By setting UNO_JAVA_JFW_JREHOME the framework is switched into direct mode
> and the office settings are disregarded.
Therefore, don't try to read the settings when using direct mode.
This makes the relevant code path for accessing the settings conditional
on 'jfw::JFW_MODE_APPLICATION' being used.
Otherwise, using direct mode e.g. by starting LibreOffice using
UNO_JAVA_JFW_JREHOME=file:///usr/lib/jvm/java-11-openjdk-amd64/ ./instdir/program/soffice --writer
then going to the "Advanced" options in "Tools" -> "Options", where
the Java settings reside would result in this SAL_WARN being triggered
warn:jfw:10207:10207:jvmfwk/source/framework.cxx:119: [Java framework] Trying to access settings files in direct mode.
and no JVM at all being shown in the list of available
Java installations.
Change-Id: I2b98d822aed2b160f970c50ca695a9f3beeacd34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104001
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'jvmfwk/source')
-rw-r--r-- | jvmfwk/source/framework.cxx | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 5270439bda6a..5a7cef449b78 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -59,13 +59,8 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI osl::MutexGuard guard(jfw::FwkMutex::get()); jfw::VendorSettings aVendorSettings; - //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 - //added manually - const jfw::MergedSettings settings; - const std::vector<OUString>& vecJRELocations = - settings.getJRELocations(); + //Use all plug-in libraries to get Java installations. std::vector<std::unique_ptr<JavaInfo>> arInfos; std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos; @@ -81,32 +76,42 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI 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) + // direct mode disregards Java settings, so only retrieve + // JREs from settings when application mode is used + if (jfw::getMode() == jfw::JFW_MODE_APPLICATION) { - 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; - - // 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()); - })) + //get the list of paths to jre locations which have been + //added manually + const jfw::MergedSettings settings; + const std::vector<OUString> vecJRELocations = + settings.getJRELocations(); + //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) { - vecInfo.push_back(std::move(aInfo)); + 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; + + // 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()); + })) + { + vecInfo.push_back(std::move(aInfo)); + } } } |