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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
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
@@ -948,6 +948,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/" + Platform.getMultiArchPath() + "/jni";
+ }
if (bootPath != null) {
// String.split not available in 1.4
StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
--- a/src/com/sun/jna/NativeLibrary.java
+++ b/src/com/sun/jna/NativeLibrary.java
@@ -942,7 +942,7 @@
// so for platforms which are not multi-arch
// this should continue to work.
if (Platform.isLinux() || Platform.iskFreeBSD() || Platform.isGNU()) {
- String multiArchPath = getMultiArchPath();
+ String multiArchPath = Platform.getMultiArchPath();
// Assemble path with all possible options
paths = new String[] {
@@ -988,30 +988,6 @@
librarySearchPath.addAll(initPaths("jna.platform.library.path"));
}
- 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";
- }
- else if (Platform.ARCH.equals("mips64el")) {
- libc = "-gnuabi64";
- }
-
- return cpu + kernel + libc;
- }
-
/**
* Get the library paths from ldconfig cache. Tested against ldconfig 2.13.
*/
--- a/src/com/sun/jna/Platform.java
+++ b/src/com/sun/jna/Platform.java
@@ -273,8 +273,12 @@
arch = "ppc64le";
}
// Map arm to armel if the binary is running as softfloat build
- if("arm".equals(arch) && platform == Platform.LINUX && isSoftFloat()) {
- arch = "armel";
+ if("arm".equals(arch) && platform == Platform.LINUX ) {
+ if(isSoftFloat()) {
+ arch = "armel";
+ } else if(!is64Bit()) {
+ arch = "armhf";
+ }
}
return arch;
@@ -366,4 +370,30 @@
}
return osPrefix;
}
+
+ public static String getMultiArchPath() {
+ String cpu = ARCH;
+ String kernel = iskFreeBSD()
+ ? "-kfreebsd"
+ : (isGNU() ? "" : "-linux");
+ String libc = "-gnu";
+
+ if (isIntel()) {
+ cpu = (is64Bit() ? "x86_64" : "i386");
+ }
+ else if (isPPC()) {
+ cpu = cpu.replace("ppc", "powerpc");
+ }
+ else if (isARM()) {
+ cpu = (is64Bit() ? "aarch64" : "arm");
+ libc = is64Bit()
+ ? "-gnu"
+ : ("armhf".equals(ARCH) ? "-gnueabihf" : "-gnueabi");
+ }
+ else if (ARCH.equals("mips64el")) {
+ libc = "-gnuabi64";
+ }
+
+ return cpu + kernel + libc;
+ }
}
|