Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java45
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java46
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java17
3 files changed, 74 insertions, 34 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 e26a78c0d..6741e52be 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
@@ -2665,6 +2665,51 @@ public class TestModuleContainer extends AbstractTest {
}
@Test
+ public void testMultiHostFragmentWithOverlapImport() throws BundleException {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+
+ // install an exporter
+ Map<String, String> exporterManifest = new HashMap<String, String>();
+ exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
+ exporterManifest.put(Constants.BUNDLE_VERSION, "1.0");
+ exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
+ installDummyModule(exporterManifest, "exporter", container);
+
+ // install a fragment to the exporter
+ Map<String, String> exporterFragManifest = new HashMap<String, String>();
+ exporterFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ exporterFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter.frag");
+ exporterFragManifest.put(Constants.EXPORT_PACKAGE, "exporter.frag");
+ exporterFragManifest.put(Constants.FRAGMENT_HOST, "exporter");
+ installDummyModule(exporterFragManifest, "exporter.frag", container);
+
+ // install a host that imports the exporter
+ Map<String, String> hostManifest = new HashMap<String, String>();
+ hostManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ hostManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host");
+ hostManifest.put(Constants.BUNDLE_VERSION, "1.0");
+ hostManifest.put(Constants.IMPORT_PACKAGE, "exporter");
+ installDummyModule(hostManifest, "host10", container);
+ hostManifest.put(Constants.BUNDLE_VERSION, "1.1");
+ installDummyModule(hostManifest, "host11", container);
+ hostManifest.put(Constants.BUNDLE_VERSION, "1.2");
+ installDummyModule(hostManifest, "host12", container);
+
+ // install a fragment that also imports the exporter
+ Map<String, String> hostFragManifest = new HashMap<String, String>();
+ hostFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ hostFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.frag");
+ hostFragManifest.put(Constants.FRAGMENT_HOST, "host");
+ hostFragManifest.put(Constants.IMPORT_PACKAGE, "exporter; version=0.0");
+ Module hostFrag = installDummyModule(hostFragManifest, "host.frag", container);
+
+ ResolutionReport report = container.resolve(Arrays.asList(hostFrag), true);
+ Assert.assertNull("Failed to resolve test.", report.getResolutionException());
+ }
+
+ @Test
public void testModuleWiringToString() throws BundleException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
index 1afed36c3..29b2b7b10 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
@@ -834,6 +834,30 @@ class Candidates
}
// Step 4
+ // First copy candidates for wrapped requirements to the host.
+ for (WrappedResource hostResource : hostResources) {
+ for (Requirement r : hostResource.getRequirements(null))
+ {
+ Requirement origReq = ((WrappedRequirement) r).getDeclaredRequirement();
+ CandidateSelector cands = m_candidateMap.get(origReq);
+ if (cands != null)
+ {
+ if (cands instanceof ShadowList)
+ {
+ m_candidateMap.put(r, ShadowList.deepCopy((ShadowList) cands));
+ } else {
+ m_candidateMap.put(r, cands.copy());
+ }
+ for (Capability cand : cands.getRemainingCandidates())
+ {
+ Set<Requirement> dependents = m_dependentMap.get(cand);
+ dependents.remove(origReq);
+ dependents.add(r);
+ }
+ }
+ }
+ }
+
for (WrappedResource hostResource : hostResources)
{
// Replaces capabilities from fragments with the capabilities
@@ -918,28 +942,6 @@ class Candidates
}
}
}
-
- // Copy candidates for fragment requirements to the host.
- for (Requirement r : hostResource.getRequirements(null))
- {
- Requirement origReq = ((WrappedRequirement) r).getDeclaredRequirement();
- CandidateSelector cands = m_candidateMap.get(origReq);
- if (cands != null)
- {
- if (cands instanceof ShadowList)
- {
- m_candidateMap.put(r, ShadowList.deepCopy((ShadowList) cands));
- } else {
- m_candidateMap.put(r, cands.copy());
- }
- for (Capability cand : cands.getRemainingCandidates())
- {
- Set<Requirement> dependents = m_dependentMap.get(cand);
- dependents.remove(origReq);
- dependents.add(r);
- }
- }
- }
}
// Lastly, verify that all mandatory revisions are still
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java
index f69025fdc..a91ba30ee 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java
@@ -27,36 +27,29 @@ import org.osgi.service.resolver.ResolveContext;
public class ShadowList extends CandidateSelector
{
- public static ShadowList createShadowList(CandidateSelector original) {
+ public static ShadowList createShadowList(CandidateSelector original) {
if (original instanceof ShadowList)
{
throw new IllegalArgumentException("Cannot create a ShadowList using another ShadowList.");
}
- return new ShadowList(original);
+ return new ShadowList(original.unmodifiable, original.unmodifiable, original.isUnmodifiable);
}
public static ShadowList deepCopy(ShadowList original) {
- List<Capability> originalCopy = new ArrayList<Capability>(original.m_original);
- return new ShadowList(original.unmodifiable, originalCopy, original.isUnmodifiable);
+ return new ShadowList(original.unmodifiable, original.m_original, original.isUnmodifiable);
}
private final List<Capability> m_original;
- private ShadowList(CandidateSelector original)
- {
- super(original);
- m_original = new ArrayList<Capability>(original.getRemainingCandidates());
- }
-
private ShadowList(CandidateSelector shadow, List<Capability> original)
{
super(shadow);
m_original = original;
}
- public ShadowList(List<Capability> unmodifiable, List<Capability> originalCopy, AtomicBoolean isUnmodifiable) {
+ private ShadowList(List<Capability> unmodifiable, List<Capability> original, AtomicBoolean isUnmodifiable) {
super(unmodifiable, isUnmodifiable);
- m_original = originalCopy;
+ m_original = new ArrayList<Capability>(original);
}
public ShadowList copy() {

Back to the top