4b88e4
diff -up ./src/com/sun/jna/Native.java.loadlib ./src/com/sun/jna/Native.java
4b88e4
--- ./src/com/sun/jna/Native.java.loadlib	2013-04-29 15:23:30.988702267 +0200
4b88e4
+++ ./src/com/sun/jna/Native.java	2013-04-29 15:25:55.409671266 +0200
4b88e4
@@ -670,99 +670,22 @@ public final class Native {
4b88e4
 
4b88e4
     /**
4b88e4
      * Loads the JNA stub library.
4b88e4
-     * First tries jna.boot.library.path, then the system path, then from the
4b88e4
-     * jar file.
4b88e4
+     * MODIFIED FROM UPSTREAM - we rip out all sorts of gunk here that is
4b88e4
+     * unnecessary when JNA is properly installed with the OS.
4b88e4
      */
4b88e4
     private static void loadNativeLibrary() {
4b88e4
         removeTemporaryFiles();
4b88e4
 
4b88e4
-        String libName = System.getProperty("jna.boot.library.name", "jnidispatch");
4b88e4
-        String bootPath = System.getProperty("jna.boot.library.path");
4b88e4
-        if (bootPath != null) {
4b88e4
-            // String.split not available in 1.4
4b88e4
-            StringTokenizer dirs = new StringTokenizer(bootPath, File.pathSeparator);
4b88e4
-            while (dirs.hasMoreTokens()) {
4b88e4
-                String dir = dirs.nextToken();
4b88e4
-                File file = new File(new File(dir), System.mapLibraryName(libName));
4b88e4
-                String path = file.getAbsolutePath();
4b88e4
-                if (file.exists()) {
4b88e4
-                    try {
4b88e4
-                        System.load(path);
4b88e4
-                        nativeLibraryPath = path;
4b88e4
-                        return;
4b88e4
-                    } catch (UnsatisfiedLinkError ex) {
4b88e4
-                        // Not a problem if already loaded in anoteher class loader
4b88e4
-                        // Unfortunately we can't distinguish the difference...
4b88e4
-                        //System.out.println("File found at " + file + " but not loadable: " + ex.getMessage());
4b88e4
-                    }
4b88e4
-                }
4b88e4
-                if (Platform.isMac()) {
4b88e4
-                    String orig, ext;
4b88e4
-                    if (path.endsWith("dylib")) {
4b88e4
-                        orig = "dylib";
4b88e4
-                        ext = "jnilib";
4b88e4
-                    } else {
4b88e4
-                        orig = "jnilib";
4b88e4
-                        ext = "dylib";
4b88e4
-                    }
4b88e4
-                    path = path.substring(0, path.lastIndexOf(orig)) + ext;
4b88e4
-                    if (new File(path).exists()) {
4b88e4
-                        try {
4b88e4
-                            System.load(path);
4b88e4
-                            nativeLibraryPath = path;
4b88e4
-                            return;
4b88e4
-                        } catch (UnsatisfiedLinkError ex) {
4b88e4
-                            System.err.println("File found at " + path + " but not loadable: " + ex.getMessage());
4b88e4
-                        }
4b88e4
-                    }
4b88e4
-                }
4b88e4
-            }
4b88e4
-        }
4b88e4
-        if (Platform.isAndroid()) {
4b88e4
-            // Native libraries on android must be bundled with the APK
4b88e4
-            System.setProperty("jna.nounpack", "true");
4b88e4
-        }
4b88e4
         try {
4b88e4
-            if (!Boolean.getBoolean("jna.nosys")) {
4b88e4
-                System.loadLibrary(libName);
4b88e4
-                return;
4b88e4
-            }
4b88e4
+            System.load("@JNIPATH@/" + System.mapLibraryName("jnidispatch"));
4b88e4
+            nativeLibraryPath = "@JNIPATH@/" + System.mapLibraryName("jnidispatch");
4b88e4
         }
4b88e4
         catch(UnsatisfiedLinkError e) {
4b88e4
-            if (Boolean.getBoolean("jna.nounpack")) {
4b88e4
-                throw e;
4b88e4
-            }
4b88e4
-        }
4b88e4
-        if (!Boolean.getBoolean("jna.nounpack")) {
4b88e4
-            loadNativeLibraryFromJar();
4b88e4
-            return;
4b88e4
+            throw new RuntimeException(e);
4b88e4
         }
4b88e4
-        throw new UnsatisfiedLinkError("Native jnidispatch library not found");
4b88e4
     }
4b88e4
 
4b88e4
     static final String JNA_TMPLIB_PREFIX = "jna";
4b88e4
-    /**
4b88e4
-     * Attempts to load the native library resource from the filesystem,
4b88e4
-     * extracting the JNA stub library from jna.jar if not already available.
4b88e4
-     */
4b88e4
-    private static void loadNativeLibraryFromJar() {
4b88e4
-        try {
4b88e4
-            String prefix = "com/sun/jna/" + getNativeLibraryResourcePrefix();
4b88e4
-            File lib = extractFromResourcePath("jnidispatch", prefix, Native.class.getClassLoader());
4b88e4
-            System.load(lib.getAbsolutePath());
4b88e4
-            nativeLibraryPath = lib.getAbsolutePath();
4b88e4
-            // Attempt to delete immediately once jnidispatch is successfully
4b88e4
-            // loaded.  This avoids the complexity of trying to do so on "exit",
4b88e4
-            // which point can vary under different circumstances (native
4b88e4
-            // compilation, dynamically loaded modules, normal application, etc).
4b88e4
-            if (isUnpacked(lib)) {
4b88e4
-                deleteLibrary(lib);
4b88e4
-            }
4b88e4
-        }
4b88e4
-        catch(IOException e) {
4b88e4
-            throw new UnsatisfiedLinkError(e.getMessage());
4b88e4
-        }
4b88e4
-    }
4b88e4
 
4b88e4
     /** Identify temporary files unpacked from classpath jar files. */
4b88e4
     static boolean isUnpacked(File file) {