int size = packages.length; ArrayList stems; if (dynamicImportPackageStems == null) { stems = new ArrayList(size); } else { stems = new ArrayList(size + dynamicImportPackageStems.length); for (int i = 0; i < dynamicImportPackageStems.length; i++) { stems.add(dynamicImportPackageStems[i]); } }  ArrayList names; if (dynamicImportPackages == null) { names = new ArrayList(size); } else { names = new ArrayList(size + dynamicImportPackages.length); for (int i = 0; i < dynamicImportPackages.length; i++) { names.add(dynamicImportPackages[i]); } }  for (int i = 0; i < size; i++) { if (packages[i].getResolution() != ImportPackageSpecification.RESOLUTION_DYNAMIC) continue; String name = packages[i].getName(); if (isDynamicallyImported(name)) continue; if (name.equals("*")) {  dynamicImportPackageAll = true; return; }  if (name.endsWith(".*")) stems.add(name.substring(0, name.length() - 1)); else names.add(name); }  size = stems.size(); if (size > 0) dynamicImportPackageStems = (String[]) stems.toArray(new String[size]);  size = names.size(); if (size > 0) dynamicImportPackages = (String[]) names.toArray(new String[size]);
ArrayList dynamicImports = new ArrayList(packages.length); for (int i = 0; i < packages.length; i++) if (packages[i].getResolution() == ImportPackageSpecification.RESOLUTION_DYNAMIC) dynamicImports.add(packages[i].getName()); if (dynamicImports.size() > 0) addDynamicImportPackage((String[]) dynamicImports.toArray(new String[dynamicImports.size()]));
	private void addDynamicImportPackage(ImportPackageSpecification[] packages) {		if (packages == null && SystemBundleLoader.getSystemPackages() == null)			return;		hasDynamicImports = true;		// make sure importedPackages is not null;		if (importedPackages == null) {			importedPackages = new KeyedHashSet();		}		if (packages == null)			return;		int size = packages.length;		ArrayList stems;		if (dynamicImportPackageStems == null) {			stems = new ArrayList(size);		} else {			stems = new ArrayList(size + dynamicImportPackageStems.length);			for (int i = 0; i < dynamicImportPackageStems.length; i++) {				stems.add(dynamicImportPackageStems[i]);			}		}		ArrayList names;		if (dynamicImportPackages == null) {			names = new ArrayList(size);		} else {			names = new ArrayList(size + dynamicImportPackages.length);			for (int i = 0; i < dynamicImportPackages.length; i++) {				names.add(dynamicImportPackages[i]);			}		}		for (int i = 0; i < size; i++) {			if (packages[i].getResolution() != ImportPackageSpecification.RESOLUTION_DYNAMIC)				continue;			String name = packages[i].getName();			if (isDynamicallyImported(name))				continue;			if (name.equals("*")) { /* shortcut */ //$NON-NLS-1$				dynamicImportPackageAll = true;				return;			}			if (name.endsWith(".*")) //$NON-NLS-1$				stems.add(name.substring(0, name.length() - 1));			else				names.add(name);		}		size = stems.size();		if (size > 0)			dynamicImportPackageStems = (String[]) stems.toArray(new String[size]);		size = names.size();		if (size > 0)			dynamicImportPackages = (String[]) names.toArray(new String[size]);	}