Do not bootdelegate in case Bundle.loadClass() has been used. (FELIX-712)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@698580 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 1c8b60f..c92cec9 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
@@ -54,6 +54,7 @@
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.PackagePermission;
 import org.osgi.framework.Version;
+import org.osgi.framework.Bundle;
 
 public class R4SearchPolicyCore implements ModuleListener
 {
@@ -595,7 +596,13 @@
                         break;
                     }
                 }
-                if (delegate)
+                // If delegate is true then there are no bundles 
+                // providing exports for this package and the instigating 
+                // class was not from a bundle. Therefore, 
+                // delegate to the parent class loader in case
+                // that this is not due to outside code calling a method
+                // on the bundle interface (e.g., Bundle.loadClass()).
+                if (delegate && !Bundle.class.isInstance(classes[i - 1])) 
                 {
                     try
                     {