jna/0002-Load-system-library.patch

106 lines
4.7 KiB
Diff
Raw Normal View History

2018-01-05 14:21:32 +00:00
From 3d08314de0494ff8bdc1a7bccc0ecc1730dbdd60 Mon Sep 17 00:00:00 2001
2017-01-16 15:01:47 +00:00
From: Michael Simacek <msimacek@redhat.com>
Date: Mon, 16 Jan 2017 11:31:32 +0100
2018-02-22 15:26:06 +00:00
Subject: [PATCH 2/6] Load system library
2017-01-16 15:01:47 +00:00
---
2019-01-17 13:41:31 +00:00
src/com/sun/jna/Native.java | 80 ++-----------------------------------
1 file changed, 4 insertions(+), 76 deletions(-)
2017-01-16 15:01:47 +00:00
diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java
2019-01-17 13:41:31 +00:00
index eae060f..11bcc5b 100644
2017-01-16 15:01:47 +00:00
--- a/src/com/sun/jna/Native.java
+++ b/src/com/sun/jna/Native.java
2019-01-17 13:41:31 +00:00
@@ -912,84 +912,12 @@ public final class Native implements Version {
2013-07-06 20:32:00 +00:00
* Loads the JNA stub library.
2019-01-17 13:41:31 +00:00
* 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.
2013-07-06 20:32:00 +00:00
*/
private static void loadNativeDispatchLibrary() {
2015-06-11 07:06:03 +00:00
- if (!Boolean.getBoolean("jna.nounpack")) {
- try {
- removeTemporaryFiles();
- }
- catch(IOException e) {
2019-01-17 13:41:31 +00:00
- LOG.log(Level.WARNING, "JNA Warning: IOException removing temporary files", e);
2015-06-11 07:06:03 +00:00
- }
- }
-
2013-07-06 20:32:00 +00:00
- 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();
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path);
2013-07-06 20:32:00 +00:00
- if (file.exists()) {
- try {
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path);
2013-07-06 20:32:00 +00:00
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", path);
2013-07-06 20:32:00 +00:00
- 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;
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Looking in {0}", path);
2013-07-06 20:32:00 +00:00
- if (new File(path).exists()) {
- try {
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying {0}", path);
2013-07-06 20:32:00 +00:00
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch at {0}", path);
2013-07-06 20:32:00 +00:00
- return;
- } catch (UnsatisfiedLinkError ex) {
2019-01-17 13:41:31 +00:00
- LOG.log(Level.WARNING, "File found at " + path + " but not loadable: " + ex.getMessage(), ex);
2013-07-06 20:32:00 +00:00
- }
- }
- }
- }
- }
2019-01-17 13:41:31 +00:00
- String jnaNosys = System.getProperty("jna.nosys", "true");
- if ((!Boolean.parseBoolean(jnaNosys)) || Platform.isAndroid()) {
2015-06-11 07:06:03 +00:00
- try {
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Trying (via loadLibrary) {0}", libName);
2013-07-06 20:32:00 +00:00
- System.loadLibrary(libName);
2019-01-17 13:41:31 +00:00
- LOG.log(DEBUG_JNA_LOAD_LEVEL, "Found jnidispatch on system path");
2013-07-06 20:32:00 +00:00
- return;
2015-06-11 07:06:03 +00:00
- }
- catch(UnsatisfiedLinkError e) {
- }
- }
2013-07-06 20:32:00 +00:00
- if (!Boolean.getBoolean("jna.noclasspath")) {
- loadNativeDispatchLibraryFromClasspath();
- }
2013-07-06 20:32:00 +00:00
- else {
- throw new UnsatisfiedLinkError("Unable to locate JNA native support library");
- }
2017-01-16 15:01:47 +00:00
+ jnidispatchPath = "@LIBDIR@/" + System.mapLibraryName("jnidispatch");
2019-01-17 13:41:31 +00:00
+ System.load(jnidispatchPath);
2013-07-06 20:32:00 +00:00
}
static final String JNA_TMPLIB_PREFIX = "jna";
2017-01-16 15:01:47 +00:00
--
2019-01-17 13:41:31 +00:00
2.20.1
2017-01-16 15:01:47 +00:00