1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
Subject: try to load native library from /usr/lib/jni if system
property jna.boot.library.path is not set
Author: Jan Dittberner <jandd@debian.org>
--- a/src/com/sun/jna/Native.java
+++ b/src/com/sun/jna/Native.java
@@ -828,6 +828,30 @@
}
/**
+ * Copied from the NativeLibrary class
+ */
+ private static String getMultiArchPath() {
+ String cpu = Platform.ARCH;
+ String kernel = Platform.iskFreeBSD()
+ ? "-kfreebsd"
+ : (Platform.isGNU() ? "" : "-linux");
+ String libc = "-gnu";
+
+ if (Platform.isIntel()) {
+ cpu = (Platform.is64Bit() ? "x86_64" : "i386");
+ }
+ else if (Platform.isPPC()) {
+ cpu = (Platform.is64Bit() ? "powerpc64" : "powerpc");
+ }
+ else if (Platform.isARM()) {
+ cpu = "arm";
+ libc = "-gnueabi";
+ }
+
+ return cpu + kernel + libc;
+ }
+
+ /**
* Loads the JNA stub library.
* First tries jna.boot.library.path, then the system path, then from the
* jar file.
@@ -844,6 +868,9 @@
String libName = System.getProperty("jna.boot.library.name", "jnidispatch");
String bootPath = System.getProperty("jna.boot.library.path");
+ if (bootPath == null) {
+ bootPath = "/usr/lib/jni" + File.pathSeparator + "/usr/lib/" + getMultiArchPath() + "/jni";
+ }
if (bootPath != null) {
// String.split not available in 1.4
StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
|