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

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