Fix alternate JREs missing bin/ directory on java.library.path
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>
This commit is contained in:
@@ -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>
|
||||
@@ -198,6 +200,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
|
||||
|
||||
Reference in New Issue
Block a user