jvmfwk/source/framework.cxx | 67 +++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 31 deletions(-)
New commits: commit f79457977f843407af77a9987926debd80f9e290 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 21 10:23:29 2020 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Oct 23 07:14:12 2020 +0200 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. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104001 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit 903a5aca86b41cd6c3d814af8bdd60b6885d300b) Conflicts: jvmfwk/source/framework.cxx Change-Id: I2b98d822aed2b160f970c50ca695a9f3beeacd34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104664 Tested-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index f0f04b8f733e..51dc841d6f6a 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -58,13 +58,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; @@ -80,33 +75,43 @@ 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::find_if( - vecInfo.begin(), vecInfo.end(), - [&aInfo](std::unique_ptr<JavaInfo> const & info) { - return areEqualJavaInfo( - info.get(), aInfo.get()); - }) - == vecInfo.end()) + //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::find_if( + vecInfo.begin(), vecInfo.end(), + [&aInfo](std::unique_ptr<JavaInfo> const & info) { + return areEqualJavaInfo( + info.get(), aInfo.get()); + }) + == vecInfo.end()) + { + vecInfo.push_back(std::move(aInfo)); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits