You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/30 18:00:39 UTC

svn commit: r799344 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java

Author: rickhall
Date: Thu Jul 30 16:00:39 2009
New Revision: 799344

URL: http://svn.apache.org/viewvc?rev=799344&view=rev
Log:
Preserve order of import declarations. (FELIX-1432)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=799344&r1=799343&r2=799344&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Thu Jul 30 16:00:39 2009
@@ -61,11 +61,9 @@
                 "Unknown 'Bundle-ManifestVersion' value: " + manifestVersion);
         }
 
-        // Create map to check for duplicate imports/exports
-        // and lists to hold capabilities and requirements.
+        // Create lists to hold capabilities and requirements.
         List capList = new ArrayList();
         List reqList = new ArrayList();
-        Map dupeMap = new HashMap();
 
         //
         // Parse bundle version.
@@ -180,14 +178,13 @@
         IRequirement[] importReqs = parseImportHeader(
             (String) headerMap.get(Constants.IMPORT_PACKAGE));
 
-        // Create non-duplicated import array.
-        dupeMap.clear();
+        // Verify there are no duplicate import declarations.
+        Set dupeSet = new HashSet();
         for (int reqIdx = 0; reqIdx < importReqs.length; reqIdx++)
         {
             // Verify that the named package has not already been declared.
             String pkgName = ((Requirement) importReqs[reqIdx]).getTargetName();
-
-            if (dupeMap.get(pkgName) == null)
+            if (!dupeSet.contains(pkgName))
             {
                 // Verify that java.* packages are not imported.
                 if (pkgName.startsWith("java."))
@@ -195,18 +192,17 @@
                     throw new BundleException(
                         "Importing java.* packages not allowed: " + pkgName);
                 }
-                dupeMap.put(pkgName, importReqs[reqIdx]);
+                dupeSet.add(pkgName);
             }
             else
             {
-                throw new BundleException(
-                    "Duplicate import - " + pkgName);
+                throw new BundleException("Duplicate import - " + pkgName);
             }
+            // If it has not already been imported, then add it to the list
+            // of requirements.
+            reqList.add(importReqs[reqIdx]);
         }
 
-        // Add import package requirements to requirement list.
-        reqList.addAll(dupeMap.values());
-
         // Create an array of all requirements.
         m_requirements = (IRequirement[]) reqList.toArray(new IRequirement[reqList.size()]);