Applied patch (FELIX-650) to properly return symbolic name when it has
parameters; modified the patch slightly to deal with the case when the
bundle has no symbolic name.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@681729 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 4e87c95..54f720b 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1328,7 +1328,21 @@
     **/
     protected String getBundleSymbolicName(FelixBundle bundle)
     {
-        return (String) bundle.getInfo().getCurrentHeader().get(Constants.BUNDLE_SYMBOLICNAME);
+        try
+        {
+            // TODO: FRAMEWORK - Rather than reparsing every time, I wonder if
+            //       we should be caching this value some place.
+            final ICapability moduleCap = ManifestParser.parseBundleSymbolicName(bundle.getInfo().getCurrentHeader());
+            if (moduleCap != null)
+            {
+                return (String) moduleCap.getProperties().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
+            }
+        }
+        catch (BundleException ex)
+        {
+            // Return null.
+        }
+        return null;
     }
 
     /**
@@ -3415,8 +3429,7 @@
             for (int i = 0; (bundles != null) && (i < bundles.length); i++)
             {
                 long id = ((FelixBundle) bundles[i]).getBundleId();
-                String sym = (String) ((FelixBundle) bundles[i])
-                    .getInfo().getCurrentHeader().get(Constants.BUNDLE_SYMBOLICNAME);
+                String sym = bundles[i].getSymbolicName();
                 Version ver = Version.parseVersion((String) ((FelixBundle) bundles[i])
                     .getInfo().getCurrentHeader().get(Constants.BUNDLE_VERSION));
                 if (symName.equals(sym) && bundleVersion.equals(ver) && (targetId != id))
diff --git a/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java b/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
index 67f597f..0681c08 100644
--- a/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
@@ -105,8 +105,7 @@
         List list = new ArrayList();
         for (int i = 0; (bundles != null) && (i < bundles.length); i++)
         {
-            String sym = (String) ((FelixBundle) bundles[i])
-                .getInfo().getCurrentHeader().get(Constants.BUNDLE_SYMBOLICNAME);
+            String sym = bundles[i].getSymbolicName();
             if ((sym != null) && sym.equals(symbolicName))
             {
                 String s = (String) ((FelixBundle) bundles[i])