Verifies that export package metadata does not include bundle symbolic name
or bundle version, since these are implicitly included.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@424379 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Export.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Export.java
index 9378d9a..c40a192 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Export.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Export.java
@@ -18,8 +18,8 @@
import java.util.*;
-import org.apache.felix.framework.util.FelixConstants;
import org.apache.felix.framework.util.Util;
+import org.osgi.framework.Constants;
public class R4Export extends R4Package
{
@@ -40,15 +40,15 @@
String mandatory = "", uses = "";
for (int i = 0; i < m_directives.length; i++)
{
- if (m_directives[i].getName().equals(FelixConstants.USES_DIRECTIVE))
+ if (m_directives[i].getName().equals(Constants.USES_DIRECTIVE))
{
uses = m_directives[i].getValue();
}
- else if (m_directives[i].getName().equals(FelixConstants.MANDATORY_DIRECTIVE))
+ else if (m_directives[i].getName().equals(Constants.MANDATORY_DIRECTIVE))
{
mandatory = m_directives[i].getValue();
}
- else if (m_directives[i].getName().equals(FelixConstants.INCLUDE_DIRECTIVE))
+ else if (m_directives[i].getName().equals(Constants.INCLUDE_DIRECTIVE))
{
String[] ss = Util.parseDelimitedString(m_directives[i].getValue(), ",");
m_includeFilter = new String[ss.length][];
@@ -57,7 +57,7 @@
m_includeFilter[filterIdx] = parseSubstring(ss[filterIdx]);
}
}
- else if (m_directives[i].getName().equals(FelixConstants.EXCLUDE_DIRECTIVE))
+ else if (m_directives[i].getName().equals(Constants.EXCLUDE_DIRECTIVE))
{
String[] ss = Util.parseDelimitedString(m_directives[i].getValue(), ",");
m_excludeFilter = new String[ss.length][];
@@ -104,16 +104,17 @@
}
}
- // Find and parse version attribute, if present.
+ // Convert version, if present.
String rangeStr = "0.0.0";
for (int i = 0; i < m_attrs.length; i++)
{
- if (m_attrs[i].getName().equals(FelixConstants.VERSION_ATTRIBUTE) ||
- m_attrs[i].getName().equals(FelixConstants.PACKAGE_SPECIFICATION_VERSION))
+ // Find and parse version attribute, if present.
+ if (m_attrs[i].getName().equals(Constants.VERSION_ATTRIBUTE) ||
+ m_attrs[i].getName().equals(Constants.PACKAGE_SPECIFICATION_VERSION))
{
// Normalize version attribute name.
m_attrs[i] = new R4Attribute(
- FelixConstants.VERSION_ATTRIBUTE, m_attrs[i].getValue(),
+ Constants.VERSION_ATTRIBUTE, m_attrs[i].getValue(),
m_attrs[i].isMandatory());
rangeStr = m_attrs[i].getValue();
break;
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ManifestParser.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ManifestParser.java
index d064c50..fe6c56b 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ManifestParser.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ManifestParser.java
@@ -305,13 +305,27 @@
}
// Verify that there are no duplicate directives.
- Map map = new HashMap();
for (int i = 0; (m_exports != null) && (i < m_exports.length); i++)
{
String targetVer = get(Constants.BUNDLE_VERSION);
targetVer = (targetVer == null) ? "0.0.0" : targetVer;
+ // First verify that the exports do not specify
+ // bundle symbolic name or bundle version.
R4Attribute[] attrs = m_exports[i].getAttributes();
+ for (int attrIdx = 0; attrIdx < attrs.length; attrIdx++)
+ {
+ // Find and parse version attribute, if present.
+ if (attrs[attrIdx].getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE) ||
+ attrs[attrIdx].getName().equals(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+ {
+ throw new BundleException(
+ "Exports must not specify bundle symbolic name or bundle version.");
+ }
+ }
+
+ // Now that we know that there are no bundle symbolic name and version
+ // attributes, add them since the spec says they are there implicitly.
R4Attribute[] newAttrs = new R4Attribute[attrs.length + 2];
System.arraycopy(attrs, 0, newAttrs, 0, attrs.length);
newAttrs[attrs.length] = new R4Attribute(