synchronized (this) { if (fragments == null) { fragments = new Vector(10); fragments.addElement(fragment);
fragments = new BundleFragment[] {fragment}; } else { boolean inserted = false;   BundleFragment[] newFragments = new BundleFragment[fragments.length+1]; for (int i = 0; i < fragments.length; i++) { if (!inserted && fragment.getBundleId() < fragments[i].getBundleId()) {    if (loader != null) { throw new BundleException(Msg.formatter.getString("FRAGMENT_ATTACHMENT ERROR")); } newFragments[i] = fragment; inserted = true;
	public void attachFragment(BundleFragment fragment) throws BundleException {		if (fragments == null) {			synchronized (this) {				if (fragments == null) {					fragments = new Vector(10);					fragments.addElement(fragment);				}			}		} else {			synchronized (fragments) {				int size = fragments.size();				boolean inserted = false;				// We must keep our fragments ordered by bundle ID; or 				// install order.				for (int i = 0; i < size; i++) {					BundleFragment frag = (BundleFragment) fragments.elementAt(i);					if (fragment.getBundleId() < frag.getBundleId()) {						// if the loader has already been created						// then we cannot attach a fragment into the middle						// of the fragment chain.						if (loader != null) {							throw new BundleException(Msg.formatter.getString("FRAGMENT_ATTACHMENT ERROR"));						}						fragments.insertElementAt(fragment, i);						inserted = true;					}				}				if (!inserted) {					fragments.addElement(fragment);				}			}		}		// If the Host ClassLoader has exists then we must attach		// the fragment to the ClassLoader.		if (loader != null) {			loader.attachFragment(fragment, SecureAction.getProperties());		}	}