felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1021894 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
Date Tue, 12 Oct 2010 19:35:53 GMT
Author: rickhall
Date: Tue Oct 12 19:35:53 2010
New Revision: 1021894

URL: http://svn.apache.org/viewvc?rev=1021894&view=rev
Log:
We should about implicit boot delegation as soon as we find a
bundle-loaded class on the call stack. (FELIX-2653)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=1021894&r1=1021893&r2=1021894&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java Tue Oct
12 19:35:53 2010
@@ -1526,16 +1526,22 @@ public class ModuleImpl implements Modul
             {
                 break;
             }
+            // Break if the current class came from a bundle, since we should
+            // not implicitly boot delegate in that case.
+            else if (ModuleClassLoader.class.isInstance(classes[i].getClassLoader()))
+            {
+                break;
+            }
             else if (isClassNotLoadedFromBundle(classes[i]))
             {
-                // If the instigating class was not from a bundle,
-                // then delegate to the parent class loader; otherwise,
-                // break out of loop and return null.
+                // Check if the current class was loaded from a class loader that
+                // came from a bundle and if so then enforce strict OSGi rules
+                // and do not implicitly boot delegate.
                 boolean delegate = true;
                 ClassLoader last = null;
                 for (ClassLoader cl = classes[i].getClassLoader(); 
-                (cl != null) && (last != cl); 
-                cl = cl.getClass().getClassLoader())
+                    (cl != null) && (last != cl);
+                    cl = cl.getClass().getClassLoader())
                 {
                     last = cl;
                     if (ModuleClassLoader.class.isInstance(cl))
@@ -1553,8 +1559,8 @@ public class ModuleImpl implements Modul
                     {
                         // Return the class or resource from the parent class loader.
                         return (isClass)
-                        ? (Object) this.getClass().getClassLoader().loadClass(name)
-                            : (Object) this.getClass().getClassLoader().getResource(name);
+                            ? (Object) this.getClass().getClassLoader().loadClass(name)
+                                : (Object) this.getClass().getClassLoader().getResource(name);
                     }
                     catch (NoClassDefFoundError ex)
                     {



Mime
View raw message