When calculating the packages available from a required bundle, we must
include all exports even when the required bundle also imports them and
is wired to a different provider. (FELIX-2479)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@966666 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
index f3cf45f..3edea27 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
@@ -1118,7 +1118,7 @@
         {
             return;
         }
-        packages = new Packages();
+        packages = new Packages(module);
 
         List<Capability> caps = module.getCapabilities();
 
@@ -1137,24 +1137,6 @@
                         new Blame(caps.get(i), null));
                 }
             }
-            // Grab all imported packages for which the module imports from itself.
-            for (Requirement req : module.getRequirements())
-            {
-                if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
-                {
-                    Set<Capability> cands = candidateMap.get(req);
-                    if ((cands != null) && (cands.size() > 0))
-                    {
-                        Capability cand = cands.iterator().next();
-                        if (cand.getModule().equals(module))
-                        {
-                            packages.m_exportedPkgs.put(
-                                (String) cand.getAttribute(Capability.PACKAGE_ATTR).getValue(),
-                                new Blame(cand, null));
-                        }
-                    }
-                }
-            }
         }
 
         modulePkgMap.put(module, packages);
@@ -1445,23 +1427,32 @@
 
     private static class Packages
     {
+        private final Module m_module;
         public final Map<String, Blame> m_exportedPkgs = new HashMap();
         public final Map<String, List<Blame>> m_importedPkgs = new HashMap();
         public final Map<String, List<Blame>> m_requiredPkgs = new HashMap();
         public final Map<String, List<Blame>> m_usedPkgs = new HashMap();
 
-        public Packages()
+        public Packages(Module module)
         {
+            m_module = module;
         }
 
         public List<String> getExportedAndReexportedPackages()
         {
             List<String> pkgs = new ArrayList();
-            // Grab all exported packages.
-            for (Entry<String, Blame> entry : m_exportedPkgs.entrySet())
+            // Grab the module's actual exported packages.
+            // Note that we ignore the calculated exported packages here,
+            // because bundles that import their own exports still continue
+            // to provide access to their exports when they are required; i.e.,
+            // the implicitly reexport the packages if wired to another provider.
+            for (Capability cap : m_module.getCapabilities())
             {
-                pkgs.add((String)
-                    entry.getValue().m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                {
+                    pkgs.add((String)
+                        cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                }
             }
             // Grab all required and reexported required packages.
             for (Entry<String, List<Blame>> entry : m_requiredPkgs.entrySet())