final void addExportedProvidersFor( String symbolicName, String packageName, ArrayList result, KeyedHashSet visited) { if (!visited.add(bundle)) return; // See if we locally provide the package. PackageSource local = null; if (isExportedPackage(packageName)) local = proxy.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. if (requiredBundles != null) { int size = reexportTable == null ? 0 : reexportTable.length; int reexportIndex = 0; for (int i = 0; i < requiredBundles.length; i++) { if (local != null) { // always add required bundles first if we locally provide the package // This allows a bundle to provide a package from a required bundle without // re-exporting the whole required bundle. requiredBundles[i] .getBundleLoader() .addExportedProvidersFor(symbolicName, packageName, result, visited); } else if (reexportIndex < size && reexportTable[reexportIndex] == i) { reexportIndex++; requiredBundles[i] .getBundleLoader() .addExportedProvidersFor(symbolicName, packageName, result, visited); } } } // now add the locally provided package. if (local != null && local.isFriend(symbolicName)) result.add(local); }
/* * Gets the package source for the pkgName. This will include the local package source * if the bundle exports the package. This is used to compare the PackageSource of a * package from two different bundles. */ public final PackageSource getPackageSource(String pkgName) { PackageSource result = findSource(pkgName); if (!isExportedPackage(pkgName)) return result; // if the package is exported then we need to get the local source PackageSource localSource = proxy.getPackageSource(pkgName); if (result == null) return localSource; if (localSource == null) return result; return createMultiSource(pkgName, new PackageSource[] {result, localSource}); }