diff options
author | Thomas Watson | 2015-08-26 18:51:44 +0000 |
---|---|---|
committer | Thomas Watson | 2015-08-26 18:51:44 +0000 |
commit | e06dc5f8aa8f053673af0aa29c5b517addc9af65 (patch) | |
tree | 10783e276bd4f83cbc4a3582863c5b3bbc470198 /bundles | |
parent | edef6f0e98107e1e21a131a3f22f2c764d31fab8 (diff) | |
download | rt.equinox.framework-e06dc5f8aa8f053673af0aa29c5b517addc9af65.tar.gz rt.equinox.framework-e06dc5f8aa8f053673af0aa29c5b517addc9af65.tar.xz rt.equinox.framework-e06dc5f8aa8f053673af0aa29c5b517addc9af65.zip |
Bug 475760 - Bundles with a header "Bundle-NativeCode = *" lead to an invalid filter being generated "(|)"
Diffstat (limited to 'bundles')
3 files changed, 26 insertions, 3 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 2981cdb99..b420fe27c 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 @@ -1955,6 +1955,16 @@ public class TestModuleContainer extends AbstractTest { Assert.assertEquals("Wrong bundle provider", a.getCurrentRevision(), bundleWires.get(0).getProvider()); } + @Test + public void testBadNativeCode() throws IOException { + try { + OSGiManifestBuilderFactory.createBuilder(getManifest("bad.native.code.MF")); + } catch (BundleException e) { + Assert.assertEquals("Wrong exception type.", BundleException.MANIFEST_ERROR, e.getType()); + } + + } + private static void assertWires(List<ModuleWire> required, List<ModuleWire>... provided) { for (ModuleWire requiredWire : required) { for (List<ModuleWire> providedList : provided) { diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/bad.native.code.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bad.native.code.MF new file mode 100755 index 000000000..951f4d520 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bad.native.code.MF @@ -0,0 +1,5 @@ +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: bad.native.code +Bundle-Version: 1.0.0 +Bundle-NativeCode: * + diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java index 846681b2e..e1f1352de 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java @@ -957,10 +957,16 @@ public final class OSGiManifestBuilderFactory { } Collections.sort(nativeClauses); - Map<String, Object> attributes = new HashMap<String, Object>(2); int numNativePaths = nativeClauses.size(); + if (numNativePaths == 0) { + String msg = "No native code clauses found in the value of " + Constants.BUNDLE_NATIVECODE + ": " + manifest.get(Constants.BUNDLE_NATIVECODE); //$NON-NLS-1$//$NON-NLS-2$ + throw new BundleException(msg, BundleException.MANIFEST_ERROR); + } StringBuilder allNativeFilters = new StringBuilder(); - allNativeFilters.append("(|"); //$NON-NLS-1$ + if (numNativePaths > 1) { + allNativeFilters.append("(|"); //$NON-NLS-1$ + } + Map<String, Object> attributes = new HashMap<String, Object>(2); for (int i = 0; i < numNativePaths; i++) { NativeClause nativeClause = nativeClauses.get(i); if (numNativePaths == 1) { @@ -970,7 +976,9 @@ public final class OSGiManifestBuilderFactory { } allNativeFilters.append(nativeClauses.get(i).filter); } - allNativeFilters.append(')'); + if (numNativePaths > 1) { + allNativeFilters.append(')'); + } Map<String, String> directives = new HashMap<String, String>(2); directives.put(NativeNamespace.REQUIREMENT_FILTER_DIRECTIVE, allNativeFilters.toString()); |