if (!failed && !cycle.contains(bundle)) {
if (failed) { setBundleUnresolved(bundle, false); if (DEBUG) ResolverImpl.log(bundle + " NOT RESOLVED"); } else if (!cycle.contains(bundle)) {
	private boolean resolveBundle(ResolverBundle bundle, ArrayList cycle) {		if (bundle.isFragment())			return false;		if (!bundle.isResolvable()) {			if (DEBUG)				ResolverImpl.log("  - " + bundle + " is unresolvable"); //$NON-NLS-1$ //$NON-NLS-2$			return false;		}		if (bundle.getState() == ResolverBundle.RESOLVED) {			// 'bundle' is already resolved so just return			if (DEBUG)				ResolverImpl.log("  - " + bundle + " already resolved"); //$NON-NLS-1$ //$NON-NLS-2$			return true;		} else if (bundle.getState() == ResolverBundle.UNRESOLVED) {			// 'bundle' is UNRESOLVED so move to RESOLVING			bundle.clearWires(true);			setBundleResolving(bundle);		}		boolean failed = false;		if (!failed) {			GenericConstraint[] genericRequires = bundle.getGenericRequires();			for (int i = 0; i < genericRequires.length; i++) {				if (!resolveGenericReq(genericRequires[i], cycle)) {					if (DEBUG || DEBUG_GENERICS)						ResolverImpl.log("** GENERICS " + genericRequires[i].getVersionConstraint().getName() + "[" + genericRequires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$					state.addResolverError(genericRequires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, genericRequires[i].getVersionConstraint().toString(), genericRequires[i].getVersionConstraint());					if (genericRequires[i].isFromFragment()) {						resolverExports.remove(bundle.detachFragment((ResolverBundle) bundleMapping.get(genericRequires[i].getVersionConstraint().getBundle()), null));						continue;					}					failed = true;					break;				}			}		}		if (!failed) {			// Iterate thru required bundles of 'bundle' trying to find matching bundles.			BundleConstraint[] requires = bundle.getRequires();			for (int i = 0; i < requires.length; i++) {				if (!resolveRequire(requires[i], cycle)) {					if (DEBUG || DEBUG_REQUIRES)						ResolverImpl.log("** REQUIRE " + requires[i].getVersionConstraint().getName() + "[" + requires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$					state.addResolverError(requires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_REQUIRE_BUNDLE, requires[i].getVersionConstraint().toString(), requires[i].getVersionConstraint());					// If the require has failed to resolve and it is from a fragment, then remove the fragment from the host					if (requires[i].isFromFragment()) {						resolverExports.remove(bundle.detachFragment((ResolverBundle) bundleMapping.get(requires[i].getVersionConstraint().getBundle()), requires[i]));						continue;					}					failed = true;					break;				}			}		}		if (!failed) {			// Iterate thru imports of 'bundle' trying to find matching exports.			ResolverImport[] imports = bundle.getImportPackages();			for (int i = 0; i < imports.length; i++) {				// Only resolve non-dynamic imports here				if (!imports[i].isDynamic() && !resolveImport(imports[i], true, cycle)) {					if (DEBUG || DEBUG_IMPORTS)						ResolverImpl.log("** IMPORT " + imports[i].getName() + "[" + imports[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$					// If the import has failed to resolve and it is from a fragment, then remove the fragment from the host					state.addResolverError(imports[i].getVersionConstraint().getBundle(), ResolverError.MISSING_IMPORT_PACKAGE, imports[i].getVersionConstraint().toString(), imports[i].getVersionConstraint());					if (imports[i].isFromFragment()) {						resolverExports.remove(bundle.detachFragment((ResolverBundle) bundleMapping.get(imports[i].getBundleDescription()), imports[i]));						continue;					}					failed = true;					break;				}			}		}		// Need to check that all mandatory imports are wired. If they are then		// set the bundle RESOLVED, otherwise set it back to UNRESOLVED		if (!failed && !cycle.contains(bundle)) {			setBundleResolved(bundle);			if (DEBUG)				ResolverImpl.log(bundle + " RESOLVED"); //$NON-NLS-1$		} else if (failed) {			setBundleUnresolved(bundle, false);			if (DEBUG)				ResolverImpl.log(bundle + " NOT RESOLVED"); //$NON-NLS-1$		}		if (bundle.getState() == ResolverBundle.UNRESOLVED)			bundle.setResolvable(false); // Set it to unresolvable so we don't attempt to resolve it again in this round		// tell the state what we resolved the constraints to		stateResolveConstraints(bundle);		return bundle.getState() != ResolverBundle.UNRESOLVED;	}