[jffi-next] 29/49: Rework the Init resource loaded a bit, so loading the boot properties file also tries via the context class loader as well as the Init class class loader

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 eceae69a63197f17ea265365fa57c9f773e5cff1
Author: Wayne Meissner <wmeissner at gmail.com>
Date:   Wed Mar 16 06:43:08 2011 +1000

    Rework the Init resource loaded a bit, so loading the boot properties file also tries via the context class loader as well as the Init class class loader
---
 src/com/kenai/jffi/Init.java | 57 +++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/src/com/kenai/jffi/Init.java b/src/com/kenai/jffi/Init.java
index b4cc25c..fab03b6 100644
--- a/src/com/kenai/jffi/Init.java
+++ b/src/com/kenai/jffi/Init.java
@@ -85,7 +85,7 @@ final class Init {
             return bootPath;
         }
 
-        InputStream is = Init.class.getResourceAsStream(bootPropertyFilename);
+        InputStream is = getResourceAsStream(bootPropertyFilename);
         if (is != null) {
             Properties p = new Properties();
             try {
@@ -172,37 +172,44 @@ final class Init {
      */
     private static final InputStream getStubLibraryStream() {
         String stubPath = getStubLibraryPath();
-        ClassLoader[] cls = new ClassLoader[]{
+        String[] paths = { stubPath, "/" + stubPath };
+
+        for (String path : paths) {
+            InputStream is = 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 = getResourceAsStream(path.replaceAll("dylib", "jnilib"));
+            }
+            if (is != null) {
+                return is;
+            }
+        }
+
+        throw new UnsatisfiedLinkError("could not locate stub library"
+                + " in jar file.  Tried " + Arrays.deepToString(paths));
+    }
+
+    private static final InputStream getResourceAsStream(String resourceName) {
+        // try both our classloader and context classloader
+        ClassLoader[] cls = new ClassLoader[] {
             Init.class.getClassLoader(),
             Thread.currentThread().getContextClassLoader()
         };
-        InputStream is = null;
-        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 (cl == null) { 
+                continue;
             }
-        }
-        if (is == null) {
-            throw new UnsatisfiedLinkError("Could not locate stub library"
-                    + " in jar file.  Tried " + Arrays.deepToString(paths));
-        }
 
-        return is;
+            InputStream is;
+            if ((is = cl.getResourceAsStream(resourceName)) != null) {
+                return is;
+            }
+        }
+        
+        return null;
     }
 
     /**

-- 
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