Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java21
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java23
2 files changed, 27 insertions, 17 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
index 426607bef..7ef9beaab 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java
@@ -27,18 +27,19 @@ class StateConverter {
}
BundleDescription createDescription(BundleRevision resource) {
-
+ Version version = Version.emptyVersion;
+ String symbolicNameSpecification = null;
Collection<Capability> idList = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
- if (idList.size() != 1)
- throw new IllegalArgumentException("Bogus osgi.identity: " + idList); //$NON-NLS-1$
- Capability id = idList.iterator().next();
-
- Map<String, Object> idAttrs = new HashMap<String, Object>(id.getAttributes());
- String symbolicName = (String) idAttrs.remove(IdentityNamespace.IDENTITY_NAMESPACE);
- Version version = (Version) idAttrs.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
-
- String symbolicNameSpecification = symbolicName + toString(idAttrs, "=", true) + toString(id.getDirectives(), ":=", true); //$NON-NLS-1$ //$NON-NLS-2$
+ if (idList.size() > 1) {
+ throw new IllegalArgumentException("Bogus osgi.identity: " + idList); //$NON-NLS-1$
+ } else if (idList.size() == 1) {
+ Capability id = idList.iterator().next();
+ Map<String, Object> idAttrs = new HashMap<String, Object>(id.getAttributes());
+ String symbolicName = (String) idAttrs.remove(IdentityNamespace.IDENTITY_NAMESPACE);
+ symbolicNameSpecification = symbolicName + toString(idAttrs, "=", true) + toString(id.getDirectives(), ":=", true); //$NON-NLS-1$ //$NON-NLS-2$
+ version = (Version) idAttrs.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
+ }
List<ExportPackageDescription> exportPackages = new ArrayList<ExportPackageDescription>();
List<GenericDescription> provideCapabilities = new ArrayList<GenericDescription>();
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
index a80ae2af2..ea10b4af3 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -80,7 +80,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory {
try {
ManifestElement[] symbolicNameElements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
- if (symbolicNameElements.length > 0) {
+ if (symbolicNameElements != null && symbolicNameElements.length > 0) {
ManifestElement bsnElement = symbolicNameElements[0];
bundle.setSymbolicName(bsnElement.getValue());
bundle.setStateBit(BundleDescriptionImpl.SINGLETON, "true".equals(bsnElement.getDirective(Constants.SINGLETON_DIRECTIVE))); //$NON-NLS-1$
@@ -111,11 +111,20 @@ public class StateObjectFactoryImpl implements StateObjectFactory {
bundle.setPlatformFilter(platformFilter);
bundle.setExecutionEnvironments(executionEnvironments);
bundle.setGenericRequires(genericRequires);
- GenericDescription[] includeIdentity = new GenericDescription[genericCapabilities == null ? 1 : genericCapabilities.length + 1];
- if (genericCapabilities != null)
- System.arraycopy(genericCapabilities, 0, includeIdentity, 1, genericCapabilities.length);
- includeIdentity[0] = StateBuilder.createOsgiIdentityCapability(bundle);
- bundle.setGenericCapabilities(includeIdentity);
+
+ List<GenericDescription> includeIdentity = new ArrayList<GenericDescription>(genericCapabilities == null ? 1 : genericCapabilities.length + 1);
+ GenericDescription genericIdentity = StateBuilder.createOsgiIdentityCapability(bundle);
+ if (genericIdentity != null) {
+ includeIdentity.add(genericIdentity);
+ }
+ if (genericCapabilities != null) {
+ for (GenericDescription genericDescription : genericCapabilities) {
+ includeIdentity.add(genericDescription);
+ }
+ }
+ if (!includeIdentity.isEmpty()) {
+ bundle.setGenericCapabilities(includeIdentity.toArray(new GenericDescription[includeIdentity.size()]));
+ }
bundle.setNativeCodeSpecification(nativeCode);
return bundle;
}

Back to the top