[Libreoffice-commits] core.git: jvmfwk/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 4 07:29:02 UTC 2021
jvmfwk/source/framework.cxx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
New commits:
commit 48c5ba19e4f4a1ad5a88b5e6f0816c080e1253ec
Author: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Mon Aug 2 12:21:17 2021 +0200
Commit: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
CommitDate: Wed Aug 4 09:28:28 2021 +0200
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 at allotropia.de>
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index 5a7cef449b78..ad1f636f00d0 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>
@@ -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
More information about the Libreoffice-commits
mailing list