Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-08-10 12:19:20 -0400
committerThomas Watson2006-08-10 12:19:20 -0400
commit987345e6e6771e4db3961f4a9e4876889ae86285 (patch)
treeb88ebaa54c8b9ba4a096da20a35eb4998cbe97e0
parentb26e2fa07f774e96234795ef92e0873ae53dcc6f (diff)
downloadrt.equinox.framework-987345e6e6771e4db3961f4a9e4876889ae86285.tar.gz
rt.equinox.framework-987345e6e6771e4db3961f4a9e4876889ae86285.tar.xz
rt.equinox.framework-987345e6e6771e4db3961f4a9e4876889ae86285.zip
Bug 152888 [performance] BundleLoader.initialize has O(n2) algorithm
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java18
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java10
2 files changed, 18 insertions, 10 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
index 1ca05c40c..e42d792f4 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
@@ -63,7 +63,7 @@ public class BundleLoader implements ClassLoaderDelegate {
/* If not null, list of package names to import dynamically. */
String[] dynamicImportPackages;
/* List of package names that are exported by this BundleLoader */
- ArrayList exportedPackages;
+ Collection exportedPackages;
/* List of required bundle BundleLoaderProxy objects */
BundleLoaderProxy[] requiredBundles;
/* List of indexes into the requiredBundles list of reexported bundles */
@@ -157,15 +157,17 @@ public class BundleLoader implements ClassLoaderDelegate {
// init the provided packages set
ExportPackageDescription[] exports = description.getSelectedExports();
if (exports != null && exports.length > 0) {
- exportedPackages = new ArrayList(exports.length);
+ exportedPackages = exports.length > 10 ? (Collection) new HashSet(exports.length) : new ArrayList(exports.length);
for (int i = 0; i < exports.length; i++) {
- if (!exportedPackages.contains(exports[i].getName())) {
- exportedPackages.add(exports[i].getName());
- // must force filtered and reexport sources to be created early
- // to prevent lazy normal package source creation.
- // We only do this for the first export of a package name.
- proxy.createPackageSource(exports[i], true);
+ if (proxy.forceSourceCreation(exports[i])) {
+ if (!exportedPackages.contains(exports[i].getName())) {
+ // must force filtered and reexport sources to be created early
+ // to prevent lazy normal package source creation.
+ // We only do this for the first export of a package name.
+ proxy.createPackageSource(exports[i], true);
+ }
}
+ exportedPackages.add(exports[i].getName());
}
}
//This is the fastest way to access to the description for fragments since the hostdescription.getFragments() is slow
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
index 42f3f0494..88bfbcb90 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
@@ -163,7 +163,7 @@ public class BundleLoaderProxy implements RequiredBundle {
PackageSource pkgSource = (PackageSource) pkgSources.getByKey(pkgName);
if (pkgSource == null) {
pkgSource = new SingleSourcePackage(pkgName, -1, this);
- synchronized (pkgSource) {
+ synchronized (pkgSources) {
pkgSources.add(pkgSource);
}
}
@@ -174,6 +174,12 @@ public class BundleLoaderProxy implements RequiredBundle {
return description.getDependents().length > 0;
}
+ boolean forceSourceCreation(ExportPackageDescription export) {
+ if (!export.isRoot())
+ return true;
+ boolean strict = Constants.STRICT_MODE.equals(bundle.framework.adaptor.getState().getPlatformProperties()[0].get(Constants.OSGI_RESOLVER_MODE));
+ return (export.getDirective(Constants.INCLUDE_DIRECTIVE) != null) || (export.getDirective(Constants.EXCLUDE_DIRECTIVE) != null) || (strict && export.getDirective(Constants.FRIENDS_DIRECTIVE) != null);
+ }
// creates a PackageSource from an ExportPackageDescription. This is called when initializing
// a BundleLoader to ensure that the proper PackageSource gets created and used for
// filtered and reexport packages. The storeSource flag is used by initialize to indicate
@@ -217,7 +223,7 @@ public class BundleLoaderProxy implements RequiredBundle {
// care too much of duplicates getting created. Only the first one will
// successfully get stored into pkgSources
if (pkgSource != null && pkgSources.getByKey(export.getName()) == null)
- synchronized (pkgSource) {
+ synchronized (pkgSources) {
pkgSources.add(pkgSource);
}
} else {

Back to the top