diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-08-02 12:21:17 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-08-04 16:25:55 +0200 |
commit | 0d66c7c726e1ede16bcfce1c4fcfdb30a46f06cc (patch) | |
tree | a1552295c26f31dbae6c1d30fbf7da0adb40754b | |
parent | afbcde91d82de49f998d3103fa241d9ffddbf2d6 (diff) |
Fix alternate JREs missing bin/ directory on java.library.pathcib-6.4-0
Exception looks like this:
java stack trace:
java.lang.UnsatisfiedLinkError: zulu11\bin\fontmanager.dll: Can't find depende
nt libraries
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1873)
at java.desktop/sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:57)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:32)
at java.desktop/sun.font.SunFontManager$1.run(SunFontManager.java:279)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<clinit>(SunFontManager.java:275)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.ja
va:189)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnviron
ment.java:223)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnviron
ment.java:251)
Change-Id: I7a16bb5813d4c089ddb4de34a250280cf6fee137
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119880
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
(cherry picked from commit 48c5ba19e4f4a1ad5a88b5e6f0816c080e1253ec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119970
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | jvmfwk/source/framework.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 32120308f932..9684e13107cb 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -26,6 +26,8 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <osl/diagnose.h> +#include <osl/file.hxx> +#include <osl/process.h> #include <osl/thread.hxx> #include <jvmfwk/framework.hxx> #include <vendorbase.hxx> @@ -219,6 +221,22 @@ javaFrameworkError jfw_startVM( } assert(pInfo != nullptr); +#ifdef _WIN32 + // Alternative JREs (AdoptOpenJDK, Azul Zulu) are missing the bin/ folder in + // java.library.path. Somehow setting java.library.path accordingly doesn't work, + // but the PATH gets picked up, so add it there. + // Without this hack, some features don't work in alternative JREs. + OUString sPATH; + osl_getEnvironment(OUString("PATH").pData, &sPATH.pData); + OUString sJRELocation; + osl::FileBase::getSystemPathFromFileURL(pInfo->sLocation + "/bin", sJRELocation); + if (sPATH.isEmpty()) + sPATH = sJRELocation; + else + sPATH = sJRELocation + OUStringChar(SAL_PATHSEPARATOR) + sPATH; + osl_setEnvironment(OUString("PATH").pData, sPATH.pData); +#endif // _WIN32 + // create JavaVMOptions array that is passed to the plugin // it contains the classpath and all options set in the //options dialog |