public void start(int options) throws BundleException {
    if (getState() == UNINSTALLED) throw new IllegalStateException("Bundle.UNINSTALLED");

    BundleStartLevel bundleStartLevel = adapt(BundleStartLevel.class);
    FrameworkStartLevel frameworkStartLevel = getFramework().adapt(FrameworkStartLevel.class);

    if ((bundleStartLevel != null)
        && (bundleStartLevel.getStartLevel() > frameworkStartLevel.getStartLevel())) {
      if ((options & START_TRANSIENT) == START_TRANSIENT) throw new BundleException("startLevel");
      else return;
    }

    if (getState() == ACTIVE) return;

    if (getState() == INSTALLED) setState(RESOLVED);

    setState(STARTING);

    String location = getLocation();

    if (location != null) {
      BundleActivator bundleActivator = null;
      Throwable exception = null;

      try {
        bundleActivator = (BundleActivator) loadClass(location.replace('/', '.')).newInstance();

        bundleActivator.start(getBundleContext());
      } catch (Throwable t) {
        logger.log(Level.SEVERE, "Error starting bundle: " + bundleActivator, t);

        if (t instanceof ThreadDeath) throw (ThreadDeath) t;
        else exception = t;
      }

      if (exception == null) this.bundleActivator = bundleActivator;
      else {
        setState(STOPPING);
        setState(RESOLVED);
        getFramework().fireBundleEvent(BundleEvent.STOPPED, this);
        throw new BundleException("BundleActivator.start", exception);
      }
    }

    if (getState() == UNINSTALLED) throw new IllegalStateException("Bundle.UNINSTALLED");

    setState(ACTIVE);
  }