StateImpl systemState = stateManager.readSystemState(context); if (systemState != null) return stateManager;
StateImpl systemState = null; if (!invalidState) { systemState = stateManager.readSystemState(context); if (systemState != null) return stateManager; }
	protected StateManager createStateManager() {		File stateLocation = null;		try {			stateLocation = fileManager.lookup(LocationManager.STATE_FILE, false);		} catch (IOException ex) {			if (Debug.DEBUG && Debug.DEBUG_GENERAL) {				Debug.println("Error reading state file " + ex.getMessage()); //$NON-NLS-1$				Debug.printStackTrace(ex);			}		}		//if it does not exist, try to read it from the parent		if (stateLocation == null || !stateLocation.isFile()) { // NOTE this check is redundant since it			// is done in StateManager, however it			// is more convenient to have it here			Location parentConfiguration = null;			Location currentConfiguration = LocationManager.getConfigurationLocation();			if (currentConfiguration != null && (parentConfiguration = currentConfiguration.getParentLocation()) != null) {				try {					File stateLocationDir = new File(parentConfiguration.getURL().getFile(), FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME);					FileManager newFileManager = initFileManager(stateLocationDir, parentConfiguration.isReadOnly() ? "none" : null); //$NON-NLS-1$);					stateLocation = newFileManager.lookup(LocationManager.STATE_FILE, true);				} catch (IOException ex) {					if (Debug.DEBUG && Debug.DEBUG_GENERAL) {						Debug.println("Error reading state file " + ex.getMessage()); //$NON-NLS-1$						Debug.printStackTrace(ex);					}				}			} else {				try {					//it did not exist in either place, so create it in the original location					stateLocation = fileManager.lookup(LocationManager.STATE_FILE, true);				} catch (IOException ex) {					if (Debug.DEBUG && Debug.DEBUG_GENERAL) {						Debug.println("Error reading state file " + ex.getMessage()); //$NON-NLS-1$						Debug.printStackTrace(ex);					}				}			}		}		stateManager = new StateManager(stateLocation, timeStamp);		stateManager.setInstaller(new EclipseBundleInstaller());		StateImpl systemState = stateManager.readSystemState(context);		if (systemState != null)			return stateManager;		systemState = stateManager.createSystemState(context);		Bundle[] installedBundles = context.getBundles();		if (installedBundles == null)			return stateManager;		StateObjectFactory factory = stateManager.getFactory();		for (int i = 0; i < installedBundles.length; i++) {			Bundle toAdd = installedBundles[i];			try {				Dictionary manifest = toAdd.getHeaders(""); //$NON-NLS-1$				// if this is a cached manifest need to get the real one				if (manifest instanceof CachedManifest)					manifest = ((CachedManifest) manifest).getManifest();				BundleDescription newDescription = factory.createBundleDescription(manifest, toAdd.getLocation(), toAdd.getBundleId());				systemState.addBundle(newDescription);			} catch (BundleException be) {				// just ignore bundle datas with invalid manifests			}		}		// we need the state resolved		systemState.setTimeStamp(timeStamp);		systemState.resolve();		return stateManager;	}