jna/0002-Load-system-library.patch

123 lines
5.1 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
---
src/com/sun/jna/Native.java | 97 ++-------------------------------------------
1 file changed, 4 insertions(+), 93 deletions(-)
diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java
2017-09-19 11:42:41 +00:00
index 91b195f..9ac3815 100644
2017-01-16 15:01:47 +00:00
--- a/src/com/sun/jna/Native.java
+++ b/src/com/sun/jna/Native.java
@@ -829,101 +829,12 @@ public final class Native implements Version {
2013-07-06 20:32:00 +00:00
/**
* 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() {
2015-06-11 07:06:03 +00:00
- if (!Boolean.getBoolean("jna.nounpack")) {
- try {
- removeTemporaryFiles();
- }
- catch(IOException e) {
- System.err.println("JNA Warning: IOException removing temporary files: " + e.getMessage());
- }
- }
-
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();
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Looking in " + path);
- }
2013-07-06 20:32:00 +00:00
- if (file.exists()) {
- try {
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Trying " + path);
- }
2013-07-06 20:32:00 +00:00
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Found jnidispatch at " + 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;
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Looking in " + path);
- }
2013-07-06 20:32:00 +00:00
- if (new File(path).exists()) {
- try {
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Trying " + path);
- }
2013-07-06 20:32:00 +00:00
- System.setProperty("jnidispatch.path", path);
- System.load(path);
- jnidispatchPath = path;
- if (DEBUG_JNA_LOAD) {
- System.out.println("Found jnidispatch at " + path);
- }
- return;
- } catch (UnsatisfiedLinkError ex) {
- System.err.println("File found at " + path + " but not loadable: " + ex.getMessage());
- }
- }
- }
- }
- }
- if (!Boolean.getBoolean("jna.nosys")) {
2015-06-11 07:06:03 +00:00
- try {
2015-09-15 13:57:13 +00:00
- if (DEBUG_JNA_LOAD) {
- System.out.println("Trying (via loadLibrary) " + libName);
- }
2013-07-06 20:32:00 +00:00
- System.loadLibrary(libName);
- if (DEBUG_JNA_LOAD) {
- System.out.println("Found jnidispatch on system path");
- }
- 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");
+ 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
--
2018-01-05 14:21:32 +00:00
2.14.3
2017-01-16 15:01:47 +00:00