[jffi-next] 27/49: Fix JRUBY-5482: Using ffi from jruby-maven-plugins fails under 1.6.0.RC2 (works with 1.5.6)

Tim Potter tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

tpot-guest pushed a commit to annotated tag upstream/1.0.10
in repository jffi-next.

commit fa8086365ca5da6d80332923e6a4a4aeedd80642
Author: Charles Oliver Nutter <headius at headius.com>
Date:   Mon Mar 14 22:30:04 2011 -0500

    Fix JRUBY-5482: Using ffi from jruby-maven-plugins fails under 1.6.0.RC2 (works with 1.5.6)
    
    Try both Init's classloader and context classloader for native bits.
---
 src/com/kenai/jffi/Init.java | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/com/kenai/jffi/Init.java b/src/com/kenai/jffi/Init.java
index 5691d6c..b4cc25c 100644
--- a/src/com/kenai/jffi/Init.java
+++ b/src/com/kenai/jffi/Init.java
@@ -172,24 +172,34 @@ final class Init {
      */
     private static final InputStream getStubLibraryStream() {
         String stubPath = getStubLibraryPath();
-        ClassLoader cl = Init.class.getClassLoader();
+        ClassLoader[] cls = new ClassLoader[]{
+            Init.class.getClassLoader(),
+            Thread.currentThread().getContextClassLoader()
+        };
         InputStream is = null;
-        String[] paths = { stubPath, "/" + stubPath };
-        
-        for (String path : paths) {
-            is = cl.getResourceAsStream(path);
-
-            // On MacOS, the stub might be named .dylib or .jnilib - cater for both
-            if (is == null && Platform.getPlatform().getOS() == Platform.OS.DARWIN) {
-                is = cl.getResourceAsStream(path.replaceAll("dylib", "jnilib"));
-            }
-            if (is != null) {
-                break;
+        String[] paths = {stubPath, "/" + stubPath};
+
+        // try both our classloader and context classloader
+        OUTER:
+        for (ClassLoader cl : cls) {
+            // skip null classloader (e.g. boot or null context loader)
+            if (cl == null) continue;
+            
+            for (String path : paths) {
+                is = cl.getResourceAsStream(path);
+
+                // On MacOS, the stub might be named .dylib or .jnilib - cater for both
+                if (is == null && Platform.getPlatform().getOS() == Platform.OS.DARWIN) {
+                    is = cl.getResourceAsStream(path.replaceAll("dylib", "jnilib"));
+                }
+                if (is != null) {
+                    break OUTER;
+                }
             }
         }
         if (is == null) {
             throw new UnsatisfiedLinkError("Could not locate stub library"
-                + " in jar file.  Tried " + Arrays.deepToString(paths));
+                    + " in jar file.  Tried " + Arrays.deepToString(paths));
         }
 
         return is;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git



More information about the pkg-java-commits mailing list