Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-08-25 21:57:27 +0000
committerThomas Watson2008-08-25 21:57:27 +0000
commit760312e5842c5fe958a4eafac1d4c51e72535438 (patch)
treee89912d5ad97a5445c95d9702b0144e447a8ce3e
parentc91c1e2b24e40f28ed163c1c298fbc2b6972a63a (diff)
downloadrt.equinox.framework-760312e5842c5fe958a4eafac1d4c51e72535438.tar.gz
rt.equinox.framework-760312e5842c5fe958a4eafac1d4c51e72535438.tar.xz
rt.equinox.framework-760312e5842c5fe958a4eafac1d4c51e72535438.zip
Bug 244624 Implement new BundleException typesv20080825-1800
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath4
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties14
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/activator/error1/Activator.java22
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/activator/error2/Activator.java17
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/activator/error3/Activator.java16
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/activator.error4/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/nativetest.c/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleExceptionTests.java97
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java1
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java4
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/NativeCodeBundleTests.java16
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/internal/plugins/InstallTests.java262
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle11/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle12/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle13/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle14/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle15/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle16/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle17/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle18/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/Headers.java7
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java23
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java8
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java2
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Constants.java1
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java2
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java6
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java2
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/loader/ClasspathManager.java2
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/AdaptorUtil.java2
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java74
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java4
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/SystemBundleData.java7
-rw-r--r--bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java3
-rw-r--r--bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseStorageHook.java2
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java43
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMessages.properties1
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMsg.java1
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java20
44 files changed, 552 insertions, 186 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index 89de756d5..7cad8f6ef 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -74,6 +74,10 @@
<classpathentry kind="src" output="bundle_tests/substitutes.n" path="bundles_src/substitutes.n"/>
<classpathentry kind="src" output="bundle_tests/substitutes.p" path="bundles_src/substitutes.p"/>
<classpathentry kind="src" output="bundle_tests/substitutes.q" path="bundles_src/substitutes.q"/>
+ <classpathentry kind="src" output="bundle_tests/activator.error1" path="bundles_src/activator.error1"/>
+ <classpathentry kind="src" output="bundle_tests/activator.error2" path="bundles_src/activator.error2"/>
+ <classpathentry kind="src" output="bundle_tests/activator.error3" path="bundles_src/activator.error3"/>
+ <classpathentry kind="src" output="bundle_tests/activator.error4" path="bundles_src/activator.error4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index 8932b984d..50b5413fd 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -163,6 +163,14 @@ source.bundle_tests/substitutes.p.jar = bundles_src/substitutes.p/
manifest.bundle_tests/substitutes.p.jar = META-INF/MANIFEST.MF
source.bundle_tests/substitutes.q.jar = bundles_src/substitutes.q/
manifest.bundle_tests/substitutes.q.jar = META-INF/MANIFEST.MF
+source.bundle_tests/activator.error1.jar = bundles_src/activator.error1/
+manifest.bundle_tests/activator.error1.jar = META-INF/MANIFEST.MF
+source.bundle_tests/activator.error2.jar = bundles_src/activator.error2/
+manifest.bundle_tests/activator.error2.jar = META-INF/MANIFEST.MF
+source.bundle_tests/activator.error3.jar = bundles_src/activator.error3/
+manifest.bundle_tests/activator.error3.jar = META-INF/MANIFEST.MF
+source.bundle_tests/activator.error4.jar = bundles_src/activator.error4/
+manifest.bundle_tests/activator.error4.jar = META-INF/MANIFEST.MF
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -237,4 +245,8 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/substitutes.m.jar,\
bundle_tests/substitutes.n.jar,\
bundle_tests/substitutes.p.jar,\
- bundle_tests/substitutes.q.jar
+ bundle_tests/substitutes.q.jar,\
+ bundle_tests/activator.error1,\
+ bundle_tests/activator.error2,\
+ bundle_tests/activator.error3,\
+ bundle_tests/activator.error4
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..01f39f234
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: activator.error1
+Bundle-SymbolicName: activator.error1
+Bundle-Version: 1.0.0
+Bundle-Activator: activator.error1.Activator
+Import-Package: org.osgi.framework
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/activator/error1/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/activator/error1/Activator.java
new file mode 100644
index 000000000..3ccacc223
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error1/activator/error1/Activator.java
@@ -0,0 +1,22 @@
+package activator.error1;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public Activator() {
+ throw new RuntimeException();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..a21e36e63
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: activator.error2
+Bundle-SymbolicName: activator.error2
+Bundle-Version: 1.0.0
+Bundle-Activator: activator.error2.Activator
+Import-Package: org.osgi.framework
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/activator/error2/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/activator/error2/Activator.java
new file mode 100644
index 000000000..68e5a6c9c
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error2/activator/error2/Activator.java
@@ -0,0 +1,17 @@
+package activator.error2;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ throw new RuntimeException();
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..8bb432505
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: activator.error3
+Bundle-SymbolicName: activator.error3
+Bundle-Version: 1.0.0
+Bundle-Activator: activator.error3.Activator
+Import-Package: org.osgi.framework
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/activator/error3/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/activator/error3/Activator.java
new file mode 100644
index 000000000..95ad1a0a4
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error3/activator/error3/Activator.java
@@ -0,0 +1,16 @@
+package activator.error3;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ // nothing
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ throw new RuntimeException();
+ }
+
+}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.error4/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error4/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..dcaf6a471
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.error4/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: activator.error1
+Bundle-SymbolicName: activator.error1
+Bundle-Version: 1.0.0
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.c/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.c/META-INF/MANIFEST.MF
index 957bf30c0..22b492c41 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.c/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/nativetest.c/META-INF/MANIFEST.MF
@@ -30,4 +30,6 @@ Bundle-NativeCode:
libs/test3/nativecode.txt;
osversion="0.0.1";
language="en";
- selection-filter="(nativecodetest=3)"
+ selection-filter="(nativecodetest=3)",
+ libs/test4/nativecode.txt;
+ selection-filter="(nativecodetest=4)"
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleExceptionTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleExceptionTests.java
new file mode 100644
index 000000000..813ee7131
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleExceptionTests.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.bundles;
+
+import java.io.IOException;
+import java.net.URL;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+public class BundleExceptionTests extends AbstractBundleTests {
+ public static Test suite() {
+ return new TestSuite(BundleExceptionTests.class);
+ }
+
+ // test throwing exception from activator constructor
+ public void testInvalidBundleActivator01() throws BundleException {
+ Bundle error1 = installer.installBundle("activator.error1"); //$NON-NLS-1$
+ try {
+ error1.start();
+ fail("Expected a start failure on invalid activator"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected activator error", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$
+ }
+ }
+
+ // test throwing exception from activator start
+ public void testInvalidBundleActivator02() throws BundleException {
+ Bundle error1 = installer.installBundle("activator.error2"); //$NON-NLS-1$
+ try {
+ error1.start();
+ fail("Expected a start failure on invalid activator"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected activator error", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$
+ }
+ }
+
+ // test throwing exception from activator stop
+ public void testInvalidBundleActivator03() throws BundleException {
+ Bundle error1 = installer.installBundle("activator.error3"); //$NON-NLS-1$
+ error1.start();
+ try {
+ error1.stop();
+ fail("Expected a stop failure on invalid activator"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected activator error", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$
+ }
+ }
+
+ // test throwing exception when installing duplicate bundles
+ public void testDuplicateError01() throws BundleException {
+ installer.installBundle("activator.error1"); //$NON-NLS-1$
+ try {
+ installer.installBundle("activator.error4"); //$NON-NLS-1$;
+ fail("Expected an install failure on duplicate bundle"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected duplicate error", BundleException.DUPLICATE_BUNDLE_ERROR, e.getType()); //$NON-NLS-1$
+ }
+ }
+
+ // test throwing exception when updating to a duplicate bundle
+ public void testDuplicateError02() throws BundleException {
+ installer.installBundle("activator.error1"); //$NON-NLS-1$
+ Bundle error2 = installer.installBundle("activator.error2"); //$NON-NLS-1$
+ try {
+ URL updateURL = new URL(installer.getBundleLocation("activator.error4")); //$NON-NLS-1$
+ error2.update(updateURL.openStream());
+ fail("Expected an update failure on duplicate bundle"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected duplicate error", BundleException.DUPLICATE_BUNDLE_ERROR, e.getType()); //$NON-NLS-1$
+ } catch (IOException e) {
+ fail("Unexpected io exception updating", e); //$NON-NLS-1$
+ }
+ }
+
+ // test uninstalling the system bundle
+ public void testUninstallSystemBundle() throws BundleException {
+ Bundle systemBundle = OSGiTestsActivator.getContext().getBundle(0);
+ assertNotNull("System Bundle is null!!", systemBundle); //$NON-NLS-1$
+ try {
+ systemBundle.uninstall();
+ fail("Expected error on uninstall of system bundle"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Expected invalid error", BundleException.INVALID_OPERATION, e.getType()); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
index 8f4e75d11..24d7b9cdf 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
@@ -18,6 +18,7 @@ public class BundleTests {
TestSuite suite = new TestSuite(BundleTests.class.getName());
suite.addTest(SystemBundleTests.suite());
suite.addTest(ServiceRegistryBundleTests.suite());
+ suite.addTest(BundleExceptionTests.suite());
suite.addTest(SubstituteExportsBundleTests.suite());
suite.addTest(PackageAdminBundleTests.suite());
suite.addTest(PlatformAdminBundleTests.suite());
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index d327d4372..6e8f0a9df 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 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
@@ -356,7 +356,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
osgiA.start(Bundle.START_TRANSIENT);
assertFalse("Bundle is started!!", osgiA.getState() == Bundle.ACTIVE); //$NON-NLS-1$
} catch (BundleException e) {
- // expected
+ assertEquals("Expected invalid operation", BundleException.INVALID_OPERATION, e.getType()); //$NON-NLS-1$
}
expectedEvents = new Object[0];
actualEvents = simpleResults.getResults(0);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/NativeCodeBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/NativeCodeBundleTests.java
index d829ac151..863efa891 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/NativeCodeBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/NativeCodeBundleTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 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
@@ -14,6 +14,7 @@ import java.io.*;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
public class NativeCodeBundleTests extends AbstractBundleTests {
public static Test suite() {
@@ -108,6 +109,19 @@ public class NativeCodeBundleTests extends AbstractBundleTests {
assertNull("1.1", results[0]);
}
+ public void testNativeCode08() throws Exception {
+ System.setProperty("nativecodetest", "4");
+ setPlatformProperties();
+ Bundle nativetestC = installer.installBundle("nativetest.c");
+ try {
+ nativetestC.start();
+ fail("Should not be able to start bundle with missing native code path");
+ } catch (BundleException e) {
+ // expected
+ assertEquals("Wrong exception type", BundleException.NATIVECODE_ERROR, e.getType());
+ }
+ }
+
private String getContent(String file) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/internal/plugins/InstallTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/internal/plugins/InstallTests.java
index 9fcf5d4d4..edce4b39c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/internal/plugins/InstallTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/internal/plugins/InstallTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -11,8 +11,8 @@
package org.eclipse.osgi.tests.internal.plugins;
import java.io.IOException;
-import junit.framework.TestCase;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.eclipse.core.tests.harness.CoreTest;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.*;
@@ -21,7 +21,7 @@ import org.osgi.service.packageadmin.PackageAdmin;
/**
* Provisory home for tests that install plugins.
*/
-public class InstallTests extends TestCase {
+public class InstallTests extends CoreTest {
public InstallTests() {
super();
@@ -35,12 +35,12 @@ public class InstallTests extends TestCase {
super.setUp();
}
- public void testInstallInvalidManifest() throws BundleException, IOException {
+ public void testInstallInvalidManifest01() throws BundleException, IOException {
Bundle installed = null;
try {
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle03");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle03"); //$NON-NLS-1$
// should have failed with BundleException
- fail("1.0");
+ fail("1.0"); //$NON-NLS-1$
} catch (BundleException be) {
// success - the manifest was invalid
} finally {
@@ -50,12 +50,174 @@ public class InstallTests extends TestCase {
}
}
+ /**
+ * Test invalid manifest; missing Bundle-SymbolicName
+ */
+ public void testInstallInvalidManifest02() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ installed = BundleTestingHelper.installBundle("testInstallInvalidManifest02", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle11"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should have failed with BundleException
+ fail("Expected a failure with no Bundle-SymbolicName header"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the manifest was invalid
+ assertEquals("Expected manifest error", BundleException.MANIFEST_ERROR, be.getType()); //$NON-NLS-1$
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
+ /**
+ * Test invalid manifest; duplicate directive
+ */
+ public void testInstallInvalidManifest03() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ installed = BundleTestingHelper.installBundle("testInstallInvalidManifest03", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle12"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should have failed with BundleException
+ fail("Expected a failure with duplicate directives"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the manifest was invalid
+ assertEquals("Expected manifest error", BundleException.MANIFEST_ERROR, be.getType()); //$NON-NLS-1$
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
+ /**
+ * Test invalid manifest; use attributes bundle-version and bundle-symbolic-name in Export-Package
+ */
+ public void testInstallInvalidManifest04() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ installed = BundleTestingHelper.installBundle("testInstallInvalidManifest04", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle13"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should have failed with BundleException
+ fail("Expected a failure with duplicate attributes"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the manifest was invalid
+ assertEquals("Expected manifest error", BundleException.MANIFEST_ERROR, be.getType()); //$NON-NLS-1$
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
+ /**
+ * Test invalid manifest; imports same package twice
+ */
+ public void testInstallInvalidManifest05() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ installed = BundleTestingHelper.installBundle("testInstallInvalidManifest05", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle14"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should have failed with BundleException
+ fail("Expected a failure with duplicate imports"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the manifest was invalid
+ assertEquals("Expected manifest error", BundleException.MANIFEST_ERROR, be.getType()); //$NON-NLS-1$
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
+ /**
+ * Test unresolvable
+ */
+ public void testStartError01() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ try {
+ installed = BundleTestingHelper.installBundle("testStartError01", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle15"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should be able to install
+ } catch (BundleException be) {
+ // failed to install unresolvable bundle
+ fail("Unexpected installation error", be); //$NON-NLS-1$
+ }
+ try {
+ installed.start();
+ // expected exception starting
+ fail("Expected a failure to start unresolved bundle"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the bundle can not resolve
+ assertEquals("Expected manifest error", BundleException.RESOLVE_ERROR, be.getType()); //$NON-NLS-1$
+ }
+
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
+ /**
+ * Test start fragment
+ */
+ public void testStartError02() throws IOException, BundleException {
+ Bundle host = null;
+ Bundle fragment = null;
+ try {
+ try {
+ host = BundleTestingHelper.installBundle("testStartError02_host", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle16"); //$NON-NLS-1$ //$NON-NLS-2$
+ fragment = BundleTestingHelper.installBundle("testStartError02_frag", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle17"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should be able to install host
+ } catch (BundleException be) {
+ // failed to install unresolvable bundle
+ fail("Unexpected installation error", be); //$NON-NLS-1$
+ }
+ try {
+ host.start();
+ } catch (BundleException be) {
+ fail("Unexpected start host error", be); //$NON-NLS-1$
+ }
+ try {
+ fragment.start();
+ // expected exception starting
+ fail("Expected a failure to start fragment bundle"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the bundle can not resolve
+ assertEquals("Expected manifest error", BundleException.INVALID_OPERATION, be.getType()); //$NON-NLS-1$
+ }
+
+ } finally {
+ if (host != null)
+ host.uninstall();
+ if (fragment != null)
+ fragment.uninstall();
+
+ }
+ }
+
+ /**
+ * Test unsupported operation with boot classpath extension
+ */
+ public void testUnsupportedOperation01() throws IOException, BundleException {
+ Bundle installed = null;
+ try {
+ installed = BundleTestingHelper.installBundle("testUnsupportedOperation01", OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle18"); //$NON-NLS-1$ //$NON-NLS-2$
+ // should have failed with BundleException
+ fail("Expected an unsupported operation exception"); //$NON-NLS-1$
+ } catch (BundleException be) {
+ // success - the manifest was invalid
+ assertEquals("Expected unsupported error", BundleException.UNSUPPORTED_OPERATION, be.getType()); //$NON-NLS-1$
+ } finally {
+ if (installed != null)
+ // clean-up - only runs if we end-up accepting an invalid manifest
+ installed.uninstall();
+ }
+ }
+
public void testInstallLocationWithSpaces() throws BundleException, IOException {
Bundle installed = null;
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle 01");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle 01"); //$NON-NLS-1$
try {
- assertEquals("1.0", "bundle01", installed.getSymbolicName());
- assertEquals("1.1", Bundle.INSTALLED, installed.getState());
+ assertEquals("1.0", "bundle01", installed.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.INSTALLED, installed.getState()); //$NON-NLS-1$
} finally {
// clean-up
installed.uninstall();
@@ -64,11 +226,11 @@ public class InstallTests extends TestCase {
public void testInstallLocationWithUnderscores() throws BundleException, IOException {
Bundle installed = null;
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle02_1.0.0");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle02_1.0.0"); //$NON-NLS-1$
try {
- assertEquals("1.0", "bundle02", installed.getSymbolicName());
- assertEquals("1.1", Bundle.INSTALLED, installed.getState());
- assertEquals("1.2", new Version("2.0"), new Version((String) installed.getHeaders().get(Constants.BUNDLE_VERSION)));
+ assertEquals("1.0", "bundle02", installed.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.INSTALLED, installed.getState()); //$NON-NLS-1$
+ assertEquals("1.2", new Version("2.0"), new Version((String) installed.getHeaders().get(Constants.BUNDLE_VERSION))); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
// clean-up
installed.uninstall();
@@ -78,16 +240,16 @@ public class InstallTests extends TestCase {
/** Ensures we see a bundle with only a extension point as a singleton */
public void testInstallBundleWithExtensionPointOnly() throws BundleException, IOException {
Bundle installed = null;
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle04");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle04"); //$NON-NLS-1$
try {
- assertEquals("1.0", "bundle04", installed.getSymbolicName());
- assertEquals("1.1", Bundle.INSTALLED, installed.getState());
- assertEquals("1.2", "1.3.7", installed.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.0", "bundle04", installed.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.INSTALLED, installed.getState()); //$NON-NLS-1$
+ assertEquals("1.2", "1.3.7", installed.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
String symbolicNameString = (String) installed.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
- assertNotNull("1.3", symbolicNameString);
+ assertNotNull("1.3", symbolicNameString); //$NON-NLS-1$
ManifestElement[] symbolicNameHeader = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicNameString);
- assertEquals("1.4", 1, symbolicNameHeader.length);
- assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE));
+ assertEquals("1.4", 1, symbolicNameHeader.length); //$NON-NLS-1$
+ assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE)); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
// clean-up
@@ -98,16 +260,16 @@ public class InstallTests extends TestCase {
/** Ensures we see a bundle with only a extension as a singleton */
public void testInstallBundleWithExtensionOnly() throws BundleException, IOException {
Bundle installed = null;
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle05");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle05"); //$NON-NLS-1$
try {
- assertEquals("1.0", "bundle05", installed.getSymbolicName());
- assertEquals("1.1", Bundle.INSTALLED, installed.getState());
- assertEquals("1.2", "1.3.8", installed.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.0", "bundle05", installed.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.INSTALLED, installed.getState()); //$NON-NLS-1$
+ assertEquals("1.2", "1.3.8", installed.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
String symbolicNameString = (String) installed.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
- assertNotNull("1.3", symbolicNameString);
+ assertNotNull("1.3", symbolicNameString); //$NON-NLS-1$
ManifestElement[] symbolicNameHeader = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicNameString);
- assertEquals("1.4", 1, symbolicNameHeader.length);
- assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE));
+ assertEquals("1.4", 1, symbolicNameHeader.length); //$NON-NLS-1$
+ assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE)); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
// clean-up
@@ -118,16 +280,16 @@ public class InstallTests extends TestCase {
/** Ensures we see a bundle with only extension and extension point as a singleton */
public void testInstallBundleWithExtensionAndExtensionPoint() throws BundleException, IOException {
Bundle installed = null;
- installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle06");
+ installed = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle06"); //$NON-NLS-1$
try {
- assertEquals("1.0", "bundle06", installed.getSymbolicName());
- assertEquals("1.1", Bundle.INSTALLED, installed.getState());
- assertEquals("1.2", "1.3.9", installed.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.0", "bundle06", installed.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.INSTALLED, installed.getState()); //$NON-NLS-1$
+ assertEquals("1.2", "1.3.9", installed.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
String symbolicNameString = (String) installed.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
- assertNotNull("1.3", symbolicNameString);
+ assertNotNull("1.3", symbolicNameString); //$NON-NLS-1$
ManifestElement[] symbolicNameHeader = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicNameString);
- assertEquals("1.4", 1, symbolicNameHeader.length);
- assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE));
+ assertEquals("1.4", 1, symbolicNameHeader.length); //$NON-NLS-1$
+ assertEquals("1.5", "true", symbolicNameHeader[0].getDirective(Constants.SINGLETON_DIRECTIVE)); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
// clean-up
@@ -137,21 +299,21 @@ public class InstallTests extends TestCase {
/** Ensures two versions of a non-singleton bundle are accepted */
public void testInstall2NonSingletonBundles() throws BundleException, IOException {
- Bundle installed1 = org.eclipse.core.tests.harness.BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle07");
+ Bundle installed1 = org.eclipse.core.tests.harness.BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle07"); //$NON-NLS-1$
ServiceReference packageAdminSR = OSGiTestsActivator.getContext().getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin) OSGiTestsActivator.getContext().getService(packageAdminSR);
packageAdmin.resolveBundles(null);
- Bundle installed2 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle07b");
+ Bundle installed2 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle07b"); //$NON-NLS-1$
packageAdmin.resolveBundles(null);
OSGiTestsActivator.getContext().ungetService(packageAdminSR);
try {
- assertEquals("1.0", "bundle07", installed2.getSymbolicName());
- assertEquals("1.1", Bundle.RESOLVED, installed2.getState());
- assertEquals("1.2", "1.0.0.b", installed2.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.0", "bundle07", installed2.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.RESOLVED, installed2.getState()); //$NON-NLS-1$
+ assertEquals("1.2", "1.0.0.b", installed2.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("1.3", "bundle07", installed1.getSymbolicName());
- assertEquals("1.4", Bundle.RESOLVED, installed1.getState());
- assertEquals("1.5", "1.0.0", installed1.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.3", "bundle07", installed1.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.4", Bundle.RESOLVED, installed1.getState()); //$NON-NLS-1$
+ assertEquals("1.5", "1.0.0", installed1.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
installed1.uninstall();
installed2.uninstall();
@@ -160,21 +322,21 @@ public class InstallTests extends TestCase {
/** Ensures two versions of a singleton bundle are accepted */
public void testInstall2SingletonBundles() throws BundleException, IOException {
- Bundle installed1 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08");
+ Bundle installed1 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08"); //$NON-NLS-1$
ServiceReference packageAdminSR = OSGiTestsActivator.getContext().getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin) OSGiTestsActivator.getContext().getService(packageAdminSR);
packageAdmin.resolveBundles(null);
- Bundle installed2 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08b");
+ Bundle installed2 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08b"); //$NON-NLS-1$
packageAdmin.resolveBundles(null);
OSGiTestsActivator.getContext().ungetService(packageAdminSR);
try {
- assertEquals("1.0", "bundle08", installed1.getSymbolicName());
- assertEquals("1.1", Bundle.RESOLVED, installed1.getState());
- assertEquals("1.2", "1.0.0", installed1.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.0", "bundle08", installed1.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.1", Bundle.RESOLVED, installed1.getState()); //$NON-NLS-1$
+ assertEquals("1.2", "1.0.0", installed1.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("1.3", "bundle08", installed2.getSymbolicName());
- assertEquals("1.4", Bundle.INSTALLED, installed2.getState());
- assertEquals("1.5", "1.0.0.b", installed2.getHeaders().get(Constants.BUNDLE_VERSION));
+ assertEquals("1.3", "bundle08", installed2.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("1.4", Bundle.INSTALLED, installed2.getState()); //$NON-NLS-1$
+ assertEquals("1.5", "1.0.0.b", installed2.getHeaders().get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
installed1.uninstall();
installed2.uninstall();
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle11/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle11/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..f4ce85aca
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle11/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle11
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle12/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle12/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..b96f5cdba
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle12/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle12
+Bundle-SymbolicName: bundle12
+Export-package: a; test:=value2; test:=value1
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle13/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle13/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..f9dcb87d0
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle13/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle13
+Bundle-SymbolicName: bundle13
+Export-package: a; test=value2; test=value1
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle14/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle14/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..0ee19b189
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle14/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle14
+Bundle-SymbolicName: bundle14
+Import-package: a; attr=value1, a; attr=value2
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle15/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle15/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..abf1275ea
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle15/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle15
+Bundle-SymbolicName: bundle15
+Import-package: willnotresolve
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle16/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle16/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..e90f72d02
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle16/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle16
+Bundle-SymbolicName: bundle16
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle17/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle17/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..fe607de83
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle17/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle17
+Bundle-SymbolicName: bundle17
+Fragment-Host: bundle16
diff --git a/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle18/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle18/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..d1a44a0f1
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/internal/plugins/installTests/bundle18/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: bundle18
+Bundle-SymbolicName: bundle18
+Fragment-Host: system.bundle; extension:=bootclasspath
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/Headers.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/Headers.java
index 364d1d407..053c6fc40 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/Headers.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/Headers.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2008 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
@@ -11,7 +11,8 @@
package org.eclipse.osgi.framework.util;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.*;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.util.ManifestElement;
@@ -244,7 +245,7 @@ public class Headers extends Dictionary implements Map {
try {
ManifestElement.parseBundleManifest(in, headers);
} catch (IOException e) {
- throw new BundleException(Msg.MANIFEST_IOEXCEPTION, e);
+ throw new BundleException(Msg.MANIFEST_IOEXCEPTION, BundleException.MANIFEST_ERROR, e);
}
headers.setReadOnly();
return headers;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
index 99d99b680..c759b0cbf 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java
@@ -145,7 +145,7 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
Debug.printStackTrace(t);
}
- throw new BundleException(NLS.bind(Msg.BUNDLE_INVALID_ACTIVATOR_EXCEPTION, activatorClassName, bundledata.getSymbolicName()), t);
+ throw new BundleException(NLS.bind(Msg.BUNDLE_INVALID_ACTIVATOR_EXCEPTION, activatorClassName, bundledata.getSymbolicName()), BundleException.ACTIVATOR_ERROR, t);
}
}
return (null);
@@ -733,7 +733,7 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
final boolean extension = (bundledata.getType() & (BundleData.TYPE_BOOTCLASSPATH_EXTENSION | BundleData.TYPE_FRAMEWORK_EXTENSION | BundleData.TYPE_EXTCLASSPATH_EXTENSION)) != 0;
// must check for AllPermission before allow a bundle extension to be updated
if (extension && !hasPermission(new AllPermission()))
- throw new BundleException(Msg.BUNDLE_EXTENSION_PERMISSION, new SecurityException(Msg.BUNDLE_EXTENSION_PERMISSION));
+ throw new BundleException(Msg.BUNDLE_EXTENSION_PERMISSION, BundleException.SECURITY_ERROR, new SecurityException(Msg.BUNDLE_EXTENSION_PERMISSION));
try {
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
@@ -1143,7 +1143,7 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
return;
}
if (doubleFault || (stateChanging == Thread.currentThread())) {
- throw new BundleException(NLS.bind(Msg.BUNDLE_STATE_CHANGE_EXCEPTION, getBundleData().getLocation(), stateChanging.getName()), new BundleStatusException(null, StatusException.CODE_WARNING, stateChanging));
+ throw new BundleException(NLS.bind(Msg.BUNDLE_STATE_CHANGE_EXCEPTION, getBundleData().getLocation(), stateChanging.getName()), BundleException.STATECHANGE_ERROR, new BundleStatusException(null, StatusException.CODE_WARNING, stateChanging));
}
try {
long start = 0;
@@ -1361,27 +1361,30 @@ public abstract class AbstractBundle implements Bundle, Comparable, KeyedElement
*/
abstract protected BundleContextImpl getContext();
- public String getResolutionFailureMessage() {
+ public BundleException getResolutionFailureException() {
BundleDescription bundleDescription = getBundleDescription();
if (bundleDescription == null)
- return Msg.BUNDLE_UNRESOLVED_EXCEPTION;
+ return new BundleException(Msg.BUNDLE_UNRESOLVED_EXCEPTION, BundleException.RESOLVE_ERROR);
// just a sanity check - this would be an inconsistency between the framework and the state
if (bundleDescription.isResolved())
- throw new IllegalStateException(Msg.BUNDLE_UNRESOLVED_STATE_CONFLICT);
- return NLS.bind(Msg.BUNDLE_UNRESOLVED_UNSATISFIED_CONSTRAINT_EXCEPTION, getResolverError(bundleDescription));
+ return new BundleException(Msg.BUNDLE_UNRESOLVED_STATE_CONFLICT, BundleException.RESOLVE_ERROR);
+ return getResolverError(bundleDescription);
}
- private String getResolverError(BundleDescription bundleDesc) {
+ private BundleException getResolverError(BundleDescription bundleDesc) {
ResolverError[] errors = framework.adaptor.getState().getResolverErrors(bundleDesc);
if (errors == null || errors.length == 0)
- return Msg.BUNDLE_UNRESOLVED_EXCEPTION;
+ return new BundleException(Msg.BUNDLE_UNRESOLVED_EXCEPTION, BundleException.RESOLVE_ERROR);
StringBuffer message = new StringBuffer();
+ int errorType = BundleException.RESOLVE_ERROR;
for (int i = 0; i < errors.length; i++) {
+ if ((errors[i].getType() & ResolverError.INVALID_NATIVECODE_PATHS) != 0)
+ errorType = BundleException.NATIVECODE_ERROR;
message.append(errors[i].toString());
if (i < errors.length - 1)
message.append(", "); //$NON-NLS-1$
}
- return message.toString();
+ return new BundleException(NLS.bind(Msg.BUNDLE_UNRESOLVED_UNSATISFIED_CONSTRAINT_EXCEPTION, message.toString()), errorType);
}
public int getKeyHashCode() {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
index 3fd6ca266..a87fd01dc 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
@@ -1025,7 +1025,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher {
String clazz = null;
clazz = bundleActivator.getClass().getName();
- throw new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {clazz, "start", bundle.getSymbolicName() == null ? "" + bundle.getBundleId() : bundle.getSymbolicName()}), t); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {clazz, "start", bundle.getSymbolicName() == null ? "" + bundle.getBundleId() : bundle.getSymbolicName()}), BundleException.ACTIVATOR_ERROR, t); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
if (Profile.PROFILE && Profile.STARTUP)
Profile.logExit("BundleContextImpl.startActivator()"); //$NON-NLS-1$
@@ -1063,7 +1063,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher {
String clazz = (activator == null) ? "" : activator.getClass().getName(); //$NON-NLS-1$
- throw new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {clazz, "stop", bundle.getSymbolicName() == null ? "" + bundle.getBundleId() : bundle.getSymbolicName()}), t); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new BundleException(NLS.bind(Msg.BUNDLE_ACTIVATOR_EXCEPTION, new Object[] {clazz, "stop", bundle.getSymbolicName() == null ? "" + bundle.getBundleId() : bundle.getSymbolicName()}), BundleException.ACTIVATOR_ERROR, t); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
activator = null;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
index eafdb3aaa..92dfa563c 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleFragment.java
@@ -220,7 +220,7 @@ public class BundleFragment extends AbstractBundle {
* @param options
*/
protected void startWorker(int options) throws BundleException {
- throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_START, this));
+ throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_START, this), BundleException.INVALID_OPERATION);
}
/**
@@ -229,7 +229,7 @@ public class BundleFragment extends AbstractBundle {
* @param options
*/
protected void stopWorker(int options) throws BundleException {
- throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_STOP, this));
+ throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_STOP, this), BundleException.INVALID_OPERATION);
}
/**
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
index af42055f9..54505d5b7 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
@@ -300,7 +300,7 @@ public class BundleHost extends AbstractBundle {
if (state == INSTALLED) {
if (!framework.packageAdmin.resolveBundles(new Bundle[] {this}))
- throw new BundleException(getResolutionFailureMessage());
+ throw getResolutionFailureException();
}
if (getStartLevel() > framework.startLevelManager.getStartLevel()) {
@@ -308,7 +308,7 @@ public class BundleHost extends AbstractBundle {
// throw exception if this is a transient start
String msg = NLS.bind(Msg.BUNDLE_TRANSIENT_START_ERROR, this);
// Use a StatusException to indicate to the lazy starter that this should result in a warning
- throw new BundleException(msg, new BundleStatusException(msg, StatusException.CODE_WARNING, this));
+ throw new BundleException(msg, BundleException.INVALID_OPERATION, new BundleStatusException(msg, StatusException.CODE_WARNING, this));
}
return;
}
@@ -379,7 +379,7 @@ public class BundleHost extends AbstractBundle {
if (state == UNINSTALLED) {
context.close();
context = null;
- throw new BundleException(NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, getBundleData().getLocation()));
+ throw new BundleException(NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, getBundleData().getLocation()), BundleException.STATECHANGE_ERROR);
}
}
@@ -570,7 +570,7 @@ public class BundleHost extends AbstractBundle {
// then we cannot attach a fragment into the middle
// of the fragment chain.
if (loader != null) {
- throw new BundleException(NLS.bind(Msg.BUNDLE_LOADER_ATTACHMENT_ERROR, fragments[i].getSymbolicName(), getSymbolicName()));
+ throw new BundleException(NLS.bind(Msg.BUNDLE_LOADER_ATTACHMENT_ERROR, fragments[i].getSymbolicName(), getSymbolicName()), BundleException.INVALID_OPERATION);
}
newFragments[i] = fragment;
inserted = true;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
index 214368d0c..5ad88bb34 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
@@ -347,7 +347,7 @@ public class BundleLoader implements ClassLoaderDelegate {
if (classpath == null) {
// no classpath
classpath = new String[0];
- bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(Msg.BUNDLE_NO_CLASSPATH_MATCH));
+ bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(Msg.BUNDLE_NO_CLASSPATH_MATCH, BundleException.MANIFEST_ERROR));
}
BundleClassLoader bcl = createBCLPrevileged(bundle.getProtectionDomain(), classpath);
parent = getParentPrivileged(bcl);
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Constants.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Constants.java
index 609bdfe6f..0fc3131c3 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Constants.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Constants.java
@@ -137,7 +137,6 @@ public class Constants implements org.osgi.framework.Constants {
/** Properties defaults */
public static final String DEFAULT_STARTLEVEL = "1"; //$NON-NLS-1$
- public static String ECLIPSE_EE_INSTALL_VERIFY = "eclipse.ee.install.verify"; //$NON-NLS-1$
public static String OSGI_COMPATIBILITY_BOOTDELEGATION = "osgi.compatibility.bootdelegation"; //$NON-NLS-1$
/** Eclipse-SystemBundle header */
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java
index 5ae3ce266..bfd0c23ab 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/EquinoxSystemBundle.java
@@ -238,7 +238,7 @@ public class EquinoxSystemBundle implements SystemBundle {
}
public void uninstall() throws BundleException {
- throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION);
+ throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION, BundleException.INVALID_OPERATION);
}
public void update() throws BundleException {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
index 9b03a696c..9f54e2f29 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
@@ -699,7 +699,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
private final Bundle duplicate;
public DuplicateBundleException(String msg, Bundle duplicate) {
- super(msg);
+ super(msg, BundleException.DUPLICATE_BUNDLE_ERROR);
this.duplicate = duplicate;
}
@@ -882,7 +882,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
* recursed to install the same bundle!
*/
if (current.equals(reservation)) {
- throw new BundleException(Msg.BUNDLE_INSTALL_RECURSION_EXCEPTION);
+ throw new BundleException(Msg.BUNDLE_INSTALL_RECURSION_EXCEPTION, BundleException.STATECHANGE_ERROR);
}
try {
/* wait for the reservation to be released */
@@ -939,7 +939,7 @@ public class Framework implements EventDispatcher, EventPublisher, Runnable {
final boolean extension = (bundledata.getType() & (BundleData.TYPE_BOOTCLASSPATH_EXTENSION | BundleData.TYPE_FRAMEWORK_EXTENSION | BundleData.TYPE_EXTCLASSPATH_EXTENSION)) != 0;
// must check for AllPermission before allow a bundle extension to be installed
if (extension && !bundle.hasPermission(new AllPermission()))
- throw new BundleException(Msg.BUNDLE_EXTENSION_PERMISSION, new SecurityException(Msg.BUNDLE_EXTENSION_PERMISSION));
+ throw new BundleException(Msg.BUNDLE_EXTENSION_PERMISSION, BundleException.SECURITY_ERROR, new SecurityException(Msg.BUNDLE_EXTENSION_PERMISSION));
try {
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
index 9ddf22b7c..084e013d4 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundle.java
@@ -335,7 +335,7 @@ public class SystemBundle extends BundleHost {
public void uninstall() throws BundleException {
framework.checkAdminPermission(this, AdminPermission.LIFECYCLE);
- throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION);
+ throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION, BundleException.INVALID_OPERATION);
}
/**
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/loader/ClasspathManager.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/loader/ClasspathManager.java
index 33c821caa..10942df05 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/loader/ClasspathManager.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/loader/ClasspathManager.java
@@ -165,7 +165,7 @@ public class ClasspathManager {
for (int i = 0; i < loaderHooks.length; i++)
hookAdded |= loaderHooks[i].addClassPathEntry(result, cp, hostloader, sourcedata, sourcedomain);
if (!addClassPathEntry(result, cp, hostloader, sourcedata, sourcedomain) && !hookAdded) {
- BundleException be = new BundleException(NLS.bind(AdaptorMsg.BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION, cp, sourcedata.getLocation()));
+ BundleException be = new BundleException(NLS.bind(AdaptorMsg.BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION, cp, sourcedata.getLocation()), BundleException.MANIFEST_ERROR);
sourcedata.getAdaptor().getEventPublisher().publishFrameworkEvent(FrameworkEvent.INFO, sourcedata.getBundle(), be);
}
}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/AdaptorUtil.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/AdaptorUtil.java
index 1c8d5c446..dc90faed1 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/AdaptorUtil.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/AdaptorUtil.java
@@ -195,7 +195,7 @@ public class AdaptorUtil {
try {
return Headers.parseManifest(url.openStream());
} catch (IOException e) {
- throw new BundleException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_DATA_ERROR_READING_MANIFEST, bundledata.getLocation()), e);
+ throw new BundleException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_DATA_ERROR_READING_MANIFEST, bundledata.getLocation()), BundleException.MANIFEST_ERROR, e);
}
}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
index bc43ad7be..f4c31091b 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
@@ -298,7 +298,7 @@ public class BaseStorage implements SynchronousBundleListener {
if (result == null)
result = AdaptorUtil.loadManifestFrom(bundleData);
if (result == null)
- throw new BundleException(NLS.bind(AdaptorMsg.MANIFEST_NOT_FOUND_EXCEPTION, Constants.OSGI_BUNDLE_MANIFEST, bundleData.getLocation()));
+ throw new BundleException(NLS.bind(AdaptorMsg.MANIFEST_NOT_FOUND_EXCEPTION, Constants.OSGI_BUNDLE_MANIFEST, bundleData.getLocation()), BundleException.MANIFEST_ERROR);
return result;
}
@@ -942,11 +942,11 @@ public class BaseStorage implements SynchronousBundleListener {
private void validateExtension(BundleData bundleData) throws BundleException {
Dictionary extensionManifest = bundleData.getManifest();
if (extensionManifest.get(Constants.IMPORT_PACKAGE) != null)
- throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_IMPORT_ERROR, bundleData.getLocation()));
+ throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_IMPORT_ERROR, bundleData.getLocation()), BundleException.MANIFEST_ERROR);
if (extensionManifest.get(Constants.REQUIRE_BUNDLE) != null)
- throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_REQUIRE_ERROR, bundleData.getLocation()));
+ throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_REQUIRE_ERROR, bundleData.getLocation()), BundleException.MANIFEST_ERROR);
if (extensionManifest.get(Constants.BUNDLE_NATIVECODE) != null)
- throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_NATIVECODE_ERROR, bundleData.getLocation()));
+ throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_EXTENSION_NATIVECODE_ERROR, bundleData.getLocation()), BundleException.MANIFEST_ERROR);
}
/**
@@ -957,13 +957,13 @@ public class BaseStorage implements SynchronousBundleListener {
*/
protected void processFrameworkExtension(BaseData bundleData, byte type) throws BundleException {
if (addFwkURLMethod == null)
- throw new BundleException("Framework extensions are not supported.", new UnsupportedOperationException()); //$NON-NLS-1$
+ throw new BundleException("Framework extensions are not supported.", BundleException.UNSUPPORTED_OPERATION, new UnsupportedOperationException()); //$NON-NLS-1$
addExtensionContent(bundleData, type, getFwkClassLoader(), addFwkURLMethod);
}
protected void processExtExtension(BaseData bundleData, byte type) throws BundleException {
if (addExtURLMethod == null)
- throw new BundleException("Extension classpath extensions are not supported.", new UnsupportedOperationException()); //$NON-NLS-1$
+ throw new BundleException("Extension classpath extensions are not supported.", BundleException.UNSUPPORTED_OPERATION, new UnsupportedOperationException()); //$NON-NLS-1$
addExtensionContent(bundleData, type, getExtClassLoader(), addExtURLMethod);
}
@@ -1030,7 +1030,7 @@ public class BaseStorage implements SynchronousBundleListener {
* @throws BundleException on errors or if boot extensions are not supported
*/
protected void processBootExtension(BundleData bundleData, byte type) throws BundleException {
- throw new BundleException("Boot classpath extensions are not supported.", new UnsupportedOperationException()); //$NON-NLS-1$
+ throw new BundleException("Boot classpath extensions are not supported.", BundleException.UNSUPPORTED_OPERATION, new UnsupportedOperationException()); //$NON-NLS-1$
}
private void initBundleStoreRoot() {
@@ -1120,21 +1120,8 @@ public class BaseStorage implements SynchronousBundleListener {
break;
}
- if (newDescription != null) {
- boolean verified = false;
- try {
- verifyEEandNativeCode(newDescription, bundleData, systemState);
- validateNativeCodePaths(newDescription, (BaseData) bundleData);
- verified = true;
- } finally {
- if (!verified) {
- if (oldDescription != null)
- systemState.updateBundle(oldDescription);
- else
- systemState.removeBundle(newDescription);
- }
- }
- }
+ if (newDescription != null)
+ validateNativeCodePaths(newDescription, (BaseData) bundleData);
}
private void validateNativeCodePaths(BundleDescription newDescription, BaseData data) {
@@ -1153,49 +1140,6 @@ public class BaseStorage implements SynchronousBundleListener {
}
}
- private void verifyEEandNativeCode(BundleDescription newDescription, BundleData bundleData, State systemState) throws BundleException {
- if (!Boolean.valueOf(FrameworkProperties.getProperty(Constants.ECLIPSE_EE_INSTALL_VERIFY, Boolean.TRUE.toString())).booleanValue() || newDescription == null)
- return;
- // do backwards compatibility for fail on install
- // check EE
- String[] ees = newDescription.getExecutionEnvironments();
- if (ees.length > 0) {
- String systemEE = FrameworkProperties.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
- if (systemEE != null && !systemEE.equals("")) { //$NON-NLS-1$
- ManifestElement[] systemEEs = ManifestElement.parseHeader(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, systemEE);
- boolean matchedEE = false;
- for (int i = 0; i < systemEEs.length && !matchedEE; i++)
- for (int j = 0; j < ees.length & !matchedEE; j++)
- if (systemEEs[i].getValue().equals(ees[j]))
- matchedEE = true;
- if (!matchedEE) {
- StringBuffer bundleEE = new StringBuffer(25);
- for (int i = 0; i < ees.length; i++) {
- if (i > 0)
- bundleEE.append(","); //$NON-NLS-1$
- bundleEE.append(ees[i]);
- }
- throw new BundleException("Cannot match Execution Environment: " + bundleEE.toString()); //$NON-NLS-1$
- }
- }
- }
- // check native code
- NativeCodeSpecification nativeCode = newDescription.getNativeCodeSpecification();
- if (nativeCode != null) {
- systemState.setPlatformProperties(new Dictionary[] {FrameworkProperties.getProperties()});
- NativeCodeDescription[] nativeCodeSuppliers = nativeCode.getPossibleSuppliers();
- NativeCodeDescription highestRanked = null;
- for (int i = 0; i < nativeCodeSuppliers.length; i++)
- if (nativeCode.isSatisfiedBy(nativeCodeSuppliers[i]) && (highestRanked == null || highestRanked.compareTo(nativeCodeSuppliers[i]) < 0))
- highestRanked = nativeCodeSuppliers[i];
- if (highestRanked == null) {
- if (!nativeCode.isOptional())
- throw new BundleException("Unsatisfied Bundle-NativeCode: " + nativeCode.toString()); //$NON-NLS-1$
- } else
- bundleData.installNativeCode(highestRanked.getNativePaths());
- }
- }
-
private class StateSaver implements Runnable {
private long delay_interval = 30000; // 30 seconds.
private long max_total_delay_interval = 1800000; // 30 minutes.
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java
index 49b6c63bf..9a1ccb025 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java
@@ -225,13 +225,13 @@ public class BaseStorageHook implements StorageHook, AdaptorHook {
String path = substituteVars(nativePaths[i].substring(EXTERNAL_LIB_PREFIX.length()));
File nativeFile = new File(path);
if (!nativeFile.exists())
- throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, nativeFile.getAbsolutePath()));
+ throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, nativeFile.getAbsolutePath()), BundleException.NATIVECODE_ERROR);
continue; // continue to next path
}
// ensure the file exists in the bundle; it will get extracted later on demand
BundleEntry nativeEntry = bundleData.getBundleFile().getEntry(nativePaths[i]);
if (nativeEntry == null)
- throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, nativePaths[i]));
+ throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, nativePaths[i]), BundleException.NATIVECODE_ERROR);
}
}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/SystemBundleData.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/SystemBundleData.java
index 142b7da39..75b4c3185 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/SystemBundleData.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/SystemBundleData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -14,7 +14,8 @@ package org.eclipse.osgi.internal.baseadaptor;
import java.io.*;
import java.net.URL;
import java.util.Enumeration;
-import org.eclipse.osgi.baseadaptor.*;
+import org.eclipse.osgi.baseadaptor.BaseAdaptor;
+import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
@@ -82,7 +83,7 @@ public class SystemBundleData extends BaseData {
Debug.println("Unable to find system bundle manifest " + Constants.OSGI_BUNDLE_MANIFEST); //$NON-NLS-1$
if (in == null)
- throw new BundleException(AdaptorMsg.SYSTEMBUNDLE_MISSING_MANIFEST);
+ throw new BundleException(AdaptorMsg.SYSTEMBUNDLE_MISSING_MANIFEST, BundleException.MANIFEST_ERROR);
return Headers.parseManifest(in);
}
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
index 5bdde0877..48566e956 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java
@@ -156,9 +156,6 @@ public class EclipseAdaptorHook implements AdaptorHook, HookConfigurator {
}
public void addProperties(Properties properties) {
- // default to not verify EE at install time
- if (properties.getProperty(Constants.ECLIPSE_EE_INSTALL_VERIFY) == null)
- properties.put(Constants.ECLIPSE_EE_INSTALL_VERIFY, "false"); //$NON-NLS-1$
// default to enable compatibility boot delegation
if (properties.getProperty(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION) == null)
properties.put(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION, "true"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseStorageHook.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseStorageHook.java
index bdabca7e2..bb750190f 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseStorageHook.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseStorageHook.java
@@ -408,7 +408,7 @@ public final class EclipseStorageHook implements StorageHook, HookConfigurator {
generatedManifest = converter.convertManifest(bundledata.getBundleFile().getBaseFile(), true, null, true, null);
} catch (PluginConversionException pce) {
String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_ERROR_CONVERTING, bundledata.getBundleFile().getBaseFile());
- throw new BundleException(message, pce);
+ throw new BundleException(message, BundleException.MANIFEST_ERROR, pce);
}
//Now we know the symbolicId and the version of the bundle, we check to see if don't have a manifest for it already
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
index 1047f3b20..a420f9c4a 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
@@ -76,7 +76,7 @@ class StateBuilder {
result.setVersion((version != null) ? Version.parseVersion(version) : Version.emptyVersion);
} catch (IllegalArgumentException ex) {
if (manifestVersion >= 2)
- throw new BundleException(ex.getMessage());
+ throw new BundleException(ex.getMessage(), BundleException.MANIFEST_ERROR, ex);
// prior to R4 the Bundle-Version header was not interpreted by the Framework;
// must not fail for old R3 style bundles
}
@@ -180,7 +180,7 @@ class StateBuilder {
String header = (String) manifest.get(DEFINED_OSGI_VALIDATE_HEADERS[i]);
if (header != null) {
ManifestElement[] elements = ManifestElement.parseHeader(DEFINED_OSGI_VALIDATE_HEADERS[i], header);
- checkForDuplicateDirectives(elements);
+ checkForDuplicateDirectivesAttributes(elements);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.IMPORT_PACKAGE)
checkImportExportSyntax(elements, false, false, jreBundle);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.DYNAMICIMPORT_PACKAGE)
@@ -190,7 +190,7 @@ class StateBuilder {
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.FRAGMENT_HOST)
checkExtensionBundle(elements);
} else if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.BUNDLE_SYMBOLICNAME) {
- throw new BundleException(NLS.bind(StateMsg.HEADER_REQUIRED, Constants.BUNDLE_SYMBOLICNAME));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_REQUIRED, Constants.BUNDLE_SYMBOLICNAME), BundleException.MANIFEST_ERROR);
}
}
}
@@ -420,7 +420,7 @@ class StateBuilder {
try {
spec.setMatchingFilter(genericRequires[i].getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE));
} catch (InvalidSyntaxException e) {
- throw new BundleException(Constants.SELECTION_FILTER_ATTRIBUTE, e);
+ throw new BundleException(Constants.SELECTION_FILTER_ATTRIBUTE, BundleException.MANIFEST_ERROR, e);
}
String optional = genericRequires[i].getAttribute(OPTIONAL_ATTR);
String multiple = genericRequires[i].getAttribute(MULTIPLE_ATTR);
@@ -500,7 +500,7 @@ class StateBuilder {
try {
result.setFilter(manifestElement.getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE));
} catch (InvalidSyntaxException e) {
- throw new BundleException(Constants.SELECTION_FILTER_ATTRIBUTE, e);
+ throw new BundleException(Constants.SELECTION_FILTER_ATTRIBUTE, BundleException.MANIFEST_ERROR, e);
}
return result;
}
@@ -530,10 +530,10 @@ class StateBuilder {
String[] packageNames = elements[i].getValueComponents();
for (int j = 0; j < packageNames.length; j++) {
if (!export && !dynamic && packages.contains(packageNames[j]))
- throw new BundleException(NLS.bind(StateMsg.HEADER_PACKAGE_DUPLICATES, packageNames[j]));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_PACKAGE_DUPLICATES, packageNames[j]), BundleException.MANIFEST_ERROR);
// check for java.*
if (!jreBundle && packageNames[j].startsWith("java.")) //$NON-NLS-1$
- throw new BundleException(NLS.bind(StateMsg.HEADER_PACKAGE_JAVA, packageNames[j]));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_PACKAGE_JAVA, packageNames[j]), BundleException.MANIFEST_ERROR);
packages.add(packageNames[j]);
}
// check for version/specification version mismatch
@@ -541,29 +541,38 @@ class StateBuilder {
if (version != null) {
String specVersion = elements[i].getAttribute(Constants.PACKAGE_SPECIFICATION_VERSION);
if (specVersion != null && !specVersion.equals(version))
- throw new BundleException(NLS.bind(StateMsg.HEADER_VERSION_ERROR, Constants.VERSION_ATTRIBUTE, Constants.PACKAGE_SPECIFICATION_VERSION));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_VERSION_ERROR, Constants.VERSION_ATTRIBUTE, Constants.PACKAGE_SPECIFICATION_VERSION), BundleException.MANIFEST_ERROR);
}
// check for bundle-symbolic-name and bundle-verion attibures
// (failure)
if (export) {
if (elements[i].getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE) != null)
- throw new BundleException(NLS.bind(StateMsg.HEADER_EXPORT_ATTR_ERROR, Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, Constants.EXPORT_PACKAGE));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_EXPORT_ATTR_ERROR, Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, Constants.EXPORT_PACKAGE), BundleException.MANIFEST_ERROR);
if (elements[i].getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE) != null)
- throw new BundleException(NLS.bind(StateMsg.HEADER_EXPORT_ATTR_ERROR, Constants.BUNDLE_VERSION_ATTRIBUTE, Constants.EXPORT_PACKAGE));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_EXPORT_ATTR_ERROR, Constants.BUNDLE_VERSION_ATTRIBUTE, Constants.EXPORT_PACKAGE), BundleException.MANIFEST_ERROR);
}
}
}
- private static void checkForDuplicateDirectives(ManifestElement[] elements) throws BundleException {
+ private static void checkForDuplicateDirectivesAttributes(ManifestElement[] elements) throws BundleException {
// check for duplicate directives
for (int i = 0; i < elements.length; i++) {
- Enumeration keys = elements[i].getDirectiveKeys();
- if (keys != null) {
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
+ Enumeration directiveKeys = elements[i].getDirectiveKeys();
+ if (directiveKeys != null) {
+ while (directiveKeys.hasMoreElements()) {
+ String key = (String) directiveKeys.nextElement();
String[] directives = elements[i].getDirectives(key);
if (directives.length > 1)
- throw new BundleException(NLS.bind(StateMsg.HEADER_DIRECTIVE_DUPLICATES, key));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_DIRECTIVE_DUPLICATES, key), BundleException.MANIFEST_ERROR);
+ }
+ }
+ Enumeration attrKeys = elements[i].getKeys();
+ if (attrKeys != null) {
+ while (attrKeys.hasMoreElements()) {
+ String key = (String) attrKeys.nextElement();
+ String[] attrs = elements[i].getAttributes(key);
+ if (attrs.length > 1)
+ throw new BundleException(NLS.bind(StateMsg.HEADER_ATTRIBUTE_DUPLICATES, key), BundleException.MANIFEST_ERROR);
}
}
}
@@ -575,6 +584,6 @@ class StateBuilder {
String hostName = elements[0].getValue();
// XXX: The extension bundle check is done against system.bundle and org.eclipse.osgi
if (!hostName.equals(Constants.SYSTEM_BUNDLE_SYMBOLICNAME) && !hostName.equals(Constants.getInternalSymbolicName()))
- throw new BundleException(NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName));
+ throw new BundleException(NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName), BundleException.MANIFEST_ERROR);
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMessages.properties b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMessages.properties
index 15cae023a..f978eb086 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMessages.properties
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMessages.properties
@@ -21,6 +21,7 @@ HEADER_PACKAGE_JAVA=Cannot specify java.* packages in Import/Export headers \"{0
HEADER_VERSION_ERROR=The attributes \"{0}\" and \"{1}\" must match
HEADER_EXPORT_ATTR_ERROR=Specifying \"{0}\" in the \"{1}\" header is not permitted
HEADER_DIRECTIVE_DUPLICATES=Duplicate directives are not permitted \"{0}\"
+HEADER_ATTRIBUTE_DUPLICATES=Duplicate attributes are not permitted \"{0}\"
HEADER_EXTENSION_ERROR=Extension bundle is not a fragment to the system bundle \"{0}\"
RES_ERROR_DISABLEDBUNDLE=The bundle is disabled: {0}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMsg.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMsg.java
index 199f55e59..c0b4f3638 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMsg.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateMsg.java
@@ -26,6 +26,7 @@ public class StateMsg extends NLS {
public static String HEADER_VERSION_ERROR;
public static String HEADER_EXPORT_ATTR_ERROR;
public static String HEADER_DIRECTIVE_DUPLICATES;
+ public static String HEADER_ATTRIBUTE_DUPLICATES;
public static String HEADER_EXTENSION_ERROR;
public static String RES_ERROR_DISABLEDBUNDLE;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
index 9e103a7c2..03fa04aaa 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
@@ -331,7 +331,7 @@ public class ManifestElement {
parseloop: while (true) {
String next = tokenizer.getString(";,"); //$NON-NLS-1$
if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
ArrayList headerValues = new ArrayList();
StringBuffer headerValue = new StringBuffer(next);
headerValues.add(next);
@@ -344,14 +344,14 @@ public class ManifestElement {
while (c == ';') {
next = tokenizer.getString(";,=:"); //$NON-NLS-1$
if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
c = tokenizer.getChar();
while (c == ':') { // may not really be a :=
c = tokenizer.getChar();
if (c != '=') {
String restOfNext = tokenizer.getToken(";,=:"); //$NON-NLS-1$
if (restOfNext == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
next += ":" + c + restOfNext; //$NON-NLS-1$
c = tokenizer.getChar();
} else
@@ -376,7 +376,7 @@ public class ManifestElement {
if (c != '=') {
String restOfNext = tokenizer.getToken("=:"); //$NON-NLS-1$
if (restOfNext == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
next += ":" + c + restOfNext; //$NON-NLS-1$
c = tokenizer.getChar();
} else
@@ -384,7 +384,7 @@ public class ManifestElement {
}
String val = tokenizer.getString(";,"); //$NON-NLS-1$
if (val == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
Debug.print(";" + next + "=" + val); //$NON-NLS-1$ //$NON-NLS-2$
@@ -395,13 +395,13 @@ public class ManifestElement {
manifestElement.addAttribute(next, val);
directive = false;
} catch (Exception e) {
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
}
c = tokenizer.getChar();
if (c == ';') /* more */{
next = tokenizer.getToken("=:"); //$NON-NLS-1$
if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
c = tokenizer.getChar();
}
}
@@ -412,7 +412,7 @@ public class ManifestElement {
continue parseloop;
if (c == '\0') /* end of value */
break parseloop;
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
}
int size = headerElements.size();
if (size == 0)
@@ -506,7 +506,7 @@ public class ManifestElement {
{
if (firstLine) /* if no previous line */
{
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_SPACE, line));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_SPACE, line), BundleException.MANIFEST_ERROR);
}
value.append(line.substring(1));
continue;
@@ -520,7 +520,7 @@ public class ManifestElement {
int colon = line.indexOf(':');
if (colon == -1) /* no colon */
{
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_LINE_NOCOLON, line));
+ throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_LINE_NOCOLON, line), BundleException.MANIFEST_ERROR);
}
header = line.substring(0, colon).trim();
value.append(line.substring(colon + 1));

Back to the top