synchronized (b) { if (b.getState() == Bundle.ACTIVE) { b.stop();
if(b != null) { synchronized (b) { if (b.getState() == Bundle.ACTIVE) { b.stop(); }
  public void shutdown() {    if (active) {      // No shuttingdown event specified      // listeners.frameworkChanged(new FrameworkEvent(FrameworkEvent.SHUTTING_DOWN));      active = false;      List slist = storage.getStartOnLaunchBundles();      shuttingdown = true;      systemBundle.systemShuttingdown();      // Stop bundles, in reverse start order      for (int i = slist.size()-1; i >= 0; i--) {	Bundle b = bundles.getBundle((String)slist.get(i));	try {	  synchronized (b) {	    if (b.getState() == Bundle.ACTIVE) {	      b.stop();	    }	  }	} catch (BundleException be) {	  listeners.frameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, b, be));	}      }      shuttingdown = false;       // Purge any unrefreshed bundles      BundleImpl [] all = bundles.getBundles();      for (int i = 0; i < all.length; i++) {	all[i].purge();      }    }  }