The class loader delegation in wires was not correctly working when a module
imported a packaged that was an aggregated (via require-bundle) export from
another bundle. The wire for the package should have been delegating to the
module and instead it was delegating directly to the module content, which
did not account for the wires of the aggregated split package. (FELIX-722)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@695629 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
index e4fdfed..ac1c74e 100755
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
@@ -97,18 +97,24 @@
         if (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
             m_capability.getProperties().get(ICapability.PACKAGE_PROPERTY).equals(pkgName))
         {
-            // Before delegating to the exporting module to satisfy
-            // the class load, we must check the include/exclude filters
-            // from the target package to make sure that the class is
-            // actually visible. However, if the exporting module is the
-            // same as the requesting module, then filtering is not
-            // performed since a module has complete access to itself.
-            if ((m_exporter == m_importer) ||
-                (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
-                    ((Capability) m_capability).isIncluded(name)))
+            // If the importer and the exporter are the same, then
+            // just ask for the class from the exporting module's
+            // content directly.
+            if (m_exporter == m_importer)
             {
                 clazz = m_exporter.getContentLoader().getClass(name);
             }
+            // Otherwise, check the include/exclude filters from the target
+            // package to make sure that the class is actually visible. In
+            // this case since the importing and exporting modules are different,
+            // we delegate to the exporting module, rather than its content,
+            // so that it can follow any internal wires it may have (e.g.,
+            // if the package has multiple sources).
+            else if (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE)
+                && ((Capability) m_capability).isIncluded(name))
+            {
+                clazz = m_exporter.getClass(name);
+            }
 
             // If no class was found, then we must throw an exception
             // since the exporter for this package did not contain the
@@ -137,7 +143,20 @@
         if (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
             m_capability.getProperties().get(ICapability.PACKAGE_PROPERTY).equals(pkgName))
         {
-            url = m_exporter.getContentLoader().getResource(name);
+            // If the importer and the exporter are the same, then
+            // just ask for the resource from the exporting module's
+            // content directly.
+            if (m_exporter == m_importer)
+            {
+                url = m_exporter.getContentLoader().getResource(name);
+            }
+            // Otherwise, delegate to the exporting module, rather than its
+            // content, so that it can follow any internal wires it may have
+            // (e.g., if the package has multiple sources).
+            else
+            {
+                url = m_exporter.getResource(name);
+            }
 
             // If no resource was found, then we must throw an exception
             // since the exporter for this package did not contain the