Bug 324774 - Update Framework source code for generics
diff --git a/bundles/org.eclipse.osgi.tests/test_files/genericCapability/p1.osgi.MF b/bundles/org.eclipse.osgi.tests/test_files/genericCapability/p1.osgi.MF
index 6a58119..1eb6b50 100644
--- a/bundles/org.eclipse.osgi.tests/test_files/genericCapability/p1.osgi.MF
+++ b/bundles/org.eclipse.osgi.tests/test_files/genericCapability/p1.osgi.MF
@@ -3,7 +3,7 @@
Bundle-SymbolicName: p1.osgi
Bundle-Version: 1.0
Provide-Capability:
- namespace.1; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC",
- namespace.2; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC",
- namespace.3; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC"
+ namespace.1; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC"; long.list:List<Long>="1,2,3"; double.list:List<Double>="0.1,0.2,0.3"; version.list:List<Version>="1.0, 2.0, 3.0"; string.list:List="A, B, C",
+ namespace.2; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC"; long.list:List<Long>="1,2,3"; double.list:List<Double>="0.1,0.2,0.3"; version.list:List<Version>="1.0, 2.0, 3.0"; string.list:List="A, B, C",
+ namespace.3; rank:Long="100"; percent:Double="0.10"; test.version:Version="1.0.0"; test.string="ABC"; long.list:List<Long>="1,2,3"; double.list:List<Double>="0.1,0.2,0.3"; version.list:List<Version>="1.0, 2.0, 3.0"; string.list:List="A, B, C"
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ExportPackageDescription.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ExportPackageDescription.java
index 9aff124..c857576 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ExportPackageDescription.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ExportPackageDescription.java
@@ -37,13 +37,13 @@
* Returns the arbitrary attributes for this package.
* @return the arbitrary attributes for this package
*/
- public Map<String, String> getAttributes();
+ public Map<String, Object> getAttributes();
/**
* Returns the directives for this package.
* @return the directives for this package
*/
- public Map<String, String> getDirectives();
+ public Map<String, Object> getDirectives();
/**
* Returns the specified directive for this package.
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/GenericDescription.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/GenericDescription.java
index ea73606..8f091ae 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/GenericDescription.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/GenericDescription.java
@@ -28,7 +28,7 @@
* Returns the arbitrary attributes for this description
* @return the arbitrary attributes for this description
*/
- public Dictionary<String, String> getAttributes();
+ public Dictionary<String, Object> getAttributes();
/**
* Returns the type of generic description capability
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ImportPackageSpecification.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ImportPackageSpecification.java
index 6589440..09da758 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ImportPackageSpecification.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/ImportPackageSpecification.java
@@ -53,13 +53,13 @@
* Returns the arbitrary attributes which this import package may be resolved to.
* @return the arbitrary attributes which this import package may be resolved to.
*/
- public Map<String, String> getAttributes();
+ public Map<String, Object> getAttributes();
/**
* Returns the directives that control this import package.
* @return the directives that control this import package.
*/
- public Map<String, String> getDirectives();
+ public Map<String, Object> getDirectives();
/**
* Returns the specified directive that control this import package.
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/Resolver.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/Resolver.java
index 842a8ec..24bed1c 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/Resolver.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/Resolver.java
@@ -46,7 +46,7 @@
* against. A <tt>null</tt> value indicates that the system properties should
* be used to match against
*/
- public void resolve(BundleDescription[] discard, Dictionary<String, String>[] platformProperties);
+ public void resolve(BundleDescription[] discard, Dictionary<Object, Object>[] platformProperties);
/**
* Flushes this resolver of any stored/cached data it may be keeping to
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/State.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/State.java
index 2602b88..3bd9b83 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/State.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/State.java
@@ -459,7 +459,7 @@
* supported properties already set. If any of the supported property values
* are changed as a result of calling this method then true is returned.
*/
- public boolean setPlatformProperties(Dictionary<String, String> platformProperties);
+ public boolean setPlatformProperties(Dictionary<?, ?> platformProperties);
/**
* Sets the platform properties of the state to a list of platform properties.
@@ -470,13 +470,14 @@
* supported properties already set. If any of the supported property values
* are changed as a result of calling this method then true is returned.
*/
- public boolean setPlatformProperties(Dictionary<String, String>[] platformProperties);
+ public boolean setPlatformProperties(Dictionary<?, ?>[] platformProperties);
/**
* Returns the list of platform properties currently set for this state.
* @return the list of platform properties currently set for this state.
*/
- public Dictionary<String, String>[] getPlatformProperties();
+ @SuppressWarnings("rawtypes")
+ public Dictionary[] getPlatformProperties();
/**
* Returns the list of system packages which are exported by the system bundle.
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/StateObjectFactory.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/StateObjectFactory.java
index b87f571..c9585c6 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/StateObjectFactory.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/service/resolver/StateObjectFactory.java
@@ -246,7 +246,7 @@
* @param importer the importing bundle (may be <code>null</code>)
* @return the created package specification
*/
- public ImportPackageSpecification createImportPackageSpecification(String packageName, VersionRange versionRange, String bundleSymbolicName, VersionRange bundleVersionRange, Map<String, String> directives, Map<String, String> attributes, BundleDescription importer);
+ public ImportPackageSpecification createImportPackageSpecification(String packageName, VersionRange versionRange, String bundleSymbolicName, VersionRange bundleVersionRange, Map<String, ?> directives, Map<String, ?> attributes, BundleDescription importer);
/**
* Creates an import package specification that is a copy of the given import package
@@ -268,7 +268,7 @@
* @param exporter the exporter of the package (may be <code>null</code>)
* @return the created package
*/
- public ExportPackageDescription createExportPackageDescription(String packageName, Version version, Map<String, String> directives, Map<String, String> attributes, boolean root, BundleDescription exporter);
+ public ExportPackageDescription createExportPackageDescription(String packageName, Version version, Map<String, ?> directives, Map<String, ?> attributes, boolean root, BundleDescription exporter);
/**
* Creates a generic description from the given parameters
@@ -279,7 +279,7 @@
* @return the created generic description
* @deprecated use {@link #createGenericDescription(String, String, Version, Map)}
*/
- public GenericDescription createGenericDescription(String name, String type, Version version, Map<String, String> attributes);
+ public GenericDescription createGenericDescription(String name, String type, Version version, Map<String, ?> attributes);
/**
* Creates a generic description from the given parameters
@@ -290,7 +290,7 @@
* @return the created generic description
* @since 3.7
*/
- public GenericDescription createGenericDescription(String type, Map<String, String> attributes, Map<String, String> directives, BundleDescription supplier);
+ public GenericDescription createGenericDescription(String type, Map<String, ?> attributes, Map<String, String> directives, BundleDescription supplier);
/**
* Creates a generic specification from the given parameters
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GroupingChecker.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GroupingChecker.java
index f866170..c1f04c2 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GroupingChecker.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GroupingChecker.java
@@ -40,7 +40,7 @@
// must check resolved imports to get any dynamically resolved imports
ExportPackageDescription[] imports = bundle.getBundleDescription().getResolvedImports();
for (ExportPackageDescription importPkg : imports) {
- ResolverExport[] exports = bundle.getResolver().getResolverExports().get(importPkg.getName());
+ List<ResolverExport> exports = bundle.getResolver().getResolverExports().get(importPkg.getName());
for (ResolverExport export : exports) {
if (export.getExportPackageDescription() == importPkg)
isConsistentInternal(bundle, export, true, null);
@@ -173,7 +173,7 @@
for (ExportPackageDescription importPkg : imports) {
if (importPkg.getExporter() == bundle.getBundleDescription() || !importPkg.getName().equals(packageName))
continue;
- ResolverExport[] exports = bundle.getResolver().getResolverExports().get(packageName);
+ List<ResolverExport> exports = bundle.getResolver().getResolverExports().get(packageName);
for (ResolverExport export : exports) {
if (export.getExportPackageDescription() == importPkg)
return getPackageRoots(export.getExporter(), packageName, visited);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/MappedList.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/MappedList.java
index 9bbc74b..a104a24 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/MappedList.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/MappedList.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osgi.internal.module;
-import java.lang.reflect.Array;
import java.util.*;
/*
@@ -20,63 +19,43 @@
*/
public class MappedList<K, V> {
// the mapping with key -> Object[] mapping
- protected final HashMap<K, Object> internal = new HashMap();
- protected final Class<V> valueClass;
- protected final V[] empty;
-
- public MappedList(Class<V> valueClass) {
- this.valueClass = valueClass;
- empty = (V[]) Array.newInstance(valueClass, 0);
- }
+ protected final HashMap<K, List<V>> internal = new HashMap<K, List<V>>();
+ @SuppressWarnings("unchecked")
+ protected final List<V> empty = Collections.EMPTY_LIST;
public void put(K key, V value) {
- Object existing = internal.get(key);
+ List<V> existing = internal.get(key);
if (existing == null) {
- internal.put(key, value);
- } else {
- V[] existingValues;
- if (existing.getClass().isArray()) {
- existingValues = (V[]) existing;
- } else {
- existingValues = (V[]) Array.newInstance(valueClass, 1);
- existingValues[0] = (V) existing;
- }
- // insert the new value
- int index = insertionIndex(existingValues, value);
- V[] newValues = (V[]) Array.newInstance(valueClass, existingValues.length + 1);
- System.arraycopy(existingValues, 0, newValues, 0, index);
- newValues[index] = value;
- System.arraycopy(existingValues, index, newValues, index + 1, existingValues.length - index);
- internal.put(key, newValues); // overwrite the old values in the map
+ existing = new ArrayList<V>(1);
+ existing.add(value);
+ internal.put(key, existing);
+ return;
}
+ // insert the new value
+ int index = insertionIndex(existing, value);
+ existing.add(index, value);
}
- protected int insertionIndex(V[] existing, V value) {
+ protected int insertionIndex(List<V> existing, V value) {
// a MappedList is by default not sorted so just insert at the end
// extending classes may override this method to provide an index that retains sorted order
- return existing.length;
+ return existing.size();
}
// removes all values with the specified key
- public V[] remove(K key) {
+ public List<V> remove(K key) {
return get(key, true);
}
// gets all values with the specified key
- public V[] get(K key) {
+ public List<V> get(K key) {
return get(key, false);
}
// gets all values with the specified and optionally removes them
- private V[] get(K key, boolean remove) {
- Object result = remove ? internal.remove(key) : internal.get(key);
- if (result != null && result.getClass().isArray())
- return (V[]) result;
- if (result == null)
- return empty;
- V[] singleValue = (V[]) Array.newInstance(valueClass, 1);
- singleValue[0] = (V) result;
- return singleValue;
+ private List<V> get(K key, boolean remove) {
+ List<V> result = remove ? internal.remove(key) : internal.get(key);
+ return result == null ? empty : result;
}
// returns the number of keyed lists
@@ -85,21 +64,14 @@
}
// returns all values of all keys
- public V[] getAllValues() {
+ public List<V> getAllValues() {
if (getSize() == 0)
return empty;
- ArrayList<V> results = new ArrayList(getSize());
- Iterator iter = internal.values().iterator();
- while (iter.hasNext()) {
- Object value = iter.next();
- if (value.getClass().isArray()) {
- Object[] values = (Object[]) value;
- for (int i = 0; i < values.length; i++)
- results.add((V) values[i]);
- } else
- results.add((V) value);
- }
- return results.toArray(empty);
+ ArrayList<V> results = new ArrayList<V>(getSize());
+ Iterator<List<V>> iter = internal.values().iterator();
+ while (iter.hasNext())
+ results.addAll(iter.next());
+ return results;
}
// removes all keys from the map
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index 7ea8c94..5bef040 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -21,7 +21,7 @@
/*
* A companion to BundleDescription from the state used while resolving.
*/
-public class ResolverBundle extends VersionSupplier implements Comparable, BundleRevision {
+public class ResolverBundle extends VersionSupplier implements Comparable<ResolverBundle>, BundleRevision {
public static final int UNRESOLVED = 0;
public static final int RESOLVING = 1;
public static final int RESOLVED = 2;
@@ -48,7 +48,7 @@
private final ResolverImpl resolver;
private boolean newFragmentExports;
private boolean newFragmentCapabilities;
- private ArrayList refs;
+ private List<ResolverBundle> refs;
ResolverBundle(BundleDescription bundle, ResolverImpl resolver) {
super(bundle);
@@ -59,7 +59,7 @@
void initialize(boolean useSelectedExports) {
if (getBundleDescription().isSingleton())
- refs = new ArrayList();
+ refs = new ArrayList<ResolverBundle>();
if (getBundleDescription().getHost() != null) {
host = new BundleConstraint(this, getBundleDescription().getHost());
exports = new ResolverExport[0];
@@ -114,13 +114,13 @@
}
ResolverExport[] getExports(String name) {
- ArrayList results = new ArrayList(1); // rare to have more than one
+ List<ResolverExport> results = new ArrayList<ResolverExport>(1); // rare to have more than one
// it is faster to ask the VersionHashMap for this package name and then compare the exporter to this
- ResolverExport[] resolverExports = resolver.getResolverExports().get(name);
+ List<ResolverExport> resolverExports = resolver.getResolverExports().get(name);
for (ResolverExport export : resolverExports)
if (export.getExporter() == this)
results.add(export);
- return (ResolverExport[]) results.toArray(new ResolverExport[results.size()]);
+ return results.toArray(new ResolverExport[results.size()]);
}
void clearWires() {
@@ -270,17 +270,17 @@
private void initFragments() {
if (fragments == null)
- fragments = new ArrayList(1);
+ fragments = new ArrayList<ResolverBundle>(1);
if (fragmentExports == null)
- fragmentExports = new HashMap(1);
+ fragmentExports = new HashMap<Long, List<ResolverExport>>(1);
if (fragmentImports == null)
- fragmentImports = new HashMap(1);
+ fragmentImports = new HashMap<Long, List<ResolverImport>>(1);
if (fragmentRequires == null)
- fragmentRequires = new HashMap(1);
+ fragmentRequires = new HashMap<Long, List<BundleConstraint>>(1);
if (fragmentGenericCapabilities == null)
- fragmentGenericCapabilities = new HashMap(1);
+ fragmentGenericCapabilities = new HashMap<Long, List<GenericCapability>>(1);
if (fragmentGenericRequires == null)
- fragmentGenericRequires = new HashMap(1);
+ fragmentGenericRequires = new HashMap<Long, List<GenericConstraint>>(1);
}
private boolean isImported(String packageName) {
@@ -321,8 +321,8 @@
initFragments();
// need to make sure there is not already another version of this fragment
// already attached to this host
- for (Iterator iFragments = fragments.iterator(); iFragments.hasNext();) {
- ResolverBundle existingFragment = (ResolverBundle) iFragments.next();
+ for (Iterator<ResolverBundle> iFragments = fragments.iterator(); iFragments.hasNext();) {
+ ResolverBundle existingFragment = iFragments.next();
String bsn = existingFragment.getName();
if (bsn != null && bsn.equals(fragment.getName()))
return;
@@ -333,7 +333,7 @@
fragment.getHost().addPossibleSupplier(this);
if (newImports.length > 0) {
- ArrayList<ResolverImport> hostImports = new ArrayList(newImports.length);
+ ArrayList<ResolverImport> hostImports = new ArrayList<ResolverImport>(newImports.length);
for (int i = 0; i < newImports.length; i++)
if (!isImported(newImports[i].getName()))
hostImports.add(new ResolverImport(this, newImports[i]));
@@ -341,7 +341,7 @@
}
if (newRequires.length > 0) {
- ArrayList<BundleConstraint> hostRequires = new ArrayList(newRequires.length);
+ ArrayList<BundleConstraint> hostRequires = new ArrayList<BundleConstraint>(newRequires.length);
for (int i = 0; i < newRequires.length; i++)
if (!isRequired(newRequires[i].getName()))
hostRequires.add(new BundleConstraint(this, newRequires[i]));
@@ -349,13 +349,13 @@
}
if (newGenericRequires.length > 0) {
- ArrayList hostGenericRequires = new ArrayList(newGenericRequires.length);
+ ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<GenericConstraint>(newGenericRequires.length);
for (int i = 0; i < newGenericRequires.length; i++)
hostGenericRequires.add(new GenericConstraint(this, newGenericRequires[i]));
fragmentGenericRequires.put(fragment.bundleID, hostGenericRequires);
}
- ArrayList<ResolverExport> hostExports = new ArrayList(newExports.length);
+ ArrayList<ResolverExport> hostExports = new ArrayList<ResolverExport>(newExports.length);
if (newExports.length > 0 && dynamicAttach) {
StateObjectFactory factory = resolver.getState().getFactory();
for (int i = 0; i < newExports.length; i++) {
@@ -377,11 +377,11 @@
if (newGenericCapabilities.length > 0 && dynamicAttach) {
StateObjectFactory factory = resolver.getState().getFactory();
for (GenericDescription capability : newGenericCapabilities) {
- Dictionary origAttrs = capability.getAttributes();
- Map attrs = new HashMap();
+ Dictionary<String, Object> origAttrs = capability.getAttributes();
+ Map<String, Object> attrs = new HashMap<String, Object>();
if (origAttrs != null) {
- for (Enumeration keys = origAttrs.keys(); keys.hasMoreElements();) {
- Object key = keys.nextElement();
+ for (Enumeration<String> keys = origAttrs.keys(); keys.hasMoreElements();) {
+ String key = keys.nextElement();
attrs.put(key, origAttrs.get(key));
}
}
@@ -409,15 +409,15 @@
return true;
}
- public static boolean equivalentMaps(Map existingDirectives, Map newDirectives, boolean exactMatch) {
+ public static boolean equivalentMaps(Map<String, Object> existingDirectives, Map<String, Object> newDirectives, boolean exactMatch) {
if (existingDirectives == null && newDirectives == null)
return true;
if (existingDirectives == null ? newDirectives != null : newDirectives == null)
return false;
if (exactMatch && existingDirectives.size() != newDirectives.size())
return false;
- for (Iterator entries = existingDirectives.entrySet().iterator(); entries.hasNext();) {
- Entry entry = (Entry) entries.next();
+ for (Iterator<Entry<String, Object>> entries = existingDirectives.entrySet().iterator(); entries.hasNext();) {
+ Entry<String, Object> entry = entries.next();
Object newValue = newDirectives.get(entry.getKey());
if (newValue == null || entry.getValue().getClass() != newValue.getClass())
return false;
@@ -500,20 +500,20 @@
// we need to check the remaining fragment constraints to make sure they do not have
// the same unresolved constraint.
for (ResolverBundle remainingFrag : fragments) {
- ArrayList additionalImports = new ArrayList(0);
- ArrayList additionalRequires = new ArrayList(0);
+ List<ResolverImport> additionalImports = new ArrayList<ResolverImport>(0);
+ List<BundleConstraint> additionalRequires = new ArrayList<BundleConstraint>(0);
if (hasUnresolvedConstraint(reason, fragment, remainingFrag, oldImports, oldRequires, additionalImports, additionalRequires))
continue;
// merge back the additional imports or requires which the detached fragment has in common with the remaining fragment
if (additionalImports.size() > 0) {
- ArrayList remainingImports = (ArrayList) fragmentImports.get(remainingFrag.bundleID);
+ List<ResolverImport> remainingImports = fragmentImports.get(remainingFrag.bundleID);
if (remainingImports == null)
fragmentImports.put(remainingFrag.bundleID, additionalImports);
else
remainingImports.addAll(additionalImports);
}
if (additionalRequires.size() > 0) {
- ArrayList remainingRequires = (ArrayList) fragmentRequires.get(remainingFrag.bundleID);
+ List<BundleConstraint> remainingRequires = fragmentRequires.get(remainingFrag.bundleID);
if (remainingRequires == null)
fragmentRequires.put(remainingFrag.bundleID, additionalRequires);
else
@@ -530,7 +530,7 @@
resolver.removeGenerics(removedCapabilities.toArray(new GenericCapability[removedCapabilities.size()]));
}
- private boolean hasUnresolvedConstraint(ResolverConstraint reason, ResolverBundle detachedFragment, ResolverBundle remainingFragment, ResolverImport[] oldImports, BundleConstraint[] oldRequires, ArrayList additionalImports, ArrayList additionalRequires) {
+ private boolean hasUnresolvedConstraint(ResolverConstraint reason, ResolverBundle detachedFragment, ResolverBundle remainingFragment, ResolverImport[] oldImports, BundleConstraint[] oldRequires, List<ResolverImport> additionalImports, List<BundleConstraint> additionalRequires) {
ImportPackageSpecification[] remainingFragImports = remainingFragment.getBundleDescription().getImportPackages();
BundleSpecification[] remainingFragRequires = remainingFragment.getBundleDescription().getRequiredBundles();
VersionConstraint[] constraints;
@@ -626,9 +626,9 @@
* If the other BSN is null then -1 is returned
* otherwise String.compareTo is used
*/
- public int compareTo(Object o) {
+ public int compareTo(ResolverBundle o) {
String bsn = getName();
- String otherBsn = ((ResolverBundle) o).getName();
+ String otherBsn = o.getName();
if (bsn == null)
return otherBsn == null ? 0 : 1;
return otherBsn == null ? -1 : bsn.compareTo(otherBsn);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 678ccd7..ce9cfc8 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -58,7 +58,7 @@
// Used to check permissions for import/export, provide/require, host/fragment
private final PermissionChecker permissionChecker;
// Set of bundles that are pending removal
- private MappedList<Long, BundleDescription> removalPending = new MappedList<Long, BundleDescription>(BundleDescription.class);
+ private MappedList<Long, BundleDescription> removalPending = new MappedList<Long, BundleDescription>();
// Indicates whether this resolver has been initialized
private boolean initialized = false;
@@ -73,7 +73,7 @@
// Keys are BundleDescriptions, values are ResolverBundles
private HashMap<BundleDescription, ResolverBundle> bundleMapping = null;
private GroupingChecker groupingChecker;
- private Comparator selectionPolicy;
+ private Comparator<BaseDescription> selectionPolicy;
private boolean developmentMode = false;
private boolean usesCalculationTimeout = false;
private long usesTimeout = -1;
@@ -89,8 +89,8 @@
// Initializes the resolver
private void initialize() {
- resolverExports = new VersionHashMap<ResolverExport>(this, ResolverExport.class);
- resolverBundles = new VersionHashMap<ResolverBundle>(this, ResolverBundle.class);
+ resolverExports = new VersionHashMap<ResolverExport>(this);
+ resolverBundles = new VersionHashMap<ResolverBundle>(this);
resolverGenerics = new HashMap<String, VersionHashMap<GenericCapability>>();
unresolvedBundles = new HashSet<ResolverBundle>();
bundleMapping = new HashMap<BundleDescription, ResolverBundle>();
@@ -102,9 +102,9 @@
for (int i = 0; i < bundles.length; i++)
initResolverBundle(bundles[i], fragmentBundles, false);
// Add each removal pending bundle to the resolver's internal state
- BundleDescription[] removedBundles = removalPending.getAllValues();
- for (int i = 0; i < removedBundles.length; i++)
- initResolverBundle(removedBundles[i], fragmentBundles, true);
+ List<BundleDescription> removedBundles = removalPending.getAllValues();
+ for (BundleDescription removed : removedBundles)
+ initResolverBundle(removed, fragmentBundles, true);
// Iterate over the resolved fragments and attach them to their hosts
for (Iterator<ResolverBundle> iter = fragmentBundles.iterator(); iter.hasNext();) {
ResolverBundle fragment = iter.next();
@@ -182,7 +182,7 @@
return;
}
String constraintName = constraint.getName();
- GenericCapability[] matches = constraintName == null ? namespace.get(constraintName) : namespace.getAllValues();
+ List<GenericCapability> matches = constraintName == null ? namespace.get(constraintName) : namespace.getAllValues();
for (GenericCapability match : matches) {
for (GenericDescription supplier : suppliers)
if (match.getBaseDescription() == supplier)
@@ -215,7 +215,7 @@
ResolverExport matchingExport = null;
ExportPackageDescription importSupplier = (ExportPackageDescription) imp.getVersionConstraint().getSupplier();
ResolverBundle exporter = importSupplier == null ? null : (ResolverBundle) bundleMapping.get(importSupplier.getExporter());
- ResolverExport[] matches = resolverExports.get(imp.getName());
+ List<ResolverExport> matches = resolverExports.get(imp.getName());
for (ResolverExport export : matches) {
if (export.getExporter() == exporter && importSupplier == export.getExportPackageDescription()) {
matchingExport = export;
@@ -235,7 +235,7 @@
// Checks a bundle to make sure it is valid. If this method returns false for
// a given bundle, then that bundle will not even be considered for resolution
- private boolean isResolvable(ResolverBundle bundle, Dictionary[] platformProperties, ArrayList rejectedSingletons, Collection<ResolverBundle> hookDisabled) {
+ private boolean isResolvable(ResolverBundle bundle, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons, Collection<ResolverBundle> hookDisabled) {
BundleDescription bundleDesc = bundle.getBundleDescription();
// check if this is a rejected singleton
if (rejectedSingletons.contains(bundleDesc))
@@ -260,15 +260,15 @@
}
// Check for singletons
if (bundleDesc.isSingleton()) {
- Object[] sameName = resolverBundles.get(bundleDesc.getName());
- if (sameName.length > 1) {
+ List<ResolverBundle> sameName = resolverBundles.get(bundleDesc.getName());
+ if (sameName.size() > 1) {
// Need to check if one is already resolved
- Collection<Capability> collisionCandidates = new ArrayList<Capability>(sameName.length - 1);
- for (Object collision : sameName) {
- if (collision == bundleDesc || !((ResolverBundle) collision).getBundleDescription().isSingleton())
+ Collection<Capability> collisionCandidates = new ArrayList<Capability>(sameName.size() - 1);
+ for (ResolverBundle collision : sameName) {
+ if (collision == bundleDesc || !collision.getBundleDescription().isSingleton())
continue; // Ignore the bundle we are resolving and non-singletons
- if (((ResolverBundle) collision).getBundleDescription().isResolved())
- collisionCandidates.add((Capability) collision);
+ if (collision.getBundleDescription().isResolved())
+ collisionCandidates.add(collision);
}
if (hook != null)
hook.filterSingletonCollisions(bundle, collisionCandidates);
@@ -331,10 +331,13 @@
return false;
try {
Filter filter = FilterImpl.newInstance(platformFilter);
- for (int i = 0; i < platformProperties.length; i++)
+ for (int i = 0; i < platformProperties.length; i++) {
// using matchCase here in case of duplicate case invarient keys (bug 180817)
- if (filter.matchCase(platformProperties[i]))
+ @SuppressWarnings("rawtypes")
+ Dictionary props = platformProperties[i];
+ if (filter.matchCase(props))
return true;
+ }
} catch (InvalidSyntaxException e) {
// return false below
}
@@ -343,30 +346,29 @@
}
// Attach fragment to its host
- private void attachFragment(ResolverBundle bundle, ArrayList rejectedSingletons, Collection processedFragments) {
+ private void attachFragment(ResolverBundle bundle, List<BundleDescription> rejectedSingletons, Collection<String> processedFragments) {
if (processedFragments.contains(bundle.getName()))
return;
processedFragments.add(bundle.getName());
// we want to attach multiple versions of the same fragment
// from highest version to lowest to give the higher versions first pick
// of the available host bundles.
- Object[] fragments = resolverBundles.get(bundle.getName());
- for (int i = 0; i < fragments.length; i++) {
- ResolverBundle fragment = (ResolverBundle) fragments[i];
+ List<ResolverBundle> fragments = resolverBundles.get(bundle.getName());
+ for (ResolverBundle fragment : fragments) {
if (!fragment.isResolved())
attachFragment0(fragment, rejectedSingletons);
}
}
- private void attachFragment0(ResolverBundle bundle, ArrayList rejectedSingletons) {
+ private void attachFragment0(ResolverBundle bundle, List<BundleDescription> rejectedSingletons) {
if (!bundle.isFragment() || !bundle.isResolvable() || rejectedSingletons.contains(bundle.getBundleDescription()))
return;
// no need to select singletons now; it will be done when we select the rest of the singleton bundles (bug 152042)
// find all available hosts to attach to.
boolean foundMatch = false;
BundleConstraint hostConstraint = bundle.getHost();
- Object[] hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
- Collection<ResolverBundle> candidates = new ArrayList(Arrays.asList(hosts));
+ List<ResolverBundle> hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
+ Collection<ResolverBundle> candidates = new ArrayList<ResolverBundle>(hosts);
// Must remove candidates that do not match before calling hooks.
for (Iterator<ResolverBundle> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
ResolverBundle host = iCandidates.next();
@@ -384,7 +386,7 @@
state.addResolverError(bundle.getBundleDescription(), ResolverError.MISSING_FRAGMENT_HOST, bundle.getHost().getVersionConstraint().toString(), bundle.getHost().getVersionConstraint());
}
- public synchronized void resolve(BundleDescription[] reRefresh, Dictionary[] platformProperties) {
+ public synchronized void resolve(BundleDescription[] reRefresh, Dictionary<Object, Object>[] platformProperties) {
if (DEBUG)
ResolverImpl.log("*** BEGIN RESOLUTION ***"); //$NON-NLS-1$
if (state == null)
@@ -418,7 +420,7 @@
// always get the latest EEs
getCurrentEEs(platformProperties);
// keep a list of rejected singletons
- ArrayList rejectedSingletons = new ArrayList();
+ List<BundleDescription> rejectedSingletons = new ArrayList<BundleDescription>();
boolean resolveOptional = platformProperties.length == 0 ? false : "true".equals(platformProperties[0].get("osgi.resolveOptional")); //$NON-NLS-1$//$NON-NLS-2$
ResolverBundle[] currentlyResolved = null;
if (resolveOptional) {
@@ -428,13 +430,14 @@
currentlyResolved[i] = bundleMapping.get(resolvedBundles[i]);
}
// attempt to resolve all unresolved bundles
+ @SuppressWarnings("unchecked")
Collection<ResolverBundle> hookDisabled = Collections.EMPTY_LIST;
if (hook != null) {
Collection<BundleRevision> resolvable = new ArrayList<BundleRevision>(unresolvedBundles);
int size = resolvable.size();
hook.filterResolvable(resolvable);
if (resolvable.size() < size) {
- hookDisabled = new ArrayList(unresolvedBundles);
+ hookDisabled = new ArrayList<ResolverBundle>(unresolvedBundles);
hookDisabled.removeAll(resolvable);
}
}
@@ -449,8 +452,7 @@
bundles = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
resolveBundles(bundles, platformProperties, rejectedSingletons, hookDisabled);
}
- for (Iterator rejected = rejectedSingletons.iterator(); rejected.hasNext();) {
- BundleDescription reject = (BundleDescription) rejected.next();
+ for (BundleDescription reject : rejectedSingletons) {
// need to do a bit of work to figure out which bundle got selected
BundleDescription[] sameNames = state.getBundles(reject.getSymbolicName());
BundleDescription sameName = reject;
@@ -476,7 +478,7 @@
return reRefresh; // we don't care about this unless we are in development mode
// when in develoment mode we need to reRefresh hosts of unresolved fragments that add new constraints
// and reRefresh and unresolved bundles that have dependents
- HashSet additionalRefresh = new HashSet();
+ Set<BundleDescription> additionalRefresh = new HashSet<BundleDescription>();
ResolverBundle[] unresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
for (int i = 0; i < unresolved.length; i++) {
addUnresolvedWithDependents(unresolved[i], additionalRefresh);
@@ -488,16 +490,16 @@
if (reRefresh != null)
for (int i = 0; i < reRefresh.length; i++)
additionalRefresh.add(reRefresh[i]);
- return (BundleDescription[]) additionalRefresh.toArray(new BundleDescription[additionalRefresh.size()]);
+ return additionalRefresh.toArray(new BundleDescription[additionalRefresh.size()]);
}
- private void addUnresolvedWithDependents(ResolverBundle unresolved, HashSet additionalRefresh) {
+ private void addUnresolvedWithDependents(ResolverBundle unresolved, Set<BundleDescription> additionalRefresh) {
BundleDescription[] dependents = unresolved.getBundleDescription().getDependents();
if (dependents.length > 0)
additionalRefresh.add(unresolved.getBundleDescription());
}
- private void addHostsFromFragmentConstraints(ResolverBundle unresolved, Set additionalRefresh) {
+ private void addHostsFromFragmentConstraints(ResolverBundle unresolved, Set<BundleDescription> additionalRefresh) {
if (!unresolved.isFragment())
return;
ImportPackageSpecification[] newImports = unresolved.getBundleDescription().getImportPackages();
@@ -505,12 +507,12 @@
if (newImports.length == 0 && newRequires.length == 0)
return; // the fragment does not have its own constraints
BundleConstraint hostConstraint = unresolved.getHost();
- Object[] hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
- for (int j = 0; j < hosts.length; j++)
- if (hostConstraint.isSatisfiedBy((ResolverBundle) hosts[j]) && ((ResolverBundle) hosts[j]).isResolved())
+ List<ResolverBundle> hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
+ for (ResolverBundle host : hosts)
+ if (hostConstraint.isSatisfiedBy(host) && host.isResolved())
// we found a host that is resolved;
// add it to the set of bundle to refresh so we can ensure this fragment is allowed to resolve
- additionalRefresh.add(((ResolverBundle) hosts[j]).getBundleDescription());
+ additionalRefresh.add(host.getBundleDescription());
}
@@ -524,7 +526,7 @@
// TODO this does not do proper uses constraint verification.
private void resolveOptionalConstraints(ResolverBundle bundle) {
BundleConstraint[] requires = bundle.getRequires();
- ArrayList cycle = new ArrayList();
+ List<ResolverBundle> cycle = new ArrayList<ResolverBundle>();
boolean resolvedOptional = false;
for (int i = 0; i < requires.length; i++)
if (requires[i].isOptional() && requires[i].getSelectedSupplier() == null) {
@@ -548,7 +550,7 @@
}
}
- private void getCurrentEEs(Dictionary[] platformProperties) {
+ private void getCurrentEEs(Dictionary<Object, Object>[] platformProperties) {
CURRENT_EES = new String[platformProperties.length][];
for (int i = 0; i < platformProperties.length; i++) {
String eeSpecs = (String) platformProperties[i].get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
@@ -556,7 +558,7 @@
}
}
- private void resolveBundles(ResolverBundle[] bundles, Dictionary[] platformProperties, ArrayList rejectedSingletons, Collection<ResolverBundle> hookDisabled) {
+ private void resolveBundles(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons, Collection<ResolverBundle> hookDisabled) {
// First check that all the meta-data is valid for each unresolved bundle
// This will reset the resolvable flag for each bundle
for (int i = 0; i < bundles.length; i++) {
@@ -573,12 +575,12 @@
stateResolveBundles(bundles);
}
- private void resolveBundles0(ResolverBundle[] bundles, Dictionary[] platformProperties, ArrayList rejectedSingletons) {
+ private void resolveBundles0(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons) {
if (developmentMode)
// need to sort bundles to keep consistent order for fragment attachment (bug 174930)
Arrays.sort(bundles);
// First attach all fragments to the matching hosts
- Collection processedFragments = new HashSet(bundles.length);
+ Collection<String> processedFragments = new HashSet<String>(bundles.length);
for (int i = 0; i < bundles.length; i++)
attachFragment(bundles[i], rejectedSingletons, processedFragments);
@@ -604,11 +606,11 @@
checkComposites(bundles, platformProperties, rejectedSingletons);
}
- private void checkComposites(ResolverBundle[] bundles, Dictionary[] platformProperties, ArrayList rejectedSingletons) {
+ private void checkComposites(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons) {
CompositeResolveHelperRegistry helpers = getCompositeHelpers();
if (helpers == null)
return;
- Set exclude = null;
+ Set<ResolverBundle> exclude = null;
for (int i = 0; i < bundles.length; i++) {
CompositeResolveHelper helper = helpers.getCompositeResolveHelper(bundles[i].getBundleDescription());
if (helper == null)
@@ -622,14 +624,14 @@
// We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561)
setBundleUnresolved(bundles[i], false, false);
if (exclude == null)
- exclude = new HashSet(1);
+ exclude = new HashSet<ResolverBundle>(1);
exclude.add(bundles[i]);
}
}
reResolveBundles(exclude, bundles, platformProperties, rejectedSingletons);
}
- private void checkUsesConstraints(ResolverBundle[] bundles, Dictionary[] platformProperties, ArrayList rejectedSingletons) {
+ private void checkUsesConstraints(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons) {
List<ResolverConstraint> conflictingConstraints = findBestCombination(bundles, platformProperties);
if (conflictingConstraints == null)
return;
@@ -661,10 +663,10 @@
reResolveBundles(conflictedBundles, bundles, platformProperties, rejectedSingletons);
}
- private void reResolveBundles(Set exclude, ResolverBundle[] bundles, Dictionary[] platformProperties, ArrayList rejectedSingletons) {
+ private void reResolveBundles(Set<ResolverBundle> exclude, ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties, List<BundleDescription> rejectedSingletons) {
if (exclude == null || exclude.size() == 0)
return;
- ArrayList remainingUnresolved = new ArrayList();
+ List<ResolverBundle> remainingUnresolved = new ArrayList<ResolverBundle>();
for (int i = 0; i < bundles.length; i++) {
if (!exclude.contains(bundles[i])) {
// We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561)
@@ -672,10 +674,10 @@
remainingUnresolved.add(bundles[i]);
}
}
- resolveBundles0((ResolverBundle[]) remainingUnresolved.toArray(new ResolverBundle[remainingUnresolved.size()]), platformProperties, rejectedSingletons);
+ resolveBundles0(remainingUnresolved.toArray(new ResolverBundle[remainingUnresolved.size()]), platformProperties, rejectedSingletons);
}
- private List<ResolverConstraint> findBestCombination(ResolverBundle[] bundles, Dictionary[] platformProperties) {
+ private List<ResolverConstraint> findBestCombination(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties) {
Object usesMode = platformProperties.length == 0 ? null : platformProperties[0].get("osgi.resolver.usesMode"); //$NON-NLS-1$
if (usesMode == null)
usesMode = secureAction.getProperty("osgi.resolver.usesMode"); //$NON-NLS-1$
@@ -979,8 +981,8 @@
}
String getSystemBundle() {
- Dictionary[] platformProperties = state.getPlatformProperties();
- String systemBundle = (String) (platformProperties.length == 0 ? null : platformProperties[0].get(Constants.STATE_SYSTEM_BUNDLE));
+ Dictionary<?, ?>[] platformProperties = state.getPlatformProperties();
+ String systemBundle = platformProperties.length == 0 ? null : (String) platformProperties[0].get(Constants.STATE_SYSTEM_BUNDLE);
if (systemBundle == null)
systemBundle = Constants.getInternalSymbolicName();
return systemBundle;
@@ -1071,7 +1073,7 @@
}
}
- private boolean selectSingletons(ResolverBundle[] bundles, ArrayList rejectedSingletons) {
+ private boolean selectSingletons(ResolverBundle[] bundles, List<BundleDescription> rejectedSingletons) {
if (developmentMode)
return false; // do no want to unresolve singletons in development mode
boolean result = false;
@@ -1079,13 +1081,12 @@
BundleDescription bundleDesc = bundles[i].getBundleDescription();
if (!bundleDesc.isSingleton() || !bundleDesc.isResolved() || rejectedSingletons.contains(bundleDesc))
continue;
- Object[] sameName = resolverBundles.get(bundleDesc.getName());
- if (sameName.length > 1) { // Need to make a selection based off of num dependents
- Collection<ResolverBundle> singletonCollisions = new ArrayList();
- for (int j = 0; j < sameName.length; j++) {
- BundleDescription sameNameDesc = ((VersionSupplier) sameName[j]).getBundleDescription();
- ResolverBundle sameNameBundle = (ResolverBundle) sameName[j];
- if (sameName[j] == bundles[i] || !sameNameDesc.isSingleton() || !sameNameDesc.isResolved() || rejectedSingletons.contains(sameNameDesc))
+ List<ResolverBundle> sameName = resolverBundles.get(bundleDesc.getName());
+ if (sameName.size() > 1) { // Need to make a selection based off of num dependents
+ Collection<ResolverBundle> singletonCollisions = new ArrayList<ResolverBundle>();
+ for (ResolverBundle sameNameBundle : sameName) {
+ BundleDescription sameNameDesc = sameNameBundle.getBundleDescription();
+ if (sameNameBundle == bundles[i] || !sameNameDesc.isSingleton() || !sameNameDesc.isResolved() || rejectedSingletons.contains(sameNameDesc))
continue; // Ignore the bundle we are selecting, non-singletons, and non-resolved
singletonCollisions.add(sameNameBundle);
}
@@ -1115,8 +1116,8 @@
for (int i = 0; i < bundles.length; i++)
bundles[i].clearRefs();
// unresolve the rejected singletons
- for (Iterator rejects = rejectedSingletons.iterator(); rejects.hasNext();)
- unresolveBundle(bundleMapping.get(rejects.next()), false);
+ for (BundleDescription rejected : rejectedSingletons)
+ unresolveBundle(bundleMapping.get(rejected), false);
// reorder exports and bundles after unresolving the bundles
resolverExports.reorder();
resolverBundles.reorder();
@@ -1288,12 +1289,12 @@
}
VersionHashMap<GenericCapability> namespace = resolverGenerics.get(constraint.getNameSpace());
String name = constraint.getName();
- GenericCapability[] capabilities;
+ List<GenericCapability> capabilities;
if (namespace == null)
- capabilities = new GenericCapability[0];
+ capabilities = Collections.EMPTY_LIST;
else
capabilities = name == null || "*".equals(name) ? namespace.getAllValues() : namespace.get(name); //$NON-NLS-1$
- Collection<GenericCapability> candidates = new ArrayList<GenericCapability>(Arrays.asList(capabilities));
+ Collection<GenericCapability> candidates = new ArrayList<GenericCapability>(capabilities);
// Must remove candidates that do not match before calling hooks.
for (Iterator<GenericCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
if (!constraint.isSatisfiedBy(iCandidates.next()))
@@ -1347,8 +1348,8 @@
ResolverImpl.log(" - already wired"); //$NON-NLS-1$
return true; // Already wired (due to grouping dependencies) so just return
}
- ResolverBundle[] bundles = resolverBundles.get(req.getVersionConstraint().getName());
- Collection<ResolverBundle> candidates = new ArrayList<ResolverBundle>(Arrays.asList(bundles));
+ List<ResolverBundle> bundles = resolverBundles.get(req.getVersionConstraint().getName());
+ Collection<ResolverBundle> candidates = new ArrayList<ResolverBundle>(bundles);
// Must remove candidates that do not match before calling hooks.
for (Iterator<ResolverBundle> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
if (!req.isSatisfiedBy(iCandidates.next()))
@@ -1410,8 +1411,8 @@
}
boolean result = false;
ResolverExport[] substitutableExps = imp.getBundle().getExports(imp.getName());
- ResolverExport[] exports = resolverExports.get(imp.getName());
- Collection<ResolverExport> candidates = new ArrayList<ResolverExport>(Arrays.asList(exports));
+ List<ResolverExport> exports = resolverExports.get(imp.getName());
+ Collection<ResolverExport> candidates = new ArrayList<ResolverExport>(exports);
// Must remove candidates that do not match before calling hooks.
for (Iterator<ResolverExport> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
if (!imp.isSatisfiedBy(iCandidates.next()))
@@ -1575,31 +1576,31 @@
stateResolveConstraints(rb);
// Gather selected exports
ResolverExport[] exports = rb.getSelectedExports();
- ArrayList selectedExports = new ArrayList(exports.length);
+ List<ExportPackageDescription> selectedExports = new ArrayList<ExportPackageDescription>(exports.length);
for (int i = 0; i < exports.length; i++) {
if (permissionChecker.checkPackagePermission(exports[i].getExportPackageDescription()))
selectedExports.add(exports[i].getExportPackageDescription());
}
- ExportPackageDescription[] selectedExportsArray = (ExportPackageDescription[]) selectedExports.toArray(new ExportPackageDescription[selectedExports.size()]);
+ ExportPackageDescription[] selectedExportsArray = selectedExports.toArray(new ExportPackageDescription[selectedExports.size()]);
// Gather substitute exports
ResolverExport[] substituted = rb.getSubstitutedExports();
- ArrayList substitutedExports = new ArrayList(substituted.length);
+ List<ExportPackageDescription> substitutedExports = new ArrayList<ExportPackageDescription>(substituted.length);
for (int i = 0; i < substituted.length; i++) {
substitutedExports.add(substituted[i].getExportPackageDescription());
}
- ExportPackageDescription[] substitutedExportsArray = (ExportPackageDescription[]) substitutedExports.toArray(new ExportPackageDescription[substitutedExports.size()]);
+ ExportPackageDescription[] substitutedExportsArray = substitutedExports.toArray(new ExportPackageDescription[substitutedExports.size()]);
// Gather exports that have been wired to
ExportPackageDescription[] exportsWiredToArray = getExportsWiredTo(rb);
// Gather bundles that have been wired to
BundleConstraint[] requires = rb.getRequires();
- ArrayList bundlesWiredTo = new ArrayList(requires.length);
+ List<BundleDescription> bundlesWiredTo = new ArrayList<BundleDescription>(requires.length);
for (int i = 0; i < requires.length; i++)
if (requires[i].getSelectedSupplier() != null)
- bundlesWiredTo.add(requires[i].getSelectedSupplier().getBaseDescription());
- BundleDescription[] bundlesWiredToArray = (BundleDescription[]) bundlesWiredTo.toArray(new BundleDescription[bundlesWiredTo.size()]);
+ bundlesWiredTo.add((BundleDescription) requires[i].getSelectedSupplier().getBaseDescription());
+ BundleDescription[] bundlesWiredToArray = bundlesWiredTo.toArray(new BundleDescription[bundlesWiredTo.size()]);
GenericCapability[] capabilities = rb.getGenericCapabilities();
List<GenericDescription> selectedCapabilities = new ArrayList<GenericDescription>(capabilities.length);
@@ -1660,11 +1661,11 @@
private static ExportPackageDescription[] getExportsWiredTo(ResolverBundle rb) {
// Gather exports that have been wired to
ResolverImport[] imports = rb.getImportPackages();
- ArrayList exportsWiredTo = new ArrayList(imports.length);
+ List<ExportPackageDescription> exportsWiredTo = new ArrayList<ExportPackageDescription>(imports.length);
for (int i = 0; i < imports.length; i++)
if (imports[i].getSelectedSupplier() != null)
- exportsWiredTo.add(imports[i].getSelectedSupplier().getBaseDescription());
- return (ExportPackageDescription[]) exportsWiredTo.toArray(new ExportPackageDescription[exportsWiredTo.size()]);
+ exportsWiredTo.add((ExportPackageDescription) imports[i].getSelectedSupplier().getBaseDescription());
+ return exportsWiredTo.toArray(new ExportPackageDescription[exportsWiredTo.size()]);
}
// Resolve dynamic import
@@ -1699,7 +1700,7 @@
found = true;
// populate the grouping checker with current imports
groupingChecker.populateRoots(resolverImports[j].getBundle());
- if (resolveImport(resolverImports[j], new ArrayList())) {
+ if (resolveImport(resolverImports[j], new ArrayList<ResolverBundle>())) {
found = false;
while (!found && resolverImports[j].getSelectedSupplier() != null) {
if (groupingChecker.isDynamicConsistent(resolverImports[j].getBundle(), (ResolverExport) resolverImports[j].getSelectedSupplier()) != null)
@@ -1729,11 +1730,11 @@
}
// this is to support adding dynamic imports on the fly.
if (!found) {
- Map directives = new HashMap(1);
+ Map<String, String> directives = new HashMap<String, String>(1, 1);
directives.put(Constants.RESOLUTION_DIRECTIVE, ImportPackageSpecification.RESOLUTION_DYNAMIC);
ImportPackageSpecification packageSpec = state.getFactory().createImportPackageSpecification(requestedPackage, null, null, null, directives, null, importingBundle);
ResolverImport newImport = new ResolverImport(rb, packageSpec);
- if (resolveImport(newImport, new ArrayList())) {
+ if (resolveImport(newImport, new ArrayList<ResolverBundle>())) {
while (newImport.getSelectedSupplier() != null) {
if (groupingChecker.isDynamicConsistent(rb, (ResolverExport) newImport.getSelectedSupplier()) != null)
newImport.selectNextSupplier();
@@ -1798,18 +1799,18 @@
if (bundle == null)
return;
// check the removed list if unresolving then remove from the removed list
- BundleDescription[] removedBundles = removalPending.remove(new Long(bundle.getBundleDescription().getBundleId()));
- for (int i = 0; i < removedBundles.length; i++) {
- ResolverBundle re = bundleMapping.get(removedBundles[i]);
+ List<BundleDescription> removedBundles = removalPending.remove(new Long(bundle.getBundleDescription().getBundleId()));
+ for (BundleDescription removedDesc : removedBundles) {
+ ResolverBundle re = bundleMapping.get(removedDesc);
unresolveBundle(re, true);
- state.removeBundleComplete(removedBundles[i]);
+ state.removeBundleComplete(removedDesc);
resolverExports.remove(re.getExportPackages());
resolverBundles.remove(re);
removeGenerics(re.getGenericCapabilities());
- bundleMapping.remove(removedBundles[i]);
+ bundleMapping.remove(removedDesc);
groupingChecker.clear(re);
// the bundle is removed
- if (removedBundles[i] == bundle.getBundleDescription())
+ if (removedDesc == bundle.getBundleDescription())
removed = true;
}
@@ -1843,9 +1844,9 @@
resolverGenerics = null;
unresolvedBundles = null;
bundleMapping = null;
- BundleDescription[] removed = removalPending.getAllValues();
- for (int i = 0; i < removed.length; i++)
- state.removeBundleComplete(removed[i]);
+ List<BundleDescription> removed = removalPending.getAllValues();
+ for (BundleDescription removedDesc : removed)
+ state.removeBundleComplete(removedDesc);
removalPending.clear();
initialized = false;
}
@@ -1879,9 +1880,8 @@
// LOGGING METHODS
private void printWirings() {
ResolverImpl.log("****** Result Wirings ******"); //$NON-NLS-1$
- Object[] bundles = resolverBundles.getAllValues();
- for (int j = 0; j < bundles.length; j++) {
- ResolverBundle rb = (ResolverBundle) bundles[j];
+ List<ResolverBundle> bundles = resolverBundles.getAllValues();
+ for (ResolverBundle rb : bundles) {
if (rb.getBundleDescription().isResolved()) {
continue;
}
@@ -1937,11 +1937,11 @@
return resolverExports;
}
- public void setSelectionPolicy(Comparator selectionPolicy) {
+ public void setSelectionPolicy(Comparator<BaseDescription> selectionPolicy) {
this.selectionPolicy = selectionPolicy;
}
- public Comparator getSelectionPolicy() {
+ public Comparator<BaseDescription> getSelectionPolicy() {
return selectionPolicy;
}
@@ -1970,7 +1970,7 @@
for (GenericCapability capability : generics) {
VersionHashMap<GenericCapability> namespace = resolverGenerics.get(capability.getNamespace());
if (namespace == null) {
- namespace = new VersionHashMap<GenericCapability>(this, GenericCapability.class);
+ namespace = new VersionHashMap<GenericCapability>(this);
resolverGenerics.put(capability.getNamespace(), namespace);
}
namespace.put(capability.getName(), capability);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
index 6e1820e..8773234 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
@@ -11,25 +11,24 @@
*******************************************************************************/
package org.eclipse.osgi.internal.module;
-import java.lang.reflect.Array;
import java.util.*;
-public class VersionHashMap<V extends VersionSupplier> extends MappedList<String, V> implements Comparator {
+public class VersionHashMap<V extends VersionSupplier> extends MappedList<String, V> implements Comparator<V> {
private final ResolverImpl resolver;
private final boolean preferSystemPackages;
- public VersionHashMap(ResolverImpl resolver, Class<V> valueClass) {
- super(valueClass);
+ public VersionHashMap(ResolverImpl resolver) {
this.resolver = resolver;
preferSystemPackages = Boolean.valueOf(ResolverImpl.secureAction.getProperty("osgi.resolver.preferSystemPackages", "true")).booleanValue(); //$NON-NLS-1$//$NON-NLS-2$
}
// assumes existing array is sorted
// finds the index where to insert the new value
- protected int insertionIndex(V[] existing, V value) {
- int index = existing.length;
- if (compare(existing[existing.length - 1], value) > 0) {
- index = Arrays.binarySearch(existing, value, this);
+ protected int insertionIndex(List<V> existing, V value) {
+ int index = existing.size();
+ if (compare(existing.get(existing.size() - 1), value) > 0) {
+ index = Collections.binarySearch(existing, value, this);
+
if (index < 0)
index = -index - 1;
}
@@ -46,32 +45,18 @@
}
private V contains(V vs, boolean remove) {
- Object existing = internal.get(vs.getName());
+ List<V> existing = internal.get(vs.getName());
if (existing == null)
return null;
- if (existing == vs) {
- if (remove)
- internal.remove(vs.getName());
+ int index = existing.indexOf(vs);
+ if (index >= 0) {
+ if (remove) {
+ existing.remove(index);
+ if (existing.size() == 0)
+ internal.remove(vs.getName());
+ }
return vs;
}
- if (!existing.getClass().isArray())
- return null;
- Object[] existingValues = (Object[]) existing;
- for (int i = 0; i < existingValues.length; i++)
- if (existingValues[i] == vs) {
- if (remove) {
- if (existingValues.length == 2) {
- internal.put(vs.getName(), existingValues[i == 0 ? 1 : 0]);
- return vs;
- }
- V[] newExisting = (V[]) Array.newInstance(valueClass, existingValues.length - 1);
- System.arraycopy(existingValues, 0, newExisting, 0, i);
- if (i + 1 < existingValues.length)
- System.arraycopy(existingValues, i + 1, newExisting, i, existingValues.length - i - 1);
- internal.put(vs.getName(), newExisting);
- }
- return vs;
- }
return null;
}
@@ -87,11 +72,10 @@
// Once we have resolved bundles, we need to make sure that version suppliers
// from the resolved bundles are ahead of those from unresolved bundles
void reorder() {
- for (Iterator it = internal.values().iterator(); it.hasNext();) {
- Object existing = it.next();
- if (!existing.getClass().isArray())
- continue;
- Arrays.sort((Object[]) existing, this);
+ for (Iterator<List<V>> it = internal.values().iterator(); it.hasNext();) {
+ List<V> existing = it.next();
+ if (existing.size() > 0)
+ Collections.sort(existing, this);
}
}
@@ -100,11 +84,7 @@
// First the resolution status of the supplying bundle.
// Second is the supplier version.
// Third is the bundle id of the supplying bundle.
- public int compare(Object o1, Object o2) {
- if (!(o1 instanceof VersionSupplier) || !(o2 instanceof VersionSupplier))
- throw new IllegalArgumentException();
- VersionSupplier vs1 = (VersionSupplier) o1;
- VersionSupplier vs2 = (VersionSupplier) o2;
+ public int compare(V vs1, V vs2) {
// if the selection policy is set then use that
if (resolver.getSelectionPolicy() != null)
return resolver.getSelectionPolicy().compare(vs1.getBaseDescription(), vs2.getBaseDescription());
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java
index 95dce28..497a8b0 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java
@@ -56,7 +56,8 @@
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof List) {
- List list = (List) value;
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>) value;
if (list.size() == 0)
continue;
Object component = list.get(0);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
index 5f3694c..445d9fe 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
@@ -51,9 +51,8 @@
private volatile int lazyDataOffset = -1;
private volatile int lazyDataSize = -1;
- //TODO These could be arrays
- private ArrayList dependencies;
- private ArrayList dependents;
+ private List<BundleDescription> dependencies;
+ private List<BundleDescription> dependents;
private volatile LazyData lazyData;
private volatile int equinox_ee = -1;
@@ -481,7 +480,7 @@
synchronized (this.monitor) {
if (dependencies == null)
return;
- Iterator iter = dependencies.iterator();
+ Iterator<BundleDescription> iter = dependencies.iterator();
while (iter.hasNext()) {
((BundleDescriptionImpl) iter.next()).removeDependent(this);
}
@@ -494,7 +493,7 @@
if (newDependencies == null)
return;
if (!checkDups && dependencies == null)
- dependencies = new ArrayList(newDependencies.length);
+ dependencies = new ArrayList<BundleDescription>(newDependencies.length);
for (int i = 0; i < newDependencies.length; i++) {
addDependency((BaseDescriptionImpl) newDependencies[i], checkDups);
}
@@ -507,7 +506,7 @@
if (bundle == this)
return;
if (dependencies == null)
- dependencies = new ArrayList(10);
+ dependencies = new ArrayList<BundleDescription>(10);
if (!checkDups || !dependencies.contains(bundle)) {
bundle.addDependent(this);
dependencies.add(bundle);
@@ -519,14 +518,14 @@
* Gets all the bundle dependencies as a result of import-package or require-bundle.
* Self and fragment bundles are removed.
*/
- List getBundleDependencies() {
+ List<BundleDescription> getBundleDependencies() {
synchronized (this.monitor) {
if (dependencies == null)
- return new ArrayList(0);
- ArrayList required = new ArrayList(dependencies.size());
- for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
- Object dep = iter.next();
- if (dep != this && dep instanceof BundleDescription && ((BundleDescription) dep).getHost() == null)
+ return new ArrayList<BundleDescription>(0);
+ ArrayList<BundleDescription> required = new ArrayList<BundleDescription>(dependencies.size());
+ for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();) {
+ BundleDescription dep = iter.next();
+ if (dep != this && dep.getHost() == null)
required.add(dep);
}
return required;
@@ -544,7 +543,7 @@
protected void addDependent(BundleDescription dependent) {
synchronized (this.monitor) {
if (dependents == null)
- dependents = new ArrayList(10);
+ dependents = new ArrayList<BundleDescription>(10);
// no need to check for duplicates here; this is only called in addDepenency which already checks for dups.
dependents.add(dependent);
}
@@ -562,7 +561,7 @@
synchronized (this.monitor) {
if (dependents == null)
return EMPTY_BUNDLEDESCS;
- return (BundleDescription[]) dependents.toArray(new BundleDescription[dependents.size()]);
+ return dependents.toArray(new BundleDescription[dependents.size()]);
}
}
@@ -665,7 +664,7 @@
}
}
- void setDynamicStamps(HashMap dynamicStamps) {
+ void setDynamicStamps(Map<String, Long> dynamicStamps) {
synchronized (this.monitor) {
checkLazyData();
lazyData.dynamicStamps = dynamicStamps;
@@ -678,7 +677,7 @@
if (lazyData.dynamicStamps == null) {
if (timestamp == null)
return;
- lazyData.dynamicStamps = new HashMap();
+ lazyData.dynamicStamps = new HashMap<String, Long>();
}
if (timestamp == null)
lazyData.dynamicStamps.remove(requestedPackage);
@@ -695,7 +694,7 @@
}
}
- HashMap getDynamicStamps() {
+ Map<String, Long> getDynamicStamps() {
LazyData currentData = loadLazyData();
synchronized (this.monitor) {
return currentData.dynamicStamps;
@@ -734,11 +733,11 @@
ExportPackageDescription[] substitutedExports;
String[] executionEnvironments;
- HashMap dynamicStamps;
+ Map<String, Long> dynamicStamps;
}
public Map<String, String> getDeclaredDirectives() {
- Map<String, String> result = new HashMap(2);
+ Map<String, String> result = new HashMap<String, String>(2);
if (!attachFragments()) {
result.put(Constants.FRAGMENT_ATTACHMENT_DIRECTIVE, Constants.FRAGMENT_ATTACHMENT_NEVER);
} else {
@@ -753,7 +752,7 @@
}
public Map<String, Object> getDeclaredAttributes() {
- Map<String, Object> result = new HashMap(1);
+ Map<String, Object> result = new HashMap<String, Object>(1);
result.put(Capability.BUNDLE_CAPABILITY, getName());
result.put(Constants.BUNDLE_VERSION_ATTRIBUTE, getVersion());
return Collections.unmodifiableMap(result);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.java
index fd91c05..ecc0680 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.java
@@ -93,7 +93,7 @@
*
* Element type: <code>Vertex</code>
*/
- public List adjacent = new ArrayList(3);
+ public List<Vertex> adjacent = new ArrayList<Vertex>(3);
/**
* Creates a new vertex with the given id.
@@ -110,14 +110,14 @@
*
* Element type: <code>Vertex</code>
*/
- private List vertexList = new ArrayList(100);
+ private List<Vertex> vertexList = new ArrayList<Vertex>(100);
/**
* Map from id to vertex.
*
* Key type: <code>Object</code>; value type: <code>Vertex</code>
*/
- private Map vertexMap = new HashMap(100);
+ private Map<Object, Vertex> vertexMap = new HashMap<Object, Vertex>(100);
/**
* DFS visit time. Non-negative.
@@ -201,8 +201,8 @@
if (initialized) {
throw new IllegalArgumentException();
}
- Vertex fromVertex = (Vertex) vertexMap.get(fromId);
- Vertex toVertex = (Vertex) vertexMap.get(toId);
+ Vertex fromVertex = vertexMap.get(fromId);
+ Vertex toVertex = vertexMap.get(toId);
// ignore edges when one of the vertices is unknown
if (fromVertex == null || toVertex == null)
return;
@@ -221,14 +221,14 @@
* (element type: <code>Object</code>)
* @exception IllegalArgumentException if the graph is not frozen
*/
- public List idsByDFSFinishTime(boolean increasing) {
+ public List<Object> idsByDFSFinishTime(boolean increasing) {
if (!initialized) {
throw new IllegalArgumentException();
}
int len = vertexList.size();
Object[] r = new Object[len];
- for (Iterator allV = vertexList.iterator(); allV.hasNext();) {
- Vertex vertex = (Vertex) allV.next();
+ for (Iterator<Vertex> allV = vertexList.iterator(); allV.hasNext();) {
+ Vertex vertex = allV.next();
int f = vertex.finishTime;
// note that finish times start at 1, not 0
if (increasing) {
@@ -264,15 +264,15 @@
* <code>Object[]</code>)
* @exception IllegalArgumentException if the graph is not frozen
*/
- public List nonTrivialComponents() {
+ public List<Object[]> nonTrivialComponents() {
if (!initialized) {
throw new IllegalArgumentException();
}
// find the roots of each component
// Map<Vertex,List<Object>> components
- Map components = new HashMap();
- for (Iterator it = vertexList.iterator(); it.hasNext();) {
- Vertex vertex = (Vertex) it.next();
+ Map<Vertex, List<Object>> components = new HashMap<Vertex, List<Object>>();
+ for (Iterator<Vertex> it = vertexList.iterator(); it.hasNext();) {
+ Vertex vertex = it.next();
if (vertex.predecessor == null) {
// this vertex is the root of a component
// if component is non-trivial we will hit a child
@@ -282,18 +282,18 @@
while (root.predecessor != null) {
root = root.predecessor;
}
- List component = (List) components.get(root);
+ List<Object> component = components.get(root);
if (component == null) {
- component = new ArrayList(2);
+ component = new ArrayList<Object>(2);
component.add(root.id);
components.put(root, component);
}
component.add(vertex.id);
}
}
- List result = new ArrayList(components.size());
- for (Iterator it = components.values().iterator(); it.hasNext();) {
- List component = (List) it.next();
+ List<Object[]> result = new ArrayList<Object[]>(components.size());
+ for (Iterator<List<Object>> it = components.values().iterator(); it.hasNext();) {
+ List<Object> component = it.next();
if (component.size() > 1) {
result.add(component.toArray());
}
@@ -369,10 +369,10 @@
// all vertex.predecessor initially null;
time = 0;
// for a stack, append to the end of an array-based list
- List stack = new ArrayList(Math.max(1, vertexList.size()));
- Iterator allAdjacent = null;
+ List<Object> stack = new ArrayList<Object>(Math.max(1, vertexList.size()));
+ Iterator<Vertex> allAdjacent = null;
Vertex vertex = null;
- Iterator allV = vertexList.iterator();
+ Iterator<Vertex> allV = vertexList.iterator();
state = NEXT_VERTEX;
nextStateLoop: while (true) {
switch (state) {
@@ -382,7 +382,7 @@
// all done
break nextStateLoop;
}
- Vertex nextVertex = (Vertex) allV.next();
+ Vertex nextVertex = allV.next();
if (nextVertex.color == Vertex.WHITE) {
stack.add(NEXT_VERTEX_OBJECT);
vertex = nextVertex;
@@ -403,7 +403,7 @@
// on entry, "allAdjacent" contains adjacent vertexes to
// be visited; "vertex" contains vertex being visited
if (allAdjacent.hasNext()) {
- Vertex adjVertex = (Vertex) allAdjacent.next();
+ Vertex adjVertex = allAdjacent.next();
if (adjVertex.color == Vertex.WHITE) {
// explore edge from vertex to adjVertex
adjVertex.predecessor = vertex;
@@ -430,7 +430,9 @@
case AFTER_NEXTED_DFS_VISIT :
// on entry, stack contains "vertex" and "allAjacent"
vertex = (Vertex) stack.remove(stack.size() - 1);
- allAdjacent = (Iterator) stack.remove(stack.size() - 1);
+ @SuppressWarnings("unchecked")
+ Iterator<Vertex> unchecked = (Iterator<Vertex>) stack.remove(stack.size() - 1);
+ allAdjacent = unchecked;
state = NEXT_ADJACENT;
continue nextStateLoop;
}
@@ -484,8 +486,8 @@
// interchange "to" and "from" to reverse edges from g1
final Digraph g2 = new Digraph();
// add vertexes
- List resortedVertexes = g1.idsByDFSFinishTime(false);
- for (Iterator it = resortedVertexes.iterator(); it.hasNext();)
+ List<Object> resortedVertexes = g1.idsByDFSFinishTime(false);
+ for (Iterator<Object> it = resortedVertexes.iterator(); it.hasNext();)
g2.addVertex(it.next());
// add edges
for (int i = 0; i < references.length; i++)
@@ -494,14 +496,14 @@
// Step 3: Return the vertexes in increasing order of depth-first finish
// time in g2
- List sortedProjectList = g2.idsByDFSFinishTime(true);
+ List<Object> sortedProjectList = g2.idsByDFSFinishTime(true);
Object[] orderedNodes = new Object[sortedProjectList.size()];
sortedProjectList.toArray(orderedNodes);
Object[][] knots;
boolean hasCycles = g2.containsCycles();
if (hasCycles) {
- List knotList = g2.nonTrivialComponents();
- knots = (Object[][]) knotList.toArray(new Object[knotList.size()][]);
+ List<Object[]> knotList = g2.nonTrivialComponents();
+ knots = knotList.toArray(new Object[knotList.size()][]);
} else {
knots = new Object[0][];
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java
index a4e9a53..334180e 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java
@@ -23,7 +23,7 @@
public static final String EQUINOX_EE = "x-equinox-ee"; //$NON-NLS-1$
private static final Integer EQUINOX_EE_DEFAULT = new Integer(-1);
private String[] uses;
- private Map attributes;
+ private Map<String, Object> attributes;
private volatile BundleDescription exporter;
private String exclude;
private String include;
@@ -33,9 +33,9 @@
private int equinox_ee = -1;
private volatile int tableIndex;
- public Map getDirectives() {
+ public Map<String, Object> getDirectives() {
synchronized (this.monitor) {
- Map result = new HashMap(7);
+ Map<String, Object> result = new HashMap<String, Object>(7);
if (uses != null)
result.put(Constants.USES_DIRECTIVE, uses);
if (exclude != null)
@@ -53,7 +53,7 @@
}
public Map<String, String> getDeclaredDirectives() {
- Map<String, String> result = new HashMap(6);
+ Map<String, String> result = new HashMap<String, String>(6);
synchronized (this.monitor) {
if (uses != null)
result.put(Constants.USES_DIRECTIVE, toString(uses));
@@ -72,7 +72,7 @@
}
public Map<String, Object> getDeclaredAttributes() {
- Map<String, Object> result = new HashMap(2);
+ Map<String, Object> result = new HashMap<String, Object>(2);
synchronized (this.monitor) {
if (attributes != null)
result.putAll(attributes);
@@ -139,7 +139,7 @@
}
}
- public void setDirectives(Map directives) {
+ public void setDirectives(Map<String, ?> directives) {
synchronized (this.monitor) {
if (directives == null)
return;
@@ -153,7 +153,7 @@
}
}
- public Map getAttributes() {
+ public Map<String, Object> getAttributes() {
synchronized (this.monitor) {
return attributes;
}
@@ -174,9 +174,10 @@
return true;
}
- protected void setAttributes(Map attributes) {
+ @SuppressWarnings("unchecked")
+ protected void setAttributes(Map<String, ?> attributes) {
synchronized (this.monitor) {
- this.attributes = attributes;
+ this.attributes = (Map<String, Object>) attributes;
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java
index 0dc1bcc..b53c563 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java
@@ -18,12 +18,12 @@
import org.osgi.framework.Version;
public class GenericDescriptionImpl extends BaseDescriptionImpl implements GenericDescription {
- private Dictionary attributes;
+ private Dictionary<String, Object> attributes;
private volatile BundleDescription supplier;
private volatile String type = GenericDescription.DEFAULT_TYPE;
private Map<String, String> directives;
- public Dictionary getAttributes() {
+ public Dictionary<String, Object> getAttributes() {
synchronized (this.monitor) {
return attributes;
}
@@ -33,7 +33,7 @@
return supplier;
}
- void setAttributes(Dictionary attributes) {
+ void setAttributes(Dictionary<String, Object> attributes) {
synchronized (this.monitor) {
this.attributes = attributes;
}
@@ -52,7 +52,7 @@
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(Constants.PROVIDE_CAPABILITY).append(": ").append(getType()); //$NON-NLS-1$
- Map attrs = getDeclaredAttributes();
+ Map<String, Object> attrs = getDeclaredAttributes();
sb.append(toString(attrs, false));
return sb.toString();
}
@@ -86,6 +86,7 @@
return version instanceof Version ? (Version) version : super.getVersion();
}
+ @SuppressWarnings("unchecked")
public Map<String, String> getDeclaredDirectives() {
synchronized (this.monitor) {
if (directives == null)
@@ -96,13 +97,13 @@
public Map<String, Object> getDeclaredAttributes() {
synchronized (this.monitor) {
- Map<String, Object> result = new HashMap(5);
+ Map<String, Object> result = new HashMap<String, Object>(5);
if (attributes != null)
- for (Enumeration keys = attributes.keys(); keys.hasMoreElements();) {
- String key = (String) keys.nextElement();
+ for (Enumeration<String> keys = attributes.keys(); keys.hasMoreElements();) {
+ String key = keys.nextElement();
Object value = attributes.get(key);
if (value instanceof List)
- value = Collections.unmodifiableList((List) value);
+ value = Collections.unmodifiableList((List<Object>) value);
result.put(key, value);
}
return Collections.unmodifiableMap(result);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
index 55092c8..edf3107 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
@@ -20,11 +20,11 @@
private String resolution = ImportPackageSpecification.RESOLUTION_STATIC; // the default is static
private String symbolicName;
private VersionRange bundleVersionRange;
- private Map attributes;
+ private Map<String, Object> attributes;
- public Map getDirectives() {
+ public Map<String, Object> getDirectives() {
synchronized (this.monitor) {
- Map result = new HashMap(5);
+ Map<String, Object> result = new HashMap<String, Object>(5);
if (resolution != null)
result.put(Constants.RESOLUTION_DIRECTIVE, resolution);
return result;
@@ -47,7 +47,7 @@
}
}
- public void setDirectives(Map directives) {
+ public void setDirectives(Map<String, ?> directives) {
synchronized (this.monitor) {
if (directives == null)
return;
@@ -73,7 +73,7 @@
}
}
- public Map getAttributes() {
+ public Map<String, Object> getAttributes() {
synchronized (this.monitor) {
return attributes;
}
@@ -120,13 +120,13 @@
if (getVersionRange() != null && !getVersionRange().isIncluded(pkgDes.getVersion()))
return false;
- Map importAttrs = getAttributes();
+ Map<String, ?> importAttrs = getAttributes();
if (importAttrs != null) {
- Map exportAttrs = pkgDes.getAttributes();
+ Map<String, ?> exportAttrs = pkgDes.getAttributes();
if (exportAttrs == null)
return false;
- for (Iterator i = importAttrs.keySet().iterator(); i.hasNext();) {
- String importKey = (String) i.next();
+ for (Iterator<String> i = importAttrs.keySet().iterator(); i.hasNext();) {
+ String importKey = i.next();
Object importValue = importAttrs.get(importKey);
Object exportValue = exportAttrs.get(importKey);
if (exportValue == null || !importValue.equals(exportValue))
@@ -172,9 +172,10 @@
}
}
- protected void setAttributes(Map attributes) {
+ @SuppressWarnings("unchecked")
+ protected void setAttributes(Map<String, ?> attributes) {
synchronized (this.monitor) {
- this.attributes = attributes;
+ this.attributes = (Map<String, Object>) attributes;
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
index f31c7d8..e6d90a2 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
@@ -82,7 +82,7 @@
State containingState = getSupplier().getContainingState();
if (containingState == null)
return 0;
- Dictionary[] platformProps = containingState.getPlatformProperties();
+ Dictionary<Object, Object>[] platformProps = containingState.getPlatformProperties();
Version osversion;
try {
osversion = Version.parseVersion((String) platformProps[0].get(Constants.FRAMEWORK_OS_VERSION));
@@ -208,10 +208,12 @@
this.supplier = supplier;
}
+ @SuppressWarnings("unchecked")
public Map<String, String> getDeclaredDirectives() {
return Collections.EMPTY_MAP;
}
+ @SuppressWarnings("unchecked")
public Map<String, Object> getDeclaredAttributes() {
return Collections.EMPTY_MAP;
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java
index b2401f8..9a808e8 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java
@@ -56,12 +56,14 @@
State containingState = getBundle().getContainingState();
if (containingState == null)
return false;
- Dictionary[] platformProps = containingState.getPlatformProperties();
+ Dictionary<Object, Object>[] platformProps = containingState.getPlatformProperties();
NativeCodeDescription nativeSupplier = (NativeCodeDescription) supplier;
Filter filter = nativeSupplier.getFilter();
boolean match = false;
for (int i = 0; i < platformProps.length && !match; i++) {
- if (filter != null && !filter.matchCase(platformProps[i]))
+ @SuppressWarnings("rawtypes")
+ Dictionary props = platformProps[i];
+ if (filter != null && !filter.matchCase(props))
continue;
String[] osNames = nativeSupplier.getOSNames();
if (osNames.length == 0)
@@ -71,7 +73,7 @@
Object aliasedPlatformOS = platformOS == null || !(platformOS instanceof String) ? platformOS : aliasMapper.aliasOSName((String) platformOS);
Object[] platformOSes;
if (aliasedPlatformOS instanceof Collection)
- platformOSes = ((Collection) aliasedPlatformOS).toArray();
+ platformOSes = ((Collection<?>) aliasedPlatformOS).toArray();
else
platformOSes = aliasedPlatformOS == null ? new Object[0] : new Object[] {aliasedPlatformOS};
for (int j = 0; j < osNames.length && !match; j++) {
@@ -81,7 +83,7 @@
if (platformOSes[k].equals(aliasedName))
match = true;
} else {
- for (Iterator iAliases = ((Collection) aliasedName).iterator(); iAliases.hasNext() && !match;)
+ for (Iterator<?> iAliases = ((Collection<?>) aliasedName).iterator(); iAliases.hasNext() && !match;)
if (platformOSes[k].equals(iAliases.next()))
match = true;
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ReadOnlyState.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ReadOnlyState.java
index 03639c8..b252ea6 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ReadOnlyState.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/ReadOnlyState.java
@@ -142,15 +142,15 @@
throw new UnsupportedOperationException();
}
- public boolean setPlatformProperties(Dictionary platformProperties) {
+ public boolean setPlatformProperties(Dictionary<?, ?> platformProperties) {
throw new UnsupportedOperationException();
}
- public boolean setPlatformProperties(Dictionary platformProperties[]) {
+ public boolean setPlatformProperties(Dictionary<?, ?> platformProperties[]) {
throw new UnsupportedOperationException();
}
- public Dictionary[] getPlatformProperties() {
+ public Dictionary<Object, Object>[] getPlatformProperties() {
return target.getPlatformProperties();
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
index 3f5511d..2b762bb 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
@@ -40,9 +40,9 @@
private static final String MULTIPLE_ATTR = "multiple"; //$NON-NLS-1$
private static final String TRUE = "true"; //$NON-NLS-1$
- static BundleDescription createBundleDescription(StateImpl state, Dictionary manifest, String location) throws BundleException {
+ static BundleDescription createBundleDescription(StateImpl state, Dictionary<String, String> manifest, String location) throws BundleException {
BundleDescriptionImpl result = new BundleDescriptionImpl();
- String manifestVersionHeader = (String) manifest.get(Constants.BUNDLE_MANIFESTVERSION);
+ String manifestVersionHeader = manifest.get(Constants.BUNDLE_MANIFESTVERSION);
boolean jreBundle = "true".equals(manifest.get(Constants.Eclipse_JREBUNDLE)); //$NON-NLS-1$
int manifestVersion = 1;
if (manifestVersionHeader != null)
@@ -51,7 +51,7 @@
validateHeaders(manifest, jreBundle);
// retrieve the symbolic-name and the singleton status
- String symbolicNameHeader = (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME);
+ String symbolicNameHeader = manifest.get(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicNameHeader != null) {
ManifestElement[] symbolicNameElements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, symbolicNameHeader);
if (symbolicNameElements.length > 0) {
@@ -73,7 +73,7 @@
}
}
// retrieve other headers
- String version = (String) manifest.get(Constants.BUNDLE_VERSION);
+ String version = manifest.get(Constants.BUNDLE_VERSION);
try {
result.setVersion((version != null) ? Version.parseVersion(version) : Version.emptyVersion);
} catch (IllegalArgumentException ex) {
@@ -85,40 +85,40 @@
// must not fail for old R3 style bundles
}
result.setLocation(location);
- result.setPlatformFilter((String) manifest.get(Constants.ECLIPSE_PLATFORMFILTER));
- result.setExecutionEnvironments(ManifestElement.getArrayFromList((String) manifest.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)));
- ManifestElement[] host = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, (String) manifest.get(Constants.FRAGMENT_HOST));
+ result.setPlatformFilter(manifest.get(Constants.ECLIPSE_PLATFORMFILTER));
+ result.setExecutionEnvironments(ManifestElement.getArrayFromList(manifest.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)));
+ ManifestElement[] host = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, manifest.get(Constants.FRAGMENT_HOST));
if (host != null)
result.setHost(createHostSpecification(host[0], state));
- ManifestElement[] exports = ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, (String) manifest.get(Constants.EXPORT_PACKAGE));
- ManifestElement[] provides = ManifestElement.parseHeader(Constants.PROVIDE_PACKAGE, (String) manifest.get(Constants.PROVIDE_PACKAGE));
+ ManifestElement[] exports = ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE));
+ ManifestElement[] provides = ManifestElement.parseHeader(Constants.PROVIDE_PACKAGE, manifest.get(Constants.PROVIDE_PACKAGE));
boolean strict = state != null && state.inStrictMode();
- ArrayList providedExports = new ArrayList(provides == null ? 0 : provides.length);
+ List<String> providedExports = new ArrayList<String>(provides == null ? 0 : provides.length);
result.setExportPackages(createExportPackages(exports, provides, providedExports, manifestVersion, strict));
- ManifestElement[] imports = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, (String) manifest.get(Constants.IMPORT_PACKAGE));
- ManifestElement[] dynamicImports = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE, (String) manifest.get(Constants.DYNAMICIMPORT_PACKAGE));
+ ManifestElement[] imports = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, manifest.get(Constants.IMPORT_PACKAGE));
+ ManifestElement[] dynamicImports = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE, manifest.get(Constants.DYNAMICIMPORT_PACKAGE));
result.setImportPackages(createImportPackages(result.getExportPackages(), providedExports, imports, dynamicImports, manifestVersion));
- ManifestElement[] requires = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, (String) manifest.get(Constants.REQUIRE_BUNDLE));
+ ManifestElement[] requires = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, manifest.get(Constants.REQUIRE_BUNDLE));
result.setRequiredBundles(createRequiredBundles(requires));
String[][] genericAliases = getGenericAliases(state);
ManifestElement[] genericRequires = getGenericRequires(manifest, genericAliases);
- ManifestElement[] osgiRequires = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, (String) manifest.get(Constants.REQUIRE_CAPABILITY));
+ ManifestElement[] osgiRequires = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, manifest.get(Constants.REQUIRE_CAPABILITY));
result.setGenericRequires(createGenericRequires(genericRequires, osgiRequires));
ManifestElement[] genericCapabilities = getGenericCapabilities(manifest, genericAliases);
- ManifestElement[] osgiCapabilities = ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) manifest.get(Constants.PROVIDE_CAPABILITY));
+ ManifestElement[] osgiCapabilities = ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, manifest.get(Constants.PROVIDE_CAPABILITY));
result.setGenericCapabilities(createGenericCapabilities(genericCapabilities, osgiCapabilities));
- ManifestElement[] nativeCode = ManifestElement.parseHeader(Constants.BUNDLE_NATIVECODE, (String) manifest.get(Constants.BUNDLE_NATIVECODE));
+ ManifestElement[] nativeCode = ManifestElement.parseHeader(Constants.BUNDLE_NATIVECODE, manifest.get(Constants.BUNDLE_NATIVECODE));
result.setNativeCodeSpecification(createNativeCode(nativeCode));
return result;
}
- private static ManifestElement[] getGenericRequires(Dictionary manifest, String[][] genericAliases) throws BundleException {
- ManifestElement[] genericRequires = ManifestElement.parseHeader(GENERIC_REQUIRE, (String) manifest.get(GENERIC_REQUIRE));
- ArrayList aliasList = null;
+ private static ManifestElement[] getGenericRequires(Dictionary<String, String> manifest, String[][] genericAliases) throws BundleException {
+ ManifestElement[] genericRequires = ManifestElement.parseHeader(GENERIC_REQUIRE, manifest.get(GENERIC_REQUIRE));
+ List<ManifestElement> aliasList = null;
if (genericAliases.length > 0) {
- aliasList = new ArrayList(genericRequires == null ? 0 : genericRequires.length);
+ aliasList = new ArrayList<ManifestElement>(genericRequires == null ? 0 : genericRequires.length);
for (int i = 0; i < genericAliases.length; i++) {
- ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAliases[i][1], (String) manifest.get(genericAliases[i][1]));
+ ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAliases[i][1], manifest.get(genericAliases[i][1]));
if (aliasReqs == null)
continue;
for (int j = 0; j < aliasReqs.length; j++) {
@@ -137,23 +137,23 @@
if (genericRequires != null)
for (int i = 0; i < genericRequires.length; i++)
aliasList.add(genericRequires[i]);
- return (ManifestElement[]) aliasList.toArray(new ManifestElement[aliasList.size()]);
+ return aliasList.toArray(new ManifestElement[aliasList.size()]);
}
- private static ManifestElement[] getGenericCapabilities(Dictionary manifest, String[][] genericAliases) throws BundleException {
- ManifestElement[] genericCapabilities = ManifestElement.parseHeader(GENERIC_CAPABILITY, (String) manifest.get(GENERIC_CAPABILITY));
- ArrayList aliasList = null;
+ private static ManifestElement[] getGenericCapabilities(Dictionary<String, String> manifest, String[][] genericAliases) throws BundleException {
+ ManifestElement[] genericCapabilities = ManifestElement.parseHeader(GENERIC_CAPABILITY, manifest.get(GENERIC_CAPABILITY));
+ List<ManifestElement> aliasList = null;
if (genericAliases.length > 0) {
- aliasList = new ArrayList(genericCapabilities == null ? 0 : genericCapabilities.length);
+ aliasList = new ArrayList<ManifestElement>(genericCapabilities == null ? 0 : genericCapabilities.length);
for (int i = 0; i < genericAliases.length; i++) {
- ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAliases[i][0], (String) manifest.get(genericAliases[i][0]));
+ ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAliases[i][0], manifest.get(genericAliases[i][0]));
if (aliasCapabilities == null)
continue;
for (int j = 0; j < aliasCapabilities.length; j++) {
StringBuffer strBuf = new StringBuffer();
strBuf.append(aliasCapabilities[j].getValue()).append(':').append(genericAliases[i][2]);
- for (Enumeration keys = aliasCapabilities[j].getKeys(); keys != null && keys.hasMoreElements();) {
- String key = (String) keys.nextElement();
+ for (Enumeration<String> keys = aliasCapabilities[j].getKeys(); keys != null && keys.hasMoreElements();) {
+ String key = keys.nextElement();
strBuf.append("; ").append(key).append("=\"").append(aliasCapabilities[j].getAttribute(key)).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
ManifestElement[] withTypes = ManifestElement.parseHeader(genericAliases[i][0], strBuf.toString());
@@ -166,7 +166,7 @@
if (genericCapabilities != null)
for (int i = 0; i < genericCapabilities.length; i++)
aliasList.add(genericCapabilities[i]);
- return (ManifestElement[]) aliasList.toArray(new ManifestElement[aliasList.size()]);
+ return aliasList.toArray(new ManifestElement[aliasList.size()]);
}
private static String[][] getGenericAliases(StateImpl state) {
@@ -181,13 +181,13 @@
}
private static String getPlatformProperty(StateImpl state, String key) {
- Dictionary[] platformProps = state == null ? null : state.getPlatformProperties();
+ Dictionary<Object, Object>[] platformProps = state == null ? null : state.getPlatformProperties();
return platformProps == null || platformProps.length == 0 ? null : (String) platformProps[0].get(key);
}
- private static void validateHeaders(Dictionary manifest, boolean jreBundle) throws BundleException {
+ private static void validateHeaders(Dictionary<String, String> manifest, boolean jreBundle) throws BundleException {
for (int i = 0; i < DEFINED_OSGI_VALIDATE_HEADERS.length; i++) {
- String header = (String) manifest.get(DEFINED_OSGI_VALIDATE_HEADERS[i]);
+ String header = manifest.get(DEFINED_OSGI_VALIDATE_HEADERS[i]);
if (header != null) {
ManifestElement[] elements = ManifestElement.parseHeader(DEFINED_OSGI_VALIDATE_HEADERS[i], header);
checkForDuplicateDirectivesAttributes(DEFINED_OSGI_VALIDATE_HEADERS[i], elements);
@@ -223,13 +223,13 @@
return result;
}
- private static ImportPackageSpecification[] createImportPackages(ExportPackageDescription[] exported, ArrayList providedExports, ManifestElement[] imported, ManifestElement[] dynamicImported, int manifestVersion) {
- ArrayList allImports = null;
+ private static ImportPackageSpecification[] createImportPackages(ExportPackageDescription[] exported, List<String> providedExports, ManifestElement[] imported, ManifestElement[] dynamicImported, int manifestVersion) {
+ List<ImportPackageSpecification> allImports = null;
if (manifestVersion < 2) {
// add implicit imports for each exported package if manifest verions is less than 2.
if (exported.length == 0 && imported == null && dynamicImported == null)
return null;
- allImports = new ArrayList(exported.length + (imported == null ? 0 : imported.length));
+ allImports = new ArrayList<ImportPackageSpecification>(exported.length + (imported == null ? 0 : imported.length));
for (int i = 0; i < exported.length; i++) {
if (providedExports.contains(exported[i].getName()))
continue;
@@ -240,7 +240,7 @@
allImports.add(result);
}
} else {
- allImports = new ArrayList(imported == null ? 0 : imported.length);
+ allImports = new ArrayList<ImportPackageSpecification>(imported == null ? 0 : imported.length);
}
// add dynamics first so they will get overriden by static imports if
@@ -251,17 +251,17 @@
if (imported != null)
for (int i = 0; i < imported.length; i++)
addImportPackages(imported[i], allImports, manifestVersion, false);
- return (ImportPackageSpecification[]) allImports.toArray(new ImportPackageSpecification[allImports.size()]);
+ return allImports.toArray(new ImportPackageSpecification[allImports.size()]);
}
- private static void addImportPackages(ManifestElement importPackage, ArrayList allImports, int manifestVersion, boolean dynamic) {
+ private static void addImportPackages(ManifestElement importPackage, List<ImportPackageSpecification> allImports, int manifestVersion, boolean dynamic) {
String[] importNames = importPackage.getValueComponents();
for (int i = 0; i < importNames.length; i++) {
// do not allow for multiple imports of same package of manifest version < 2
if (manifestVersion < 2) {
- Iterator iter = allImports.iterator();
+ Iterator<ImportPackageSpecification> iter = allImports.iterator();
while (iter.hasNext())
- if (importNames[i].equals(((ImportPackageSpecification) iter.next()).getName()))
+ if (importNames[i].equals(iter.next().getName()))
iter.remove();
}
@@ -294,20 +294,20 @@
return result;
}
- static ExportPackageDescription[] createExportPackages(ManifestElement[] exported, ManifestElement[] provides, ArrayList providedExports, int manifestVersion, boolean strict) {
+ static ExportPackageDescription[] createExportPackages(ManifestElement[] exported, ManifestElement[] provides, List<String> providedExports, int manifestVersion, boolean strict) {
int numExports = (exported == null ? 0 : exported.length) + (provides == null ? 0 : provides.length);
if (numExports == 0)
return null;
- ArrayList allExports = new ArrayList(numExports);
+ List<ExportPackageDescription> allExports = new ArrayList<ExportPackageDescription>(numExports);
if (exported != null)
for (int i = 0; i < exported.length; i++)
addExportPackages(exported[i], allExports, manifestVersion, strict);
if (provides != null)
addProvidePackages(provides, allExports, providedExports);
- return (ExportPackageDescription[]) allExports.toArray(new ExportPackageDescription[allExports.size()]);
+ return allExports.toArray(new ExportPackageDescription[allExports.size()]);
}
- private static void addExportPackages(ManifestElement exportPackage, ArrayList allExports, int manifestVersion, boolean strict) {
+ private static void addExportPackages(ManifestElement exportPackage, List<ExportPackageDescription> allExports, int manifestVersion, boolean strict) {
String[] exportNames = exportPackage.getValueComponents();
for (int i = 0; i < exportNames.length; i++) {
// if we are in strict mode and the package is marked as internal, skip it.
@@ -331,8 +331,8 @@
}
}
- private static void addProvidePackages(ManifestElement[] provides, ArrayList allExports, ArrayList providedExports) {
- ExportPackageDescription[] currentExports = (ExportPackageDescription[]) allExports.toArray(new ExportPackageDescription[allExports.size()]);
+ private static void addProvidePackages(ManifestElement[] provides, List<ExportPackageDescription> allExports, List<String> providedExports) {
+ ExportPackageDescription[] currentExports = allExports.toArray(new ExportPackageDescription[allExports.size()]);
for (int i = 0; i < provides.length; i++) {
boolean duplicate = false;
for (int j = 0; j < currentExports.length; j++)
@@ -349,14 +349,14 @@
}
}
- private static Map getAttributes(ManifestElement element, String[] definedAttrs) {
- Enumeration keys = element.getKeys();
- Map arbitraryAttrs = null;
+ private static Map<String, Object> getAttributes(ManifestElement element, String[] definedAttrs) {
+ Enumeration<String> keys = element.getKeys();
+ Map<String, Object> arbitraryAttrs = null;
if (keys == null)
return null;
while (keys.hasMoreElements()) {
boolean definedAttr = false;
- String key = (String) keys.nextElement();
+ String key = keys.nextElement();
for (int i = 0; i < definedAttrs.length; i++) {
if (definedAttrs[i].equals(key)) {
definedAttr = true;
@@ -372,7 +372,7 @@
}
if (!definedAttr) {
if (arbitraryAttrs == null)
- arbitraryAttrs = new HashMap();
+ arbitraryAttrs = new HashMap<String, Object>();
arbitraryAttrs.put(key, convertValue(type, value));
}
}
@@ -391,8 +391,8 @@
return new Long(value);
else if (ATTR_TYPE_URI.equalsIgnoreCase(type))
try {
- Class uriClazz = Class.forName("java.net.URI"); //$NON-NLS-1$
- Constructor constructor = uriClazz.getConstructor(new Class[] {String.class});
+ Class<?> uriClazz = Class.forName("java.net.URI"); //$NON-NLS-1$
+ Constructor<?> constructor = uriClazz.getConstructor(new Class[] {String.class});
return constructor.newInstance(new Object[] {value});
} catch (ClassNotFoundException e) {
// oh well cannot support; just use string
@@ -535,14 +535,14 @@
break types; // ignore any namespace that is not effective at resolve time.
GenericDescriptionImpl desc = new GenericDescriptionImpl();
desc.setType(namespace);
- Map mapAttrs = getAttributes(element, new String[0]);
- Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable(mapAttrs);
+ Map<String, Object> mapAttrs = getAttributes(element, new String[0]);
+ Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(mapAttrs);
desc.setAttributes(attrs);
- Map<String, String> directives = new HashMap();
- Enumeration keys = element.getDirectiveKeys();
+ Map<String, String> directives = new HashMap<String, String>();
+ Enumeration<String> keys = element.getDirectiveKeys();
if (keys != null)
for (keys = element.getDirectiveKeys(); keys.hasMoreElements();) {
- String key = (String) keys.nextElement();
+ String key = keys.nextElement();
directives.put(key, element.getDirective(key));
}
desc.setDirectives(directives);
@@ -555,7 +555,7 @@
private static List<GenericDescription> createEquinoxCapabilities(ManifestElement[] equinoxCapabilities) {
if (equinoxCapabilities == null)
return null;
- ArrayList<GenericDescription> results = new ArrayList(equinoxCapabilities.length);
+ ArrayList<GenericDescription> results = new ArrayList<GenericDescription>(equinoxCapabilities.length);
for (int i = 0; i < equinoxCapabilities.length; i++) {
String[] genericNames = equinoxCapabilities[i].getValueComponents();
for (int j = 0; j < genericNames.length; j++) {
@@ -566,8 +566,8 @@
name = genericNames[j].substring(0, colonIdx);
desc.setType(genericNames[j].substring(colonIdx + 1));
}
- Map mapAttrs = getAttributes(equinoxCapabilities[i], new String[] {Constants.VERSION_ATTRIBUTE});
- Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable(mapAttrs);
+ Map<String, Object> mapAttrs = getAttributes(equinoxCapabilities[i], new String[] {Constants.VERSION_ATTRIBUTE});
+ Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(mapAttrs);
attrs.put(desc.getType(), name);
String versionString = equinoxCapabilities[i].getAttribute(Constants.VERSION_ATTRIBUTE);
if (versionString != null)
@@ -633,7 +633,7 @@
if (elements == null)
return;
int length = elements.length;
- Set packages = new HashSet(length);
+ Set<String> packages = new HashSet<String>(length);
for (int i = 0; i < length; i++) {
// check for duplicate imports
String[] packageNames = elements[i].getValueComponents();
@@ -674,10 +674,10 @@
private static void checkForDuplicateDirectivesAttributes(String headerKey, ManifestElement[] elements) throws BundleException {
// check for duplicate directives
for (int i = 0; i < elements.length; i++) {
- Enumeration directiveKeys = elements[i].getDirectiveKeys();
+ Enumeration<String> directiveKeys = elements[i].getDirectiveKeys();
if (directiveKeys != null) {
while (directiveKeys.hasMoreElements()) {
- String key = (String) directiveKeys.nextElement();
+ String key = directiveKeys.nextElement();
String[] directives = elements[i].getDirectives(key);
if (directives.length > 1) {
String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString());
@@ -685,10 +685,10 @@
}
}
}
- Enumeration attrKeys = elements[i].getKeys();
+ Enumeration<String> attrKeys = elements[i].getKeys();
if (attrKeys != null) {
while (attrKeys.hasMoreElements()) {
- String key = (String) attrKeys.nextElement();
+ String key = attrKeys.nextElement();
String[] attrs = elements[i].getAttributes(key);
if (attrs.length > 1) {
String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString());
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java
index cf06fdd..846b03d 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java
@@ -22,7 +22,7 @@
private final State state;
- private final Map changes = new HashMap();
+ private final Map<BundleDescription, BundleDelta> changes = new HashMap<BundleDescription, BundleDelta>();
public StateDeltaImpl(State state) {
this.state = state;
@@ -30,19 +30,19 @@
public BundleDelta[] getChanges() {
synchronized (this.changes) {
- return (BundleDelta[]) changes.values().toArray(new BundleDelta[changes.size()]);
+ return changes.values().toArray(new BundleDelta[changes.size()]);
}
}
public BundleDelta[] getChanges(int mask, boolean exact) {
synchronized (this.changes) {
- List result = new ArrayList();
- for (Iterator changesIter = changes.values().iterator(); changesIter.hasNext();) {
- BundleDelta change = (BundleDelta) changesIter.next();
+ List<BundleDelta> result = new ArrayList<BundleDelta>();
+ for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) {
+ BundleDelta change = changesIter.next();
if (mask == change.getType() || (!exact && (change.getType() & mask) != 0))
result.add(change);
}
- return (BundleDelta[]) result.toArray(new BundleDelta[result.size()]);
+ return result.toArray(new BundleDelta[result.size()]);
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index e4ee07b..36e1a3b 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -30,16 +30,16 @@
if (bundles == null || bundles.length == 0)
return new BundleDescription[0];
- Set reachable = new HashSet(bundles.length);
+ Set<BundleDescription> reachable = new HashSet<BundleDescription>(bundles.length);
for (int i = 0; i < bundles.length; i++) {
if (!bundles[i].isResolved())
continue;
addDependentBundles(bundles[i], reachable);
}
- return (BundleDescription[]) reachable.toArray(new BundleDescription[reachable.size()]);
+ return reachable.toArray(new BundleDescription[reachable.size()]);
}
- private void addDependentBundles(BundleDescription bundle, Set reachable) {
+ private void addDependentBundles(BundleDescription bundle, Set<BundleDescription> reachable) {
if (reachable.contains(bundle))
return;
reachable.add(bundle);
@@ -51,32 +51,32 @@
public BundleDescription[] getPrerequisites(BundleDescription[] bundles) {
if (bundles == null || bundles.length == 0)
return new BundleDescription[0];
- Set reachable = new HashSet(bundles.length);
+ Set<BundleDescription> reachable = new HashSet<BundleDescription>(bundles.length);
for (int i = 0; i < bundles.length; i++)
addPrerequisites(bundles[i], reachable);
- return (BundleDescription[]) reachable.toArray(new BundleDescription[reachable.size()]);
+ return reachable.toArray(new BundleDescription[reachable.size()]);
}
- private void addPrerequisites(BundleDescription bundle, Set reachable) {
+ private void addPrerequisites(BundleDescription bundle, Set<BundleDescription> reachable) {
if (reachable.contains(bundle))
return;
reachable.add(bundle);
- List depList = ((BundleDescriptionImpl) bundle).getBundleDependencies();
- BundleDescription[] dependencies = (BundleDescription[]) depList.toArray(new BundleDescription[depList.size()]);
+ List<BundleDescription> depList = ((BundleDescriptionImpl) bundle).getBundleDependencies();
+ BundleDescription[] dependencies = depList.toArray(new BundleDescription[depList.size()]);
for (int i = 0; i < dependencies.length; i++)
addPrerequisites(dependencies[i], reachable);
}
- private Map getExportedPackageMap(State state) {
- Map result = new HashMap(11);
+ private Map<String, Set<ExportPackageDescription>> getExportedPackageMap(State state) {
+ Map<String, Set<ExportPackageDescription>> result = new HashMap<String, Set<ExportPackageDescription>>(11);
BundleDescription[] bundles = state.getBundles();
for (int i = 0; i < bundles.length; i++) {
ExportPackageDescription[] packages = bundles[i].getExportPackages();
for (int j = 0; j < packages.length; j++) {
ExportPackageDescription description = packages[j];
- Set exports = (Set) result.get(description.getName());
+ Set<ExportPackageDescription> exports = result.get(description.getName());
if (exports == null) {
- exports = new HashSet(1);
+ exports = new HashSet<ExportPackageDescription>(1);
result.put(description.getName(), exports);
}
exports.add(description);
@@ -85,8 +85,8 @@
return result;
}
- private Map getGenericsMap(State state, boolean resolved) {
- Map result = new HashMap(11);
+ private Map<String, Set<GenericDescription>> getGenericsMap(State state, boolean resolved) {
+ Map<String, Set<GenericDescription>> result = new HashMap<String, Set<GenericDescription>>(11);
BundleDescription[] bundles = state.getBundles();
for (int i = 0; i < bundles.length; i++) {
if (resolved && !bundles[i].isResolved())
@@ -94,9 +94,9 @@
GenericDescription[] generics = bundles[i].getGenericCapabilities();
for (int j = 0; j < generics.length; j++) {
GenericDescription description = generics[j];
- Set genericSet = (Set) result.get(description.getName());
+ Set<GenericDescription> genericSet = result.get(description.getName());
if (genericSet == null) {
- genericSet = new HashSet(1);
+ genericSet = new HashSet<GenericDescription>(1);
result.put(description.getName(), genericSet);
}
genericSet.add(description);
@@ -106,14 +106,14 @@
}
private VersionConstraint[] getUnsatisfiedLeaves(State state, BundleDescription[] bundles) {
- Map packages = getExportedPackageMap(state);
- Map generics = getGenericsMap(state, false);
- HashSet result = new HashSet(11);
- ArrayList bundleList = new ArrayList(bundles.length);
+ Map<String, Set<ExportPackageDescription>> packages = getExportedPackageMap(state);
+ Map<String, Set<GenericDescription>> generics = getGenericsMap(state, false);
+ Set<VersionConstraint> result = new HashSet<VersionConstraint>(11);
+ List<BundleDescription> bundleList = new ArrayList<BundleDescription>(bundles.length);
for (int i = 0; i < bundles.length; i++)
bundleList.add(bundles[i]);
for (int i = 0; i < bundleList.size(); i++) {
- BundleDescription description = (BundleDescription) bundleList.get(i);
+ BundleDescription description = bundleList.get(i);
VersionConstraint[] constraints = getUnsatisfiedConstraints(description);
for (int j = 0; j < constraints.length; j++) {
VersionConstraint constraint = constraints[j];
@@ -123,17 +123,17 @@
for (int k = 0; k < suppliers.length && satisfied == null; k++)
satisfied = constraint.isSatisfiedBy(suppliers[k]) ? suppliers[k] : null;
} else if (constraint instanceof ImportPackageSpecification) {
- Set exports = (Set) packages.get(constraint.getName());
+ Set<ExportPackageDescription> exports = packages.get(constraint.getName());
if (exports != null)
- for (Iterator iter = exports.iterator(); iter.hasNext() && satisfied == null;) {
- ExportPackageDescription exportDesc = (ExportPackageDescription) iter.next();
+ for (Iterator<ExportPackageDescription> iter = exports.iterator(); iter.hasNext() && satisfied == null;) {
+ ExportPackageDescription exportDesc = iter.next();
satisfied = constraint.isSatisfiedBy(exportDesc) ? exportDesc : null;
}
} else if (constraint instanceof GenericSpecification) {
- Set genericSet = (Set) generics.get(constraint.getName());
+ Set<GenericDescription> genericSet = generics.get(constraint.getName());
if (genericSet != null)
- for (Iterator iter = genericSet.iterator(); iter.hasNext() && satisfied == null;) {
- GenericDescription genDesc = (GenericDescription) iter.next();
+ for (Iterator<GenericDescription> iter = genericSet.iterator(); iter.hasNext() && satisfied == null;) {
+ GenericDescription genDesc = iter.next();
satisfied = constraint.isSatisfiedBy(genDesc) ? genDesc : null;
}
}
@@ -143,7 +143,7 @@
bundleList.add(satisfied.getSupplier());
}
}
- return (VersionConstraint[]) result.toArray(new VersionConstraint[result.size()]);
+ return result.toArray(new VersionConstraint[result.size()]);
}
@@ -162,7 +162,7 @@
if (containingState == null)
// it is a bug in the client to call this method when not attached to a state
throw new IllegalStateException("Does not belong to a state"); //$NON-NLS-1$
- List unsatisfied = new ArrayList();
+ List<VersionConstraint> unsatisfied = new ArrayList<VersionConstraint>();
HostSpecification host = bundle.getHost();
if (host != null)
if (!host.isResolved() && !isResolvable(host))
@@ -182,7 +182,7 @@
NativeCodeSpecification nativeCode = bundle.getNativeCodeSpecification();
if (nativeCode != null && !nativeCode.isResolved())
unsatisfied.add(nativeCode);
- return (VersionConstraint[]) unsatisfied.toArray(new VersionConstraint[unsatisfied.size()]);
+ return unsatisfied.toArray(new VersionConstraint[unsatisfied.size()]);
}
/**
@@ -197,12 +197,12 @@
}
private boolean isResolvable(GenericSpecification constraint) {
- Map genericCapabilities = getGenericsMap(constraint.getBundle().getContainingState(), true);
- Set genericSet = (Set) genericCapabilities.get(constraint.getName());
+ Map<String, Set<GenericDescription>> genericCapabilities = getGenericsMap(constraint.getBundle().getContainingState(), true);
+ Set<GenericDescription> genericSet = genericCapabilities.get(constraint.getName());
if (genericSet == null)
return false;
- for (Iterator iter = genericSet.iterator(); iter.hasNext();)
- if (constraint.isSatisfiedBy((GenericDescription) iter.next()))
+ for (Iterator<GenericDescription> iter = genericSet.iterator(); iter.hasNext();)
+ if (constraint.isSatisfiedBy(iter.next()))
return true;
return false;
}
@@ -233,11 +233,11 @@
}
public Object[][] sortBundles(BundleDescription[] toSort) {
- List references = new ArrayList(toSort.length);
+ List<Object[]> references = new ArrayList<Object[]>(toSort.length);
for (int i = 0; i < toSort.length; i++)
if (toSort[i].isResolved())
buildReferences(toSort[i], references);
- Object[][] cycles = ComputeNodeOrder.computeNodeOrder(toSort, (Object[][]) references.toArray(new Object[references.size()][]));
+ Object[][] cycles = ComputeNodeOrder.computeNodeOrder(toSort, references.toArray(new Object[references.size()][]));
if (cycles.length == 0)
return cycles;
// fix up host/fragment orders (bug 184127)
@@ -271,7 +271,7 @@
}
}
- private void buildReferences(BundleDescription description, List references) {
+ private void buildReferences(BundleDescription description, List<Object[]> references) {
HostSpecification host = description.getHost();
// it is a fragment
if (host != null) {
@@ -288,12 +288,12 @@
}
}
- private void buildReferences(BundleDescription description, List dependencies, List references) {
- for (Iterator iter = dependencies.iterator(); iter.hasNext();)
- addReference(description, (BundleDescription) iter.next(), references);
+ private void buildReferences(BundleDescription description, List<BundleDescription> dependencies, List<Object[]> references) {
+ for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();)
+ addReference(description, iter.next(), references);
}
- private void addReference(BundleDescription description, BundleDescription reference, List references) {
+ private void addReference(BundleDescription description, BundleDescription reference, List<Object[]> references) {
// build the reference from the description
if (description == reference || reference == null)
return;
@@ -318,9 +318,9 @@
if (state != null)
strict = state.inStrictMode();
BundleDescription host = (BundleDescription) (bundle.getHost() == null ? bundle : bundle.getHost().getSupplier());
- 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
+ List<ExportPackageDescription> orderedPkgList = new ArrayList<ExportPackageDescription>(); // list of all ExportPackageDescriptions that are visible (ArrayList is used to keep order)
+ Set<ExportPackageDescription> pkgSet = new HashSet<ExportPackageDescription>();
+ Set<String> importList = new HashSet<String>(); // list of package names which are directly imported
// get the list of directly imported packages first.
ImportsHolder imports = new ImportsHolder(bundle, options);
for (int i = 0; i < imports.getSize(); i++) {
@@ -333,9 +333,9 @@
}
// get the sources of the required bundles of the exporter
BundleSpecification[] requires = pkgSupplier.getExporter().getRequiredBundles();
- Set visited = new HashSet();
+ Set<BundleDescription> visited = new HashSet<BundleDescription>();
visited.add(bundle); // always add self to prevent recursing into self
- Set importNames = new HashSet(1);
+ Set<String> importNames = new HashSet<String>(1);
importNames.add(imports.getName(i));
for (int j = 0; j < requires.length; j++) {
BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier();
@@ -347,46 +347,46 @@
}
// now find all the packages that are visible from required bundles
RequiresHolder requires = new RequiresHolder(bundle, options);
- Set visited = new HashSet(requires.getSize());
+ Set<BundleDescription> visited = new HashSet<BundleDescription>(requires.getSize());
visited.add(bundle); // always add self to prevent recursing into self
for (int i = 0; i < requires.getSize(); i++) {
BundleDescription bundleSupplier = requires.getSupplier(i);
if (bundleSupplier != null)
getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, null, options);
}
- return (ExportPackageDescription[]) orderedPkgList.toArray(new ExportPackageDescription[orderedPkgList.size()]);
+ return orderedPkgList.toArray(new ExportPackageDescription[orderedPkgList.size()]);
}
- private void getPackages(BundleDescription requiredBundle, String symbolicName, Set importList, ArrayList orderedPkgList, Set pkgSet, Set visited, boolean strict, Set pkgNames, int options) {
+ private void getPackages(BundleDescription requiredBundle, String symbolicName, Set<String> importList, List<ExportPackageDescription> orderedPkgList, Set<ExportPackageDescription> pkgSet, Set<BundleDescription> visited, boolean strict, Set<String> pkgNames, int options) {
if (visited.contains(requiredBundle))
return; // prevent duplicate entries and infinate loops incase of cycles
visited.add(requiredBundle);
// add all the exported packages from the required bundle; take x-friends into account.
ExportPackageDescription[] substitutedExports = requiredBundle.getSubstitutedExports();
ExportPackageDescription[] imports = requiredBundle.getResolvedImports();
- Set substituteNames = null; // a temporary set used to scope packages we get from getPackages
+ Set<String> substituteNames = null; // a temporary set used to scope packages we get from getPackages
for (int i = 0; i < substitutedExports.length; i++) {
if ((pkgNames == null || pkgNames.contains(substitutedExports[i].getName()))) {
for (int j = 0; j < imports.length; j++) {
if (substitutedExports[i].getName().equals(imports[j].getName()) && !pkgSet.contains(imports[j])) {
if (substituteNames == null)
- substituteNames = new HashSet(1);
+ substituteNames = new HashSet<String>(1);
else
substituteNames.clear();
// substituteNames is a set of one package containing the single substitute we are trying to get the source for
substituteNames.add(substitutedExports[i].getName());
- getPackages(imports[j].getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet(0), strict, substituteNames, options);
+ getPackages(imports[j].getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet<BundleDescription>(0), strict, substituteNames, options);
}
}
}
}
- importList = substitutedExports.length == 0 ? importList : new HashSet(importList);
+ importList = substitutedExports.length == 0 ? importList : new HashSet<String>(importList);
for (int i = 0; i < substitutedExports.length; i++)
// we add the package name to the import list to prevent required bundles from adding more sources
importList.add(substitutedExports[i].getName());
ExportPackageDescription[] exports = requiredBundle.getSelectedExports();
- HashSet exportNames = new HashSet(exports.length); // set is used to improve performance of duplicate check.
+ HashSet<String> exportNames = new HashSet<String>(exports.length); // set is used to improve performance of duplicate check.
for (int i = 0; i < exports.length; i++)
if ((pkgNames == null || pkgNames.contains(exports[i].getName())) && !isSystemExport(exports[i], options) && isFriend(symbolicName, exports[i], strict) && !importList.contains(exports[i].getName()) && !pkgSet.contains(exports[i])) {
if (!exportNames.contains(exports[i].getName())) {
@@ -406,7 +406,7 @@
getPackages(requiredBundles.getSupplier(i), symbolicName, importList, orderedPkgList, pkgSet, visited, strict, pkgNames, options);
} else if (exportNames.size() > 0) {
// adding any exports from required bundles which we also export
- Set tmpVisited = new HashSet();
+ Set<BundleDescription> tmpVisited = new HashSet<BundleDescription>();
getPackages(requiredBundles.getSupplier(i), symbolicName, importList, orderedPkgList, pkgSet, tmpVisited, strict, exportNames, options);
}
}
@@ -497,14 +497,14 @@
private final BundleSpecification[] requiredBundles;
private final BundleDescription[] resolvedRequires;
private final boolean isUsingResolved;
- private final Map resolvedBundlesExported;
+ private final Map<BundleDescription, Boolean> resolvedBundlesExported;
// Depending on the options used, either requiredBundles or resolvedRequires is initialize, but not both.
RequiresHolder(BundleDescription bundle, int options) {
isUsingResolved = (options & StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES) != 0;
if (isUsingResolved) {
requiredBundles = null;
- resolvedBundlesExported = new HashMap();
+ resolvedBundlesExported = new HashMap<BundleDescription, Boolean>();
resolvedRequires = bundle.getResolvedRequires();
determineRequiresVisibility(bundle);
} else {
@@ -522,7 +522,7 @@
boolean isExported(int index) {
if (isUsingResolved)
- return ((Boolean) resolvedBundlesExported.get(resolvedRequires[index])).booleanValue();
+ return resolvedBundlesExported.get(resolvedRequires[index]).booleanValue();
return requiredBundles[index].isExported();
}
@@ -538,7 +538,7 @@
*/
private void determineRequiresVisibility(BundleDescription bundle) {
BundleSpecification[] required = bundle.getRequiredBundles();
- HashSet resolved = new HashSet();
+ Set<BundleDescription> resolved = new HashSet<BundleDescription>();
for (int i = 0; i < resolvedRequires.length; i++) {
resolved.add(resolvedRequires[i]);
@@ -547,7 +547,7 @@
// Get the visibility of all directly required bundles
for (int i = 0; i < required.length; i++) {
if (required[i].getSupplier() != null) {
- resolvedBundlesExported.put(required[i].getSupplier(), new Boolean(required[i].isExported()));
+ resolvedBundlesExported.put((BundleDescription) required[i].getSupplier(), new Boolean(required[i].isExported()));
resolved.remove(required[i].getSupplier());
}
}
@@ -560,7 +560,7 @@
BundleSpecification[] fragmentRequiredBundles = fragments[i].getRequiredBundles();
for (int j = 0; j < fragmentRequiredBundles.length; j++) {
if (resolved.contains(fragmentRequiredBundles[j].getSupplier())) {
- resolvedBundlesExported.put(fragmentRequiredBundles[j].getSupplier(), new Boolean(fragmentRequiredBundles[j].isExported()));
+ resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundles[j].getSupplier(), new Boolean(fragmentRequiredBundles[j].isExported()));
resolved.remove(fragmentRequiredBundles[j].getSupplier());
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index ef8788d..a05d5d2 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -42,17 +42,18 @@
private volatile boolean resolved = true;
private volatile long timeStamp = System.currentTimeMillis();
private final KeyedHashSet bundleDescriptions = new KeyedHashSet(false);
- private final HashMap resolverErrors = new HashMap();
+ private final Map<BundleDescription, List<ResolverError>> resolverErrors = new HashMap<BundleDescription, List<ResolverError>>();
private StateObjectFactory factory;
private final KeyedHashSet resolvedBundles = new KeyedHashSet();
- private final HashMap disabledBundles = new HashMap();
+ private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap<BundleDescription, List<DisabledInfo>>();
private volatile boolean fullyLoaded = false;
private boolean dynamicCacheChanged = false;
// only used for lazy loading of BundleDescriptions
private StateReader reader;
- private Dictionary[] platformProperties = {new Hashtable(PROPS.length)}; // Dictionary here because of Filter API
+ @SuppressWarnings("unchecked")
+ private Dictionary<Object, Object>[] platformProperties = new Dictionary[] {new Hashtable<String, String>(PROPS.length)}; // Dictionary here because of Filter API
private long highestBundleId = -1;
- private final HashSet platformPropertyKeys = new HashSet(PROPS.length);
+ private final Set<String> platformPropertyKeys = new HashSet<String>(PROPS.length);
private ResolverHook hook;
private static long cumulativeTime;
@@ -107,11 +108,11 @@
if (!bundleDescriptions.remove(existing))
return false;
resolvedBundles.remove(existing);
- ArrayList infos = (ArrayList) disabledBundles.remove(existing);
+ List<DisabledInfo> infos = disabledBundles.remove(existing);
if (infos != null) {
- ArrayList newInfos = new ArrayList(infos.size());
- for (Iterator iInfos = infos.iterator(); iInfos.hasNext();) {
- DisabledInfo info = (DisabledInfo) iInfos.next();
+ List<DisabledInfo> newInfos = new ArrayList<DisabledInfo>(infos.size());
+ for (Iterator<DisabledInfo> iInfos = infos.iterator(); iInfos.hasNext();) {
+ DisabledInfo info = iInfos.next();
newInfos.add(new DisabledInfo(info.getPolicyName(), info.getMessage(), newDescription));
}
disabledBundles.put(newDescription, newInfos);
@@ -209,13 +210,13 @@
synchronized (this.monitor) {
if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName))
symbolicName = getSystemBundle();
- final List bundles = new ArrayList();
- for (Iterator iter = bundleDescriptions.iterator(); iter.hasNext();) {
+ final List<BundleDescription> bundles = new ArrayList<BundleDescription>();
+ for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) {
BundleDescription bundle = (BundleDescription) iter.next();
if (symbolicName.equals(bundle.getSymbolicName()))
bundles.add(bundle);
}
- return (BundleDescription[]) bundles.toArray(new BundleDescription[bundles.size()]);
+ return bundles.toArray(new BundleDescription[bundles.size()]);
}
}
@@ -231,8 +232,8 @@
if (result != null)
return result;
// need to look in removal pending bundles;
- for (Iterator iter = removalPendings.iterator(); iter.hasNext();) {
- BundleDescription removedBundle = (BundleDescription) iter.next();
+ for (Iterator<BundleDescription> iter = removalPendings.iterator(); iter.hasNext();) {
+ BundleDescription removedBundle = iter.next();
if (removedBundle.getBundleId() == id) // just return the first matching id
return removedBundle;
}
@@ -457,10 +458,11 @@
reResolve = mergeBundles(reResolve, removed);
}
// use the Headers class to handle ignoring case while matching keys (bug 180817)
- Headers[] tmpPlatformProperties = new Headers[platformProperties.length];
+ @SuppressWarnings("unchecked")
+ Headers<Object, Object>[] tmpPlatformProperties = new Headers[platformProperties.length];
for (int i = 0; i < platformProperties.length; i++) {
- tmpPlatformProperties[i] = new Headers(platformProperties[i].size());
- for (Enumeration keys = platformProperties[i].keys(); keys.hasMoreElements();) {
+ tmpPlatformProperties[i] = new Headers<Object, Object>(platformProperties[i].size());
+ for (Enumeration<Object> keys = platformProperties[i].keys(); keys.hasMoreElements();) {
Object key = keys.nextElement();
tmpPlatformProperties[i].put(key, platformProperties[i].get(key));
}
@@ -494,7 +496,7 @@
if (reResolve.length == 0)
return reResolve; // if reResolve length==0 then we want to prevent pending removal
// merge in all removal pending bundles that are not already in the list
- ArrayList result = new ArrayList(reResolve.length + removed.length);
+ List<BundleDescription> result = new ArrayList<BundleDescription>(reResolve.length + removed.length);
for (int i = 0; i < reResolve.length; i++)
result.add(reResolve[i]);
for (int i = 0; i < removed.length; i++) {
@@ -508,7 +510,7 @@
if (!found)
result.add(removed[i]);
}
- return (BundleDescription[]) result.toArray(new BundleDescription[result.size()]);
+ return result.toArray(new BundleDescription[result.size()]);
}
private void flush(BundleDescription[] bundles) {
@@ -597,8 +599,8 @@
public ExportPackageDescription[] getExportedPackages() {
fullyLoad();
- final List allExportedPackages = new ArrayList();
- for (Iterator iter = resolvedBundles.iterator(); iter.hasNext();) {
+ final List<ExportPackageDescription> allExportedPackages = new ArrayList<ExportPackageDescription>();
+ for (Iterator<KeyedElement> iter = resolvedBundles.iterator(); iter.hasNext();) {
BundleDescription bundle = (BundleDescription) iter.next();
ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
if (bundlePackages == null)
@@ -606,20 +608,20 @@
for (int i = 0; i < bundlePackages.length; i++)
allExportedPackages.add(bundlePackages[i]);
}
- for (Iterator iter = removalPendings.iterator(); iter.hasNext();) {
- BundleDescription bundle = (BundleDescription) iter.next();
+ for (Iterator<BundleDescription> iter = removalPendings.iterator(); iter.hasNext();) {
+ BundleDescription bundle = iter.next();
ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
if (bundlePackages == null)
continue;
for (int i = 0; i < bundlePackages.length; i++)
allExportedPackages.add(bundlePackages[i]);
}
- return (ExportPackageDescription[]) allExportedPackages.toArray(new ExportPackageDescription[allExportedPackages.size()]);
+ return allExportedPackages.toArray(new ExportPackageDescription[allExportedPackages.size()]);
}
BundleDescription[] getFragments(final BundleDescription host) {
- final List fragments = new ArrayList();
- for (Iterator iter = bundleDescriptions.iterator(); iter.hasNext();) {
+ final List<BundleDescription> fragments = new ArrayList<BundleDescription>();
+ for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) {
BundleDescription bundle = (BundleDescription) iter.next();
HostSpecification hostSpec = bundle.getHost();
@@ -633,7 +635,7 @@
}
}
}
- return (BundleDescription[]) fragments.toArray(new BundleDescription[fragments.size()]);
+ return fragments.toArray(new BundleDescription[fragments.size()]);
}
public void setTimeStamp(long newTimeStamp) {
@@ -660,7 +662,7 @@
public BundleDescription getBundleByLocation(String location) {
synchronized (this.monitor) {
- for (Iterator i = bundleDescriptions.iterator(); i.hasNext();) {
+ for (Iterator<KeyedElement> i = bundleDescriptions.iterator(); i.hasNext();) {
BundleDescription current = (BundleDescription) i.next();
if (location.equals(current.getLocation()))
return current;
@@ -691,24 +693,25 @@
resolver.setState(this);
}
- public boolean setPlatformProperties(Dictionary platformProperties) {
+ public boolean setPlatformProperties(Dictionary<?, ?> platformProperties) {
return setPlatformProperties(new Dictionary[] {platformProperties});
}
- public boolean setPlatformProperties(Dictionary[] platformProperties) {
+ public boolean setPlatformProperties(Dictionary<?, ?>[] platformProperties) {
return setPlatformProperties(platformProperties, true);
}
- synchronized boolean setPlatformProperties(Dictionary[] platformProperties, boolean resetSystemExports) {
+ synchronized boolean setPlatformProperties(Dictionary<?, ?>[] platformProperties, boolean resetSystemExports) {
if (platformProperties.length == 0)
throw new IllegalArgumentException();
// copy the properties for our use internally;
// only copy String and String[] values
- Dictionary[] newPlatformProperties = new Dictionary[platformProperties.length];
+ @SuppressWarnings("unchecked")
+ Dictionary<Object, Object>[] newPlatformProperties = new Dictionary[platformProperties.length];
for (int i = 0; i < platformProperties.length; i++) {
- newPlatformProperties[i] = new Hashtable(platformProperties[i].size());
+ newPlatformProperties[i] = new Hashtable<Object, Object>(platformProperties[i].size());
synchronized (platformProperties[i]) {
- for (Enumeration keys = platformProperties[i].keys(); keys.hasMoreElements();) {
+ for (Enumeration<?> keys = platformProperties[i].keys(); keys.hasMoreElements();) {
Object key = keys.nextElement();
Object value = platformProperties[i].get(key);
newPlatformProperties[i].put(key, value);
@@ -768,16 +771,16 @@
for (int idx = 0; idx < systemBundles.length; idx++) {
BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[idx];
ExportPackageDescription[] exports = systemBundle.getExportPackages();
- ArrayList newExports = new ArrayList(exports.length);
+ List<ExportPackageDescription> newExports = new ArrayList<ExportPackageDescription>(exports.length);
for (int i = 0; i < exports.length; i++)
if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0)
newExports.add(exports[i]);
addSystemExports(newExports);
- systemBundle.setExportPackages((ExportPackageDescription[]) newExports.toArray(new ExportPackageDescription[newExports.size()]));
+ systemBundle.setExportPackages(newExports.toArray(new ExportPackageDescription[newExports.size()]));
}
}
- private void addSystemExports(ArrayList exports) {
+ private void addSystemExports(List<ExportPackageDescription> exports) {
for (int i = 0; i < platformProperties.length; i++)
try {
addSystemExports(exports, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMPACKAGES)), i);
@@ -787,7 +790,7 @@
}
}
- private void addSystemExports(ArrayList exports, ManifestElement[] elements, int index) {
+ private void addSystemExports(List<ExportPackageDescription> exports, ManifestElement[] elements, int index) {
if (elements == null)
return;
ExportPackageDescription[] systemExports = StateBuilder.createExportPackages(elements, null, null, 2, false);
@@ -828,6 +831,7 @@
StateBuilder.createOSGiCapabilities(elements, capabilities);
}
+ @SuppressWarnings("rawtypes")
public Dictionary[] getPlatformProperties() {
return platformProperties;
}
@@ -853,7 +857,7 @@
return !origObj.equals(newObj);
}
- private boolean changedProps(Dictionary origProps, Dictionary newProps, String[] keys) {
+ private boolean changedProps(Dictionary<Object, Object> origProps, Dictionary<Object, Object> newProps, String[] keys) {
for (int i = 0; i < keys.length; i++) {
Object origProp = origProps.get(keys[i]);
Object newProp = newProps.get(keys[i]);
@@ -983,7 +987,7 @@
public ExportPackageDescription[] getSystemPackages() {
synchronized (this.monitor) {
- ArrayList result = new ArrayList();
+ List<ExportPackageDescription> result = new ArrayList<ExportPackageDescription>();
BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
if (systemBundles.length > 0) {
BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[0];
@@ -992,7 +996,7 @@
if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() >= 0)
result.add(exports[i]);
}
- return (ExportPackageDescription[]) result.toArray(new ExportPackageDescription[result.size()]);
+ return result.toArray(new ExportPackageDescription[result.size()]);
}
}
@@ -1006,8 +1010,8 @@
synchronized (this.monitor) {
if (bundle.isResolved())
return new ResolverError[0];
- ArrayList result = (ArrayList) resolverErrors.get(bundle);
- return result == null ? new ResolverError[0] : (ResolverError[]) result.toArray(new ResolverError[result.size()]);
+ List<ResolverError> result = resolverErrors.get(bundle);
+ return result == null ? new ResolverError[0] : result.toArray(new ResolverError[result.size()]);
}
}
@@ -1015,9 +1019,9 @@
synchronized (this.monitor) {
if (!resolving)
throw new IllegalStateException(); // TODO need error message here!
- ArrayList errors = (ArrayList) resolverErrors.get(bundle);
+ List<ResolverError> errors = resolverErrors.get(bundle);
if (errors == null) {
- errors = new ArrayList(1);
+ errors = new ArrayList<ResolverError>(1);
resolverErrors.put(bundle, errors);
}
errors.add(new ResolverErrorImpl((BundleDescriptionImpl) bundle, type, data, unsatisfied));
@@ -1058,7 +1062,7 @@
String[] getPlatformPropertyKeys() {
synchronized (platformPropertyKeys) {
- return (String[]) platformPropertyKeys.toArray(new String[platformPropertyKeys.size()]);
+ return platformPropertyKeys.toArray(new String[platformPropertyKeys.size()]);
}
}
@@ -1074,7 +1078,7 @@
public BundleDescription[] getDisabledBundles() {
synchronized (this.monitor) {
- return (BundleDescription[]) disabledBundles.keySet().toArray(new BundleDescription[0]);
+ return disabledBundles.keySet().toArray(new BundleDescription[0]);
}
}
@@ -1082,15 +1086,15 @@
synchronized (this.monitor) {
if (getBundle(disabledInfo.getBundle().getBundleId()) != disabledInfo.getBundle())
throw new IllegalArgumentException(NLS.bind(StateMsg.BUNDLE_NOT_IN_STATE, disabledInfo.getBundle()));
- ArrayList currentInfos = (ArrayList) disabledBundles.get(disabledInfo.getBundle());
+ List<DisabledInfo> currentInfos = disabledBundles.get(disabledInfo.getBundle());
if (currentInfos == null) {
- currentInfos = new ArrayList(1);
+ currentInfos = new ArrayList<DisabledInfo>(1);
currentInfos.add(disabledInfo);
disabledBundles.put(disabledInfo.getBundle(), currentInfos);
} else {
- Iterator it = currentInfos.iterator();
+ Iterator<DisabledInfo> it = currentInfos.iterator();
while (it.hasNext()) {
- DisabledInfo currentInfo = (DisabledInfo) it.next();
+ DisabledInfo currentInfo = it.next();
if (disabledInfo.getPolicyName().equals(currentInfo.getPolicyName())) {
currentInfos.remove(currentInfo);
break;
@@ -1104,7 +1108,7 @@
public void removeDisabledInfo(DisabledInfo disabledInfo) {
synchronized (this.monitor) {
- ArrayList currentInfos = (ArrayList) disabledBundles.get(disabledInfo.getBundle());
+ List<DisabledInfo> currentInfos = disabledBundles.get(disabledInfo.getBundle());
if ((currentInfos != null) && currentInfos.contains(disabledInfo)) {
currentInfos.remove(disabledInfo);
if (currentInfos.isEmpty()) {
@@ -1117,12 +1121,12 @@
public DisabledInfo getDisabledInfo(BundleDescription bundle, String policyName) {
synchronized (this.monitor) {
- ArrayList currentInfos = (ArrayList) disabledBundles.get(bundle);
+ List<DisabledInfo> currentInfos = disabledBundles.get(bundle);
if (currentInfos == null)
return null;
- Iterator it = currentInfos.iterator();
+ Iterator<DisabledInfo> it = currentInfos.iterator();
while (it.hasNext()) {
- DisabledInfo currentInfo = (DisabledInfo) it.next();
+ DisabledInfo currentInfo = it.next();
if (currentInfo.getPolicyName().equals(policyName)) {
return currentInfo;
}
@@ -1133,8 +1137,8 @@
public DisabledInfo[] getDisabledInfos(BundleDescription bundle) {
synchronized (this.monitor) {
- ArrayList currentInfos = (ArrayList) disabledBundles.get(bundle);
- return currentInfos == null ? EMPTY_DISABLEDINFOS : (DisabledInfo[]) currentInfos.toArray(new DisabledInfo[currentInfos.size()]);
+ List<DisabledInfo> currentInfos = disabledBundles.get(bundle);
+ return currentInfos == null ? EMPTY_DISABLEDINFOS : currentInfos.toArray(new DisabledInfo[currentInfos.size()]);
}
}
@@ -1142,11 +1146,11 @@
* Used by StateWriter to get all the DisabledInfo objects to persist
*/
DisabledInfo[] getDisabledInfos() {
- ArrayList results = new ArrayList();
+ List<DisabledInfo> results = new ArrayList<DisabledInfo>();
synchronized (this.monitor) {
- for (Iterator allDisabledInfos = disabledBundles.values().iterator(); allDisabledInfos.hasNext();)
- results.addAll((Collection) allDisabledInfos.next());
+ for (Iterator<List<DisabledInfo>> allDisabledInfos = disabledBundles.values().iterator(); allDisabledInfos.hasNext();)
+ results.addAll(allDisabledInfos.next());
}
- return (DisabledInfo[]) results.toArray(new DisabledInfo[results.size()]);
+ return results.toArray(new DisabledInfo[results.size()]);
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
index 782be7e..a864a22 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
@@ -24,11 +24,11 @@
/**
* @deprecated
*/
- public BundleDescription createBundleDescription(Dictionary manifest, String location, long id) throws BundleException {
+ public BundleDescription createBundleDescription(Dictionary<String, String> manifest, String location, long id) throws BundleException {
return createBundleDescription(null, manifest, location, id);
}
- public BundleDescription createBundleDescription(State state, Dictionary manifest, String location, long id) throws BundleException {
+ public BundleDescription createBundleDescription(State state, Dictionary<String, String> manifest, String location, long id) throws BundleException {
BundleDescriptionImpl result = (BundleDescriptionImpl) StateBuilder.createBundleDescription((StateImpl) state, manifest, location);
result.setBundleId(id);
return result;
@@ -200,7 +200,7 @@
return hostSpec;
}
- public ImportPackageSpecification createImportPackageSpecification(String packageName, VersionRange versionRange, String bundleSymbolicName, VersionRange bundleVersionRange, Map directives, Map attributes, BundleDescription importer) {
+ public ImportPackageSpecification createImportPackageSpecification(String packageName, VersionRange versionRange, String bundleSymbolicName, VersionRange bundleVersionRange, Map<String, ?> directives, Map<String, ?> attributes, BundleDescription importer) {
ImportPackageSpecificationImpl packageSpec = new ImportPackageSpecificationImpl();
packageSpec.setName(packageName);
packageSpec.setVersionRange(versionRange);
@@ -227,7 +227,7 @@
return createExportPackageDescription(original.getName(), original.getVersion(), original.getDirectives(), original.getAttributes(), true, null);
}
- public ExportPackageDescription createExportPackageDescription(String packageName, Version version, Map directives, Map attributes, boolean root, BundleDescription exporter) {
+ public ExportPackageDescription createExportPackageDescription(String packageName, Version version, Map<String, ?> directives, Map<String, ?> attributes, boolean root, BundleDescription exporter) {
ExportPackageDescriptionImpl exportPackage = new ExportPackageDescriptionImpl();
exportPackage.setName(packageName);
exportPackage.setVersion(version);
@@ -240,18 +240,18 @@
/**
* @deprecated
*/
- public GenericDescription createGenericDescription(String name, String type, Version version, Map attributes) {
+ public GenericDescription createGenericDescription(String name, String type, Version version, Map<String, ?> attributes) {
return createGenericDescription(name, type, version, attributes, null, null);
}
- public GenericDescription createGenericDescription(String type, Map attributes, Map directives, BundleDescription supplier) {
+ public GenericDescription createGenericDescription(String type, Map<String, ?> attributes, Map<String, String> directives, BundleDescription supplier) {
return createGenericDescription(null, type, null, attributes, directives, supplier);
}
- private GenericDescription createGenericDescription(String name, String type, Version version, Map attributes, Map directives, BundleDescription supplier) {
+ private GenericDescription createGenericDescription(String name, String type, Version version, Map<String, ?> attributes, Map<String, String> directives, BundleDescription supplier) {
GenericDescriptionImpl result = new GenericDescriptionImpl();
result.setType(type);
- Dictionary attrs = attributes == null ? new Hashtable() : new Hashtable(attributes);
+ Dictionary<String, Object> attrs = attributes == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(attributes);
if (version != null) {
Object versionObj = attrs.get(Constants.VERSION_ATTRIBUTE);
if (!(versionObj instanceof Version) && version != null)
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
index 2590231..bad9196 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
@@ -32,13 +32,13 @@
public static final String LAZY_FILE = ".lazy"; //$NON-NLS-1$
private static final int BUFFER_SIZE_LAZY = 4096;
private static final int BUFFER_SIZE_FULLYREAD = 16384;
- private static final SecureAction secureAction = (SecureAction) AccessController.doPrivileged(SecureAction.createSecureAction());
+ private static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction());
// objectTable will be a hashmap of objects. The objects will be things
// like BundleDescription, ExportPackageDescription, Version etc.. The integer
// index value will be used in the cache to allow cross-references in the
// cached state.
- final Map objectTable = Collections.synchronizedMap(new HashMap());
+ final Map<Integer, Object> objectTable = Collections.synchronizedMap(new HashMap<Integer, Object>());
private volatile File stateFile;
private volatile File lazyFile;
@@ -47,7 +47,7 @@
private volatile int numBundles;
private volatile boolean accessedFlag = false;
- public static final byte STATE_CACHE_VERSION = 33;
+ public static final byte STATE_CACHE_VERSION = 34;
public static final byte NULL = 0;
public static final byte OBJECT = 1;
public static final byte INDEX = 2;
@@ -97,9 +97,9 @@
String[] platformPropKeys = (String[]) readPlatformProp(in);
state.addPlatformPropertyKeys(platformPropKeys);
int numSets = in.readInt();
- Dictionary[] platformProps = new Dictionary[numSets];
+ Dictionary<?, ?>[] platformProps = new Dictionary[numSets];
for (int i = 0; i < numSets; i++) {
- Hashtable props = new Hashtable(platformPropKeys.length);
+ Hashtable<Object, Object> props = new Hashtable<Object, Object>(platformPropKeys.length);
int numProps = in.readInt();
for (int j = 0; j < numProps; j++) {
Object value = readPlatformProp(in);
@@ -157,9 +157,9 @@
String[] platformPropKeys = (String[]) readPlatformProp(in);
state.addPlatformPropertyKeys(platformPropKeys);
int numSets = in.readInt();
- Dictionary[] platformProps = new Dictionary[numSets];
+ Dictionary<?, ?>[] platformProps = new Dictionary[numSets];
for (int i = 0; i < numSets; i++) {
- Hashtable props = new Hashtable(platformPropKeys.length);
+ Hashtable<Object, Object> props = new Hashtable<Object, Object>(platformPropKeys.length);
int numProps = in.readInt();
for (int j = 0; j < numProps; j++) {
Object value = readPlatformProp(in);
@@ -324,7 +324,7 @@
int dynamicPkgCnt = in.readInt();
if (dynamicPkgCnt > 0) {
- HashMap dynamicStamps = new HashMap(dynamicPkgCnt);
+ HashMap<String, Long> dynamicStamps = new HashMap<String, Long>(dynamicPkgCnt);
for (int i = 0; i < dynamicPkgCnt; i++) {
String pkg = readString(in, false);
Long stamp = new Long(in.readLong());
@@ -403,11 +403,11 @@
return new DisabledInfo(readString(in, false), readString(in, false), readBundleDescription(in));
}
- private Map readMap(DataInputStream in) throws IOException {
+ private Map<String, Object> readMap(DataInputStream in) throws IOException {
int count = in.readInt();
if (count == 0)
return null;
- HashMap result = new HashMap(count);
+ HashMap<String, Object> result = new HashMap<String, Object>(count);
for (int i = 0; i < count; i++) {
String key = readString(in, false);
Object value = null;
@@ -429,8 +429,8 @@
else if (type == 7) {
value = readString(in, false);
try {
- Class uriClazz = Class.forName("java.net.URI"); //$NON-NLS-1$
- Constructor constructor = uriClazz.getConstructor(new Class[] {String.class});
+ Class<?> uriClazz = Class.forName("java.net.URI"); //$NON-NLS-1$
+ Constructor<?> constructor = uriClazz.getConstructor(new Class[] {String.class});
value = constructor.newInstance(new Object[] {value});
} catch (ClassNotFoundException e) {
// oh well cannot support; just use the string
@@ -439,6 +439,32 @@
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
+ } else if (type == 8) {
+ int listType = in.readByte();
+ int size = in.readInt();
+ List<Object> list = new ArrayList<Object>(size);
+ for (int j = 0; j < size; j++) {
+ switch (listType) {
+ case 0 :
+ list.add(readString(in, false));
+ break;
+ case 3 :
+ list.add(new Integer(in.readInt()));
+ break;
+ case 4 :
+ list.add(new Long(in.readLong()));
+ break;
+ case 5 :
+ list.add(new Double(in.readDouble()));
+ break;
+ case 6 :
+ list.add(readVersion(in));
+ break;
+ default :
+ throw new IOException("Invalid type: " + listType); //$NON-NLS-1$
+ }
+ }
+ value = list;
}
result.put(key, value);
}
@@ -499,11 +525,11 @@
readBaseDescription(result, in);
result.setSupplier(readBundleDescription(in));
result.setType(readString(in, false));
- Map mapAttrs = readMap(in);
- Dictionary attrs = new Hashtable();
+ Map<String, Object> mapAttrs = readMap(in);
+ Dictionary<String, Object> attrs = new Hashtable<String, Object>();
if (mapAttrs != null) {
- for (Iterator keys = mapAttrs.keySet().iterator(); keys.hasNext();) {
- Object key = keys.next();
+ for (Iterator<String> keys = mapAttrs.keySet().iterator(); keys.hasNext();) {
+ String key = keys.next();
attrs.put(key, mapAttrs.get(key));
}
}
@@ -688,7 +714,7 @@
try {
in = openLazyFile();
// get the set of bundles that must be loaded according to dependencies
- ArrayList toLoad = new ArrayList();
+ List<BundleDescriptionImpl> toLoad = new ArrayList<BundleDescriptionImpl>();
addDependencies(target, toLoad);
int skipBytes[] = getSkipBytes(toLoad);
// look for the lazy data of the toLoad list
@@ -700,14 +726,14 @@
}
}
- private void addDependencies(BundleDescriptionImpl target, List toLoad) {
+ private void addDependencies(BundleDescriptionImpl target, List<BundleDescriptionImpl> toLoad) {
if (toLoad.contains(target) || target.isFullyLoaded())
return;
- Iterator load = toLoad.iterator();
+ Iterator<BundleDescriptionImpl> load = toLoad.iterator();
int i = 0;
while (load.hasNext()) {
// insert the target into the list sorted by lazy data offsets
- BundleDescriptionImpl bundle = (BundleDescriptionImpl) load.next();
+ BundleDescriptionImpl bundle = load.next();
if (target.getLazyDataOffset() < bundle.getLazyDataOffset())
break;
i++;
@@ -716,28 +742,28 @@
toLoad.add(target);
else
toLoad.add(i, target);
- List deps = target.getBundleDependencies();
- for (Iterator iter = deps.iterator(); iter.hasNext();)
+ List<BundleDescription> deps = target.getBundleDependencies();
+ for (Iterator<BundleDescription> iter = deps.iterator(); iter.hasNext();)
addDependencies((BundleDescriptionImpl) iter.next(), toLoad);
}
- private int[] getSkipBytes(ArrayList toLoad) {
+ private int[] getSkipBytes(List<BundleDescriptionImpl> toLoad) {
int[] skipBytes = new int[toLoad.size()];
for (int i = 0; i < skipBytes.length; i++) {
- BundleDescriptionImpl current = (BundleDescriptionImpl) toLoad.get(i);
+ BundleDescriptionImpl current = toLoad.get(i);
if (i == 0) {
skipBytes[i] = current.getLazyDataOffset();
continue;
}
- BundleDescriptionImpl previous = (BundleDescriptionImpl) toLoad.get(i - 1);
+ BundleDescriptionImpl previous = toLoad.get(i - 1);
skipBytes[i] = current.getLazyDataOffset() - previous.getLazyDataOffset() - previous.getLazyDataSize();
}
return skipBytes;
}
void flushLazyObjectCache() {
- for (Iterator entries = objectTable.entrySet().iterator(); entries.hasNext();) {
- Map.Entry entry = (Entry) entries.next();
+ for (Iterator<Entry<Integer, Object>> entries = objectTable.entrySet().iterator(); entries.hasNext();) {
+ Map.Entry<Integer, Object> entry = entries.next();
if (entry.getValue() instanceof ExportPackageDescription || entry.getValue() instanceof GenericDescription)
entries.remove();
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateWriter.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateWriter.java
index bb2bb17..6f01d6a 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateWriter.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateWriter.java
@@ -14,7 +14,8 @@
import java.io.*;
import java.util.*;
import org.eclipse.osgi.service.resolver.*;
-import org.osgi.framework.*;
+import org.osgi.framework.Filter;
+import org.osgi.framework.Version;
/**
* This class is <strong>not</strong> thread safe. Instances must not be
@@ -26,12 +27,12 @@
// like BundleDescription, ExportPackageDescription, Version etc.. The integer
// index value will be used in the cache to allow cross-references in the
// cached state.
- private final Map objectTable = new HashMap();
+ private final Map<Object, Integer> objectTable = new HashMap<Object, Integer>();
- private final ArrayList forcedWrite = new ArrayList();
+ private final List<BundleDescription> forcedWrite = new ArrayList<BundleDescription>();
private int addToObjectTable(Object object) {
- Integer cur = (Integer) objectTable.get(object);
+ Integer cur = objectTable.get(object);
if (cur != null)
return cur.intValue();
objectTable.put(object, new Integer(objectTable.size()));
@@ -67,10 +68,10 @@
// write the platform property keys
String[] platformPropKeys = state.getPlatformPropertyKeys();
writePlatformProp(platformPropKeys, out);
- Dictionary[] propSet = state.getPlatformProperties();
+ Dictionary<Object, Object>[] propSet = state.getPlatformProperties();
out.writeInt(propSet.length);
for (int i = 0; i < propSet.length; i++) {
- Dictionary props = propSet[i];
+ Dictionary<Object, Object> props = propSet[i];
out.writeInt(platformPropKeys.length);
for (int j = 0; j < platformPropKeys.length; j++)
writePlatformProp(props.get(platformPropKeys[j]), out);
@@ -117,10 +118,10 @@
String[] platformPropKeys = state.getPlatformPropertyKeys();
writePlatformProp(platformPropKeys, outState);
// write the platform property values
- Dictionary[] propSet = state.getPlatformProperties();
+ Dictionary<Object, Object>[] propSet = state.getPlatformProperties();
outState.writeInt(propSet.length);
for (int i = 0; i < propSet.length; i++) {
- Dictionary props = propSet[i];
+ Dictionary<Object, Object> props = propSet[i];
outState.writeInt(platformPropKeys.length);
for (int j = 0; j < platformPropKeys.length; j++)
writePlatformProp(props.get(platformPropKeys[j]), outState);
@@ -212,10 +213,10 @@
out.writeBoolean(bundle.dynamicFragments());
writeHostSpec((HostSpecificationImpl) bundle.getHost(), out, force);
- List dependencies = ((BundleDescriptionImpl) bundle).getBundleDependencies();
+ List<BundleDescription> dependencies = ((BundleDescriptionImpl) bundle).getBundleDependencies();
out.writeInt(dependencies.size());
- for (Iterator iter = dependencies.iterator(); iter.hasNext();)
- writeBundleDescription((BundleDescription) iter.next(), out, force);
+ for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();)
+ writeBundleDescription(iter.next(), out, force);
// the rest is lazy loaded data
}
@@ -284,15 +285,15 @@
for (int i = 0; i < ees.length; i++)
writeStringOrNull(ees[i], out);
- HashMap dynamicStamps = ((BundleDescriptionImpl) bundle).getDynamicStamps();
+ Map<String, Long> dynamicStamps = ((BundleDescriptionImpl) bundle).getDynamicStamps();
if (dynamicStamps == null)
out.writeInt(0);
else {
out.writeInt(dynamicStamps.size());
- for (Iterator pkgs = dynamicStamps.keySet().iterator(); pkgs.hasNext();) {
- String pkg = (String) pkgs.next();
+ for (Iterator<String> pkgs = dynamicStamps.keySet().iterator(); pkgs.hasNext();) {
+ String pkg = pkgs.next();
writeStringOrNull(pkg, out);
- out.writeLong(((Long) dynamicStamps.get(pkg)).longValue());
+ out.writeLong(dynamicStamps.get(pkg).longValue());
}
}
@@ -366,15 +367,14 @@
writeBaseDescription(description, out);
writeBundleDescription(description.getSupplier(), out, false);
writeStringOrNull(description.getType() == GenericDescription.DEFAULT_TYPE ? null : description.getType(), out);
- Dictionary attrs = description.getAttributes();
- Map mapAttrs = new HashMap(attrs.size());
- for (Enumeration keys = attrs.keys(); keys.hasMoreElements();) {
- Object key = keys.nextElement();
- if (!Constants.VERSION_ATTRIBUTE.equals(key))
- mapAttrs.put(key, attrs.get(key));
+ Dictionary<String, Object> attrs = description.getAttributes();
+ Map<String, Object> mapAttrs = new HashMap<String, Object>(attrs.size());
+ for (Enumeration<String> keys = attrs.keys(); keys.hasMoreElements();) {
+ String key = keys.nextElement();
+ mapAttrs.put(key, attrs.get(key));
}
writeMap(out, mapAttrs);
- Map directives = description.getDeclaredDirectives();
+ Map<String, String> directives = description.getDeclaredDirectives();
writeMap(out, directives);
}
@@ -438,14 +438,14 @@
writeStringOrNull(strings[i], out);
}
- private void writeMap(DataOutputStream out, Map source) throws IOException {
+ private void writeMap(DataOutputStream out, Map<String, ?> source) throws IOException {
if (source == null) {
out.writeInt(0);
} else {
out.writeInt(source.size());
- Iterator iter = source.keySet().iterator();
+ Iterator<String> iter = source.keySet().iterator();
while (iter.hasNext()) {
- String key = (String) iter.next();
+ String key = iter.next();
Object value = source.get(key);
writeStringOrNull(key, out);
if (value instanceof String) {
@@ -472,11 +472,60 @@
} else if ("java.net.URI".equals(value.getClass().getName())) { //$NON-NLS-1$
out.writeByte(7);
writeStringOrNull(value.toString(), out);
+ } else if (value instanceof List) {
+ writeList(out, (List<?>) value);
}
}
}
}
+ private void writeList(DataOutputStream out, List<?> list) throws IOException {
+ byte type = getListType(list);
+ if (type == -2)
+ return; // don't understand the list type
+ out.writeByte(8);
+ out.writeByte(type);
+ out.writeInt(list.size());
+ for (Object value : list) {
+ switch (type) {
+ case 0 :
+ writeStringOrNull((String) value, out);
+ break;
+ case 3 :
+ out.writeInt(((Integer) value).intValue());
+ break;
+ case 4 :
+ out.writeLong(((Long) value).longValue());
+ break;
+ case 5 :
+ out.writeDouble(((Double) value).doubleValue());
+ break;
+ case 6 :
+ writeVersion((Version) value, out);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+
+ private byte getListType(List<?> list) {
+ if (list.size() == 0)
+ return -1;
+ Object type = list.get(0);
+ if (type instanceof String)
+ return 0;
+ if (type instanceof Integer)
+ return 3;
+ if (type instanceof Long)
+ return 4;
+ if (type instanceof Double)
+ return 5;
+ if (type instanceof Version)
+ return 6;
+ return -2;
+ }
+
private void writeList(DataOutputStream out, String[] list) throws IOException {
if (list == null) {
out.writeInt(0);
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/UserState.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/UserState.java
index 9fcfdbc..9059279 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/UserState.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/UserState.java
@@ -20,7 +20,7 @@
*/
public class UserState extends StateImpl {
// TODO this is not an accurate way to record updates
- private final Set updated = Collections.synchronizedSet(new HashSet());
+ private final Set<String> updated = Collections.synchronizedSet(new HashSet<String>());
public boolean removeBundle(BundleDescription description) {
if (description.getLocation() != null)