Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2018-11-14 17:00:57 -0500
committerThomas Watson2018-11-16 10:50:09 -0500
commit6043d928c30679720e0b3970754a470db25a9ec6 (patch)
tree18ac1207ad65f411b30b773aaa27bd07d3c3e452
parentb6937a1091da056b50164cb90f3753d246386c36 (diff)
downloadrt.equinox.framework-6043d928c30679720e0b3970754a470db25a9ec6.tar.gz
rt.equinox.framework-6043d928c30679720e0b3970754a470db25a9ec6.tar.xz
rt.equinox.framework-6043d928c30679720e0b3970754a470db25a9ec6.zip
Bug 541249 - Stop using KeyedHashSet where possible
Change-Id: I853df7d5009be4c968a3027f7aeba098135de45f Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java95
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/KeyedHashSet.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java30
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoaderSources.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java15
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java14
9 files changed, 117 insertions, 72 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
index 5ecb348f0..38d565005 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.osgi.compatibility.state
-Bundle-Version: 1.1.200.qualifier
+Bundle-Version: 1.1.300.qualifier
ExtensionBundle-Activator: org.eclipse.osgi.compatibility.state.Activator
Fragment-Host: org.eclipse.osgi;bundle-version="3.12.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/bundles/org.eclipse.osgi.compatibility.state/pom.xml b/bundles/org.eclipse.osgi.compatibility.state/pom.xml
index 45f68a136..0661a6561 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/pom.xml
+++ b/bundles/org.eclipse.osgi.compatibility.state/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.compatibility.state</artifactId>
- <version>1.1.200-SNAPSHOT</version>
+ <version>1.1.300-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index cdb667d9d..35f598419 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -16,14 +16,51 @@
*******************************************************************************/
package org.eclipse.osgi.internal.resolver;
-import java.util.*;
-import org.eclipse.osgi.framework.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.eclipse.osgi.internal.framework.FilterImpl;
-import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.service.resolver.BaseDescription;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.DisabledInfo;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.GenericDescription;
+import org.eclipse.osgi.service.resolver.GenericSpecification;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.osgi.service.resolver.NativeCodeDescription;
+import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
+import org.eclipse.osgi.service.resolver.Resolver;
+import org.eclipse.osgi.service.resolver.ResolverError;
+import org.eclipse.osgi.service.resolver.ResolverHookException;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.osgi.service.resolver.StateDelta;
+import org.eclipse.osgi.service.resolver.StateHelper;
+import org.eclipse.osgi.service.resolver.StateObjectFactory;
+import org.eclipse.osgi.service.resolver.StateWire;
+import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.wiring.BundleRevision;
@@ -120,10 +157,10 @@ public abstract class StateImpl implements State {
private boolean resolved = true;
private long timeStamp = System.currentTimeMillis();
- private final KeyedHashSet bundleDescriptions = new KeyedHashSet(false);
+ private final Map<Long, BundleDescription> bundleDescriptions = new HashMap<>();
private final Map<BundleDescription, List<ResolverError>> resolverErrors = new HashMap<>();
private StateObjectFactory factory;
- private final KeyedHashSet resolvedBundles = new KeyedHashSet();
+ private final Map<Long, BundleDescription> resolvedBundles = new HashMap<>();
private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap<>();
private final Map<String, Set<BundleDescription>> bundleNameCache = new HashMap<>();
private boolean fullyLoaded = false;
@@ -146,6 +183,14 @@ public abstract class StateImpl implements State {
addPlatformPropertyKeys(PROPS);
}
+ private static boolean add(BundleDescription bundle, Map<Long, BundleDescription> map, boolean replace) {
+ if (!replace && map.containsKey(bundle.getBundleId())) {
+ return false;
+ }
+ map.put(bundle.getBundleId(), bundle);
+ return true;
+ }
+
public boolean addBundle(BundleDescription description) {
synchronized (this.monitor) {
if (!basicAddBundle(description))
@@ -182,13 +227,13 @@ public abstract class StateImpl implements State {
public boolean updateBundle(BundleDescription newDescription) {
synchronized (this.monitor) {
- BundleDescriptionImpl existing = (BundleDescriptionImpl) bundleDescriptions.get((BundleDescriptionImpl) newDescription);
+ BundleDescriptionImpl existing = (BundleDescriptionImpl) bundleDescriptions.get(newDescription.getBundleId());
if (existing == null)
return false;
- if (!bundleDescriptions.remove(existing))
+ if (bundleDescriptions.remove(existing.getBundleId()) == null)
return false;
removeBundleNameCacheEntry(existing);
- resolvedBundles.remove(existing);
+ resolvedBundles.remove(existing.getBundleId());
List<DisabledInfo> infos = disabledBundles.remove(existing);
if (infos != null) {
List<DisabledInfo> newInfos = new ArrayList<>(infos.size());
@@ -238,10 +283,10 @@ public abstract class StateImpl implements State {
public boolean removeBundle(BundleDescription toRemove) {
synchronized (this.monitor) {
- toRemove = (BundleDescription) bundleDescriptions.get((KeyedElement) toRemove);
- if (toRemove == null || !bundleDescriptions.remove((KeyedElement) toRemove))
+ toRemove = bundleDescriptions.get(toRemove.getBundleId());
+ if (toRemove == null || bundleDescriptions.remove(toRemove.getBundleId()) == null)
return false;
- resolvedBundles.remove((KeyedElement) toRemove);
+ resolvedBundles.remove(toRemove.getBundleId());
disabledBundles.remove(toRemove);
removeBundleNameCacheEntry(toRemove);
resolved = false;
@@ -299,13 +344,13 @@ public abstract class StateImpl implements State {
public BundleDescription[] getBundles() {
synchronized (this.monitor) {
- return (BundleDescription[]) bundleDescriptions.elements(new BundleDescription[bundleDescriptions.size()]);
+ return bundleDescriptions.values().toArray(new BundleDescription[0]);
}
}
public BundleDescription getBundle(long id) {
synchronized (this.monitor) {
- BundleDescription result = (BundleDescription) bundleDescriptions.getByKey(new Long(id));
+ BundleDescription result = bundleDescriptions.get(id);
if (result != null)
return result;
// need to look in removal pending bundles;
@@ -400,10 +445,10 @@ public abstract class StateImpl implements State {
modifiable.setStateBit(BundleDescriptionImpl.RESOLVED, status);
if (status) {
resolverErrors.remove(modifiable);
- resolvedBundles.add(modifiable);
+ add(modifiable, resolvedBundles, true);
} else {
// remove the bundle from the resolved pool
- resolvedBundles.remove(modifiable);
+ resolvedBundles.remove(modifiable.getBundleId());
modifiable.removeDependencies();
}
// to support development mode we will resolveConstraints even if the resolve status == false
@@ -659,7 +704,7 @@ public abstract class StateImpl implements State {
public BundleDescription[] getResolvedBundles() {
synchronized (this.monitor) {
- return (BundleDescription[]) resolvedBundles.elements(new BundleDescription[resolvedBundles.size()]);
+ return resolvedBundles.values().toArray(new BundleDescription[0]);
}
}
@@ -686,7 +731,7 @@ public abstract class StateImpl implements State {
}
((BundleDescriptionImpl) description).setContainingState(this);
((BundleDescriptionImpl) description).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, false);
- if (bundleDescriptions.add((BundleDescriptionImpl) description)) {
+ if (add(description, bundleDescriptions, false)) {
if (description.getBundleId() > getHighestBundleId())
highestBundleId = description.getBundleId();
addBundleNameCacheEntry(description);
@@ -698,7 +743,7 @@ public abstract class StateImpl implements State {
void addResolvedBundle(BundleDescriptionImpl resolvedBundle) {
synchronized (this.monitor) {
- resolvedBundles.add(resolvedBundle);
+ add(resolvedBundle, resolvedBundles, true);
}
}
@@ -706,8 +751,8 @@ public abstract class StateImpl implements State {
fullyLoad();
synchronized (this.monitor) {
List<ExportPackageDescription> allExportedPackages = new ArrayList<>();
- for (Iterator<KeyedElement> iter = resolvedBundles.iterator(); iter.hasNext();) {
- BundleDescription bundle = (BundleDescription) iter.next();
+ for (Iterator<BundleDescription> iter = resolvedBundles.values().iterator(); iter.hasNext();) {
+ BundleDescription bundle = iter.next();
ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
if (bundlePackages == null)
continue;
@@ -729,8 +774,8 @@ public abstract class StateImpl implements State {
BundleDescription[] getFragments(final BundleDescription host) {
final List<BundleDescription> fragments = new ArrayList<>();
synchronized (this.monitor) {
- for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) {
- BundleDescription bundle = (BundleDescription) iter.next();
+ for (Iterator<BundleDescription> iter = bundleDescriptions.values().iterator(); iter.hasNext();) {
+ BundleDescription bundle = iter.next();
HostSpecification hostSpec = bundle.getHost();
if (hostSpec != null) {
@@ -771,8 +816,8 @@ public abstract class StateImpl implements State {
public BundleDescription getBundleByLocation(String location) {
synchronized (this.monitor) {
- for (Iterator<KeyedElement> i = bundleDescriptions.iterator(); i.hasNext();) {
- BundleDescription current = (BundleDescription) i.next();
+ for (Iterator<BundleDescription> i = bundleDescriptions.values().iterator(); i.hasNext();) {
+ BundleDescription current = i.next();
if (location.equals(current.getLocation()))
return current;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/KeyedHashSet.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/KeyedHashSet.java
index 0db7e07b7..98445fa69 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/KeyedHashSet.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/KeyedHashSet.java
@@ -22,8 +22,10 @@ import java.util.NoSuchElementException;
* reduce the overhead of storing the keys of each individual element<p>
* This class in not thread safe, clients must ensure synchronization when modifying an object of this type.
* @since 3.2
+ * @deprecated This class will be removed in a future release
*/
// This class was moved from /org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/KeyedHashSet.java
+@Deprecated
public class KeyedHashSet {
public static final int MINIMUM_SIZE = 7;
int elementCount = 0;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index f86899473..9d8cfad81 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -42,8 +42,6 @@ import org.eclipse.osgi.container.ModuleWire;
import org.eclipse.osgi.container.ModuleWiring;
import org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory;
import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace;
-import org.eclipse.osgi.framework.util.KeyedElement;
-import org.eclipse.osgi.framework.util.KeyedHashSet;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
@@ -106,9 +104,9 @@ public class BundleLoader extends ModuleLoader {
private final BundleLoaderSources exportSources;
/* cache of required package sources. Key is packagename, value is PackageSource */
- private final KeyedHashSet requiredSources = new KeyedHashSet(false);
+ private final Map<String, PackageSource> requiredSources = new HashMap<>();
/* cache of imported packages. Key is packagename, Value is PackageSource */
- private final KeyedHashSet importedSources = new KeyedHashSet(false);
+ private final Map<String, PackageSource> importedSources = new HashMap<>();
private final List<ModuleWire> requiredBundleWires;
/* @GuardedBy("importedSources") */
@@ -786,13 +784,13 @@ public class BundleLoader extends ModuleLoader {
boolean subPackages = (options & BundleWiring.LISTRESOURCES_RECURSE) != 0;
List<String> packages = new ArrayList<>();
// search imported package names
- KeyedHashSet importSources = getImportedSources(null);
- KeyedElement[] imports;
+ Map<String, PackageSource> importSources = getImportedSources(null);
+ Collection<PackageSource> imports;
synchronized (importSources) {
- imports = importSources.elements();
+ imports = new ArrayList<>(importSources.values());
}
- for (KeyedElement keyedElement : imports) {
- String id = ((PackageSource) keyedElement).getId();
+ for (PackageSource source : imports) {
+ String id = source.getId();
if (id.equals(pkgName) || (subPackages && isSubPackage(pkgName, id)))
packages.add(id);
}
@@ -1144,13 +1142,13 @@ public class BundleLoader extends ModuleLoader {
}
private PackageSource findImportedSource(String pkgName, Collection<BundleLoader> visited) {
- KeyedHashSet imports = getImportedSources(visited);
+ Map<String, PackageSource> imports = getImportedSources(visited);
synchronized (imports) {
- return (PackageSource) imports.getByKey(pkgName);
+ return imports.get(pkgName);
}
}
- private KeyedHashSet getImportedSources(Collection<BundleLoader> visited) {
+ private Map<String, PackageSource> getImportedSources(Collection<BundleLoader> visited) {
synchronized (importedSources) {
if (importsInitialized) {
return importedSources;
@@ -1160,7 +1158,7 @@ public class BundleLoader extends ModuleLoader {
for (ModuleWire importWire : importWires) {
PackageSource source = createExportPackageSource(importWire, visited);
if (source != null) {
- importedSources.add(source);
+ importedSources.put(source.getId(), source);
}
}
}
@@ -1182,7 +1180,7 @@ public class BundleLoader extends ModuleLoader {
Debug.println("BundleLoader[" + this + "] using dynamic import source: " + source); //$NON-NLS-1$ //$NON-NLS-2$
}
synchronized (importedSources) {
- importedSources.add(source);
+ importedSources.put(source.getId(), source);
}
return source;
}
@@ -1195,7 +1193,7 @@ public class BundleLoader extends ModuleLoader {
return null;
}
synchronized (requiredSources) {
- PackageSource result = (PackageSource) requiredSources.getByKey(pkgName);
+ PackageSource result = requiredSources.get(pkgName);
if (result != null)
return result.isNullSource() ? null : result;
}
@@ -1225,7 +1223,7 @@ public class BundleLoader extends ModuleLoader {
source = createMultiSource(pkgName, srcs);
}
synchronized (requiredSources) {
- requiredSources.add(source);
+ requiredSources.put(source.getId(), source);
}
return source.isNullSource() ? null : source;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoaderSources.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoaderSources.java
index 7ea06d35c..982a2cd2d 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoaderSources.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoaderSources.java
@@ -14,29 +14,31 @@
package org.eclipse.osgi.internal.loader;
import java.security.AccessController;
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.osgi.container.ModuleCapability;
-import org.eclipse.osgi.framework.util.KeyedHashSet;
import org.eclipse.osgi.framework.util.SecureAction;
-import org.eclipse.osgi.internal.loader.sources.*;
+import org.eclipse.osgi.internal.loader.sources.FilteredSourcePackage;
+import org.eclipse.osgi.internal.loader.sources.PackageSource;
+import org.eclipse.osgi.internal.loader.sources.SingleSourcePackage;
import org.osgi.framework.namespace.PackageNamespace;
public class BundleLoaderSources {
static SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction());
- private final KeyedHashSet pkgSources;
+ private final Map<String, PackageSource> pkgSources;
private final BundleLoader loader;
public BundleLoaderSources(BundleLoader loader) {
- this.pkgSources = new KeyedHashSet(false);
+ this.pkgSources = new HashMap<>();
this.loader = loader;
}
PackageSource getPackageSource(String pkgName) {
synchronized (pkgSources) {
- PackageSource pkgSource = (PackageSource) pkgSources.getByKey(pkgName);
+ PackageSource pkgSource = pkgSources.get(pkgName);
if (pkgSource == null) {
pkgSource = new SingleSourcePackage(pkgName, loader);
- pkgSources.add(pkgSource);
+ pkgSources.put(pkgSource.getId(), pkgSource);
}
return pkgSource;
}
@@ -67,8 +69,8 @@ public class BundleLoaderSources {
if (storeSource) {
if (pkgSource != null) {
synchronized (pkgSources) {
- if (pkgSources.getByKey(name) == null) {
- pkgSources.add(pkgSource);
+ if (pkgSources.get(name) == null) {
+ pkgSources.put(pkgSource.getId(), pkgSource);
}
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java
index 99bbce154..5b7882b67 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java
@@ -30,7 +30,6 @@ import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.framework.util.KeyedElement;
-import org.eclipse.osgi.framework.util.KeyedHashSet;
import org.eclipse.osgi.storage.BundleInfo;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.eclipse.osgi.storage.Storage;
@@ -60,7 +59,7 @@ public class ClasspathEntry {
private final ManifestPackageAttributes mainManifestPackageAttributes;
private final Map<String, ManifestPackageAttributes> perPackageManifestAttributes;
private final List<BundleFile> mrBundleFiles;
- private KeyedHashSet userObjects = null;
+ private HashMap<Object, KeyedElement> userObjects = null;
// TODO Note that PDE has internal dependency on this field type/name (bug 267238)
@SuppressWarnings("unused")
@@ -164,7 +163,7 @@ public class ClasspathEntry {
public synchronized Object getUserObject(Object key) {
if (userObjects == null)
return null;
- return userObjects.getByKey(key);
+ return userObjects.get(key);
}
@@ -174,8 +173,10 @@ public class ClasspathEntry {
*/
public synchronized void addUserObject(KeyedElement userObject) {
if (userObjects == null)
- userObjects = new KeyedHashSet(5, false);
- userObjects.add(userObject);
+ userObjects = new HashMap<>(5);
+ if (!userObjects.containsKey(userObject.getKey())) {
+ userObjects.put(userObject.getKey(), userObject);
+ }
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java
index cc0ec615a..d397e4140 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java
@@ -14,8 +14,11 @@
package org.eclipse.osgi.internal.loader.sources;
import java.net.URL;
-import java.util.*;
-import org.eclipse.osgi.framework.util.KeyedHashSet;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* This class is used to optimize finding provided-packages for a bundle.
@@ -24,7 +27,7 @@ import org.eclipse.osgi.framework.util.KeyedHashSet;
* be done again.
*/
public class NullPackageSource extends PackageSource {
- static KeyedHashSet sources;
+ static Map<String, NullPackageSource> sources = new HashMap<>();
private NullPackageSource(String name) {
super(name);
@@ -51,13 +54,11 @@ public class NullPackageSource extends PackageSource {
}
public static synchronized NullPackageSource getNullPackageSource(String name) {
- if (sources == null)
- sources = new KeyedHashSet();
- NullPackageSource result = (NullPackageSource) sources.getByKey(name);
+ NullPackageSource result = sources.get(name);
if (result != null)
return result;
result = new NullPackageSource(name);
- sources.add(result);
+ sources.put(name, result);
return result;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java
index 516ac33d0..c7e490319 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java
@@ -19,7 +19,6 @@ import java.util.Collection;
import java.util.Enumeration;
import org.eclipse.osgi.container.ModuleRevision;
import org.eclipse.osgi.container.ModuleWiring;
-import org.eclipse.osgi.framework.util.KeyedElement;
import org.eclipse.osgi.internal.framework.EquinoxBundle;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.eclipse.osgi.internal.loader.BundleLoader;
@@ -28,7 +27,7 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceFactory;
import org.osgi.service.packageadmin.PackageAdmin;
-public abstract class PackageSource implements KeyedElement {
+public abstract class PackageSource {
protected final String id;
public PackageSource(String id) {
@@ -42,18 +41,15 @@ public abstract class PackageSource implements KeyedElement {
public abstract SingleSourcePackage[] getSuppliers();
- public boolean compare(KeyedElement other) {
- return id.equals(((PackageSource) other).getId());
+ public boolean compare(PackageSource other) {
+ return id.equals(other.getId());
}
- public int getKeyHashCode() {
+ @Override
+ public int hashCode() {
return id.hashCode();
}
- public Object getKey() {
- return id;
- }
-
public boolean isNullSource() {
return false;
}

Back to the top