a3b510
From bcf69af8de6512b4ad518af141c3bfd12e58fecc Mon Sep 17 00:00:00 2001
f9fdbd
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
0a2b95
Date: Thu, 25 Jun 2015 10:02:10 +0200
f9fdbd
Subject: [PATCH] Fix JNI
787ee0
MIME-Version: 1.0
787ee0
Content-Type: text/plain; charset=UTF-8
787ee0
Content-Transfer-Encoding: 8bit
f9fdbd
0a2b95
Prefer JNI per Java Fedora packaging guidelines.
787ee0
787ee0
Signed-off-by: Petr Písař <ppisar@redhat.com>
f9fdbd
---
0a2b95
 packages/jpl/jpl.pl                     | 5 +++--
a3b510
 packages/jpl/src/java/org/jpl7/JPL.java | 4 +---
a3b510
 2 files changed, 4 insertions(+), 5 deletions(-)
f9fdbd
f9fdbd
diff --git a/packages/jpl/jpl.pl b/packages/jpl/jpl.pl
a3b510
index 024dd79..ffeccd9 100644
95321f
--- a/packages/jpl/jpl.pl
95321f
+++ b/packages/jpl/jpl.pl
c176a2
@@ -3952,7 +3952,8 @@ prolog:error_message(java_exception(Ex))
c81199
 :- multifile user:file_search_path/2.
c81199
 :- dynamic   user:file_search_path/2.
c81199
 
c81199
-user:file_search_path(jar, swi(lib)).
95321f
+user:file_search_path(jar, 'LIBDIR/swipl-jpl').
95321f
+user:file_search_path(jni, 'LIBDIR/swipl-jpl').
c81199
 
c176a2
 classpath(DirOrJar) :-
c176a2
     getenv('CLASSPATH', ClassPath),
c176a2
@@ -4126,7 +4127,7 @@ add_jpl_to_classpath :-
c81199
 
c81199
 libjpl(File) :-
787ee0
     (   current_prolog_flag(unix, true)
787ee0
-    ->  File = foreign(libjpl)
787ee0
+    ->  File = jni(libjpl)
787ee0
     ;   File = foreign(jpl)
787ee0
     ).
c81199
 
0a2b95
diff --git a/packages/jpl/src/java/org/jpl7/JPL.java b/packages/jpl/src/java/org/jpl7/JPL.java
a3b510
index 9705fa5..8d849dd 100644
0a2b95
--- a/packages/jpl/src/java/org/jpl7/JPL.java
0a2b95
+++ b/packages/jpl/src/java/org/jpl7/JPL.java
c176a2
@@ -109,9 +109,11 @@ public class JPL {
f9fdbd
 		} else if (nativeLibraryDir != null) {
787ee0
 			System.load((new File(nativeLibraryDir, System.mapLibraryName(nativeLibraryName))).getAbsolutePath());
f9fdbd
 		} else {
a3b510
-			System.loadLibrary(nativeLibraryName); // as resolved somewhere on
a3b510
-													// system property
a3b510
-													// 'java.library.path'
c176a2
+			try {
c176a2
+				System.load((new File(LIBDIR, System.mapLibraryName(nativeLibraryName))).getAbsolutePath());
c176a2
+			} catch (UnsatisfiedLinkError e) {
c176a2
+				System.loadLibrary(nativeLibraryName);
c176a2
+			}
f9fdbd
 		}
f9fdbd
 	}
787ee0
 
f9fdbd
-- 
a3b510
2.7.4