After the module loader layer was re-engineered, the check to determine 
when to delegate to the parent class loader when a class cannot be found 
was never updated to take into account that other classes could be 
present on the call stack. Karl Pauls uncovered this issue. This is a 
fix for it, but I think a better more general approach is needed.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@497586 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
index e63160d..f1a10c9 100755
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
@@ -23,6 +23,7 @@
 import java.security.ProtectionDomain;
 import java.util.*;
 
+import org.apache.felix.framework.Felix;
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.util.*;
 import org.apache.felix.framework.util.manifestparser.*;
@@ -451,10 +452,15 @@
             // of the R4 search policy classes, nor a class loader or
             // class itself, because we want to ignore the calls to
             // ClassLoader.loadClass() and Class.forName().
-            if (!R4SearchPolicyCore.class.equals(classes[i])
-                && !R4SearchPolicy.class.equals(classes[i])
-                && !ClassLoader.class.isAssignableFrom(classes[i])
-                && !Class.class.isAssignableFrom(classes[i]))
+// TODO: FRAMEWORK - This check is a hack and we should see if we can think
+// of another way to do it, since it won't necessarily work in all situations.
+             if (!R4SearchPolicyCore.class.equals(classes[i])
+                 && !R4SearchPolicy.class.equals(classes[i])
+                 && !IModule.class.isAssignableFrom(classes[i])
+                 && !Felix.class.equals(classes[i])
+                 && !Bundle.class.isAssignableFrom(classes[i])
+                 && !ClassLoader.class.isAssignableFrom(classes[i])
+                 && !Class.class.isAssignableFrom(classes[i]))
             {
                 // If the instigating class was not from a bundle, then
                 // delegate to the parent class loader. Otherwise, break
@@ -1900,4 +1906,4 @@
 
         return sb.toString();
     }
-}
\ No newline at end of file
+}