Bug 548137 - Platform.getBundle( Constants.SYSTEM_BUNDLE_SYMBOLICNAME )
returns null
Change-Id: Iec0e0cc9300bb888ebe334c2a3312de7fbc26e51
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 9ad4cf0..63b554e 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -226,6 +226,9 @@
}
public Bundle[] getBundles(String symbolicName, String versionRange) {
+ if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName)) {
+ symbolicName = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getSymbolicName();
+ }
Map<String, String> directives = Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE,
getRequirementFilter(symbolicName, versionRange));
Collection<BundleCapability> matchingBundleCapabilities = fwkWiring.findProviders(ModuleContainer
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java
index 0338b87..6466603 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java
@@ -293,6 +293,16 @@
assertNull("no match => null result", result);
}
+ public void testGetSystemBundle() {
+ Bundle expectedSystem = RuntimeTestsPlugin.getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
+ Bundle actualSystem = Platform.getBundle(Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
+ assertEquals("Wrong system bundle.", expectedSystem, actualSystem);
+
+ Bundle[] actualSystems = Platform.getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null);
+ assertEquals("Wrong number of system bundles.", 1, actualSystems.length);
+ assertEquals("Wrong system bundle.", expectedSystem, actualSystems[0]);
+ }
+
/**
* Helper method to create empty bundles with just name and version given. The
* bundles are packaged to jars and installed into the container. The jars are