From c8f0a37ff804e6329b21a4b7bfabb0667263c6e5 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 9 Mar 2017 20:43:09 +0100 Subject: Related tdf#54443 List only matching JREs I.e. show only 64bit JRE for 64bit LO and 32bit JRE for 32bit LO Change-Id: Id5e890637c7e1014bcb4e6fdd9ed9a33765112d5 Reviewed-on: https://gerrit.libreoffice.org/35026 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt (cherry picked from commit 9143dd4ebe37b608e43d04434cf831624bf55b65) Reviewed-on: https://gerrit.libreoffice.org/35162 Reviewed-by: Thorsten Behrens --- jvmfwk/inc/vendorbase.hxx | 2 ++ jvmfwk/inc/vendorplugin.hxx | 1 + .../plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 6 ++++- jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx | 26 +++++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/jvmfwk/inc/vendorbase.hxx b/jvmfwk/inc/vendorbase.hxx index 2a24c9590858..c9ebcb256913 100644 --- a/jvmfwk/inc/vendorbase.hxx +++ b/jvmfwk/inc/vendorbase.hxx @@ -133,6 +133,7 @@ public: const OUString & getRuntimeLibrary() const; const OUString & getLibraryPath() const; bool supportsAccessibility() const; + bool isValidArch() const; /* determines if prior to running java something has to be done, like setting the LD_LIBRARY_PATH. This implementation checks if an LD_LIBRARY_PATH (getLD_LIBRARY_PATH) needs to be set and @@ -178,6 +179,7 @@ protected: OUString m_sHome; OUString m_sRuntimeLibrary; OUString m_sLD_LIBRARY_PATH; + OUString m_sArch; bool m_bAccessibility; diff --git a/jvmfwk/inc/vendorplugin.hxx b/jvmfwk/inc/vendorplugin.hxx index 8df13b153b83..426157b6ed54 100644 --- a/jvmfwk/inc/vendorplugin.hxx +++ b/jvmfwk/inc/vendorplugin.hxx @@ -55,6 +55,7 @@ enum class javaPluginError FailedVersion, NoJre, WrongVendor, + WrongArch, VmCreationFailed }; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 63791bceac16..d69b439f2f0a 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -227,6 +227,10 @@ javaPluginError checkJavaVersionRequirements( rtl_uString * * arExcludeList, sal_Int32 nLenList) { + if (!aVendorInfo->isValidArch()) + { + return javaPluginError::WrongArch; + } if (!sMinVersion.isEmpty()) { try @@ -334,7 +338,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( javaPluginError err = checkJavaVersionRequirements( cur, sMinVersion, sMaxVersion, arExcludeList, nLenList); - if (err == javaPluginError::FailedVersion) + if (err == javaPluginError::FailedVersion || err == javaPluginError::WrongArch) continue; else if (err == javaPluginError::WrongVersionFormat) return err; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx index 9b580ccaa8fb..ef9da176ebc4 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx @@ -62,12 +62,14 @@ bool VendorBase::initialize(vector > props) OUString sVendorProperty("java.vendor"); OUString sVersionProperty("java.version"); OUString sHomeProperty("java.home"); + OUString sArchProperty("os.arch"); OUString sAccessProperty("javax.accessibility.assistive_technologies"); bool bVersion = false; bool bVendor = false; bool bHome = false; bool bAccess = false; + bool bArch = false; typedef vector >::const_iterator it_prop; for (it_prop i = props.begin(); i != props.end(); ++i) @@ -103,6 +105,11 @@ bool VendorBase::initialize(vector > props) bHome = true; #endif } + else if (!bArch && sArchProperty.equals(i->first)) + { + m_sArch = i->second; + bArch = true; + } else if (!bAccess && sAccessProperty.equals(i->first)) { if (!i->second.isEmpty()) @@ -115,7 +122,7 @@ bool VendorBase::initialize(vector > props) //must search through all properties. } - if (!bVersion || !bVendor || !bHome) + if (!bVersion || !bVendor || !bHome || !bArch) return false; // init m_sRuntimeLibrary @@ -201,6 +208,23 @@ const OUString & VendorBase::getRuntimeLibrary() const { return m_sRuntimeLibrary; } + +bool VendorBase::isValidArch() const +{ + // Warning: These values come from the "os.arch" property. + // It is not defined what the exact values are. + // Oracle JRE 8 has "x86" and "amd64", the others were found at http://lopica.sourceforge.net/os.html . + // There might still be missing some options; we need to extend the check once we find out. +#if defined _WIN32 + return m_sArch == "x86" || m_sArch == "i386" || m_sArch == "i686"; +#elif defined _WIN64 + return m_sArch == "amd64" || m_sArch == "x86_64"; +#else + (void)this; + return true; +#endif +} + bool VendorBase::supportsAccessibility() const { return m_bAccessibility; -- cgit