diff options
Diffstat (limited to 'bundles/org.eclipse.osgi.compatibility.state')
22 files changed, 260 insertions, 261 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java index 55ace736b..77113e4f9 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2012, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -103,7 +103,7 @@ public class PlatformAdminImpl implements PlatformAdmin { } private Dictionary<String, Object> asDictionary(Map<String, ?> map) { - return new Hashtable<String, Object>(map); + return new Hashtable<>(map); } @Override diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java index 361c30b5c..cc6d41936 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2013, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -82,7 +82,7 @@ class PlatformBundleListener implements SynchronousBundleListener, FrameworkList if (lastResolveStamp != database.getRevisionsTimestamp()) { Collection<ModuleRevision> containerRemovalPending = container.getRemovalPending(); BundleDescription[] stateRemovalPendingDescs = systemState.getRemovalPending(); - Collection<BundleDescription> stateRemovalPending = new ArrayList<BundleDescription>(stateRemovalPendingDescs.length); + Collection<BundleDescription> stateRemovalPending = new ArrayList<>(stateRemovalPendingDescs.length); for (BundleDescription description : stateRemovalPendingDescs) { if (!containerRemovalPending.contains(description.getUserObject())) { stateRemovalPending.add(description); @@ -150,7 +150,7 @@ class PlatformBundleListener implements SynchronousBundleListener, FrameworkList candidates.clear(); return; } - Collection<ModuleWiring> wirings = new ArrayList<ModuleWiring>(1); + Collection<ModuleWiring> wirings = new ArrayList<>(1); if ((reqRevision.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { if (ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(namespace) || HostNamespace.HOST_NAMESPACE.equals(namespace)) { wirings.add(reqWiring); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java index 56b59211c..afea17e11 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java @@ -35,18 +35,18 @@ class StateConverter { throw new IllegalArgumentException("Bogus osgi.identity: " + idList); //$NON-NLS-1$ } else if (idList.size() == 1) { Capability id = idList.iterator().next(); - Map<String, Object> idAttrs = new HashMap<String, Object>(id.getAttributes()); + Map<String, Object> idAttrs = new HashMap<>(id.getAttributes()); String symbolicName = (String) idAttrs.remove(IdentityNamespace.IDENTITY_NAMESPACE); symbolicNameSpecification = symbolicName + toString(idAttrs, "=", true) + toString(id.getDirectives(), ":=", true); //$NON-NLS-1$ //$NON-NLS-2$ version = (Version) idAttrs.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); } - List<ExportPackageDescription> exportPackages = new ArrayList<ExportPackageDescription>(); - List<GenericDescription> provideCapabilities = new ArrayList<GenericDescription>(); - List<ImportPackageSpecification> importPackages = new ArrayList<ImportPackageSpecification>(); - List<GenericSpecification> requireCapabilities = new ArrayList<GenericSpecification>(); - List<HostSpecification> fragmentHost = new ArrayList<HostSpecification>(0); - List<BundleSpecification> requireBundles = new ArrayList<BundleSpecification>(); + List<ExportPackageDescription> exportPackages = new ArrayList<>(); + List<GenericDescription> provideCapabilities = new ArrayList<>(); + List<ImportPackageSpecification> importPackages = new ArrayList<>(); + List<GenericSpecification> requireCapabilities = new ArrayList<>(); + List<HostSpecification> fragmentHost = new ArrayList<>(0); + List<BundleSpecification> requireBundles = new ArrayList<>(); Collection<Capability> capabilities = resource.getCapabilities(null); @@ -90,7 +90,7 @@ class StateConverter { } private List<ExportPackageDescription> creatExportPackage(Capability capability) { - Map<String, Object> attributes = new HashMap<String, Object>(capability.getAttributes()); + Map<String, Object> attributes = new HashMap<>(capability.getAttributes()); Map<String, String> directives = capability.getDirectives(); String packageName = (String) attributes.remove(PackageNamespace.PACKAGE_NAMESPACE); // remove invalid attributes @@ -144,7 +144,7 @@ class StateConverter { } private List<GenericSpecification> createRequireCapability(Requirement requirement) { - Map<String, String> directives = new HashMap<String, String>(requirement.getDirectives()); + Map<String, String> directives = new HashMap<>(requirement.getDirectives()); String filter = directives.get(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (filter != null) { directives.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, escapeFilterInput(filter)); @@ -185,7 +185,7 @@ class StateConverter { } private String createOSGiRequirement(Requirement requirement, String namespace, String... versions) { - Map<String, String> directives = new HashMap<String, String>(requirement.getDirectives()); + Map<String, String> directives = new HashMap<>(requirement.getDirectives()); String filter = directives.remove(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (filter == null) throw new IllegalArgumentException("No filter directive found:" + requirement); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java index 0acce4bd7..97136b1a2 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. All rights reserved. + * Copyright (c) 2004, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -20,7 +20,7 @@ public class GroupingChecker { // a mapping of bundles to their package roots; keyed by // ResolverBundle -> HashMap of packages; keyed by // package name -> PackageRoots - private Map<ResolverBundle, Map<String, PackageRoots>> bundles = new HashMap<ResolverBundle, Map<String, PackageRoots>>(); + private Map<ResolverBundle, Map<String, PackageRoots>> bundles = new HashMap<>(); /* * This method fully populates a bundles package roots for the purpose of resolving @@ -108,7 +108,7 @@ public class GroupingChecker { String[] uses = matchingCapability.getUsesDirective(); if (uses == null) return null; - ArrayList<PackageRoots[]> results = new ArrayList<PackageRoots[]>(0); + ArrayList<PackageRoots[]> results = new ArrayList<>(0); for (String usedPackage : uses) { PackageRoots providingRoots = getPackageRoots(matchingCapability.getResolverBundle(), usedPackage, null); providingRoots.addConflicts(requiringBundle, usedPackage, null, results); @@ -167,7 +167,7 @@ public class GroupingChecker { PackageRoots getPackageRoots(ResolverBundle bundle, String packageName, List<ResolverBundle> visited) { Map<String, PackageRoots> packages = bundles.get(bundle); if (packages == null) { - packages = new HashMap<String, PackageRoots>(5); + packages = new HashMap<>(5); bundles.put(bundle, packages); } PackageRoots packageRoots = packages.get(packageName); @@ -209,7 +209,7 @@ public class GroupingChecker { } // check if the bundle exports the package ResolverExport[] exports = bundle.getExports(packageName); - List<PackageRoots> roots = new ArrayList<PackageRoots>(0); + List<PackageRoots> roots = new ArrayList<>(0); // check roots from required bundles BundleConstraint[] requires = bundle.getRequires(); for (int i = 0; i < requires.length; i++) { @@ -326,7 +326,7 @@ public class GroupingChecker { if (roots == null) return results; if (visited == null) - visited = new ArrayList<PackageRoots>(1); + visited = new ArrayList<>(1); if (visited.contains(this)) return results; visited.add(this); @@ -346,7 +346,7 @@ public class GroupingChecker { if (thisUsedRoots != nullPackageRoots && importingUsedRoots != nullPackageRoots) if (!(subSet(thisUsedRoots.roots, importingUsedRoots.roots) || subSet(importingUsedRoots.roots, thisUsedRoots.roots))) { if (results == null) - results = new ArrayList<PackageRoots[]>(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, importingUsedRoots}); } // need to check the usedRoots consistency for transitive closure @@ -366,7 +366,7 @@ public class GroupingChecker { if (uses == null) continue; if (visited == null) - visited = new ArrayList<PackageRoots>(1); + visited = new ArrayList<>(1); if (visited.contains(this)) return results; visited.add(this); @@ -380,7 +380,7 @@ public class GroupingChecker { if (thisUsedRoots != nullPackageRoots && exportingUsedRoots != nullPackageRoots) if (!(subSet(thisUsedRoots.roots, exportingUsedRoots.roots) || subSet(exportingUsedRoots.roots, thisUsedRoots.roots))) { if (results == null) - results = new ArrayList<PackageRoots[]>(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, exportingUsedRoots}); } // need to check the usedRoots consistency for transitive closure @@ -397,7 +397,7 @@ public class GroupingChecker { if (this != nullPackageRoots && bundleUsedRoots != nullPackageRoots) if (!(subSet(this.roots, bundleUsedRoots.roots) || subSet(bundleUsedRoots.roots, this.roots))) { if (results == null) - results = new ArrayList<PackageRoots[]>(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, bundleUsedRoots}); } // need to check the usedRoots consistency for transitive closure diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java index 6c9482788..92880fb2f 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,13 +19,13 @@ import java.util.*; */ public class MappedList<K, V> { // the mapping with key -> Object[] mapping - protected final HashMap<K, List<V>> internal = new HashMap<K, List<V>>(); + protected final HashMap<K, List<V>> internal = new HashMap<>(); protected final List<V> empty = Collections.<V> emptyList(); public void put(K key, V value) { List<V> existing = internal.get(key); if (existing == null) { - existing = new ArrayList<V>(1); + existing = new ArrayList<>(1); existing.add(value); internal.put(key, existing); return; @@ -66,7 +66,7 @@ public class MappedList<K, V> { public List<V> getAllValues() { if (getSize() == 0) return empty; - ArrayList<V> results = new ArrayList<V>(getSize()); + ArrayList<V> results = new ArrayList<>(getSize()); Iterator<List<V>> iter = internal.values().iterator(); while (iter.hasNext()) results.addAll(iter.next()); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java index 8f16f561d..4502c1992 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,7 +62,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv imports = new ResolverImport[0]; requires = new BundleConstraint[0]; GenericSpecification[] requirements = getBundleDescription().getGenericRequires(); - List<GenericConstraint> constraints = new ArrayList<GenericConstraint>(); + List<GenericConstraint> constraints = new ArrayList<>(); for (GenericSpecification requirement : requirements) { if (StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getType())) constraints.add(new GenericConstraint(this, requirement)); @@ -83,7 +83,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv ImportPackageSpecification[] actualImports = getBundleDescription().getImportPackages(); // Reorder imports so that optionals are at the end so that we wire statics before optionals - List<ResolverImport> importList = new ArrayList<ResolverImport>(actualImports.length); + List<ResolverImport> importList = new ArrayList<>(actualImports.length); for (int i = actualImports.length - 1; i >= 0; i--) if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(actualImports[i].getDirective(Constants.RESOLUTION_DIRECTIVE))) importList.add(new ResolverImport(this, actualImports[i])); @@ -125,7 +125,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv } ResolverExport[] getExports(String name) { - List<ResolverExport> results = new ArrayList<ResolverExport>(1); // rare to have more than one + List<ResolverExport> results = new ArrayList<>(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 List<ResolverExport> resolverExports = resolver.getResolverExports().get(name); for (ResolverExport export : resolverExports) @@ -172,7 +172,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv } private <T> List<T> getAll(T[] hostEntries, Map<Long, List<T>> fragmentMap) { - List<T> result = new ArrayList<T>(hostEntries.length); + List<T> result = new ArrayList<>(hostEntries.length); for (T entry : hostEntries) result.add(entry); for (ResolverBundle fragment : fragments) { @@ -281,17 +281,17 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv private void initFragments() { if (fragments == null) - fragments = new ArrayList<ResolverBundle>(1); + fragments = new ArrayList<>(1); if (fragmentExports == null) - fragmentExports = new HashMap<Long, List<ResolverExport>>(1); + fragmentExports = new HashMap<>(1); if (fragmentImports == null) - fragmentImports = new HashMap<Long, List<ResolverImport>>(1); + fragmentImports = new HashMap<>(1); if (fragmentRequires == null) - fragmentRequires = new HashMap<Long, List<BundleConstraint>>(1); + fragmentRequires = new HashMap<>(1); if (fragmentGenericCapabilities == null) - fragmentGenericCapabilities = new HashMap<Long, List<GenericCapability>>(1); + fragmentGenericCapabilities = new HashMap<>(1); if (fragmentGenericRequires == null) - fragmentGenericRequires = new HashMap<Long, List<GenericConstraint>>(1); + fragmentGenericRequires = new HashMap<>(1); } private boolean isImported(String packageName) { @@ -342,7 +342,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv fragment.getHost().addPossibleSupplier(this); if (newImports.length > 0) { - ArrayList<ResolverImport> hostImports = new ArrayList<ResolverImport>(newImports.length); + ArrayList<ResolverImport> hostImports = new ArrayList<>(newImports.length); for (int i = 0; i < newImports.length; i++) if (!isImported(newImports[i].getName())) hostImports.add(new ResolverImport(this, newImports[i])); @@ -350,7 +350,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv } if (newRequires.length > 0) { - ArrayList<BundleConstraint> hostRequires = new ArrayList<BundleConstraint>(newRequires.length); + ArrayList<BundleConstraint> hostRequires = new ArrayList<>(newRequires.length); for (int i = 0; i < newRequires.length; i++) if (!isRequired(newRequires[i].getName())) hostRequires.add(new BundleConstraint(this, newRequires[i])); @@ -358,7 +358,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv } if (newGenericRequires.length > 0) { - ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<GenericConstraint>(newGenericRequires.length); + ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<>(newGenericRequires.length); for (int i = 0; i < newGenericRequires.length; i++) { // only add namespaces that are not osgi.ee if (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequires[i].getType())) @@ -368,7 +368,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv fragmentGenericRequires.put(fragment.bundleID, hostGenericRequires); } - ArrayList<ResolverExport> hostExports = new ArrayList<ResolverExport>(newExports.length); + ArrayList<ResolverExport> hostExports = new ArrayList<>(newExports.length); if (newExports.length > 0 && dynamicAttach) { for (int i = 0; i < newExports.length; i++) { ResolverExport currentExports[] = getExports(newExports[i].getName()); @@ -385,7 +385,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv fragmentExports.put(fragment.bundleID, hostExports); } - List<GenericCapability> hostCapabilities = new ArrayList<GenericCapability>(newGenericCapabilities.length); + List<GenericCapability> hostCapabilities = new ArrayList<>(newGenericCapabilities.length); if (newGenericCapabilities.length > 0 && dynamicAttach) { for (GenericDescription capability : newGenericCapabilities) { if (!IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) { @@ -536,8 +536,8 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv // bug 353103: must make a snapshot to avoid ConcurrentModificationException ResolverBundle[] remainingFrags = fragments.toArray(new ResolverBundle[fragments.size()]); for (ResolverBundle remainingFrag : remainingFrags) { - List<ResolverImport> additionalImports = new ArrayList<ResolverImport>(0); - List<BundleConstraint> additionalRequires = new ArrayList<BundleConstraint>(0); + List<ResolverImport> additionalImports = new ArrayList<>(0); + List<BundleConstraint> additionalRequires = new ArrayList<>(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 diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java index 9118adb6e..f215c1b9b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2004, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -53,7 +53,7 @@ public class ResolverImpl implements Resolver { // 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>(); + private MappedList<Long, BundleDescription> removalPending = new MappedList<>(); // Indicates whether this resolver has been initialized private boolean initialized = false; @@ -85,15 +85,15 @@ public class ResolverImpl implements Resolver { // Initializes the resolver private void initialize() { - 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>(); + resolverExports = new VersionHashMap<>(this); + resolverBundles = new VersionHashMap<>(this); + resolverGenerics = new HashMap<>(); + unresolvedBundles = new HashSet<>(); + bundleMapping = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); groupingChecker = new GroupingChecker(); - ArrayList<ResolverBundle> fragmentBundles = new ArrayList<ResolverBundle>(); + ArrayList<ResolverBundle> fragmentBundles = new ArrayList<>(); // Add each bundle to the resolver's internal state for (int i = 0; i < bundles.length; i++) initResolverBundle(bundles[i], fragmentBundles, false); @@ -137,7 +137,7 @@ public class ResolverImpl implements Resolver { // Re-wire previously resolved bundles private void rewireBundles() { - List<ResolverBundle> visited = new ArrayList<ResolverBundle>(bundleMapping.size()); + List<ResolverBundle> visited = new ArrayList<>(bundleMapping.size()); for (ResolverBundle rb : bundleMapping.values()) { if (!rb.getBundleDescription().isResolved()) continue; @@ -350,8 +350,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List<ResolverBundle> hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName()); - candidates = new ArrayList<ResolverBundle>(hosts); - List<BundleCapability> hostCapabilities = new ArrayList<BundleCapability>(hosts.size()); + candidates = new ArrayList<>(hosts); + List<BundleCapability> hostCapabilities = new ArrayList<>(hosts.size()); // Must remove candidates that do not match before calling hooks. for (Iterator<ResolverBundle> iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverBundle host = iCandidates.next(); @@ -365,7 +365,7 @@ public class ResolverImpl implements Resolver { } if (hook != null) - hook.filterMatches(hostConstraint.getRequirement(), asCapabilities(new ArrayMap<BundleCapability, ResolverBundle>(hostCapabilities, candidates))); + hook.filterMatches(hostConstraint.getRequirement(), asCapabilities(new ArrayMap<>(hostCapabilities, candidates))); } while (timestamp != state.getTimeStamp()); // we are left with only candidates that satisfy the host constraint for (ResolverBundle host : candidates) { @@ -443,24 +443,24 @@ public class ResolverImpl implements Resolver { // attempt to resolve all unresolved bundles Collection<ResolverBundle> hookDisabled = Collections.EMPTY_LIST; if (hook != null) { - List<ResolverBundle> resolvableBundles = new ArrayList<ResolverBundle>(unresolvedBundles); - List<BundleRevision> resolvableRevisions = new ArrayList<BundleRevision>(resolvableBundles.size()); + List<ResolverBundle> resolvableBundles = new ArrayList<>(unresolvedBundles); + List<BundleRevision> resolvableRevisions = new ArrayList<>(resolvableBundles.size()); for (ResolverBundle bundle : resolvableBundles) resolvableRevisions.add(bundle.getBundleDescription()); - ArrayMap<BundleRevision, ResolverBundle> resolvable = new ArrayMap<BundleRevision, ResolverBundle>(resolvableRevisions, resolvableBundles); + ArrayMap<BundleRevision, ResolverBundle> resolvable = new ArrayMap<>(resolvableRevisions, resolvableBundles); int size = resolvableBundles.size(); hook.filterResolvable(resolvable); if (resolvable.size() < size) { - hookDisabled = new ArrayList<ResolverBundle>(unresolvedBundles); + hookDisabled = new ArrayList<>(unresolvedBundles); hookDisabled.removeAll(resolvableBundles); } } usesCalculationTimeout = false; - List<ResolverBundle> toResolve = new ArrayList<ResolverBundle>(unresolvedBundles); + List<ResolverBundle> toResolve = new ArrayList<>(unresolvedBundles); // first resolve the system bundle to allow osgi.ee capabilities to be resolved - List<ResolverBundle> unresolvedSystemBundles = new ArrayList<ResolverBundle>(1); + List<ResolverBundle> unresolvedSystemBundles = new ArrayList<>(1); String systemBSN = getSystemBundle(); for (Iterator<ResolverBundle> iToResolve = toResolve.iterator(); iToResolve.hasNext();) { ResolverBundle rb = iToResolve.next(); @@ -549,7 +549,7 @@ public class ResolverImpl implements Resolver { 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 - Set<BundleDescription> additionalRefresh = new HashSet<BundleDescription>(); + Set<BundleDescription> additionalRefresh = new HashSet<>(); ResolverBundle[] unresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]); for (int i = 0; i < unresolved.length; i++) { addUnresolvedWithDependents(unresolved[i], additionalRefresh); @@ -588,7 +588,7 @@ public class ResolverImpl implements Resolver { } private Collection<ResolverBundle> resolveOptionalConstraints(ResolverBundle[] bundles) { - Collection<ResolverBundle> result = new ArrayList<ResolverBundle>(); + Collection<ResolverBundle> result = new ArrayList<>(); for (int i = 0; i < bundles.length; i++) { if (bundles[i] != null && resolveOptionalConstraints(bundles[i])) { result.add(bundles[i]); @@ -600,7 +600,7 @@ public class ResolverImpl implements Resolver { // TODO this does not do proper uses constraint verification. private boolean resolveOptionalConstraints(ResolverBundle bundle) { BundleConstraint[] requires = bundle.getRequires(); - List<ResolverBundle> cycle = new ArrayList<ResolverBundle>(); + List<ResolverBundle> cycle = new ArrayList<>(); boolean resolvedOptional = false; for (int i = 0; i < requires.length; i++) if (requires[i].isOptional() && requires[i].getSelectedSupplier() == null) { @@ -647,7 +647,7 @@ public class ResolverImpl implements Resolver { private void selectSingletons(ResolverBundle[] bundles) { if (developmentMode) return; // want all singletons to resolve in devmode - Map<String, Collection<ResolverBundle>> selectedSingletons = new HashMap<String, Collection<ResolverBundle>>(bundles.length); + Map<String, Collection<ResolverBundle>> selectedSingletons = new HashMap<>(bundles.length); for (ResolverBundle bundle : bundles) { if (!bundle.getBundleDescription().isSingleton() || !bundle.isResolvable()) continue; @@ -655,7 +655,7 @@ public class ResolverImpl implements Resolver { Collection<ResolverBundle> selected = selectedSingletons.get(bsn); if (selected != null) continue; // already processed the bsn - selected = new ArrayList<ResolverBundle>(1); + selected = new ArrayList<>(1); selectedSingletons.put(bsn, selected); List<ResolverBundle> sameBSN = resolverBundles.get(bsn); @@ -677,7 +677,7 @@ public class ResolverImpl implements Resolver { Collection<ResolverBundle> collisions = collisionMap.get(singleton); if (collisions == null || !singleton.isResolvable()) continue; // not a singleton or not resolvable - Collection<ResolverBundle> pickOneToResolve = new ArrayList<ResolverBundle>(); + Collection<ResolverBundle> pickOneToResolve = new ArrayList<>(); for (ResolverBundle collision : collisions) { if (selected.contains(collision)) { // Must fail since there is already a selected bundle which is a collision of the singleton bundle @@ -729,12 +729,12 @@ public class ResolverImpl implements Resolver { } private Map<ResolverBundle, Collection<ResolverBundle>> getCollisionMap(List<ResolverBundle> sameBSN) { - Map<ResolverBundle, Collection<ResolverBundle>> result = new HashMap<ResolverBundle, Collection<ResolverBundle>>(); + Map<ResolverBundle, Collection<ResolverBundle>> result = new HashMap<>(); for (ResolverBundle singleton : sameBSN) { if (!singleton.getBundleDescription().isSingleton() || !singleton.isResolvable()) continue; // ignore non-singleton and non-resolvable - List<ResolverBundle> collisionCandidates = new ArrayList<ResolverBundle>(sameBSN.size() - 1); - List<BundleCapability> capabilities = new ArrayList<BundleCapability>(sameBSN.size() - 1); + List<ResolverBundle> collisionCandidates = new ArrayList<>(sameBSN.size() - 1); + List<BundleCapability> capabilities = new ArrayList<>(sameBSN.size() - 1); for (ResolverBundle collision : sameBSN) { if (collision == singleton || !collision.getBundleDescription().isSingleton() || !collision.isResolvable()) continue; // Ignore the bundle we are checking and non-singletons and non-resolvable @@ -742,7 +742,7 @@ public class ResolverImpl implements Resolver { capabilities.add(getIdentity(collision)); } if (hook != null) - hook.filterSingletonCollisions(getIdentity(singleton), asCapabilities(new ArrayMap<BundleCapability, ResolverBundle>(capabilities, collisionCandidates))); + hook.filterSingletonCollisions(getIdentity(singleton), asCapabilities(new ArrayMap<>(capabilities, collisionCandidates))); result.put(singleton, collisionCandidates); } return result; @@ -758,12 +758,12 @@ public class ResolverImpl implements Resolver { // 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<String> processedFragments = new HashSet<String>(bundles.length); + Collection<String> processedFragments = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) attachFragment(bundles[i], processedFragments); // Lists of cyclic dependencies recording during resolving - List<ResolverBundle> cycle = new ArrayList<ResolverBundle>(1); // start small + List<ResolverBundle> cycle = new ArrayList<>(1); // start small // Attempt to resolve all unresolved bundles for (int i = 0; i < bundles.length; i++) { if (DEBUG) @@ -801,7 +801,7 @@ public class ResolverImpl implements Resolver { // 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<ResolverBundle>(1); + exclude = new HashSet<>(1); exclude.add(bundles[i]); } } @@ -819,7 +819,7 @@ public class ResolverImpl implements Resolver { continue; } if (conflictedBundles == null) - conflictedBundles = new HashSet<ResolverBundle>(conflictingConstraints.size()); + conflictedBundles = new HashSet<>(conflictingConstraints.size()); ResolverBundle conflictedBundle; if (conflict.isFromFragment()) conflictedBundle = bundleMapping.get(conflict.getVersionConstraint().getBundle()); @@ -842,7 +842,7 @@ public class ResolverImpl implements Resolver { private void reResolveBundles(Set<ResolverBundle> exclude, ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties) { if (exclude == null || exclude.size() == 0) return; - List<ResolverBundle> remainingUnresolved = new ArrayList<ResolverBundle>(); + List<ResolverBundle> remainingUnresolved = new ArrayList<>(); 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) @@ -859,9 +859,9 @@ public class ResolverImpl implements Resolver { usesMode = secureAction.getProperty("osgi.resolver.usesMode"); //$NON-NLS-1$ if ("ignore".equals(usesMode) || developmentMode) //$NON-NLS-1$ return null; - Set<String> bundleConstraints = new HashSet<String>(); - Set<String> packageConstraints = new HashSet<String>(); - Collection<GenericConstraint> multiRequirementWithMultiSuppliers = new ArrayList<GenericConstraint>(); + Set<String> bundleConstraints = new HashSet<>(); + Set<String> packageConstraints = new HashSet<>(); + Collection<GenericConstraint> multiRequirementWithMultiSuppliers = new ArrayList<>(); // first try out the initial selections List<ResolverConstraint> initialConflicts = getConflicts(bundles, packageConstraints, bundleConstraints, multiRequirementWithMultiSuppliers); if (initialConflicts == null || "tryFirst".equals(usesMode) || usesCalculationTimeout) { //$NON-NLS-1$ @@ -991,7 +991,7 @@ public class ResolverImpl implements Resolver { private ResolverBundle[] getConflictedBundles(List<ResolverConstraint> bestConflicts) { if (bestConflicts == null) return new ResolverBundle[0]; - List<ResolverBundle> conflictedBundles = new ArrayList<ResolverBundle>(bestConflicts.size()); + List<ResolverBundle> conflictedBundles = new ArrayList<>(bestConflicts.size()); for (ResolverConstraint constraint : bestConflicts) if (!conflictedBundles.contains(constraint.getBundle())) conflictedBundles.add(constraint.getBundle()); @@ -1044,7 +1044,7 @@ public class ResolverImpl implements Resolver { printConflict(conflict, requires[i], bundle); if (conflicts == null) - conflicts = new ArrayList<ResolverConstraint>(1); + conflicts = new ArrayList<>(1); conflicts.add(requires[i]); } } @@ -1059,7 +1059,7 @@ public class ResolverImpl implements Resolver { printConflict(conflict, imports[i], bundle); if (conflicts == null) - conflicts = new ArrayList<ResolverConstraint>(1); + conflicts = new ArrayList<>(1); conflicts.add(imports[i]); } } @@ -1081,7 +1081,7 @@ public class ResolverImpl implements Resolver { PackageRoots[][] conflict = groupingChecker.isConsistent(bundle, (GenericCapability) supplier); if (conflict != null) { if (capabilityConflicts == null) - capabilityConflicts = new ArrayList<PackageRoots[][]>(1); + capabilityConflicts = new ArrayList<>(1); capabilityConflicts.add(conflict); } } @@ -1092,7 +1092,7 @@ public class ResolverImpl implements Resolver { if (capabilityConflicts.size() == suppliers.length) { // every capability conflicted if (conflicts == null) - conflicts = new ArrayList<ResolverConstraint>(1); + conflicts = new ArrayList<>(1); conflicts.add(capabilityRequirement); } } @@ -1136,9 +1136,9 @@ public class ResolverImpl implements Resolver { // get a list of resolver constraints that have multiple suppliers // a 2 demensional array is used each entry is a list of identical constraints that have identical suppliers. private ResolverConstraint[][] getMultipleSuppliers(ResolverBundle[] bundles, Set<String> packageConstraints, Set<String> bundleConstraints) { - List<ResolverImport> multipleImportSupplierList = new ArrayList<ResolverImport>(1); - List<BundleConstraint> multipleRequireSupplierList = new ArrayList<BundleConstraint>(1); - List<GenericConstraint> multipleGenericSupplierList = new ArrayList<GenericConstraint>(1); + List<ResolverImport> multipleImportSupplierList = new ArrayList<>(1); + List<BundleConstraint> multipleRequireSupplierList = new ArrayList<>(1); + List<GenericConstraint> multipleGenericSupplierList = new ArrayList<>(1); for (ResolverBundle bundle : bundles) { BundleConstraint[] requires = bundle.getRequires(); for (BundleConstraint require : requires) @@ -1176,17 +1176,17 @@ public class ResolverImpl implements Resolver { if (genericRequire.getNumPossibleSuppliers() > 1 && !genericRequire.isMultiple()) multipleGenericSupplierList.add(genericRequire); } - List<ResolverConstraint[]> results = new ArrayList<ResolverConstraint[]>(); + List<ResolverConstraint[]> results = new ArrayList<>(); if (multipleImportSupplierList.size() + multipleRequireSupplierList.size() + multipleGenericSupplierList.size() > usesMultipleSuppliersLimit) { // we have hit a max on the multiple suppliers in the lists without merging. // first merge the identical constraints that have identical suppliers - Map<String, List<List<ResolverConstraint>>> multipleImportSupplierMaps = new HashMap<String, List<List<ResolverConstraint>>>(); + Map<String, List<List<ResolverConstraint>>> multipleImportSupplierMaps = new HashMap<>(); for (ResolverImport importPkg : multipleImportSupplierList) addMutipleSupplierConstraint(multipleImportSupplierMaps, importPkg, importPkg.getName()); - Map<String, List<List<ResolverConstraint>>> multipleRequireSupplierMaps = new HashMap<String, List<List<ResolverConstraint>>>(); + Map<String, List<List<ResolverConstraint>>> multipleRequireSupplierMaps = new HashMap<>(); for (BundleConstraint requireBundle : multipleRequireSupplierList) addMutipleSupplierConstraint(multipleRequireSupplierMaps, requireBundle, requireBundle.getName()); - Map<String, List<List<ResolverConstraint>>> multipleGenericSupplierMaps = new HashMap<String, List<List<ResolverConstraint>>>(); + Map<String, List<List<ResolverConstraint>>> multipleGenericSupplierMaps = new HashMap<>(); for (GenericConstraint genericRequire : multipleGenericSupplierList) addMutipleSupplierConstraint(multipleGenericSupplierMaps, genericRequire, genericRequire.getNameSpace()); addMergedSuppliers(results, multipleImportSupplierMaps); @@ -1196,7 +1196,7 @@ public class ResolverImpl implements Resolver { if (results.size() > usesMultipleSuppliersLimit && packageConstraints != null && bundleConstraints != null) { // we still have too big of a list; filter out constraints that are not in conflict List<ResolverConstraint[]> tooBig = results; - results = new ArrayList<ResolverConstraint[]>(); + results = new ArrayList<>(); for (ResolverConstraint[] constraints : tooBig) { ResolverConstraint constraint = constraints.length > 0 ? constraints[0] : null; if (constraint instanceof ResolverImport) { @@ -1240,8 +1240,8 @@ public class ResolverImpl implements Resolver { private void addMutipleSupplierConstraint(Map<String, List<List<ResolverConstraint>>> constraints, ResolverConstraint constraint, String key) { List<List<ResolverConstraint>> mergedConstraintLists = constraints.get(key); if (mergedConstraintLists == null) { - mergedConstraintLists = new ArrayList<List<ResolverConstraint>>(0); - List<ResolverConstraint> constraintList = new ArrayList<ResolverConstraint>(1); + mergedConstraintLists = new ArrayList<>(0); + List<ResolverConstraint> constraintList = new ArrayList<>(1); constraintList.add(constraint); mergedConstraintLists.add(constraintList); constraints.put(key, mergedConstraintLists); @@ -1259,7 +1259,7 @@ public class ResolverImpl implements Resolver { constraintList.add(constraint); return; } - List<ResolverConstraint> constraintList = new ArrayList<ResolverConstraint>(1); + List<ResolverConstraint> constraintList = new ArrayList<>(1); constraintList.add(constraint); mergedConstraintLists.add(constraintList); } @@ -1299,7 +1299,7 @@ public class ResolverImpl implements Resolver { ResolverBundle cycleBundle = cycle.get(i); cycleBundle.clearWires(); } - List<ResolverBundle> innerCycle = new ArrayList<ResolverBundle>(cycle.size()); + List<ResolverBundle> innerCycle = new ArrayList<>(cycle.size()); for (int i = 0; i < cycle.size(); i++) resolveBundle(cycle.get(i), innerCycle); checkCycle(innerCycle); @@ -1494,8 +1494,8 @@ public class ResolverImpl implements Resolver { capabilities = Collections.EMPTY_LIST; else capabilities = name == null || name.indexOf('*') >= 0 ? namespace.getAllValues() : namespace.get(name); - candidates = new ArrayList<GenericCapability>(capabilities); - List<BundleCapability> genCapabilities = new ArrayList<BundleCapability>(candidates.size()); + candidates = new ArrayList<>(capabilities); + List<BundleCapability> genCapabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator<GenericCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) { GenericCapability capability = iCandidates.next(); @@ -1506,7 +1506,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(constraint.getRequirement(), asCapabilities(new ArrayMap<BundleCapability, GenericCapability>(genCapabilities, candidates))); + hook.filterMatches(constraint.getRequirement(), asCapabilities(new ArrayMap<>(genCapabilities, candidates))); } while (timestamp != state.getTimeStamp()); boolean result = false; // We are left with only capabilities that satisfy the constraint. @@ -1576,8 +1576,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List<ResolverBundle> bundles = resolverBundles.get(req.getVersionConstraint().getName()); - candidates = new ArrayList<ResolverBundle>(bundles); - List<BundleCapability> capabilities = new ArrayList<BundleCapability>(candidates.size()); + candidates = new ArrayList<>(bundles); + List<BundleCapability> capabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator<ResolverBundle> iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverBundle bundle = iCandidates.next(); @@ -1588,7 +1588,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(req.getRequirement(), asCapabilities(new ArrayMap<BundleCapability, ResolverBundle>(capabilities, candidates))); + hook.filterMatches(req.getRequirement(), asCapabilities(new ArrayMap<>(capabilities, candidates))); } while (timestamp != state.getTimeStamp()); // We are left with only capabilities that satisfy the require bundle. boolean result = false; @@ -1648,8 +1648,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List<ResolverExport> exports = resolverExports.get(imp.getName()); - candidates = new ArrayList<ResolverExport>(exports); - List<BundleCapability> capabilities = new ArrayList<BundleCapability>(candidates.size()); + candidates = new ArrayList<>(exports); + List<BundleCapability> capabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator<ResolverExport> iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverExport export = iCandidates.next(); @@ -1660,7 +1660,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(imp.getRequirement(), asCapabilities(new ArrayMap<BundleCapability, ResolverExport>(capabilities, candidates))); + hook.filterMatches(imp.getRequirement(), asCapabilities(new ArrayMap<>(capabilities, candidates))); } while (timestamp != state.getTimeStamp()); // We are left with only capabilities that satisfy the import. for (ResolverExport export : candidates) { @@ -1827,11 +1827,11 @@ public class ResolverImpl implements Resolver { stateResolveConstraints(rb); // Build up the state wires - Map<String, List<StateWire>> stateWires = new HashMap<String, List<StateWire>>(); + Map<String, List<StateWire>> stateWires = new HashMap<>(); // Gather selected exports ResolverExport[] exports = rb.getSelectedExports(); - List<ExportPackageDescription> selectedExports = new ArrayList<ExportPackageDescription>(exports.length); + List<ExportPackageDescription> selectedExports = new ArrayList<>(exports.length); for (int i = 0; i < exports.length; i++) { if (permissionChecker.checkPackagePermission(exports[i].getExportPackageDescription())) selectedExports.add(exports[i].getExportPackageDescription()); @@ -1840,7 +1840,7 @@ public class ResolverImpl implements Resolver { // Gather substitute exports ResolverExport[] substituted = rb.getSubstitutedExports(); - List<ExportPackageDescription> substitutedExports = new ArrayList<ExportPackageDescription>(substituted.length); + List<ExportPackageDescription> substitutedExports = new ArrayList<>(substituted.length); for (int i = 0; i < substituted.length; i++) { substitutedExports.add(substituted[i].getExportPackageDescription()); } @@ -1851,8 +1851,8 @@ public class ResolverImpl implements Resolver { // Gather bundles that have been wired to BundleConstraint[] requires = rb.getRequires(); - List<BundleDescription> bundlesWiredTo = new ArrayList<BundleDescription>(requires.length); - List<StateWire> requireWires = new ArrayList<StateWire>(requires.length); + List<BundleDescription> bundlesWiredTo = new ArrayList<>(requires.length); + List<StateWire> requireWires = new ArrayList<>(requires.length); for (int i = 0; i < requires.length; i++) if (requires[i].getSelectedSupplier() != null) { BundleDescription supplier = (BundleDescription) requires[i].getSelectedSupplier().getBaseDescription(); @@ -1865,14 +1865,14 @@ public class ResolverImpl implements Resolver { stateWires.put(BundleRevision.BUNDLE_NAMESPACE, requireWires); GenericCapability[] capabilities = rb.getGenericCapabilities(); - List<GenericDescription> selectedCapabilities = new ArrayList<GenericDescription>(capabilities.length); + List<GenericDescription> selectedCapabilities = new ArrayList<>(capabilities.length); for (GenericCapability capability : capabilities) if (capability.isEffective() && permissionChecker.checkCapabilityPermission(capability.getGenericDescription())) selectedCapabilities.add(capability.getGenericDescription()); GenericDescription[] selectedCapabilitiesArray = selectedCapabilities.toArray(new GenericDescription[selectedCapabilities.size()]); GenericConstraint[] genericRequires = rb.getGenericRequires(); - List<GenericDescription> resolvedGenericRequires = new ArrayList<GenericDescription>(genericRequires.length); + List<GenericDescription> resolvedGenericRequires = new ArrayList<>(genericRequires.length); for (GenericConstraint genericConstraint : genericRequires) { VersionSupplier[] matching = genericConstraint.getMatchingCapabilities(); if (matching != null) @@ -1882,7 +1882,7 @@ public class ResolverImpl implements Resolver { StateWire genericWire = newStateWire(rb.getBundleDescription(), genericConstraint.getVersionConstraint(), supplier.getSupplier(), supplier); List<StateWire> genericWires = stateWires.get(genericConstraint.getNameSpace()); if (genericWires == null) { - genericWires = new ArrayList<StateWire>(); + genericWires = new ArrayList<>(); stateWires.put(genericConstraint.getNameSpace(), genericWires); } genericWires.add(genericWire); @@ -1895,7 +1895,7 @@ public class ResolverImpl implements Resolver { VersionSupplier[] matchingBundles = rb.getHost().getPossibleSuppliers(); if (matchingBundles != null && matchingBundles.length > 0) { hostBundles = new BundleDescription[matchingBundles.length]; - List<StateWire> hostWires = new ArrayList<StateWire>(matchingBundles.length); + List<StateWire> hostWires = new ArrayList<>(matchingBundles.length); stateWires.put(BundleRevision.HOST_NAMESPACE, hostWires); for (int i = 0; i < matchingBundles.length; i++) { hostBundles[i] = matchingBundles[i].getBundleDescription(); @@ -1937,8 +1937,8 @@ public class ResolverImpl implements Resolver { private static ExportPackageDescription[] getExportsWiredTo(ResolverBundle rb, Map<String, List<StateWire>> stateWires) { // Gather exports that have been wired to ResolverImport[] imports = rb.getImportPackages(); - List<ExportPackageDescription> exportsWiredTo = new ArrayList<ExportPackageDescription>(imports.length); - List<StateWire> importWires = new ArrayList<StateWire>(imports.length); + List<ExportPackageDescription> exportsWiredTo = new ArrayList<>(imports.length); + List<StateWire> importWires = new ArrayList<>(imports.length); for (int i = 0; i < imports.length; i++) if (imports[i].getSelectedSupplier() != null) { ExportPackageDescription supplier = (ExportPackageDescription) imports[i].getSelectedSupplier().getBaseDescription(); @@ -2003,7 +2003,7 @@ public class ResolverImpl implements Resolver { Map<String, List<StateWire>> wires = ((BundleDescriptionImpl) importingBundle).getWires(); List<StateWire> imports = wires.get(BundleRevision.PACKAGE_NAMESPACE); if (imports == null) { - imports = new ArrayList<StateWire>(); + imports = new ArrayList<>(); wires.put(BundleRevision.PACKAGE_NAMESPACE, imports); } imports.add(newStateWire(importingBundle, requirement, capabilityHost, capability)); @@ -2294,7 +2294,7 @@ public class ResolverImpl implements Resolver { String type = capability.getGenericDescription().getType(); VersionHashMap<GenericCapability> namespace = resolverGenerics.get(type); if (namespace == null) { - namespace = new VersionHashMap<GenericCapability>(this); + namespace = new VersionHashMap<>(this); resolverGenerics.put(type, namespace); } namespace.put(capability.getName(), capability); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java index 3abcdfdb6..1eddc7035 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -140,7 +140,7 @@ public abstract class BaseDescriptionImpl implements BaseDescription { if (namespace.equals(internalName)) return attrs; // we are doing an alias, must remove internal Name and add alias - attrs = new HashMap<String, Object>(attrs); + attrs = new HashMap<>(attrs); Object nameValue = attrs.remove(internalName); if (nameValue != null) attrs.put(namespace, nameValue); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java index e460d9c91..d16b510d2 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -258,7 +258,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements LazyData currentData = loadLazyData(); synchronized (this.monitor) { if (currentData.stateWires == null) { - currentData.stateWires = new HashMap<String, List<StateWire>>(0); + currentData.stateWires = new HashMap<>(0); } return currentData.stateWires; } @@ -535,7 +535,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (newDependencies == null) return; if (!checkDups && dependencies == null) - dependencies = new ArrayList<BundleDescription>(newDependencies.length); + dependencies = new ArrayList<>(newDependencies.length); for (int i = 0; i < newDependencies.length; i++) { addDependency((BaseDescriptionImpl) newDependencies[i], checkDups); } @@ -548,7 +548,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (bundle == this) return; if (dependencies == null) - dependencies = new ArrayList<BundleDescription>(10); + dependencies = new ArrayList<>(10); if (!checkDups || !dependencies.contains(bundle)) { bundle.addDependent(this); dependencies.add(bundle); @@ -563,8 +563,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List<BundleDescription> getBundleDependencies() { synchronized (this.monitor) { if (dependencies == null) - return new ArrayList<BundleDescription>(0); - ArrayList<BundleDescription> required = new ArrayList<BundleDescription>(dependencies.size()); + return new ArrayList<>(0); + ArrayList<BundleDescription> required = new ArrayList<>(dependencies.size()); for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();) { BundleDescription dep = iter.next(); if (dep != this && dep.getHost() == null) @@ -577,7 +577,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements protected void addDependent(BundleDescription dependent) { synchronized (this.monitor) { if (dependents == null) - dependents = new ArrayList<BundleDescription>(10); + dependents = new ArrayList<>(10); // no need to check for duplicates here; this is only called in addDepenency which already checks for dups. dependents.add(dependent); } @@ -684,7 +684,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements LazyData currentData = loadLazyData(); synchronized (this.monitor) { if (currentData.addedDynamicImports == null) - currentData.addedDynamicImports = new ArrayList<ImportPackageSpecification>(); + currentData.addedDynamicImports = new ArrayList<>(); for (ImportPackageSpecification addImport : dynamicImport) { if (!ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(addImport.getDirective(Constants.RESOLUTION_DIRECTIVE))) throw new IllegalArgumentException("Import must be a dynamic import."); //$NON-NLS-1$ @@ -746,7 +746,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (lazyData.dynamicStamps == null) { if (timestamp == null) return; - lazyData.dynamicStamps = new HashMap<String, Long>(); + lazyData.dynamicStamps = new HashMap<>(); } if (timestamp == null) lazyData.dynamicStamps.remove(requestedPackage); @@ -858,7 +858,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public Map<String, String> getDeclaredDirectives() { - Map<String, String> result = new HashMap<String, String>(2); + Map<String, String> result = new HashMap<>(2); Map<String, String> arbitrary = getArbitraryDirectives(); if (arbitrary != null) result.putAll(arbitrary); @@ -879,7 +879,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public Map<String, Object> getDeclaredAttributes() { - Map<String, Object> result = new HashMap<String, Object>(1); + Map<String, Object> result = new HashMap<>(1); synchronized (this.monitor) { if (attributes != null) result.putAll(attributes); @@ -890,7 +890,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public List<BundleRequirement> getDeclaredRequirements(String namespace) { - List<BundleRequirement> result = new ArrayList<BundleRequirement>(); + List<BundleRequirement> result = new ArrayList<>(); if (namespace == null || BundleRevision.BUNDLE_NAMESPACE.equals(namespace)) { BundleSpecification[] requires = getRequiredBundles(); for (BundleSpecification require : requires) { @@ -914,7 +914,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public List<BundleCapability> getDeclaredCapabilities(String namespace) { - List<BundleCapability> result = new ArrayList<BundleCapability>(); + List<BundleCapability> result = new ArrayList<>(); if (host == null) { if (getSymbolicName() != null) { if (namespace == null || BundleRevision.BUNDLE_NAMESPACE.equals(namespace)) { @@ -1083,7 +1083,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements public List<BundleCapability> getCapabilities(String namespace) { if (!isInUse()) return null; - List<BundleCapability> result = new ArrayList<BundleCapability>(); + List<BundleCapability> result = new ArrayList<>(); GenericDescription[] genericCapabilities = getSelectedGenericCapabilities(); for (GenericDescription capabilitiy : genericCapabilities) { if (namespace == null || namespace.equals(capabilitiy.getType())) @@ -1116,7 +1116,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (requiredWires == null) // happens if not in use return null; - List<BundleRequirement> requirements = new ArrayList<BundleRequirement>(requiredWires.size()); + List<BundleRequirement> requirements = new ArrayList<>(requiredWires.size()); for (BundleWire wire : requiredWires) { if (!requirements.contains(wire.getRequirement())) requirements.add(wire.getRequirement()); @@ -1152,7 +1152,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (!isInUse()) return null; BundleDescription[] dependentBundles = getDependents(); - List<BundleWire> unorderedResult = new ArrayList<BundleWire>(); + List<BundleWire> unorderedResult = new ArrayList<>(); for (BundleDescription dependent : dependentBundles) { List<BundleWire> dependentWires = dependent.getWiring().getRequiredWires(namespace); if (dependentWires != null) @@ -1161,7 +1161,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements unorderedResult.add(bundleWire); } } - List<BundleWire> orderedResult = new ArrayList<BundleWire>(unorderedResult.size()); + List<BundleWire> orderedResult = new ArrayList<>(unorderedResult.size()); List<BundleCapability> capabilities = getCapabilities(namespace); for (BundleCapability capability : capabilities) { for (Iterator<BundleWire> wires = unorderedResult.iterator(); wires.hasNext();) { @@ -1185,7 +1185,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List<BundleWire> result = Collections.<BundleWire> emptyList(); Map<String, List<StateWire>> wireMap = getWires(); if (namespace == null) { - result = new ArrayList<BundleWire>(); + result = new ArrayList<>(); for (List<StateWire> wires : wireMap.values()) { for (StateWire wire : wires) { result.add(new BundleWireImpl(wire)); @@ -1196,7 +1196,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List<StateWire> wires = wireMap.get(namespace); if (wires == null) return result; - result = new ArrayList<BundleWire>(wires.size()); + result = new ArrayList<>(wires.size()); for (StateWire wire : wires) { result.add(new BundleWireImpl(wire)); } diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java index c0776d788..7fbe25896 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -118,7 +118,7 @@ public class BundleSpecificationImpl extends VersionConstraintImpl implements Bu @Override protected Map<String, String> getInternalDirectives() { - Map<String, String> result = new HashMap<String, String>(2); + Map<String, String> result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java index 121d14dea..a7467ba58 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements public Map<String, Object> getDirectives() { synchronized (this.monitor) { - Map<String, Object> result = new HashMap<String, Object>(7); + Map<String, Object> result = new HashMap<>(7); if (uses != null) result.put(Constants.USES_DIRECTIVE, uses); if (exclude != null) @@ -68,7 +68,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements } public Map<String, String> getDeclaredDirectives() { - Map<String, String> result = new HashMap<String, String>(6); + Map<String, String> result = new HashMap<>(6); synchronized (this.monitor) { Map<String, String> arbitrary = getArbitraryDirectives(); if (arbitrary != null) @@ -90,7 +90,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements } public Map<String, Object> getDeclaredAttributes() { - Map<String, Object> result = new HashMap<String, Object>(2); + Map<String, Object> result = new HashMap<>(2); synchronized (this.monitor) { if (attributes != null) result.putAll(attributes); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java index d6ce6d87b..b5adf213b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,7 +31,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener setType(fragmentDeclaration.getType()); Dictionary<String, Object> origAttrs = fragmentDeclaration.getAttributes(); if (origAttrs != null) { - Hashtable<String, Object> copyAttrs = new Hashtable<String, Object>(); + Hashtable<String, Object> copyAttrs = new Hashtable<>(); for (Enumeration<String> keys = origAttrs.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); copyAttrs.put(key, origAttrs.get(key)); @@ -39,7 +39,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener setAttributes(copyAttrs); } Map<String, String> origDirectives = fragmentDeclaration.getDeclaredDirectives(); - Map<String, String> copyDirectives = new HashMap<String, String>(origDirectives); + Map<String, String> copyDirectives = new HashMap<>(origDirectives); setDirectives(copyDirectives); setSupplier(host); this.fragmentDeclaration = fragmentDeclaration; @@ -118,7 +118,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener public Map<String, Object> getDeclaredAttributes() { synchronized (this.monitor) { - Map<String, Object> result = new HashMap<String, Object>(5); + Map<String, Object> result = new HashMap<>(5); if (attributes != null) for (Enumeration<String> keys = attributes.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java index f53e941b9..45fed239f 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -169,7 +169,7 @@ public class GenericSpecificationImpl extends VersionConstraintImpl implements G @Override protected Map<String, String> getInternalDirectives() { - Map<String, String> result = new HashMap<String, String>(2); + Map<String, String> result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); @@ -187,7 +187,7 @@ public class GenericSpecificationImpl extends VersionConstraintImpl implements G @Override protected Map<String, Object> getInteralAttributes() { synchronized (this.monitor) { - return attributes == null ? Collections.<String, Object> emptyMap() : new HashMap<String, Object>(attributes); + return attributes == null ? Collections.<String, Object> emptyMap() : new HashMap<>(attributes); } } diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java index 2b2f2f6ff..cc66a8770 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -137,7 +137,7 @@ public class HostSpecificationImpl extends VersionConstraintImpl implements Host @Override protected Map<String, String> getInternalDirectives() { - Map<String, String> result = new HashMap<String, String>(2); + Map<String, String> result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java index a81392533..8348ae2f0 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2012 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,7 +27,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem public Map<String, Object> getDirectives() { synchronized (this.monitor) { - Map<String, Object> result = new HashMap<String, Object>(5); + Map<String, Object> result = new HashMap<>(5); if (resolution != null) result.put(Constants.RESOLUTION_DIRECTIVE, resolution); return result; @@ -216,7 +216,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem @Override protected Map<String, String> getInternalDirectives() { synchronized (this.monitor) { - Map<String, String> result = new HashMap<String, String>(5); + Map<String, String> result = new HashMap<>(5); if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); if (resolution != null) { diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java index 7689ad400..0ae88cc40 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,7 +112,7 @@ public class StateBuilder { ManifestElement[] exports = ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE)); ManifestElement[] provides = ManifestElement.parseHeader(StateImpl.PROVIDE_PACKAGE, manifest.get(StateImpl.PROVIDE_PACKAGE)); boolean strict = state != null && state.inStrictMode(); - List<String> providedExports = new ArrayList<String>(provides == null ? 0 : provides.length); + List<String> providedExports = new ArrayList<>(provides == null ? 0 : provides.length); result.setExportPackages(createExportPackages(exports, provides, providedExports, strict)); ManifestElement[] imports = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, manifest.get(Constants.IMPORT_PACKAGE)); ManifestElement[] dynamicImports = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE, manifest.get(Constants.DYNAMICIMPORT_PACKAGE)); @@ -135,7 +135,7 @@ public class StateBuilder { ManifestElement[] genericRequires = ManifestElement.parseHeader(GENERIC_REQUIRE, manifest.get(GENERIC_REQUIRE)); List<ManifestElement> aliasList = null; if (genericAliases.length > 0) { - aliasList = new ArrayList<ManifestElement>(genericRequires == null ? 0 : genericRequires.length); + aliasList = new ArrayList<>(genericRequires == null ? 0 : genericRequires.length); for (int i = 0; i < genericAliases.length; i++) { ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAliases[i][1], manifest.get(genericAliases[i][1])); if (aliasReqs == null) @@ -163,7 +163,7 @@ public class StateBuilder { ManifestElement[] genericCapabilities = ManifestElement.parseHeader(GENERIC_CAPABILITY, manifest.get(GENERIC_CAPABILITY)); List<ManifestElement> aliasList = null; if (genericAliases.length > 0) { - aliasList = new ArrayList<ManifestElement>(genericCapabilities == null ? 0 : genericCapabilities.length); + aliasList = new ArrayList<>(genericCapabilities == null ? 0 : genericCapabilities.length); for (int i = 0; i < genericAliases.length; i++) { ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAliases[i][0], manifest.get(genericAliases[i][0])); if (aliasCapabilities == null) @@ -250,7 +250,7 @@ public class StateBuilder { // 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<ImportPackageSpecification>(exported.length + (imported == null ? 0 : imported.length)); + allImports = new ArrayList<>(exported.length + (imported == null ? 0 : imported.length)); for (int i = 0; i < exported.length; i++) { if (providedExports.contains(exported[i].getName())) continue; @@ -261,7 +261,7 @@ public class StateBuilder { allImports.add(result); } } else { - allImports = new ArrayList<ImportPackageSpecification>(imported == null ? 0 : imported.length); + allImports = new ArrayList<>(imported == null ? 0 : imported.length); } // add dynamics first so they will get overriden by static imports if @@ -320,7 +320,7 @@ public class StateBuilder { int numExports = (exported == null ? 0 : exported.length) + (provides == null ? 0 : provides.length); if (numExports == 0) return null; - List<ExportPackageDescription> allExports = new ArrayList<ExportPackageDescription>(numExports); + List<ExportPackageDescription> allExports = new ArrayList<>(numExports); if (exported != null) for (int i = 0; i < exported.length; i++) addExportPackages(exported[i], allExports, strict); @@ -384,7 +384,7 @@ public class StateBuilder { continue keyloop; } if (arbitraryDirectives == null) - arbitraryDirectives = new HashMap<String, String>(); + arbitraryDirectives = new HashMap<>(); arbitraryDirectives.put(key, element.getDirective(key)); } return arbitraryDirectives; @@ -413,7 +413,7 @@ public class StateBuilder { } if (!definedAttr) { if (arbitraryAttrs == null) - arbitraryAttrs = new HashMap<String, Object>(); + arbitraryAttrs = new HashMap<>(); arbitraryAttrs.put(key, convertValue(type, value)); } } @@ -461,7 +461,7 @@ public class StateBuilder { throw new RuntimeException("Invalid type, missing ending '>' : " + type); //$NON-NLS-1$ } List<String> tokens = new Tokenizer(value).getEscapedTokens(","); //$NON-NLS-1$ - List<Object> components = new ArrayList<Object>(); + List<Object> components = new ArrayList<>(); for (String component : tokens) { components.add(convertValue(componentType, component)); } @@ -494,8 +494,8 @@ public class StateBuilder { if (brees == null || brees.length == 0) return result; if (result == null) - result = new ArrayList<GenericSpecification>(brees.length); - List<String> breeFilters = new ArrayList<String>(); + result = new ArrayList<>(brees.length); + List<String> breeFilters = new ArrayList<>(); for (String bree : brees) breeFilters.add(createOSGiEERequirementFilter(bree)); String filterSpec; @@ -609,7 +609,7 @@ public class StateBuilder { if (osgiRequires == null) return result; if (result == null) - result = new ArrayList<GenericSpecification>(); + result = new ArrayList<>(); for (ManifestElement element : osgiRequires) { String[] namespaces = element.getValueComponents(); for (String namespace : namespaces) { @@ -647,7 +647,7 @@ public class StateBuilder { private static List<GenericSpecification> createEquinoxRequires(ManifestElement[] equinoxRequires) throws BundleException { if (equinoxRequires == null) return null; - ArrayList<GenericSpecification> results = new ArrayList<GenericSpecification>(equinoxRequires.length); + ArrayList<GenericSpecification> results = new ArrayList<>(equinoxRequires.length); for (int i = 0; i < equinoxRequires.length; i++) { String[] genericNames = equinoxRequires[i].getValueComponents(); for (int j = 0; j < genericNames.length; j++) { @@ -686,7 +686,7 @@ public class StateBuilder { static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result, BundleDescription description) throws BundleException { if (result == null) - result = new ArrayList<GenericDescription>(osgiCapabilities == null ? 1 : osgiCapabilities.length + 1); + result = new ArrayList<>(osgiCapabilities == null ? 1 : osgiCapabilities.length + 1); // Always have an osgi.identity capability if there is a symbolic name. GenericDescription osgiIdentity = createOsgiIdentityCapability(description); if (osgiIdentity != null) @@ -699,7 +699,7 @@ public class StateBuilder { if (osgiCapabilities == null) return result; if (result == null) - result = new ArrayList<GenericDescription>(osgiCapabilities.length); + result = new ArrayList<>(osgiCapabilities.length); for (ManifestElement element : osgiCapabilities) { String[] namespaces = element.getValueComponents(); @@ -712,9 +712,9 @@ public class StateBuilder { Map<String, Object> mapAttrs = getAttributes(element, new String[0]); if (profileIndex != null) mapAttrs.put(ExportPackageDescriptionImpl.EQUINOX_EE, profileIndex); - Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(mapAttrs); + Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<>(mapAttrs); desc.setAttributes(attrs); - Map<String, String> directives = new HashMap<String, String>(); + Map<String, String> directives = new HashMap<>(); Enumeration<String> keys = element.getDirectiveKeys(); if (keys != null) for (keys = element.getDirectiveKeys(); keys.hasMoreElements();) { @@ -731,7 +731,7 @@ public class StateBuilder { private static List<GenericDescription> createEquinoxCapabilities(ManifestElement[] equinoxCapabilities) throws BundleException { if (equinoxCapabilities == null) return null; - ArrayList<GenericDescription> results = new ArrayList<GenericDescription>(equinoxCapabilities.length); + ArrayList<GenericDescription> results = new ArrayList<>(equinoxCapabilities.length); for (int i = 0; i < equinoxCapabilities.length; i++) { String[] genericNames = equinoxCapabilities[i].getValueComponents(); for (int j = 0; j < genericNames.length; j++) { @@ -745,7 +745,7 @@ public class StateBuilder { throw new BundleException("A bundle is not allowed to define a capability in the " + IdentityNamespace.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$ } 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); + Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<>(mapAttrs); attrs.put(desc.getType(), name); String versionString = equinoxCapabilities[i].getAttribute(Constants.VERSION_ATTRIBUTE); if (versionString != null) @@ -811,7 +811,7 @@ public class StateBuilder { if (elements == null) return; int length = elements.length; - Set<String> packages = new HashSet<String>(length); + Set<String> packages = new HashSet<>(length); for (int i = 0; i < length; i++) { // check for duplicate imports String[] packageNames = elements[i].getValueComponents(); @@ -893,7 +893,7 @@ public class StateBuilder { return null; GenericDescriptionImpl result = new GenericDescriptionImpl(); result.setType(IdentityNamespace.IDENTITY_NAMESPACE); - Dictionary<String, Object> attributes = new Hashtable<String, Object>(description.getDeclaredAttributes()); + Dictionary<String, Object> attributes = new Hashtable<>(description.getDeclaredAttributes()); // remove osgi.wiring.bundle and bundle-version attributes attributes.remove(BundleNamespace.BUNDLE_NAMESPACE); attributes.remove(Constants.BUNDLE_VERSION_ATTRIBUTE); @@ -901,7 +901,7 @@ public class StateBuilder { attributes.put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, description.getHost() == null ? IdentityNamespace.TYPE_BUNDLE : IdentityNamespace.TYPE_FRAGMENT); attributes.put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, description.getVersion()); result.setAttributes(attributes); - Map<String, String> directives = new HashMap<String, String>(description.getDeclaredDirectives()); + Map<String, String> directives = new HashMap<>(description.getDeclaredDirectives()); // remove defaults directive values if (!description.isSingleton()) directives.remove(Constants.SINGLETON_DIRECTIVE); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java index 966a0224d..1e269f4a4 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,7 @@ final class StateDeltaImpl implements StateDelta { private final State state; - private final Map<BundleDescription, BundleDelta> changes = new HashMap<BundleDescription, BundleDelta>(); + private final Map<BundleDescription, BundleDelta> changes = new HashMap<>(); private ResolverHookException error; public StateDeltaImpl(State state) { @@ -37,7 +37,7 @@ final class StateDeltaImpl implements StateDelta { public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { - List<BundleDelta> result = new ArrayList<BundleDelta>(); + List<BundleDelta> result = new ArrayList<>(); for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java index 29f4e2b26..ad13c790a 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,7 +37,7 @@ public final class StateHelperImpl implements StateHelper { if (bundles == null || bundles.length == 0) return new BundleDescription[0]; - Set<BundleDescription> reachable = new HashSet<BundleDescription>(bundles.length); + Set<BundleDescription> reachable = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) { if (!bundles[i].isResolved()) continue; @@ -58,7 +58,7 @@ public final class StateHelperImpl implements StateHelper { public BundleDescription[] getPrerequisites(BundleDescription[] bundles) { if (bundles == null || bundles.length == 0) return new BundleDescription[0]; - Set<BundleDescription> reachable = new HashSet<BundleDescription>(bundles.length); + Set<BundleDescription> reachable = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) addPrerequisites(bundles[i], reachable); return reachable.toArray(new BundleDescription[reachable.size()]); @@ -75,7 +75,7 @@ public final class StateHelperImpl implements StateHelper { } private Map<String, List<ExportPackageDescription>> getExportedPackageMap(State state) { - Map<String, List<ExportPackageDescription>> result = new HashMap<String, List<ExportPackageDescription>>(); + Map<String, List<ExportPackageDescription>> result = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); for (int i = 0; i < bundles.length; i++) { ExportPackageDescription[] packages = bundles[i].getExportPackages(); @@ -83,7 +83,7 @@ public final class StateHelperImpl implements StateHelper { ExportPackageDescription description = packages[j]; List<ExportPackageDescription> exports = result.get(description.getName()); if (exports == null) { - exports = new ArrayList<ExportPackageDescription>(); + exports = new ArrayList<>(); result.put(description.getName(), exports); } exports.add(description); @@ -93,7 +93,7 @@ public final class StateHelperImpl implements StateHelper { } private Map<String, List<GenericDescription>> getGenericsMap(State state, boolean resolved) { - Map<String, List<GenericDescription>> result = new HashMap<String, List<GenericDescription>>(); + Map<String, List<GenericDescription>> result = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); for (int i = 0; i < bundles.length; i++) { if (resolved && !bundles[i].isResolved()) @@ -103,7 +103,7 @@ public final class StateHelperImpl implements StateHelper { GenericDescription description = generics[j]; List<GenericDescription> genericList = result.get(description.getName()); if (genericList == null) { - genericList = new ArrayList<GenericDescription>(1); + genericList = new ArrayList<>(1); result.put(description.getName(), genericList); } genericList.add(description); @@ -115,8 +115,8 @@ public final class StateHelperImpl implements StateHelper { private VersionConstraint[] getUnsatisfiedLeaves(State state, BundleDescription[] bundles, ResolverHook hook) { Map<String, List<ExportPackageDescription>> packages = getExportedPackageMap(state); Map<String, List<GenericDescription>> generics = getGenericsMap(state, false); - Set<VersionConstraint> result = new HashSet<VersionConstraint>(); - List<BundleDescription> bundleList = new ArrayList<BundleDescription>(bundles.length); + Set<VersionConstraint> result = new HashSet<>(); + List<BundleDescription> bundleList = new ArrayList<>(bundles.length); for (int i = 0; i < bundles.length; i++) bundleList.add(bundles[i]); for (int i = 0; i < bundleList.size(); i++) { @@ -193,7 +193,7 @@ public final class StateHelperImpl implements StateHelper { 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<VersionConstraint> unsatisfied = new ArrayList<VersionConstraint>(); + List<VersionConstraint> unsatisfied = new ArrayList<>(); HostSpecification host = bundle.getHost(); if (host != null) if (!host.isResolved() && !isBundleConstraintResolvable(host, BundleRevision.HOST_NAMESPACE, hook)) @@ -225,14 +225,14 @@ public final class StateHelperImpl implements StateHelper { } private ArrayMap<BundleCapability, BaseDescription> asArrayMap(List<BaseDescription> descriptions, String namespace) { - List<BundleCapability> capabilities = new ArrayList<BundleCapability>(descriptions.size()); + List<BundleCapability> capabilities = new ArrayList<>(descriptions.size()); for (BaseDescription description : descriptions) capabilities.add(((BaseDescriptionImpl) description).getCapability(namespace)); - return new ArrayMap<BundleCapability, BaseDescription>(capabilities, descriptions); + return new ArrayMap<>(capabilities, descriptions); } private List<BaseDescription> getPossibleCandidates(VersionConstraint constraint, BaseDescription[] descriptions, String namespace, ResolverHook hook, boolean resolved) { - List<BaseDescription> candidates = new ArrayList<BaseDescription>(); + List<BaseDescription> candidates = new ArrayList<>(); for (int i = 0; i < descriptions.length; i++) if ((!resolved || descriptions[i].getSupplier().isResolved()) && constraint.isSatisfiedBy(descriptions[i])) candidates.add(descriptions[i]); @@ -300,7 +300,7 @@ public final class StateHelperImpl implements StateHelper { } public Object[][] sortBundles(BundleDescription[] toSort) { - List<Object[]> references = new ArrayList<Object[]>(toSort.length); + List<Object[]> references = new ArrayList<>(toSort.length); for (int i = 0; i < toSort.length; i++) if (toSort[i].isResolved()) buildReferences(toSort[i], references); @@ -391,9 +391,9 @@ public final class StateHelperImpl implements StateHelper { if (state != null) strict = state.inStrictMode(); BundleDescription host = (BundleDescription) (bundle.getHost() == null ? bundle : bundle.getHost().getSupplier()); - 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 + List<ExportPackageDescription> orderedPkgList = new ArrayList<>(); // list of all ExportPackageDescriptions that are visible (ArrayList is used to keep order) + Set<ExportPackageDescription> pkgSet = new HashSet<>(); + Set<String> importList = new HashSet<>(); // 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++) { @@ -406,9 +406,9 @@ public final class StateHelperImpl implements StateHelper { } // get the sources of the required bundles of the exporter BundleSpecification[] requires = pkgSupplier.getExporter().getRequiredBundles(); - Set<BundleDescription> visited = new HashSet<BundleDescription>(); + Set<BundleDescription> visited = new HashSet<>(); visited.add(bundle); // always add self to prevent recursing into self - Set<String> importNames = new HashSet<String>(1); + Set<String> importNames = new HashSet<>(1); importNames.add(imports.getName(i)); for (int j = 0; j < requires.length; j++) { BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier(); @@ -420,7 +420,7 @@ public final class StateHelperImpl implements StateHelper { } // now find all the packages that are visible from required bundles RequiresHolder requires = new RequiresHolder(bundle, options); - Set<BundleDescription> visited = new HashSet<BundleDescription>(requires.getSize()); + Set<BundleDescription> visited = new HashSet<>(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); @@ -443,7 +443,7 @@ public final class StateHelperImpl implements StateHelper { 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<String>(1); + substituteNames = new HashSet<>(1); else substituteNames.clear(); // substituteNames is a set of one package containing the single substitute we are trying to get the source for @@ -453,13 +453,13 @@ public final class StateHelperImpl implements StateHelper { } } } - importList = substitutedExports.length == 0 ? importList : new HashSet<String>(importList); + importList = substitutedExports.length == 0 ? importList : new HashSet<>(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<String> exportNames = new HashSet<String>(exports.length); // set is used to improve performance of duplicate check. + HashSet<String> exportNames = new HashSet<>(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())) { @@ -479,7 +479,7 @@ public final class StateHelperImpl implements StateHelper { 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<BundleDescription> tmpVisited = new HashSet<BundleDescription>(); + Set<BundleDescription> tmpVisited = new HashSet<>(); getPackages(requiredBundles.getSupplier(i), symbolicName, importList, orderedPkgList, pkgSet, tmpVisited, strict, exportNames, options); } } @@ -577,7 +577,7 @@ class RequiresHolder { isUsingResolved = (options & StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES) != 0; if (isUsingResolved) { requiredBundles = null; - resolvedBundlesExported = new HashMap<BundleDescription, Boolean>(); + resolvedBundlesExported = new HashMap<>(); resolvedRequires = bundle.getResolvedRequires(); determineRequiresVisibility(bundle); } else { @@ -611,7 +611,7 @@ class RequiresHolder { */ private void determineRequiresVisibility(BundleDescription bundle) { BundleSpecification[] required = bundle.getRequiredBundles(); - Set<BundleDescription> resolved = new HashSet<BundleDescription>(); + Set<BundleDescription> resolved = new HashSet<>(); for (int i = 0; i < resolvedRequires.length; i++) { resolved.add(resolvedRequires[i]); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java index 5972e4363..163c88a4d 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,15 +112,15 @@ public abstract class StateImpl implements State { transient private Resolver resolver; transient private StateDeltaImpl changes; transient private boolean resolving = false; - transient private LinkedList<BundleDescription> removalPendings = new LinkedList<BundleDescription>(); + transient private LinkedList<BundleDescription> removalPendings = new LinkedList<>(); private boolean resolved = true; private long timeStamp = System.currentTimeMillis(); private final KeyedHashSet bundleDescriptions = new KeyedHashSet(false); - private final Map<BundleDescription, List<ResolverError>> resolverErrors = new HashMap<BundleDescription, List<ResolverError>>(); + private final Map<BundleDescription, List<ResolverError>> resolverErrors = new HashMap<>(); private StateObjectFactory factory; private final KeyedHashSet resolvedBundles = new KeyedHashSet(); - private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap<BundleDescription, List<DisabledInfo>>(); + private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap<>(); private boolean fullyLoaded = false; private boolean dynamicCacheChanged = false; // only used for lazy loading of BundleDescriptions @@ -128,7 +128,7 @@ public abstract class StateImpl implements State { @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 Set<String> platformPropertyKeys = new HashSet<String>(PROPS.length); + private final Set<String> platformPropertyKeys = new HashSet<>(PROPS.length); private ResolverHookFactory hookFactory; private ResolverHook hook; private boolean developmentMode = false; @@ -185,7 +185,7 @@ public abstract class StateImpl implements State { resolvedBundles.remove(existing); List<DisabledInfo> infos = disabledBundles.remove(existing); if (infos != null) { - List<DisabledInfo> newInfos = new ArrayList<DisabledInfo>(infos.size()); + List<DisabledInfo> newInfos = new ArrayList<>(infos.size()); for (Iterator<DisabledInfo> iInfos = infos.iterator(); iInfos.hasNext();) { DisabledInfo info = iInfos.next(); newInfos.add(new DisabledInfo(info.getPolicyName(), info.getMessage(), newDescription)); @@ -282,7 +282,7 @@ public abstract class StateImpl implements State { synchronized (this.monitor) { if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName)) symbolicName = getSystemBundle(); - final List<BundleDescription> bundles = new ArrayList<BundleDescription>(); + final List<BundleDescription> bundles = new ArrayList<>(); for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); if (symbolicName.equals(bundle.getSymbolicName())) @@ -513,7 +513,7 @@ public abstract class StateImpl implements State { if (reResolve == null) reResolve = internalGetRemovalPending(); if (triggers == null) { - Set<BundleDescription> triggerSet = new HashSet<BundleDescription>(); + Set<BundleDescription> triggerSet = new HashSet<>(); Collection<BundleDescription> closure = getDependencyClosure(Arrays.asList(reResolve)); for (BundleDescription toRefresh : closure) { Bundle bundle = toRefresh.getBundle(); @@ -527,7 +527,7 @@ public abstract class StateImpl implements State { @SuppressWarnings("unchecked") Headers<Object, Object>[] tmpPlatformProperties = new Headers[platformProperties.length]; for (int i = 0; i < platformProperties.length; i++) { - tmpPlatformProperties[i] = new Headers<Object, Object>(platformProperties[i].size()); + tmpPlatformProperties[i] = new Headers<>(platformProperties[i].size()); for (Enumeration<Object> keys = platformProperties[i].keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); tmpPlatformProperties[i].put(key, platformProperties[i].get(key)); @@ -568,7 +568,7 @@ public abstract class StateImpl implements State { 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 - List<BundleDescription> result = new ArrayList<BundleDescription>(reResolve.length + removed.length); + List<BundleDescription> result = new ArrayList<>(reResolve.length + removed.length); for (int i = 0; i < reResolve.length; i++) result.add(reResolve[i]); for (int i = 0; i < removed.length; i++) { @@ -699,7 +699,7 @@ public abstract class StateImpl implements State { public ExportPackageDescription[] getExportedPackages() { fullyLoad(); synchronized (this.monitor) { - List<ExportPackageDescription> allExportedPackages = new ArrayList<ExportPackageDescription>(); + List<ExportPackageDescription> allExportedPackages = new ArrayList<>(); for (Iterator<KeyedElement> iter = resolvedBundles.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); ExportPackageDescription[] bundlePackages = bundle.getSelectedExports(); @@ -721,7 +721,7 @@ public abstract class StateImpl implements State { } BundleDescription[] getFragments(final BundleDescription host) { - final List<BundleDescription> fragments = new ArrayList<BundleDescription>(); + final List<BundleDescription> fragments = new ArrayList<>(); synchronized (this.monitor) { for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); @@ -812,7 +812,7 @@ public abstract class StateImpl implements State { @SuppressWarnings("unchecked") Dictionary<Object, Object>[] newPlatformProperties = new Dictionary[platformProperties.length]; for (int i = 0; i < platformProperties.length; i++) { - newPlatformProperties[i] = new Hashtable<Object, Object>(platformProperties[i].size()); + newPlatformProperties[i] = new Hashtable<>(platformProperties[i].size()); synchronized (platformProperties[i]) { for (Enumeration<?> keys = platformProperties[i].keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); @@ -876,7 +876,7 @@ public abstract class StateImpl implements State { for (int idx = 0; idx < systemBundles.length; idx++) { BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[idx]; ExportPackageDescription[] exports = systemBundle.getExportPackages(); - List<ExportPackageDescription> newExports = new ArrayList<ExportPackageDescription>(exports.length); + List<ExportPackageDescription> newExports = new ArrayList<>(exports.length); for (int i = 0; i < exports.length; i++) if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0) newExports.add(exports[i]); @@ -910,7 +910,7 @@ public abstract class StateImpl implements State { BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); for (BundleDescription systemBundle : systemBundles) { GenericDescription[] capabilities = systemBundle.getGenericCapabilities(); - List<GenericDescription> newCapabilities = new ArrayList<GenericDescription>(capabilities.length); + List<GenericDescription> newCapabilities = new ArrayList<>(capabilities.length); for (GenericDescription capability : capabilities) { Object equinoxEEIndex = capability.getDeclaredAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE); if (equinoxEEIndex == null) @@ -940,14 +940,14 @@ public abstract class StateImpl implements State { if (OSGI_EE_NAMESPACE.equals(capability.getType()) && profileIndex.equals(capability.getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE))) return; // profile already specifies osgi.ee capabilities } - Map<String, List<String>> eeVersions = new HashMap<String, List<String>>(); + Map<String, List<String>> eeVersions = new HashMap<>(); String[] ees = ManifestElement.getArrayFromList(profileEE); for (String ee : ees) { String[] eeNameVersion = StateBuilder.getOSGiEENameVersion(ee); List<String> versions = eeVersions.get(eeNameVersion[0]); if (versions == null) { - versions = new ArrayList<String>(); + versions = new ArrayList<>(); eeVersions.put(eeNameVersion[0], versions); } if (eeNameVersion[1] != null && !versions.contains(eeNameVersion[1])) @@ -956,10 +956,10 @@ public abstract class StateImpl implements State { for (Map.Entry<String, List<String>> eeVersion : eeVersions.entrySet()) { GenericDescriptionImpl capability = new GenericDescriptionImpl(); capability.setType(OSGI_EE_NAMESPACE); - Dictionary<String, Object> attributes = new Hashtable<String, Object>(); + Dictionary<String, Object> attributes = new Hashtable<>(); attributes.put(capability.getType(), eeVersion.getKey()); if (eeVersion.getValue().size() > 0) { - List<Version> versions = new ArrayList<Version>(eeVersion.getValue().size()); + List<Version> versions = new ArrayList<>(eeVersion.getValue().size()); for (String version : eeVersion.getValue()) { versions.add(new Version(version)); } @@ -1036,7 +1036,7 @@ public abstract class StateImpl implements State { public Collection<BundleDescription> getDependencyClosure(Collection<BundleDescription> bundles) { BundleDescription[] removals = getRemovalPending(); - Set<BundleDescription> result = new HashSet<BundleDescription>(); + Set<BundleDescription> result = new HashSet<>(); for (BundleDescription bundle : bundles) { addDependents(bundle, result, removals); } @@ -1086,7 +1086,7 @@ public abstract class StateImpl implements State { resolving = true; ResolverHookFactory currentFactory = hookFactory; if (currentFactory != null) { - Collection<BundleRevision> triggers = new ArrayList<BundleRevision>(1); + Collection<BundleRevision> triggers = new ArrayList<>(1); triggers.add(importingBundle); triggers = Collections.unmodifiableCollection(triggers); currentHook = begin(triggers); @@ -1165,7 +1165,7 @@ public abstract class StateImpl implements State { public ExportPackageDescription[] getSystemPackages() { synchronized (this.monitor) { - List<ExportPackageDescription> result = new ArrayList<ExportPackageDescription>(); + List<ExportPackageDescription> result = new ArrayList<>(); BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); if (systemBundles.length > 0) { BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[0]; @@ -1199,7 +1199,7 @@ public abstract class StateImpl implements State { throw new IllegalStateException(); // TODO need error message here! List<ResolverError> errors = resolverErrors.get(bundle); if (errors == null) { - errors = new ArrayList<ResolverError>(1); + errors = new ArrayList<>(1); resolverErrors.put(bundle, errors); } errors.add(new ResolverErrorImpl((BundleDescriptionImpl) bundle, type, data, unsatisfied)); @@ -1266,7 +1266,7 @@ public abstract class StateImpl implements State { throw new IllegalArgumentException(NLS.bind(StateMsg.BUNDLE_NOT_IN_STATE, disabledInfo.getBundle())); List<DisabledInfo> currentInfos = disabledBundles.get(disabledInfo.getBundle()); if (currentInfos == null) { - currentInfos = new ArrayList<DisabledInfo>(1); + currentInfos = new ArrayList<>(1); currentInfos.add(disabledInfo); disabledBundles.put(disabledInfo.getBundle(), currentInfos); } else { @@ -1324,7 +1324,7 @@ public abstract class StateImpl implements State { * Used by StateWriter to get all the DisabledInfo objects to persist */ DisabledInfo[] getDisabledInfos() { - List<DisabledInfo> results = new ArrayList<DisabledInfo>(); + List<DisabledInfo> results = new ArrayList<>(); synchronized (this.monitor) { for (Iterator<List<DisabledInfo>> allDisabledInfos = disabledBundles.values().iterator(); allDisabledInfos.hasNext();) results.addAll(allDisabledInfos.next()); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java index 3561689e6..d5201f667 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,7 +112,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { bundle.setExecutionEnvironments(executionEnvironments); bundle.setGenericRequires(genericRequires); - List<GenericDescription> includeIdentity = new ArrayList<GenericDescription>(genericCapabilities == null ? 1 : genericCapabilities.length + 1); + List<GenericDescription> includeIdentity = new ArrayList<>(genericCapabilities == null ? 1 : genericCapabilities.length + 1); GenericDescription genericIdentity = StateBuilder.createOsgiIdentityCapability(bundle); if (genericIdentity != null) { includeIdentity.add(genericIdentity); @@ -332,7 +332,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { 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<String, Object> attrs = attributes == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(attributes); + Dictionary<String, Object> attrs = attributes == null ? new Hashtable<String, Object>() : new Hashtable<>(attributes); if (version != null) { Object versionObj = attrs.get(Constants.VERSION_ATTRIBUTE); if (!(versionObj instanceof Version) && version != null) @@ -509,7 +509,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, declaration); if (elements == null) return Collections.<BundleSpecification> emptyList(); - List<BundleSpecification> result = new ArrayList<BundleSpecification>(elements.length); + List<BundleSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createRequiredBundle(element)); return result; @@ -523,7 +523,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, declaration); if (elements == null) return Collections.<HostSpecification> emptyList(); - List<HostSpecification> result = new ArrayList<HostSpecification>(elements.length); + List<HostSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createHostSpecification(element, null)); return result; @@ -537,7 +537,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) return Collections.<ImportPackageSpecification> emptyList(); - List<ImportPackageSpecification> result = new ArrayList<ImportPackageSpecification>(elements.length); + List<ImportPackageSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addImportPackages(element, result, 2, false); return result; @@ -573,7 +573,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) return Collections.<ExportPackageDescription> emptyList(); - List<ExportPackageDescription> result = new ArrayList<ExportPackageDescription>(elements.length); + List<ExportPackageDescription> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addExportPackages(element, result, false); return result; diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java index 149c0cb7d..a139e6252 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -104,7 +104,7 @@ final class StateReader { int numSets = in.readInt(); Dictionary<?, ?>[] platformProps = new Dictionary[numSets]; for (int i = 0; i < numSets; i++) { - Hashtable<Object, Object> props = new Hashtable<Object, Object>(platformPropKeys.length); + Hashtable<Object, Object> props = new Hashtable<>(platformPropKeys.length); int numProps = in.readInt(); for (int j = 0; j < numProps; j++) { Object value = readPlatformProp(in); @@ -164,7 +164,7 @@ final class StateReader { int numSets = in.readInt(); Dictionary<?, ?>[] platformProps = new Dictionary[numSets]; for (int i = 0; i < numSets; i++) { - Hashtable<Object, Object> props = new Hashtable<Object, Object>(platformPropKeys.length); + Hashtable<Object, Object> props = new Hashtable<>(platformPropKeys.length); int numProps = in.readInt(); for (int j = 0; j < numProps; j++) { Object value = readPlatformProp(in); @@ -335,7 +335,7 @@ final class StateReader { int dynamicPkgCnt = in.readInt(); if (dynamicPkgCnt > 0) { - HashMap<String, Long> dynamicStamps = new HashMap<String, Long>(dynamicPkgCnt); + HashMap<String, Long> dynamicStamps = new HashMap<>(dynamicPkgCnt); for (int i = 0; i < dynamicPkgCnt; i++) { String pkg = readString(in, false); Long stamp = new Long(in.readLong()); @@ -432,7 +432,7 @@ final class StateReader { int count = in.readInt(); if (count == 0) return null; - HashMap<String, Object> result = new HashMap<String, Object>(count); + HashMap<String, Object> result = new HashMap<>(count); for (int i = 0; i < count; i++) { String key = readString(in, false); Object value = null; @@ -467,7 +467,7 @@ final class StateReader { } else if (type == 8) { int listType = in.readByte(); int size = in.readInt(); - List<Object> list = new ArrayList<Object>(size); + List<Object> list = new ArrayList<>(size); for (int j = 0; j < size; j++) { switch (listType) { case 0 : @@ -607,7 +607,7 @@ final class StateReader { result.setSupplier(readBundleDescription(in)); result.setType(readString(in, false)); Map<String, Object> mapAttrs = readMap(in); - Dictionary<String, Object> attrs = new Hashtable<String, Object>(); + Dictionary<String, Object> attrs = new Hashtable<>(); if (mapAttrs != null) { for (Iterator<String> keys = mapAttrs.keySet().iterator(); keys.hasNext();) { String key = keys.next(); @@ -718,8 +718,7 @@ final class StateReader { int minorComponent = in.readInt(); int serviceComponent = in.readInt(); String qualifierComponent = readString(in, false); - Version result = (Version) ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent)); - //Version result = new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent); + Version result = ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent)); return result; } @@ -763,12 +762,12 @@ final class StateReader { if (intern) return string.intern(); - return (String) ObjectPool.intern(string); + return ObjectPool.intern(string); } if (intern) return in.readUTF().intern(); - return (String) ObjectPool.intern(in.readUTF()); + return ObjectPool.intern(in.readUTF()); } private byte readTag(DataInputStream in) throws IOException { @@ -818,7 +817,7 @@ final class StateReader { try { in = openLazyFile(); // get the set of bundles that must be loaded according to dependencies - List<BundleDescriptionImpl> toLoad = new ArrayList<BundleDescriptionImpl>(); + List<BundleDescriptionImpl> toLoad = new ArrayList<>(); addDependencies(target, toLoad); int skipBytes[] = getSkipBytes(toLoad); // look for the lazy data of the toLoad list diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java index 28ebabc70..be522861b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,9 +27,9 @@ class StateWriter { // 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<Object, Integer> objectTable = new HashMap<Object, Integer>(); + private final Map<Object, Integer> objectTable = new HashMap<>(); - private final List<Object> forcedWrite = new ArrayList<Object>(); + private final List<Object> forcedWrite = new ArrayList<>(); private int addToObjectTable(Object object) { Integer cur = objectTable.get(object); @@ -383,7 +383,7 @@ class StateWriter { writeBundleDescription(description.getSupplier(), out, false); writeStringOrNull(description.getType() == GenericDescription.DEFAULT_TYPE ? null : description.getType(), out); Dictionary<String, Object> attrs = description.getAttributes(); - Map<String, Object> mapAttrs = new HashMap<String, Object>(attrs.size()); + Map<String, Object> mapAttrs = new HashMap<>(attrs.size()); for (Enumeration<String> keys = attrs.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); mapAttrs.put(key, attrs.get(key)); |