jna/jna-system-libjnidispatch.patch

92 lines
4.3 KiB
Diff

--- jna-5.4.0/src/com/sun/jna/Native.java 2019-07-19 21:22:03.000000000 +0200
+++ jna-5.4.0/src/com/sun/jna/Native.java 2019-10-10 18:58:56.464572605 +0200
@@ -912,84 +912,12 @@
* 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() {
- if (!Boolean.getBoolean("jna.nounpack")) {
- try {
- removeTemporaryFiles();
- }
- catch(IOException e) {
- LOG.log(Level.WARNING, "JNA Warning: IOException removing temporary files", e);
- }
- }
-
- 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();
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path);
- if (file.exists()) {
- try {
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path);
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", 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;
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path);
- if (new File(path).exists()) {
- try {
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path);
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", path);
- return;
- } catch (UnsatisfiedLinkError ex) {
- LOG.log(Level.WARNING, "File found at " + path + " but not loadable: " + ex.getMessage(), ex);
- }
- }
- }
- }
- }
- String jnaNosys = System.getProperty("jna.nosys", "true");
- if ((!Boolean.parseBoolean(jnaNosys)) || Platform.isAndroid()) {
- try {
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying (via loadLibrary) {0}", libName);
- System.loadLibrary(libName);
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch on system path");
- return;
- }
- catch(UnsatisfiedLinkError e) {
- }
- }
- if (!Boolean.getBoolean("jna.noclasspath")) {
- loadNativeDispatchLibraryFromClasspath();
- }
- else {
- throw new UnsatisfiedLinkError("Unable to locate JNA native support library");
- }
+ jnidispatchPath = "@LIBDIR@/" + System.mapLibraryName("jnidispatch");
+ System.load(jnidispatchPath);
}
static final String JNA_TMPLIB_PREFIX = "jna";