diff options
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/common/util/JarUtil.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index 84ec59d..f1488f1 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -53,6 +53,26 @@ public class JarUtil { private static final boolean DEBUG = Debug.debug("JarUtil"); /** + * This interface allows users to provide an URL resolver that will convert custom classloader + * URLs like Eclipse/OSGi "bundleresource:" URLs to normal "jar:" URLs. This is needed when + * the classloader has been customized. + */ + public interface Resolver { + URL resolve(URL url); + } + + /** If non-null, we use this to resolve class file URLs after querying them from the classloader. */ + private static Resolver resolver; + + /** + * Setter. + * @param r Resolver to use after querying class file URLs from the classloader. + */ + public static void setResolver(Resolver r) { + resolver = r; + } + + /** * Returns <code>true</code> if the Class's <code>"com.jogamp.common.GlueGenVersion"</code> * is loaded from a JarFile and hence has a Jar URL like * URL <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code>. @@ -92,7 +112,9 @@ public class JarUtil { if(null == clazzBinName || null == cl) { throw new IllegalArgumentException("null arguments: clazzBinName "+clazzBinName+", cl "+cl); } - final URL url = IOUtil.getClassURL(clazzBinName, cl); + URL url = IOUtil.getClassURL(clazzBinName, cl); + if(resolver != null) + url = resolver.resolve(url); // test name .. final String urlS = url.toExternalForm(); if(DEBUG) { |