StateImpl state = (StateImpl) bundle.getContainingState(); boolean strict = false; if (state != null) strict = state.inStrictMode(); ArrayList orderedPkgList = new ArrayList(); Set pkgSet = new HashSet(); Set importList = new HashSet();  ImportPackageSpecification[] imports = bundle.getImportPackages(); for (int i = 0; i < imports.length; i++) { ExportPackageDescription pkgSupplier = (ExportPackageDescription) imports[i].getSupplier(); if (pkgSupplier == null) continue; if (!isSystemExport(pkgSupplier) && !pkgSet.contains(pkgSupplier)) { orderedPkgList.add(pkgSupplier); pkgSet.add(pkgSupplier); }  BundleSpecification[] requires = pkgSupplier.getExporter().getRequiredBundles(); Set visited = new HashSet(); visited.add(bundle); Set importNames = new HashSet(1); importNames.add(imports[i].getName()); for (int j = 0; j < requires.length; j++) { BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier(); if (bundleSupplier != null) getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, importNames); } importList.add(imports[i].getName()); }  BundleSpecification[] requires = bundle.getRequiredBundles(); Set visited = new HashSet(requires.length); visited.add(bundle); for (int i = 0; i < requires.length; i++) { BundleDescription bundleSupplier = (BundleDescription) requires[i].getSupplier(); if (bundleSupplier != null) getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, null); } return (ExportPackageDescription[]) orderedPkgList.toArray(new ExportPackageDescription[orderedPkgList.size()]);
return getVisiblePackages(bundle, 0);
	public ExportPackageDescription[] getVisiblePackages(BundleDescription bundle) {		StateImpl state = (StateImpl) bundle.getContainingState();		boolean strict = false;		if (state != null)			strict = state.inStrictMode();		ArrayList orderedPkgList = new ArrayList(); // list of all ExportPackageDescriptions that are visible (ArrayList is used to keep order)		Set pkgSet = new HashSet();		Set importList = new HashSet(); // list of package names which are directly imported		// get the list of directly imported packages first.		ImportPackageSpecification[] imports = bundle.getImportPackages();		for (int i = 0; i < imports.length; i++) {			ExportPackageDescription pkgSupplier = (ExportPackageDescription) imports[i].getSupplier();			if (pkgSupplier == null)				continue;			if (!isSystemExport(pkgSupplier) && !pkgSet.contains(pkgSupplier)) {				orderedPkgList.add(pkgSupplier);				pkgSet.add(pkgSupplier);			}			// get the sources of the required bundles of the exporter			BundleSpecification[] requires = pkgSupplier.getExporter().getRequiredBundles();			Set visited = new HashSet();			visited.add(bundle); // always add self to prevent recursing into self			Set importNames = new HashSet(1);			importNames.add(imports[i].getName());			for (int j = 0; j < requires.length; j++) {				BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier();				if (bundleSupplier != null)					getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, importNames);			}			importList.add(imports[i].getName()); // besure to add to direct import list		}		// now find all the packages that are visible from required bundles		BundleSpecification[] requires = bundle.getRequiredBundles();		Set visited = new HashSet(requires.length);		visited.add(bundle); // always add self to prevent recursing into self		for (int i = 0; i < requires.length; i++) {			BundleDescription bundleSupplier = (BundleDescription) requires[i].getSupplier();			if (bundleSupplier != null)				getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, null);		}		return (ExportPackageDescription[]) orderedPkgList.toArray(new ExportPackageDescription[orderedPkgList.size()]);	}