[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - jvmfwk/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 4 14:26:31 UTC 2021


 jvmfwk/source/framework.cxx |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit 0d66c7c726e1ede16bcfce1c4fcfdb30a46f06cc
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Mon Aug 2 12:21:17 2021 +0200
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Wed Aug 4 16:25:55 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>
    (cherry picked from commit 48c5ba19e4f4a1ad5a88b5e6f0816c080e1253ec)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119970
    Tested-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>

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


More information about the Libreoffice-commits mailing list