Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2020-05-01 18:55:27 +0000
committerThomas Watson2020-05-01 18:55:27 +0000
commit33b6eb6b4a50da63af53291783d86936725873c5 (patch)
treee00762bb334d52deacb4715669ce6dfe569e1f8e
parentdc4da5a38a48ed720e3a8abb940328a045ede84c (diff)
downloadrt.equinox.framework-33b6eb6b4a50da63af53291783d86936725873c5.tar.gz
rt.equinox.framework-33b6eb6b4a50da63af53291783d86936725873c5.tar.xz
rt.equinox.framework-33b6eb6b4a50da63af53291783d86936725873c5.zip
Change-Id: Ife170357e1714723cdcb913aa4ff4af188674cb4 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java53
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java13
2 files changed, 65 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index b6f7cac9a..37da06d9a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -71,6 +71,7 @@ import org.eclipse.osgi.container.ModuleWire;
import org.eclipse.osgi.container.ModuleWiring;
import org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory;
import org.eclipse.osgi.container.namespaces.EclipsePlatformNamespace;
+import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace;
import org.eclipse.osgi.framework.util.ThreadInfoReport;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
@@ -3349,6 +3350,58 @@ public class TestModuleContainer extends AbstractTest {
assertWires(systemFrag3HostWires, hostWires);
}
+ @Test
+ public void testSystemBundleFragmentsWithNonEffectiveCapsReqs() throws BundleException, IOException {
+ // install the system.bundle
+ Module systemBundle = createContainerWithSystemBundle(true);
+ ModuleContainer container = systemBundle.getContainer();
+
+ ModuleWiring systemWiring = systemBundle.getCurrentRevision().getWiring();
+
+ // install an system.bundle fragment with activator
+ Map<String, String> systemFragManifest = new HashMap<>();
+ systemFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ systemFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
+ systemFragManifest.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
+ systemFragManifest.put(Constants.EXTENSION_BUNDLE_ACTIVATOR, "systemFrag.Activator");
+ systemFragManifest.put(Constants.REQUIRE_CAPABILITY,
+ "does.not.exist; effective:=never; filter:=\"(never=true)\"");
+ systemFragManifest.put(Constants.PROVIDE_CAPABILITY,
+ "non.effective.cap; non.effective.cap=test; effective:=never");
+
+ Module systemFrag = installDummyModule(systemFragManifest, "systemFrag", container);
+
+ ResolutionReport report = container.resolve(Arrays.asList(systemFrag), true);
+ Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
+
+ List<ModuleWire> hostWires = systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
+ assertEquals("Wrong number of fragments.", 1, hostWires.size());
+ Assert.assertEquals("Unexpected fragment revision: " + hostWires, systemFrag.getCurrentRevision(),
+ hostWires.get(0).getRequirer());
+
+ List<ModuleCapability> dataCaps = systemWiring
+ .getModuleCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE);
+ assertTrue("Unexpected module data capabilities: " + dataCaps, dataCaps.isEmpty());
+
+ List<ModuleCapability> nonEffectiveCaps = systemBundle.getCurrentRevision().getWiring()
+ .getModuleCapabilities("non.effective.cap");
+ assertTrue("Unexpected non-effective capabilities: " + nonEffectiveCaps, nonEffectiveCaps.isEmpty());
+
+ List<ModuleRequirement> nonEffectiveReqs = systemWiring.getModuleRequirements("does.not.exist");
+ assertTrue("Unexpected non-effective requirements: " + nonEffectiveReqs, nonEffectiveReqs.isEmpty());
+
+ Map<String, String> failResolutionManifest = new HashMap<>();
+ failResolutionManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ failResolutionManifest.put(Constants.BUNDLE_SYMBOLICNAME, "failResolution");
+ failResolutionManifest.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
+ failResolutionManifest.put(Constants.REQUIRE_CAPABILITY,
+ "non.effective.cap; filter:=\"(non.effective.cap=test)\"");
+ Module failResolution = installDummyModule(failResolutionManifest, "failResolution", container);
+ report = container.resolve(Arrays.asList(failResolution), false);
+ String resolutionMsg = report.getResolutionReportMessage(failResolution.getCurrentRevision());
+ assertTrue("Wrong resolution message:" + resolutionMsg, resolutionMsg.contains("non.effective.cap"));
+ }
+
private Module createContainerWithSystemBundle(boolean resolveSystemBundle) throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index a9464d429..778a9cee5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -365,6 +365,10 @@ final class ModuleResolver {
if (NON_PAYLOAD_CAPABILITIES.contains(fragmentCapability.getNamespace())) {
continue; // don't include, not a payload capability
}
+ Object effective = fragmentCapability.getDirectives().get(Namespace.CAPABILITY_EFFECTIVE_DIRECTIVE);
+ if (effective != null && !Namespace.EFFECTIVE_RESOLVE.equals(effective)) {
+ continue; // don't include, not effective
+ }
if (!fragmentCapability.getNamespace().equals(currentNamespace)) {
currentNamespace = fragmentCapability.getNamespace();
fastForward(iCapabilities);
@@ -382,7 +386,11 @@ final class ModuleResolver {
List<ModuleRequirement> fragmentRequriements = hostWire.getRequirer().getModuleRequirements(null);
for (ModuleRequirement fragmentRequirement : fragmentRequriements) {
if (NON_PAYLOAD_REQUIREMENTS.contains(fragmentRequirement.getNamespace())) {
- continue; // don't inlcude, not a payload requirement
+ continue; // don't include, not a payload requirement
+ }
+ Object effective = fragmentRequirement.getDirectives().get(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE);
+ if (effective != null && !Namespace.EFFECTIVE_RESOLVE.equals(effective)) {
+ continue; // don't include, not effective
}
if (!fragmentRequirement.getNamespace().equals(currentNamespace)) {
currentNamespace = fragmentRequirement.getNamespace();
@@ -1303,6 +1311,9 @@ final class ModuleResolver {
}
private boolean failToWire(ModuleRequirement requirement, ModuleRevision requirer, List<Wire> wires) {
+ if (!isEffective(requirement)) {
+ return false;
+ }
List<ModuleCapability> matching = moduleDatabase.findCapabilities(requirement);
List<Wire> newWires = new ArrayList<>(0);
filterProviders(requirement, matching, false);

Back to the top