Description: Try to load native library [java.library.path]/libnative-platform.so first
 instead of extractDir or classpath.
 It will load first file matching expected name for paths listed in java.library.path
Author: Damien Raude-Morvan <drazzib@debian.org>
Last-Update: 2014-01-19
Forwarded: no
--- a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java
+++ b/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java
@@ -31,6 +31,17 @@
     }
 
     public File find(String libraryFileName) throws IOException {
+	// Try to load from [java.library.path]/libnative-platform.so first
+	// before extractDir or classpath
+	String[] libPaths = System.getProperty("java.library.path").split(java.io.File.pathSeparator);
+	for (String libPath : libPaths) {
+	  // For each JNI path, try to load lib
+	  File libFile = new File(libPath, libraryFileName);
+	  if (libFile.isFile()) {
+	      return libFile;
+	  }
+	}
+
         if (extractDir != null) {
             File libFile = new File(extractDir, String.format("%s/%s", NativeLibraryFunctions.VERSION, libraryFileName));
             File lockFile = new File(libFile.getParentFile(), libFile.getName() + ".lock");
