Bug 281708 Calling Bundle.start should not resolve a bundle that does not have it start-level met
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 afbb7b2..6600e21 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
@@ -460,6 +460,25 @@
compareResults(expectedEvents, actualEvents);
}
+ public void testStartResolve() throws Exception {
+ // install a bundle and set its start-level high, then crank up the framework start-level. This should result in no events
+ Bundle test = installer.installBundle("test"); //$NON-NLS-1$
+ StartLevel startLevel = installer.getStartLevel();
+ startLevel.setBundleStartLevel(test, startLevel.getStartLevel() + 10);
+ try {
+ test.start();
+ } catch (BundleException e) {
+ fail("Unexpected exception", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state", Bundle.INSTALLED, test.getState()); //$NON-NLS-1$
+ startLevel.setStartLevel(startLevel.getStartLevel() + 15);
+ Object[] expectedFrameworkEvents = new Object[1];
+ expectedFrameworkEvents[0] = new FrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, OSGiTestsActivator.getContext().getBundle(0), null);
+ Object[] actualFrameworkEvents = frameworkListenerResults.getResults(1);
+ compareResults(expectedFrameworkEvents, actualFrameworkEvents);
+ assertEquals("Wrong state", Bundle.ACTIVE, test.getState()); //$NON-NLS-1$
+ }
+
public void testStopTransient() throws Exception {
Bundle osgiA = installer.installBundle("osgi.lazystart.a"); //$NON-NLS-1$
installer.resolveBundles(new Bundle[] {osgiA});
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 2a4a522..de4bf43 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
@@ -304,11 +304,6 @@
if (!framework.active || (state & ACTIVE) != 0)
return;
- if (state == INSTALLED) {
- if (!framework.packageAdmin.resolveBundles(new Bundle[] {this}))
- throw getResolutionFailureException();
- }
-
if (getStartLevel() > framework.startLevelManager.getStartLevel()) {
if ((options & START_TRANSIENT) != 0) {
// throw exception if this is a transient start
@@ -318,6 +313,12 @@
}
return;
}
+
+ if (state == INSTALLED) {
+ if (!framework.packageAdmin.resolveBundles(new Bundle[] {this}))
+ throw getResolutionFailureException();
+ }
+
if ((options & START_ACTIVATION_POLICY) != 0 && (bundledata.getStatus() & Constants.BUNDLE_LAZY_START) != 0) {
// the bundle must use the activation policy here.
if ((state & RESOLVED) != 0) {