Blame SOURCES/0002-Load-system-library.patch

14a704
From 3d08314de0494ff8bdc1a7bccc0ecc1730dbdd60 Mon Sep 17 00:00:00 2001
14a704
From: Michael Simacek <msimacek@redhat.com>
14a704
Date: Mon, 16 Jan 2017 11:31:32 +0100
14a704
Subject: [PATCH 2/6] Load system library
14a704
14a704
---
14a704
 src/com/sun/jna/Native.java | 97 ++-------------------------------------------
14a704
 1 file changed, 4 insertions(+), 93 deletions(-)
14a704
14a704
diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java
14a704
index 91b195f..9ac3815 100644
14a704
--- a/src/com/sun/jna/Native.java
14a704
+++ b/src/com/sun/jna/Native.java
14a704
@@ -829,101 +829,12 @@ public final class Native implements Version {
14a704
 
14a704
     /**
14a704
      * Loads the JNA stub library.
14a704
-     * First tries jna.boot.library.path, then the system path, then from the
14a704
-     * jar file.
14a704
+     * MODIFIED FROM UPSTREAM - we rip out all sorts of gunk here that is
14a704
+     * unnecessary when JNA is properly installed with the OS.
14a704
      */
14a704
     private static void loadNativeDispatchLibrary() {
14a704
-        if (!Boolean.getBoolean("jna.nounpack")) {
14a704
-            try {
14a704
-                removeTemporaryFiles();
14a704
-            }
14a704
-            catch(IOException e) {
14a704
-                System.err.println("JNA Warning: IOException removing temporary files: " + e.getMessage());
14a704
-            }
14a704
-        }
14a704
-
14a704
-        String libName = System.getProperty("jna.boot.library.name", "jnidispatch");
14a704
-        String bootPath = System.getProperty("jna.boot.library.path");
14a704
-        if (bootPath != null) {
14a704
-            // String.split not available in 1.4
14a704
-            StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
14a704
-            while (dirs.hasMoreTokens()) {
14a704
-                String dir = dirs.nextToken();
14a704
-                File file = new File(new File(dir), System.mapLibraryName(libName).replace(".dylib", ".jnilib"));
14a704
-                String path = file.getAbsolutePath();
14a704
-                if (DEBUG_JNA_LOAD) {
14a704
-                    System.out.println("Looking in " + path);
14a704
-                }
14a704
-                if (file.exists()) {
14a704
-                    try {
14a704
-                        if (DEBUG_JNA_LOAD) {
14a704
-                            System.out.println("Trying " + path);
14a704
-                        }
14a704
-                        System.setProperty("jnidispatch.path", path);
14a704
-                        System.load(path);
14a704
-                        jnidispatchPath = path;
14a704
-                        if (DEBUG_JNA_LOAD) {
14a704
-                            System.out.println("Found jnidispatch at " + path);
14a704
-                        }
14a704
-                        return;
14a704
-                    } catch (UnsatisfiedLinkError ex) {
14a704
-                        // Not a problem if already loaded in anoteher class loader
14a704
-                        // Unfortunately we can't distinguish the difference...
14a704
-                        //System.out.println("File found at " + file + " but not loadable: " + ex.getMessage());
14a704
-                    }
14a704
-                }
14a704
-                if (Platform.isMac()) {
14a704
-                    String orig, ext;
14a704
-                    if (path.endsWith("dylib")) {
14a704
-                        orig = "dylib";
14a704
-                        ext = "jnilib";
14a704
-                    } else {
14a704
-                        orig = "jnilib";
14a704
-                        ext = "dylib";
14a704
-                    }
14a704
-                    path = path.substring(0, path.lastIndexOf(orig)) + ext;
14a704
-                    if (DEBUG_JNA_LOAD) {
14a704
-                        System.out.println("Looking in " + path);
14a704
-                    }
14a704
-                    if (new File(path).exists()) {
14a704
-                        try {
14a704
-                            if (DEBUG_JNA_LOAD) {
14a704
-                                System.out.println("Trying " + path);
14a704
-                            }
14a704
-                            System.setProperty("jnidispatch.path", path);
14a704
-                            System.load(path);
14a704
-                            jnidispatchPath = path;
14a704
-                            if (DEBUG_JNA_LOAD) {
14a704
-                                System.out.println("Found jnidispatch at " + path);
14a704
-                            }
14a704
-                            return;
14a704
-                        } catch (UnsatisfiedLinkError ex) {
14a704
-                            System.err.println("File found at " + path + " but not loadable: " + ex.getMessage());
14a704
-                        }
14a704
-                    }
14a704
-                }
14a704
-            }
14a704
-        }
14a704
-        if (!Boolean.getBoolean("jna.nosys")) {
14a704
-            try {
14a704
-                if (DEBUG_JNA_LOAD) {
14a704
-                    System.out.println("Trying (via loadLibrary) " + libName);
14a704
-                }
14a704
-                System.loadLibrary(libName);
14a704
-                if (DEBUG_JNA_LOAD) {
14a704
-                    System.out.println("Found jnidispatch on system path");
14a704
-                }
14a704
-                return;
14a704
-            }
14a704
-            catch(UnsatisfiedLinkError e) {
14a704
-            }
14a704
-        }
14a704
-        if (!Boolean.getBoolean("jna.noclasspath")) {
14a704
-            loadNativeDispatchLibraryFromClasspath();
14a704
-        }
14a704
-        else {
14a704
-            throw new UnsatisfiedLinkError("Unable to locate JNA native support library");
14a704
-        }
14a704
+        jnidispatchPath = "@LIBDIR@/" + System.mapLibraryName("jnidispatch");
14a704
+        System.load(jnidispatchPath);
14a704
     }
14a704
 
14a704
     static final String JNA_TMPLIB_PREFIX = "jna";
14a704
-- 
14a704
2.14.3
14a704