Debug.printStackTrace(e.getNestedException());
Debug.printStackTrace(e.getNestedException() == null ? e : e.getNestedException());
	private AbstractBundle[] processDelta(BundleDelta[] bundleDeltas, boolean refreshPackages) {		Util.sort(bundleDeltas, 0, bundleDeltas.length);		ArrayList bundlesList = new ArrayList(bundleDeltas.length);		// get all the bundles that are going to be refreshed		for (int i = 0; i < bundleDeltas.length; i++) {			if ((bundleDeltas[i].getType() & BundleDelta.REMOVAL_COMPLETE) != 0 && (bundleDeltas[i].getType() & BundleDelta.REMOVED) == 0)				// this means the bundle was previously pending removal; do not add to list because it was already removed from before.				continue;			AbstractBundle changedBundle = framework.getBundle(bundleDeltas[i].getBundle().getBundleId());			if (changedBundle != null && !bundlesList.contains(changedBundle))				bundlesList.add(changedBundle);		}		AbstractBundle[] refresh = (AbstractBundle[]) bundlesList.toArray(new AbstractBundle[bundlesList.size()]);		boolean[] previouslyResolved = new boolean[refresh.length];		AbstractBundle[] resolved = null;		try {			try {				if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {					Debug.println("refreshPackages: Suspend each bundle and acquire its state change lock"); //$NON-NLS-1$				}				// find which bundles were previously resolved and handle extension bundles				boolean restart = false;				for (int i = refresh.length - 1; i >= 0; i--) {					previouslyResolved[i] = refresh[i].isResolved();					if (refresh[i] == framework.systemBundle)						restart = true;					else if (((refresh[i].bundledata.getType() & BundleData.TYPE_FRAMEWORK_EXTENSION) != 0) && previouslyResolved[i])						restart = true;					else if ((refresh[i].bundledata.getType() & BundleData.TYPE_BOOTCLASSPATH_EXTENSION) != 0)						restart = true;				}				if (restart) {					FrameworkProperties.setProperty("osgi.forcedRestart", "true"); //$NON-NLS-1$ //$NON-NLS-2$					// must publish PACKAGE_REFRESHED event here because we are done.					if (refreshPackages)						framework.publishFrameworkEvent(FrameworkEvent.PACKAGES_REFRESHED, framework.systemBundle, null);					restartFramework();				}				// now suspend each bundle and grab its state change lock.				if (refreshPackages)					for (int i = refresh.length - 1; i >= 0; i--)						suspendBundle(refresh[i]);				/*				 * Refresh the bundles which will unexport the packages.				 * This will move RESOLVED bundles to the INSTALLED state.				 */				if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {					Debug.println("refreshPackages: refresh the bundles"); //$NON-NLS-1$				}				synchronized (framework.bundles) {					for (int i = 0; i < refresh.length; i++)						refresh[i].refresh();				}				// send out unresolved events outside synch block (defect #80610)				for (int i = 0; i < refresh.length; i++) {					// send out unresolved events					if (previouslyResolved[i])						framework.publishBundleEvent(BundleEvent.UNRESOLVED, refresh[i]);				}				/*				 * apply Deltas.				 */				if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {					Debug.println("refreshPackages: applying deltas to bundles"); //$NON-NLS-1$				}				synchronized (framework.bundles) {					resolved = applyDeltas(bundleDeltas);				}			} finally {				/*				 * Release the state change locks.				 */				if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {					Debug.println("refreshPackages: release the state change locks"); //$NON-NLS-1$				}				if (refreshPackages)					for (int i = 0; i < refresh.length; i++) {						AbstractBundle changedBundle = refresh[i];						changedBundle.completeStateChange();					}			}			/*			 * Take this opportunity to clean up the adaptor storage.			 */			if (refreshPackages) {				if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN)					Debug.println("refreshPackages: clean up adaptor storage"); //$NON-NLS-1$				try {					framework.adaptor.compactStorage();				} catch (IOException e) {					if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {						Debug.println("refreshPackages exception: " + e.getMessage()); //$NON-NLS-1$						Debug.printStackTrace(e);					}					framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, new BundleException(Msg.BUNDLE_REFRESH_FAILURE, e)); 				}			}		} catch (BundleException e) {			if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN) {				Debug.println("refreshPackages exception: " + e.getMessage()); //$NON-NLS-1$				Debug.printStackTrace(e.getNestedException());			}			framework.publishFrameworkEvent(FrameworkEvent.ERROR, framework.systemBundle, new BundleException(Msg.BUNDLE_REFRESH_FAILURE, e)); 		}		// send out any resolved.  This must be done after the state change locks have been release.		if (Debug.DEBUG && Debug.DEBUG_PACKAGEADMIN)			Debug.println("refreshPackages: send out RESOLVED events"); //$NON-NLS-1$		if (resolved != null)			for (int i = 0; i < resolved.length; i++)				framework.publishBundleEvent(BundleEvent.RESOLVED, resolved[i]);		return refresh;	}