Re-apply FELIX-843 patch to latest BND code

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@738794 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java b/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
index 69d7db0..6661e6c 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Analyzer.java
@@ -164,7 +164,7 @@
             }
 
             exports = merge("export-package", exportInstructions, contained,
-                    superfluous.keySet());
+                    superfluous.keySet(), null);
 
             for (Iterator<Map.Entry<String, Map<String, String>>> i = superfluous
                     .entrySet().iterator(); i.hasNext();) {
@@ -196,7 +196,7 @@
             // merge the info for matching packages
             Set<String> extra = new TreeSet<String>(importInstructions.keySet());
             imports = merge("import-package", importInstructions,
-                    referredAndExported, extra);
+                    referredAndExported, extra, ignored);
 
             // Instructions that have not been used could be superfluous
             // or if they do not contain wildcards, should be added
@@ -626,13 +626,13 @@
         if (bndInfo == null) {
             bndInfo = new Properties();
             try {
-                InputStream in = getClass().getResourceAsStream("bnd.info");
+                InputStream in = Analyzer.class.getResourceAsStream("bnd.info");
                 if (in != null) {
                     bndInfo.load(in);
                     in.close();
                 }
             } catch (IOException ioe) {
-                warning("Could not read bnd.info in " + getClass().getPackage()
+                warning("Could not read bnd.info in " + Analyzer.class.getPackage()
                         + ioe);
             }
         }
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java b/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
index 393e7ee..7c631ae 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Builder.java
@@ -266,7 +266,7 @@
             // Private-Package
             Map<String, Map<String, String>> filtered = merge(
                     CONDITIONAL_PACKAGE, conditionals, imports,
-                    new HashSet<String>());
+                    new HashSet<String>(), null);
 
             // Imports can also specify a private import. These
             // packages must also be copied to the bundle
diff --git a/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java b/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
index 548495c..29da425 100644
--- a/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
+++ b/bundleplugin/src/main/java/aQute/lib/osgi/Processor.java
@@ -664,8 +664,9 @@
 
     public static Map<String, Map<String, String>> merge(String type,
             Map<String, Map<String, String>> instructions,
-            Map<String, Map<String, String>> actual, Set<String> superfluous) {
-        Map<String, Map<String, String>> ignored = newMap();
+            Map<String, Map<String, String>> actual,
+            Set<String> superfluous,
+            Map<String, Map<String,String>> ignored) {
         Map<String, Map<String, String>> toVisit = new HashMap<String, Map<String, String>>(
                 actual); // we do not want to ruin our
         // original
@@ -706,7 +707,7 @@
                         newAttributes.putAll(actual.get(packageName));
                         newAttributes.putAll(instructedAttributes);
                         result.put(packageName, newAttributes);
-                    } else {
+                    } else if (ignored != null) {
                         ignored.put(packageName, new HashMap<String, String>());
                     }
                     p.remove(); // Can never match again for another pattern