bundleDir.delete();
if(!bundleDir.delete()) {   try { archive.setStartLevel(-2); } catch (Exception e) { Debug.println("Failed to mark bundle " + id + " as uninstalled, " + bundleDir + " must be deleted manually: " + e); } }
  synchronized public void uninstall() throws BundleException {    framework.checkAdminPermission();    try {      archive.setStartLevel(-1);    } catch (Exception ignored) {    }    bDelayedStart = false;        switch (state) {    case ACTIVE:      try {	stop();      } catch (BundleException be) {	framework.listeners.frameworkError(this, be);      }      // Fall through    case INSTALLED:    case RESOLVED:      framework.bundles.remove(location);      if (bpkgs.unregisterPackages(false)) {	if (classLoader != null) {	  AccessController.doPrivileged(new PrivilegedAction() {	      public Object run() {		classLoader.purge();		classLoader = null;		return null;	      }	    });	}	archive.close();      } else {	saveZombiePackages();	classLoader = null;      }      bpkgs = null;      bactivator = null;      if (bundleDir != null) {	AccessController.doPrivileged(new PrivilegedAction() {	  public Object run() {	    bundleDir.delete();	    bundleDir = null;	    return null;	  }	});      }          // id, location and headers survices after uninstall.      state = UNINSTALLED;      framework.listeners.bundleChanged(new BundleEvent(BundleEvent.UNINSTALLED, this));      break;    case STARTING:      // Wait for RUNNING state, this doesn't happen now      // since we are synchronized.      throw new IllegalStateException("Bundle.uninstall: Bundle is in STARTING state");    case STOPPING:      // Wait for RESOLVED state, this doesn't happen now      // since we are synchronized.      throw new IllegalStateException("Bundle.uninstall: Bundle is in STOPPING state");    case UNINSTALLED:      throw new IllegalStateException("Bundle.uninstall: Bundle is in UNINSTALLED state");    }  }