diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-08-16 11:09:47 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-08-19 12:20:57 +0200 |
commit | 97b61ea3297e04e64aab1e1a4ec50202e9f86fff (patch) | |
tree | f344bfcb84aef2a27392dcd49388f5613e500ce1 /ridljar | |
parent | 71ebb55b4e888c8d1642d52742fc6d0d11ba3b9e (diff) |
ridljar: check that UnoClassLoader is used for NativeLibraryLoader
The native libraries are local to class loaders, so
System.load("java_uno.so") will fail with any other class loader.
Change-Id: Ifa3b1b8dfef07b64828943654e28ff1f0fb5a494
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120527
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ridljar')
-rw-r--r-- | ridljar/com/sun/star/lib/util/NativeLibraryLoader.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java b/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java index eb5c6af34e90..d255a71ea5d1 100644 --- a/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java +++ b/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java @@ -21,6 +21,7 @@ package com.sun.star.lib.util; import java.io.File; import java.net.URL; import java.net.URLClassLoader; +import com.sun.star.lib.unoloader.UnoClassLoader; /** * Helper functions to locate and load native files. @@ -35,6 +36,14 @@ import java.net.URLClassLoader; * algorithm.</p> */ public final class NativeLibraryLoader { + static { + // if it's some other class loader, then resolving the symbol + // Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call in + // java_uno will not work and result in UnsatisfiedLinkError + if (!(NativeLibraryLoader.class.getClassLoader() instanceof com.sun.star.lib.unoloader.UnoClassLoader)) { + System.err.println("warning: com.sun.star.lib.util.NativeLibraryLoader must be loaded by com.sun.star.lib.unoloader.UnoClassLoader for java_uno bridge to work (not a problem if this is using Java remote bridge or unit test)"); + } + } /** * Load a system library, using a given class loader to locate the library. * |