ead55372fe
- Fix FTBFS (Resolves: rhbz#1106955)
113 lines
4.6 KiB
Diff
113 lines
4.6 KiB
Diff
diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java
|
|
index 6bdf0db..763d2ef 100644
|
|
--- a/src/com/sun/jna/Native.java
|
|
+++ b/src/com/sun/jna/Native.java
|
|
@@ -642,8 +642,8 @@ public final class Native implements Version {
|
|
|
|
/**
|
|
* Loads the JNA stub library.
|
|
- * First tries jna.boot.library.path, then the system path, then from the
|
|
- * jar file.
|
|
+ * MODIFIED FROM UPSTREAM - we rip out all sorts of gunk here that is
|
|
+ * unnecessary when JNA is properly installed with the OS.
|
|
*/
|
|
private static void loadNativeDispatchLibrary() {
|
|
|
|
@@ -656,88 +656,19 @@ public final class Native implements Version {
|
|
}
|
|
}
|
|
|
|
- String libName = System.getProperty("jna.boot.library.name", "jnidispatch");
|
|
- String bootPath = System.getProperty("jna.boot.library.path");
|
|
- if (bootPath != null) {
|
|
- // String.split not available in 1.4
|
|
- StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
|
|
- while (dirs.hasMoreTokens()) {
|
|
- String dir = dirs.nextToken();
|
|
- File file = new File(new File(dir), System.mapLibraryName(libName).replace(".dylib", ".jnilib"));
|
|
- String path = file.getAbsolutePath();
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Looking in " + path);
|
|
- }
|
|
- if (file.exists()) {
|
|
- try {
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Trying " + path);
|
|
- }
|
|
- System.setProperty("jnidispatch.path", path);
|
|
- System.load(path);
|
|
- jnidispatchPath = path;
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Found jnidispatch at " + path);
|
|
- }
|
|
- return;
|
|
- } catch (UnsatisfiedLinkError ex) {
|
|
- // Not a problem if already loaded in anoteher class loader
|
|
- // Unfortunately we can't distinguish the difference...
|
|
- //System.out.println("File found at " + file + " but not loadable: " + ex.getMessage());
|
|
- }
|
|
- }
|
|
- if (Platform.isMac()) {
|
|
- String orig, ext;
|
|
- if (path.endsWith("dylib")) {
|
|
- orig = "dylib";
|
|
- ext = "jnilib";
|
|
- } else {
|
|
- orig = "jnilib";
|
|
- ext = "dylib";
|
|
- }
|
|
- path = path.substring(0, path.lastIndexOf(orig)) + ext;
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Looking in " + path);
|
|
- }
|
|
- if (new File(path).exists()) {
|
|
- try {
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Trying " + path);
|
|
- }
|
|
- System.setProperty("jnidispatch.path", path);
|
|
- System.load(path);
|
|
- jnidispatchPath = path;
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Found jnidispatch at " + path);
|
|
- }
|
|
- return;
|
|
- } catch (UnsatisfiedLinkError ex) {
|
|
- System.err.println("File found at " + path + " but not loadable: " + ex.getMessage());
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- if (!Boolean.getBoolean("jna.nosys")) {
|
|
+ String[] libdirs = {"/usr/lib64/jna/", "/usr/lib/jna/"};
|
|
+ for (String libdir: libdirs) {
|
|
try {
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Trying (via loadLibrary) " + libName);
|
|
- }
|
|
- System.loadLibrary(libName);
|
|
- if (DEBUG_JNA_LOAD) {
|
|
- System.out.println("Found jnidispatch on system path");
|
|
- }
|
|
- return;
|
|
+ System.load(libdir + System.mapLibraryName("jnidispatch"));
|
|
+ jnidispatchPath = libdir + System.mapLibraryName("jnidispatch");
|
|
+ break;
|
|
}
|
|
catch(UnsatisfiedLinkError e) {
|
|
+ if (libdir.equals(libdirs[libdirs.length - 1])) {
|
|
+ throw new RuntimeException(e);
|
|
+ }
|
|
}
|
|
}
|
|
- if (!Boolean.getBoolean("jna.noclasspath")) {
|
|
- loadNativeDispatchLibraryFromClasspath();
|
|
- }
|
|
- else {
|
|
- throw new UnsatisfiedLinkError("Unable to locate JNA native support library");
|
|
- }
|
|
}
|
|
|
|
static final String JNA_TMPLIB_PREFIX = "jna";
|