diff options
author | Hannes Wellmann | 2021-07-14 17:34:51 +0000 |
---|---|---|
committer | Lars Vogel | 2021-07-23 11:19:19 +0000 |
commit | e3bccaf7f84aadea18a0815ce72139a21a277768 (patch) | |
tree | 6864bf2c3e334fd4afa3a22177fa7ee8e4ab17a0 | |
parent | 84793cad4d2a540b3cf268d8848b9592e0726b0c (diff) | |
download | rt.equinox.framework-e3bccaf7f84aadea18a0815ce72139a21a277768.tar.gz rt.equinox.framework-e3bccaf7f84aadea18a0815ce72139a21a277768.tar.xz rt.equinox.framework-e3bccaf7f84aadea18a0815ce72139a21a277768.zip |
Bug 574850 - [Clean-up] Remove generic type arguments where possible (2)
Use the regex "\.\<.*\(" to finds locations in java files where generic
type arguments are specified in method calls.
And use Sonar-Lint Eclipse plug-in to find remaining locations where the
diamond operator can be used.
Change-Id: I8d751b2fa833439d217909efc97096ec093793be
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183106
Reviewed-by: Lars Vogel <Lars.Vogel@vogella.com>
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
52 files changed, 324 insertions, 208 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF index 108e99984..3bab8401d 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.osgi.compatibility.state -Bundle-Version: 1.2.400.qualifier +Bundle-Version: 1.2.500.qualifier ExtensionBundle-Activator: org.eclipse.osgi.compatibility.state.Activator Fragment-Host: org.eclipse.osgi;bundle-version="3.12.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.eclipse.osgi.compatibility.state/pom.xml b/bundles/org.eclipse.osgi.compatibility.state/pom.xml index 3b441109d..81c39d8ff 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/pom.xml +++ b/bundles/org.eclipse.osgi.compatibility.state/pom.xml @@ -19,6 +19,6 @@ </parent> <groupId>org.eclipse.osgi</groupId> <artifactId>org.eclipse.osgi.compatibility.state</artifactId> - <version>1.2.400-SNAPSHOT</version> + <version>1.2.500-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> 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 9d4248b3b..fdccbf30f 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, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which accompanies this distribution, @@ -12,7 +12,10 @@ ******************************************************************************/ package org.eclipse.osgi.internal.module; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.osgi.service.resolver.BundleSpecification; import org.eclipse.osgi.service.resolver.ExportPackageDescription; @@ -40,7 +43,7 @@ public class GroupingChecker { for (BundleConstraint require : requires) { ResolverBundle selectedSupplier = (ResolverBundle) require.getSelectedSupplier(); if (selectedSupplier != null) - isConsistentInternal(bundle, selectedSupplier, new ArrayList<ResolverBundle>(1), true, null); + isConsistentInternal(bundle, selectedSupplier, new ArrayList<>(1), true, null); } // process all imports // must check resolved imports to get any dynamically resolved imports @@ -71,7 +74,7 @@ public class GroupingChecker { * If an inconsistency is found the export inconsistency is returned; otherwise null is returned */ public PackageRoots[][] isConsistent(ResolverBundle requiringBundle, ResolverBundle matchingBundle) { - List<PackageRoots[]> results = isConsistentInternal(requiringBundle, matchingBundle, new ArrayList<ResolverBundle>(1), false, null); + List<PackageRoots[]> results = isConsistentInternal(requiringBundle, matchingBundle, new ArrayList<>(1), false, null); return results == null ? null : results.toArray(new PackageRoots[results.size()][]); } 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 8d4bb5b41..0a9d7ad28 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, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,7 +13,11 @@ *******************************************************************************/ package org.eclipse.osgi.internal.module; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; /* * A MappedList maps values into keyed list arrays. All values with the same key are stored @@ -23,7 +27,7 @@ import java.util.*; public class MappedList<K, V> { // the mapping with key -> Object[] mapping protected final HashMap<K, List<V>> internal = new HashMap<>(); - protected final List<V> empty = Collections.<V> emptyList(); + protected final List<V> empty = Collections.emptyList(); public void put(K key, V value) { List<V> existing = internal.get(key); 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 7cd4e670c..89de26db7 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, 2020 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which accompanies this distribution, @@ -423,7 +423,7 @@ public class ResolverImpl implements Resolver { if (!(StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getNameSpace()) || requirement.isEffective())) continue; { - if (!resolveGenericReq(requirement, new ArrayList<ResolverBundle>(0))) { + if (!resolveGenericReq(requirement, new ArrayList<>(0))) { if (DEBUG || DEBUG_GENERICS) ResolverImpl.log("** GENERICS " + requirement.getVersionConstraint().getName() + "[" + requirement.getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ state.addResolverError(requirement.getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, requirement.getVersionConstraint().toString(), requirement.getVersionConstraint()); @@ -2104,7 +2104,7 @@ public class ResolverImpl implements Resolver { if (!requestedPackage.equals(dynamicImport.getName())) return null; - if (resolveImport(dynamicImport, new ArrayList<ResolverBundle>())) { + if (resolveImport(dynamicImport, new ArrayList<>())) { // populate the grouping checker with current imports groupingChecker.populateRoots(dynamicImport.getBundle()); while (dynamicImport.getSelectedSupplier() != null) { 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 0c6d04e04..a1f3d16a2 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, 2020 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -1218,7 +1218,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements public List<BundleWire> getRequiredWires(String namespace) { if (!isInUse()) return null; - List<BundleWire> result = Collections.<BundleWire> emptyList(); + List<BundleWire> result = Collections.emptyList(); Map<String, List<StateWire>> wireMap = getWires(); if (namespace == null) { result = new ArrayList<>(); 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 d0e449f3d..e21366310 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, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,8 +14,12 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; -import org.eclipse.osgi.service.resolver.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleSpecification; +import org.eclipse.osgi.service.resolver.VersionRange; import org.osgi.framework.Constants; import org.osgi.framework.wiring.BundleRevision; @@ -153,7 +157,7 @@ public class BundleSpecificationImpl extends VersionConstraintImpl implements Bu @Override protected Map<String, Object> getInteralAttributes() { - return Collections.<String, Object> emptyMap(); + return Collections.emptyMap(); } @Override 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 aba9d629c..9818dc324 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, 2016 IBM Corporation and others. + * Copyright (c) 2006, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,8 +14,16 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; -import org.eclipse.osgi.service.resolver.*; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.GenericDescription; import org.osgi.framework.Constants; import org.osgi.framework.Version; @@ -117,7 +125,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener public Map<String, String> getDeclaredDirectives() { synchronized (this.monitor) { if (directives == null) - return Collections.<String, String> emptyMap(); + return Collections.emptyMap(); return Collections.unmodifiableMap(directives); } } 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 086e921df..3f8db6219 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, 2016 IBM Corporation and others. + * Copyright (c) 2006, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,10 +14,16 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.eclipse.osgi.internal.framework.FilterImpl; -import org.eclipse.osgi.service.resolver.*; -import org.osgi.framework.*; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.GenericDescription; +import org.eclipse.osgi.service.resolver.GenericSpecification; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.resource.Namespace; public class GenericSpecificationImpl extends VersionConstraintImpl implements GenericSpecification { @@ -195,7 +201,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<>(attributes); + return attributes == null ? Collections.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 0ae911cf8..72421e5c3 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, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,8 +15,13 @@ package org.eclipse.osgi.internal.resolver; -import java.util.*; -import org.eclipse.osgi.service.resolver.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.HostSpecification; +import org.eclipse.osgi.service.resolver.VersionRange; import org.osgi.framework.Constants; import org.osgi.framework.wiring.BundleRevision; @@ -170,7 +175,7 @@ public class HostSpecificationImpl extends VersionConstraintImpl implements Host @Override protected Map<String, Object> getInteralAttributes() { - return Collections.<String, Object> emptyMap(); + return Collections.emptyMap(); } @Override 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 47c9f1c09..ab363a785 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, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,9 +15,15 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.eclipse.osgi.internal.framework.EquinoxContainer; -import org.eclipse.osgi.service.resolver.*; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.ExportPackageDescription; +import org.eclipse.osgi.service.resolver.ImportPackageSpecification; +import org.eclipse.osgi.service.resolver.VersionRange; import org.osgi.framework.Constants; import org.osgi.framework.wiring.BundleRevision; @@ -258,7 +264,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem @Override protected Map<String, Object> getInteralAttributes() { - return Collections.<String, Object> emptyMap(); + return Collections.emptyMap(); } @Override diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java index 8f6a1939f..ef8fb252b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. + * Copyright (c) 2007, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,11 +14,18 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Map; import org.eclipse.osgi.internal.framework.FilterImpl; -import org.eclipse.osgi.service.resolver.*; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.NativeCodeDescription; +import org.eclipse.osgi.service.resolver.State; import org.eclipse.osgi.service.resolver.VersionRange; -import org.osgi.framework.*; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.Version; public class NativeCodeDescriptionImpl extends BaseDescriptionImpl implements NativeCodeDescription { private static final VersionRange[] EMPTY_VERSIONRANGES = new VersionRange[0]; @@ -213,10 +220,10 @@ public class NativeCodeDescriptionImpl extends BaseDescriptionImpl implements Na } public Map<String, String> getDeclaredDirectives() { - return Collections.<String, String> emptyMap(); + return Collections.emptyMap(); } public Map<String, Object> getDeclaredAttributes() { - return Collections.<String, Object> emptyMap(); + return Collections.emptyMap(); } } diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java index 5877f1040..39c47660d 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 IBM Corporation and others. + * Copyright (c) 2007, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,11 +14,19 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Map; import org.eclipse.osgi.internal.framework.AliasMapper; -import org.eclipse.osgi.service.resolver.*; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.NativeCodeDescription; +import org.eclipse.osgi.service.resolver.NativeCodeSpecification; +import org.eclipse.osgi.service.resolver.State; import org.eclipse.osgi.service.resolver.VersionRange; -import org.osgi.framework.*; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.Version; public class NativeCodeSpecificationImpl extends VersionConstraintImpl implements NativeCodeSpecification { private static final NativeCodeDescription[] EMPTY_NATIVECODEDESCRIPTIONS = new NativeCodeDescription[0]; @@ -187,12 +195,12 @@ public class NativeCodeSpecificationImpl extends VersionConstraintImpl implement @Override protected Map<String, String> getInternalDirectives() { - return Collections.<String, String> emptyMap(); + return Collections.emptyMap(); } @Override protected Map<String, Object> getInteralAttributes() { - return Collections.<String, Object> emptyMap(); + return Collections.emptyMap(); } @Override 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 78da2ae4a..8c00533d7 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, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -489,7 +489,7 @@ public final class StateHelperImpl implements StateHelper { substituteNames.clear(); // substituteNames is a set of one package containing the single substitute we are trying to get the source for substituteNames.add(exportName); - getPackages(resolvedImport.getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet<BundleDescription>(0), strict, substituteNames, options); + getPackages(resolvedImport.getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet<>(0), strict, substituteNames, options); } } } 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 e7b26ea87..e569fd95f 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, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -534,7 +534,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, declaration); if (elements == null) - return Collections.<BundleSpecification> emptyList(); + return Collections.emptyList(); List<BundleSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createRequiredBundle(element)); @@ -548,7 +548,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, declaration); if (elements == null) - return Collections.<HostSpecification> emptyList(); + return Collections.emptyList(); List<HostSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createHostSpecification(element, null)); @@ -562,7 +562,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) - return Collections.<ImportPackageSpecification> emptyList(); + return Collections.emptyList(); List<ImportPackageSpecification> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addImportPackages(element, result, 2, false); @@ -576,8 +576,8 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, declaration); if (elements == null) - return Collections.<GenericDescription> emptyList(); - return StateBuilder.createOSGiCapabilities(elements, new ArrayList<GenericDescription>(elements.length), (Integer) null); + return Collections.emptyList(); + return StateBuilder.createOSGiCapabilities(elements, new ArrayList<>(elements.length), (Integer) null); } catch (BundleException e) { throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } @@ -587,8 +587,8 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_CAPABILITY, declaration); if (elements == null) - return Collections.<GenericSpecification> emptyList(); - return StateBuilder.createOSGiRequires(elements, new ArrayList<GenericSpecification>(elements.length)); + return Collections.emptyList(); + return StateBuilder.createOSGiRequires(elements, new ArrayList<>(elements.length)); } catch (BundleException e) { throw new IllegalArgumentException("Declaration is invalid: " + declaration, e); //$NON-NLS-1$ } @@ -598,7 +598,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) - return Collections.<ExportPackageDescription> emptyList(); + return Collections.emptyList(); List<ExportPackageDescription> result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addExportPackages(element, result, false); diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java index 1b95e51d1..684b93e1a 100644 --- a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java +++ b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2017 IBM Corporation and others. + * Copyright (c) 2013, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -91,9 +91,9 @@ public class TestHookConfigurator implements HookConfigurator { replace.setId(5678); replace.setSymbolicName("replace"); replace.setVersion(Version.parseVersion("1.1.1")); - replace.addCapability("replace", Collections.<String, String> emptyMap(), Collections.<String, Object> emptyMap()); - replace.addCapability(IdentityNamespace.IDENTITY_NAMESPACE, Collections.<String, String> emptyMap(), Collections.<String, Object> singletonMap(IdentityNamespace.IDENTITY_NAMESPACE, "replace")); - replace.addCapability(BundleNamespace.BUNDLE_NAMESPACE, Collections.<String, String> emptyMap(), Collections.<String, Object> singletonMap(BundleNamespace.BUNDLE_NAMESPACE, "replace")); + replace.addCapability("replace", Collections.emptyMap(), Collections.emptyMap()); + replace.addCapability(IdentityNamespace.IDENTITY_NAMESPACE, Collections.emptyMap(), Collections.singletonMap(IdentityNamespace.IDENTITY_NAMESPACE, "replace")); + replace.addCapability(BundleNamespace.BUNDLE_NAMESPACE, Collections.emptyMap(), Collections.singletonMap(BundleNamespace.BUNDLE_NAMESPACE, "replace")); return replace; } if (TestHookConfigurator.adaptManifest) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java index 39712fffc..3a80a4814 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 IBM Corporation and others. + * Copyright (c) 2017, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -222,7 +222,7 @@ public class MultiReleaseJarTests extends AbstractBundleTests { classPathJarEntries.put("META-INF/versions/11/multi/release/test/sub/testResource11.txt", getBytes("multi/release/test/sub/testResource11.txt", base, new byte[] {'1', '1'})); classPathJarEntries.put("META-INF/versions/11/multi/release/test/sub/testResourceAdd11.txt", getBytes("multi/release/test/sub/testResourceAdd11.txt", base)); - createMRJar(classpathMrJar, Collections.<String, String> emptyMap(), classPathJarEntries); + createMRJar(classpathMrJar, Collections.emptyMap(), classPathJarEntries); bundleEntries.put(classpathMrJar.getName(), StorageUtil.getBytes(new FileInputStream(classpathMrJar), -1, 4000)); // This will not be required by the spec, but equinox does support exploded inner jars in a bundle diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java index eaaac922e..39920192e 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2017 IBM Corporation and others. + * Copyright (c) 2013, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -170,7 +170,7 @@ public class TestModuleContainer extends AbstractTest { Assert.assertNull("Unexpected install errors.", installErrors); } } - container.resolve(new ArrayList<Module>(), false); + container.resolve(new ArrayList<>(), false); List<Module> modules = container.getModules(); for (Module module : modules) { if (module.getCurrentRevision().getWiring() == null) { @@ -203,7 +203,7 @@ public class TestModuleContainer extends AbstractTest { resolvedModuleDatabase.store(new DataOutputStream(bytes), false); bytes.close(); adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray()))); - adaptor.getContainer().resolve(new ArrayList<Module>(), false); + adaptor.getContainer().resolve(new ArrayList<>(), false); } // Disabled @Test @@ -227,7 +227,7 @@ public class TestModuleContainer extends AbstractTest { resolvedModuleDatabase.store(new DataOutputStream(bytes), true); bytes.close(); adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray()))); - adaptor.getContainer().resolve(new ArrayList<Module>(), false); + adaptor.getContainer().resolve(new ArrayList<>(), false); } // Disabled @Test @@ -457,7 +457,7 @@ public class TestModuleContainer extends AbstractTest { @Test public void testInstallCollision02() throws BundleException, IOException { - DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.<String, String> emptyMap()); + DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.emptyMap()); ModuleContainer container = adaptor.getContainer(); installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container); installDummyModule("b1_v1.MF", "b1_a", container); @@ -494,7 +494,7 @@ public class TestModuleContainer extends AbstractTest { @Test public void testUpdateCollision03() throws BundleException, IOException { - DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.<String, String> emptyMap()); + DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.emptyMap()); ModuleContainer container = adaptor.getContainer(); Module b1_v1 = installDummyModule("b1_v1.MF", "b1_v1", container); installDummyModule("b1_v2.MF", "b1_v2", container); @@ -550,7 +550,7 @@ public class TestModuleContainer extends AbstractTest { }; } }; - DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap(), resolverHookFactory); + DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.emptyMap(), resolverHookFactory); ModuleContainer container = adaptor.getContainer(); Module s1 = installDummyModule("singleton1_v1.MF", "s1_v1", container); @@ -615,7 +615,7 @@ public class TestModuleContainer extends AbstractTest { }; } }; - DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap(), resolverHookFactory); + DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.emptyMap(), resolverHookFactory); ModuleContainer container = adaptor.getContainer(); Module s1_v1 = installDummyModule("singleton1_v1.MF", "s1_v1", container); @@ -2609,8 +2609,8 @@ public class TestModuleContainer extends AbstractTest { ModuleRevisionBuilder builder = new ModuleRevisionBuilder(); builder.setSymbolicName("invalid.attr"); builder.setVersion(Version.valueOf("1.0.0")); - builder.addCapability("test", Collections.<String, String> emptyMap(), Collections.singletonMap("test", (Object) testInt)); - builder.addCapability("test.list", Collections.<String, String> emptyMap(), Collections.singletonMap("test.list", (Object) testIntList)); + builder.addCapability("test", Collections.emptyMap(), Collections.singletonMap("test", (Object) testInt)); + builder.addCapability("test.list", Collections.emptyMap(), Collections.singletonMap("test.list", (Object) testIntList)); Module invalid = container.install(null, builder.getSymbolicName(), builder, null); Object testAttr = invalid.getCurrentRevision().getCapabilities("test").get(0).getAttributes().get("test"); @@ -2902,7 +2902,7 @@ public class TestModuleContainer extends AbstractTest { manifest.put(Constants.EXPORT_PACKAGE, "export"); installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container); - report = container.resolve(Collections.<Module> emptySet(), false); + report = container.resolve(Collections.emptySet(), false); Assert.assertNull("Found a error.", report.getResolutionException()); State expectedState = enabled ? State.ACTIVE : State.RESOLVED; diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/dummys/UnresolvedProviderEntryBuilder.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/dummys/UnresolvedProviderEntryBuilder.java index 8529fb409..d0d237085 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/dummys/UnresolvedProviderEntryBuilder.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/dummys/UnresolvedProviderEntryBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -35,7 +35,7 @@ public class UnresolvedProviderEntryBuilder { } public UnresolvedProviderEntryBuilder requirement(Requirement key) { - data.put(key, new ArrayList<Capability>()); + data.put(key, new ArrayList<>()); lastRequirement = key; return this; } diff --git a/bundles/org.eclipse.osgi.util/src/org/osgi/util/promise/PromiseFactory.java b/bundles/org.eclipse.osgi.util/src/org/osgi/util/promise/PromiseFactory.java index 23eb0cc47..8c4cd82d1 100644 --- a/bundles/org.eclipse.osgi.util/src/org/osgi/util/promise/PromiseFactory.java +++ b/bundles/org.eclipse.osgi.util/src/org/osgi/util/promise/PromiseFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2017, 2018). All Rights Reserved. + * Copyright (c) OSGi Alliance (2017, 2021). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -347,8 +347,7 @@ public class PromiseFactory { callbacks = new DefaultExecutors(); scheduledExecutor = new ScheduledExecutor(2, callbacks); callbackExecutor = new ThreadPoolExecutor(0, 64, 60L, - TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), - callbacks, callbacks); + TimeUnit.SECONDS, new SynchronousQueue<>(), callbacks, callbacks); } static Executor callbackExecutor() { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java index c8f1919b8..ab7bf6fb0 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java @@ -494,7 +494,7 @@ public final class ModuleContainer implements DebugOptionsListener { private ResolutionReport resolve(Collection<Module> triggers, boolean triggersMandatory, boolean restartTriggers) { if (isRefreshingSystemModule()) { - return new ModuleResolutionReport(null, Collections.<Resource, List<Entry>> emptyMap(), new ResolutionException("Unable to resolve while shutting down the framework.")); //$NON-NLS-1$ + return new ModuleResolutionReport(null, Collections.emptyMap(), new ResolutionException("Unable to resolve while shutting down the framework.")); //$NON-NLS-1$ } ResolutionReport report = null; try (ResolutionLock.Permits resolutionPermits = _resolutionLock.acquire(1)) { @@ -505,14 +505,14 @@ public final class ModuleContainer implements DebugOptionsListener { if (e.getCause() instanceof BundleException) { BundleException be = (BundleException) e.getCause(); if (be.getType() == BundleException.REJECTED_BY_HOOK || be.getType() == BundleException.STATECHANGE_ERROR) { - return new ModuleResolutionReport(null, Collections.<Resource, List<Entry>> emptyMap(), new ResolutionException(be)); + return new ModuleResolutionReport(null, Collections.emptyMap(), new ResolutionException(be)); } } throw e; } } while (report == null); } catch (ResolutionLockException e) { - return new ModuleResolutionReport(null, Collections.<Resource, List<Entry>> emptyMap(), new ResolutionException("Timeout acquiring lock for resolution", e, Collections.<Requirement> emptyList())); //$NON-NLS-1$ + return new ModuleResolutionReport(null, Collections.emptyMap(), new ResolutionException("Timeout acquiring lock for resolution", e, Collections.emptyList())); //$NON-NLS-1$ } return report; } @@ -547,7 +547,7 @@ public final class ModuleContainer implements DebugOptionsListener { ModuleResolutionReport report = moduleResolver.resolveDelta(triggerRevisions, triggersMandatory, unresolved, wiringClone, moduleDatabase); Map<Resource, List<Wire>> resolutionResult = report.getResolutionResult(); - Map<ModuleRevision, ModuleWiring> deltaWiring = resolutionResult == null ? Collections.<ModuleRevision, ModuleWiring> emptyMap() : moduleResolver.generateDelta(resolutionResult, wiringClone); + Map<ModuleRevision, ModuleWiring> deltaWiring = resolutionResult == null ? Collections.emptyMap() : moduleResolver.generateDelta(resolutionResult, wiringClone); if (deltaWiring.isEmpty()) return report; // nothing to do @@ -617,7 +617,7 @@ public final class ModuleContainer implements DebugOptionsListener { for (DynamicModuleRequirement dynamicReq : dynamicReqs) { ModuleResolutionReport report = moduleResolver.resolveDynamicDelta(dynamicReq, unresolved, wiringClone, moduleDatabase); Map<Resource, List<Wire>> resolutionResult = report.getResolutionResult(); - deltaWiring = resolutionResult == null ? Collections.<ModuleRevision, ModuleWiring> emptyMap() : moduleResolver.generateDelta(resolutionResult, wiringClone); + deltaWiring = resolutionResult == null ? Collections.emptyMap() : moduleResolver.generateDelta(resolutionResult, wiringClone); if (deltaWiring.get(revision) != null) { break; } @@ -656,7 +656,7 @@ public final class ModuleContainer implements DebugOptionsListener { // Save the result ModuleWiring wiring = deltaWiring.get(revision); result = findExistingDynamicWire(wiring, dynamicPkgName); - } while (!applyDelta(deltaWiring, modulesResolved, Collections.<Module> emptyList(), timestamp, false, resolutionPermits)); + } while (!applyDelta(deltaWiring, modulesResolved, Collections.emptyList(), timestamp, false, resolutionPermits)); } catch (ResolutionLockException e) { return null; } @@ -858,7 +858,7 @@ public final class ModuleContainer implements DebugOptionsListener { } // If there are any triggers re-start them now if requested - Set<Module> triggerSet = restartTriggers ? new HashSet<>(triggers) : Collections.<Module> emptySet(); + Set<Module> triggerSet = restartTriggers ? new HashSet<>(triggers) : Collections.emptySet(); if (restartTriggers) { for (Module module : triggers) { if (module.getId() != 0 && Module.RESOLVED_SET.contains(module.getState())) { @@ -1415,8 +1415,8 @@ public final class ModuleContainer implements DebugOptionsListener { static Requirement getIdentityRequirement(String name, Version version) { version = version == null ? Version.emptyVersion : version; String filter = "(&(" + IdentityNamespace.IDENTITY_NAMESPACE + "=" + name + ")(" + IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE + "=" + version.toString() + "))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$ - Map<String, String> directives = Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); - return new ModuleRequirement(IdentityNamespace.IDENTITY_NAMESPACE, directives, Collections.<String, Object> emptyMap(), null); + Map<String, String> directives = Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); + return new ModuleRequirement(IdentityNamespace.IDENTITY_NAMESPACE, directives, Collections.emptyMap(), null); } class ContainerWiring implements FrameworkWiring, EventDispatcher<ContainerWiring, FrameworkListener[], Collection<Module>> { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolutionReport.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolutionReport.java index 2e021392d..edd51c87e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolutionReport.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolutionReport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2016 IBM Corporation and others. + * Copyright (c) 2013, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,15 +13,27 @@ *******************************************************************************/ package org.eclipse.osgi.container; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.eclipse.osgi.internal.framework.FilterImpl; import org.eclipse.osgi.internal.messages.Msg; import org.eclipse.osgi.report.resolution.ResolutionReport; import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.namespace.*; +import org.osgi.framework.namespace.BundleNamespace; +import org.osgi.framework.namespace.HostNamespace; +import org.osgi.framework.namespace.PackageNamespace; import org.osgi.framework.wiring.BundleRevision; -import org.osgi.resource.*; +import org.osgi.resource.Capability; +import org.osgi.resource.Namespace; +import org.osgi.resource.Requirement; +import org.osgi.resource.Resource; +import org.osgi.resource.Wire; import org.osgi.service.resolver.ResolutionException; /** @@ -72,8 +84,8 @@ class ModuleResolutionReport implements ResolutionReport { private final Map<Resource, List<Wire>> resolutionResult; ModuleResolutionReport(Map<Resource, List<Wire>> resolutionResult, Map<Resource, List<Entry>> entries, ResolutionException cause) { - this.entries = entries == null ? Collections.<Resource, List<Entry>> emptyMap() : Collections.unmodifiableMap(new HashMap<>(entries)); - this.resolutionResult = resolutionResult == null ? Collections.<Resource, List<Wire>> emptyMap() : Collections.unmodifiableMap(resolutionResult); + this.entries = entries == null ? Collections.emptyMap() : Collections.unmodifiableMap(new HashMap<>(entries)); + this.resolutionResult = resolutionResult == null ? Collections.emptyMap() : Collections.unmodifiableMap(resolutionResult); this.resolutionException = cause; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java index bf8260712..d50937c33 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java @@ -465,7 +465,7 @@ final class ModuleResolver { } Map<Resource, ResolutionException> getUsesConstraintViolations() { - return errors == null ? Collections.<Resource, ResolutionException> emptyMap() : errors; + return errors == null ? Collections.emptyMap() : errors; } @Override @@ -811,7 +811,7 @@ final class ModuleResolver { Collection<Resource> relatedFragments = new ArrayList<>(); for (String hostBSN : getHostBSNs(hostCaps)) { String matchFilter = "(" + EquinoxFragmentNamespace.FRAGMENT_NAMESPACE + "=" + hostBSN + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - Requirement fragmentRequirement = ModuleContainer.createRequirement(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections.<String, Object> emptyMap()); + Requirement fragmentRequirement = ModuleContainer.createRequirement(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections.emptyMap()); List<ModuleCapability> candidates = moduleDatabase.findCapabilities(fragmentRequirement); // filter out disabled fragments and singletons filterDisabled(candidates); @@ -870,7 +870,7 @@ final class ModuleResolver { if (e.getCause() instanceof BundleException) { BundleException be = (BundleException) e.getCause(); if (be.getType() == BundleException.REJECTED_BY_HOOK) { - return new ModuleResolutionReport(null, Collections.<Resource, List<Entry>> emptyMap(), new ResolutionException(be)); + return new ModuleResolutionReport(null, Collections.emptyMap(), new ResolutionException(be)); } } throw e; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java index 7549469a9..a0cf9edbe 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -352,7 +352,7 @@ public final class ModuleRevisionBuilder { if (size == 1) { if (map.getClass() != SINGLETON_MAP_CLASS) { Map.Entry<? extends K, ? extends V> entry = map.entrySet().iterator().next(); - map = Collections.<K, V> singletonMap(entry.getKey(), entry.getValue()); + map = Collections.singletonMap(entry.getKey(), entry.getValue()); } } else { if (map.getClass() != UNMODIFIABLE_MAP_CLASS) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java index 3772f1108..bdd3398e3 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java @@ -79,8 +79,7 @@ public final class ModuleWiring implements BundleWiring { this.requirements = requirements; this.providedWires = providedWires; this.requiredWires = requiredWires; - this.substitutedPkgNames = substitutedPkgNames.isEmpty() ? Collections.<String>emptyList() - : substitutedPkgNames; + this.substitutedPkgNames = substitutedPkgNames.isEmpty() ? Collections.emptyList() : substitutedPkgNames; } @Override diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java index 91c379b3f..b3c8ece4b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -405,7 +405,7 @@ public final class OSGiManifestBuilderFactory { if ("true".equals(optionalAttr) && packageDirectives.get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE) == null) { //$NON-NLS-1$ packageDirectives.put(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, Namespace.RESOLUTION_OPTIONAL); } - builder.addRequirement(PackageNamespace.PACKAGE_NAMESPACE, packageDirectives, new HashMap<String, Object>(0)); + builder.addRequirement(PackageNamespace.PACKAGE_NAMESPACE, packageDirectives, new HashMap<>(0)); } } } @@ -422,7 +422,7 @@ public final class OSGiManifestBuilderFactory { filter.append('(').append(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE).append(">=").append(packageVersion).append("))"); //$NON-NLS-1$//$NON-NLS-2$ Map<String, String> directives = new HashMap<>(1); directives.put(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()); - builder.addRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, new HashMap<String, Object>(0)); + builder.addRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, new HashMap<>(0)); } } @@ -478,7 +478,7 @@ public final class OSGiManifestBuilderFactory { if ("true".equals(reprovideAttr) && bundleDirectives.get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE) == null) { //$NON-NLS-1$ bundleDirectives.put(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE, BundleNamespace.VISIBILITY_REEXPORT); } - builder.addRequirement(BundleNamespace.BUNDLE_NAMESPACE, bundleDirectives, new HashMap<String, Object>(0)); + builder.addRequirement(BundleNamespace.BUNDLE_NAMESPACE, bundleDirectives, new HashMap<>(0)); } } } @@ -509,10 +509,10 @@ public final class OSGiManifestBuilderFactory { // need to add (&...) filter.insert(0, "(&").append(')'); //$NON-NLS-1$ directives.put(BundleNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()); - builder.addRequirement(HostNamespace.HOST_NAMESPACE, directives, new HashMap<String, Object>(0)); + builder.addRequirement(HostNamespace.HOST_NAMESPACE, directives, new HashMap<>(0)); // Add a fragment capability to advertise what host this resource is providing a fragment for directives = Collections.singletonMap(EquinoxModuleDataNamespace.CAPABILITY_EFFECTIVE_DIRECTIVE, EquinoxModuleDataNamespace.EFFECTIVE_INFORMATION); - builder.addCapability(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, directives, Collections.<String, Object> singletonMap(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, hostName)); + builder.addCapability(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, directives, Collections.singletonMap(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, hostName)); } private static void getProvideCapabilities(ModuleRevisionBuilder builder, ManifestElement[] provideElements, boolean checkSystemCapabilities) throws BundleException { @@ -553,7 +553,7 @@ public final class OSGiManifestBuilderFactory { // only support one HashMap<String, String> directives = new HashMap<>(); directives.put(EclipsePlatformNamespace.REQUIREMENT_FILTER_DIRECTIVE, platformFilter); - builder.addRequirement(EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE, directives, Collections.<String, Object> emptyMap()); + builder.addRequirement(EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE, directives, Collections.emptyMap()); } @SuppressWarnings("deprecation") @@ -733,7 +733,7 @@ public final class OSGiManifestBuilderFactory { Map<String, String> directives = new HashMap<>(1); directives.put(ExecutionEnvironmentNamespace.REQUIREMENT_FILTER_DIRECTIVE, filterSpec); - builder.addRequirement(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, directives, new HashMap<String, Object>(0)); + builder.addRequirement(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, directives, new HashMap<>(0)); } static String escapeFilterInput(final String value) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ObjectPool.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ObjectPool.java index 44853f0eb..e68483511 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ObjectPool.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ObjectPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation and others. + * Copyright (c) 2009, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -38,7 +38,7 @@ public class ObjectPool { Debug.println("[ObjectPool] Found duplicate object: " + getObjectString(obj)); //$NON-NLS-1$ } } else { - objectCache.put(obj, new WeakReference<Object>(obj)); + objectCache.put(obj, new WeakReference<>(obj)); if (DEBUG_OBJECTPOOL_ADDS) Debug.println("[ObjectPool] Added unique object to pool: " + getObjectString(obj) + " Pool size: " + objectCache.size()); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/DelegatingConnectClassLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/DelegatingConnectClassLoader.java index d9e1cf522..9b16f162d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/DelegatingConnectClassLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/DelegatingConnectClassLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. + * Copyright (c) 2019, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -56,12 +56,12 @@ public class DelegatingConnectClassLoader extends EquinoxClassLoader { @Override public Enumeration<URL> findLocalResources(String resource) { if (connectClassLoader == null) { - return Collections.enumeration(Collections.<URL> emptyList()); + return Collections.enumeration(Collections.emptyList()); } try { return connectClassLoader.getResources(resource); } catch (IOException e) { - return Collections.enumeration(Collections.<URL> emptyList()); + return Collections.enumeration(Collections.emptyList()); } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/AtomicLazyInitializer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/AtomicLazyInitializer.java index 071ab6181..e55380cff 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/AtomicLazyInitializer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/AtomicLazyInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2016 IBM Corporation and others. + * Copyright (c) 2014, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -69,7 +69,7 @@ public class AtomicLazyInitializer<V> { } private static <T> T unchecked(Exception exception) { - return AtomicLazyInitializer.<T, RuntimeException> unchecked0(exception); + return AtomicLazyInitializer.unchecked0(exception); } @SuppressWarnings("unchecked") diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/Capabilities.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/Capabilities.java index 68318a67a..76942e892 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/Capabilities.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/Capabilities.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,7 +13,15 @@ *******************************************************************************/ package org.eclipse.osgi.internal.container; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.osgi.container.ModuleCapability; @@ -22,8 +30,13 @@ import org.eclipse.osgi.internal.framework.FilterImpl; import org.eclipse.osgi.util.ManifestElement; import org.osgi.framework.Filter; import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.namespace.*; -import org.osgi.resource.*; +import org.osgi.framework.namespace.AbstractWiringNamespace; +import org.osgi.framework.namespace.BundleNamespace; +import org.osgi.framework.namespace.HostNamespace; +import org.osgi.framework.namespace.PackageNamespace; +import org.osgi.resource.Capability; +import org.osgi.resource.Namespace; +import org.osgi.resource.Requirement; public class Capabilities { static class NamespaceSet { @@ -234,7 +247,7 @@ public class Capabilities { } } } - return packageNames == null ? Collections.<String> emptyList() : packageNames; + return packageNames == null ? Collections.emptyList() : packageNames; } /** diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java index 320d68957..00f05f74f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2020 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -1063,8 +1063,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object, @SuppressWarnings("unchecked") ServiceReference<S>[] refs = (ServiceReference<S>[]) getServiceReferences(clazz.getName(), filter); if (refs == null) { - Collection<ServiceReference<S>> empty = Collections.<ServiceReference<S>> emptyList(); - return empty; + return Collections.emptyList(); } List<ServiceReference<S>> result = new ArrayList<>(refs.length); Collections.addAll(result, refs); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java index fe0c79a11..584427a07 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -173,7 +173,7 @@ public class ContextFinder extends ClassLoader implements PrivilegedAction<List< public Enumeration<URL> getResources(String arg0) throws IOException { //Shortcut cycle if (startLoading(arg0) == false) { - return Collections.enumeration(Collections.<URL> emptyList()); + return Collections.enumeration(Collections.emptyList()); } try { List<ClassLoader> toConsult = findClassLoaders(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java index 43098b906..626ff65fd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -110,7 +110,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { this.resolverExecutor = new AtomicLazyInitializer<>(); this.lazyResolverExecutorCreator = createLazyExecutorCreator( // "Equinox resolver thread - " + EquinoxContainerAdaptor.this.toString(), //$NON-NLS-1$ - resolverThreadCnt, new SynchronousQueue<Runnable>()); + resolverThreadCnt, new SynchronousQueue<>()); // For the start-level we can safely use a growing queue because the thread feeding the // start-level executor with work is a single thread and it can safely block waiting @@ -118,7 +118,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { this.startLevelExecutor = new AtomicLazyInitializer<>(); this.lazyStartLevelExecutorCreator = createLazyExecutorCreator(// "Equinox start level thread - " + EquinoxContainerAdaptor.this.toString(), //$NON-NLS-1$ - startLevelThreadCnt, new LinkedBlockingQueue<Runnable>(1000)); + startLevelThreadCnt, new LinkedBlockingQueue<>(1000)); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java index 528eba60f..563af451a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2020 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -199,7 +199,7 @@ public abstract class FilterImpl implements Filter { */ @Override public boolean match(ServiceReference<?> reference) { - return matches0((reference != null) ? ServiceReferenceMap.asMap(reference) : Collections.<String, Object> emptyMap()); + return matches0((reference != null) ? ServiceReferenceMap.asMap(reference) : Collections.emptyMap()); } /** @@ -216,7 +216,7 @@ public abstract class FilterImpl implements Filter { */ @Override public boolean match(Dictionary<String, ?> dictionary) { - return matches0((dictionary != null) ? new CaseInsensitiveDictionaryMap<>(dictionary) : Collections.<String, Object> emptyMap()); + return matches0((dictionary != null) ? new CaseInsensitiveDictionaryMap<>(dictionary) : Collections.emptyMap()); } /** @@ -232,7 +232,7 @@ public abstract class FilterImpl implements Filter { */ @Override public boolean matchCase(Dictionary<String, ?> dictionary) { - return matches0((dictionary != null) ? DictionaryMap.asMap(dictionary) : Collections.<String, Object> emptyMap()); + return matches0((dictionary != null) ? DictionaryMap.asMap(dictionary) : Collections.emptyMap()); } /** @@ -249,7 +249,7 @@ public abstract class FilterImpl implements Filter { */ @Override public boolean matches(Map<String, ?> map) { - return matches0((map != null) ? map : Collections.<String, Object> emptyMap()); + return matches0((map != null) ? map : Collections.emptyMap()); } abstract boolean matches0(Map<String, ?> map); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java index 9fb875edf..15adb5f96 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -193,13 +193,13 @@ class OSGiFrameworkHooks { Module systemModule = mContainer == null ? null : mContainer.getModule(0); ServiceRegistry registry = container.getServiceRegistry(); if (registry == null || systemModule == null) { - return new CoreResolverHook(Collections.<HookReference> emptyList(), systemModule); + return new CoreResolverHook(Collections.emptyList(), systemModule); } BundleContextImpl context = (BundleContextImpl) EquinoxContainer.secureAction.getContext(systemModule.getBundle()); ServiceReferenceImpl<ResolverHookFactory>[] refs = getHookReferences(registry, context); - List<HookReference> hookRefs = refs == null ? Collections.<CoreResolverHookFactory.HookReference>emptyList() + List<HookReference> hookRefs = refs == null ? Collections.emptyList() : new ArrayList<>(refs.length); if (refs != null) { for (ServiceReferenceImpl<ResolverHookFactory> hookRef : refs) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java index eb6f31ce8..b28b28dbb 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2017 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -107,7 +107,7 @@ public class PackageAdminImpl implements PackageAdmin { @Override public ExportedPackage[] getExportedPackages(String name) { String filter = "(" + PackageNamespace.PACKAGE_NAMESPACE + "=" + (name == null ? "*" : name) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ - Map<String, String> directives = Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); + Map<String, String> directives = Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); Map<String, Boolean> attributes = Collections.singletonMap(Capabilities.SYNTHETIC_REQUIREMENT, Boolean.TRUE); Requirement packageReq = ModuleContainer.createRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, attributes); Collection<BundleCapability> packageCaps = frameworkWiring.findProviders(packageReq); @@ -158,7 +158,7 @@ public class PackageAdminImpl implements PackageAdmin { @Override public RequiredBundle[] getRequiredBundles(String symbolicName) { String filter = "(" + BundleNamespace.BUNDLE_NAMESPACE + "=" + (symbolicName == null ? "*" : symbolicName) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ - Map<String, String> directives = Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); + Map<String, String> directives = Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); Map<String, Boolean> attributes = Collections.singletonMap(Capabilities.SYNTHETIC_REQUIREMENT, Boolean.TRUE); Requirement bundleReq = ModuleContainer.createRequirement(BundleNamespace.BUNDLE_NAMESPACE, directives, attributes); Collection<BundleCapability> bundleCaps = frameworkWiring.findProviders(bundleReq); @@ -184,7 +184,7 @@ public class PackageAdminImpl implements PackageAdmin { } VersionRange range = versionRange == null ? null : new VersionRange(versionRange); String filter = (range != null ? "(&" : "") + "(" + IdentityNamespace.IDENTITY_NAMESPACE + "=" + symbolicName + ")" + (range != null ? range.toFilterString(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE) + ")" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ - Requirement identityReq = ModuleContainer.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter), Collections.<String, Object> emptyMap()); + Requirement identityReq = ModuleContainer.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter), Collections.emptyMap()); Collection<BundleCapability> identityCaps = frameworkWiring.findProviders(identityReq); if (identityCaps.isEmpty()) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java index a1f451eee..716f0789a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2020 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -183,7 +183,7 @@ public class BundleLoader extends ModuleLoader { // initialize the required bundle wires List<ModuleWire> currentRequireBundleWires = wiring.getRequiredModuleWires(BundleNamespace.BUNDLE_NAMESPACE); - requiredBundleWires = currentRequireBundleWires == null || currentRequireBundleWires.isEmpty() ? Collections.<ModuleWire> emptyList() : Collections.unmodifiableList(currentRequireBundleWires); + requiredBundleWires = currentRequireBundleWires == null || currentRequireBundleWires.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(currentRequireBundleWires); //Initialize the policy handler List<ModuleCapability> moduleDatas = wiring.getRevision().getModuleCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE); @@ -857,9 +857,9 @@ public class BundleLoader extends ModuleLoader { public static <E> Enumeration<E> compoundEnumerations(Enumeration<E> list1, Enumeration<E> list2) { if (list2 == null || !list2.hasMoreElements()) - return list1 == null ? BundleLoader.<E> emptyEnumeration() : list1; + return list1 == null ? BundleLoader.emptyEnumeration() : list1; if (list1 == null || !list1.hasMoreElements()) - return list2 == null ? BundleLoader.<E> emptyEnumeration() : list2; + return list2 == null ? BundleLoader.emptyEnumeration() : list2; List<E> compoundResults = new ArrayList<>(); while (list1.hasMoreElements()) compoundResults.add(list1.nextElement()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java index d01648744..062cc8c48 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -83,8 +83,7 @@ public class GlobalPolicy implements IBuddyPolicy { private Collection<Bundle> getExportingBundles(String pkgName) { Collection<Bundle> result = new ArrayList<>(); String filter = "(" + PackageNamespace.PACKAGE_NAMESPACE + "=" + pkgName + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Map<String, String> directives = Collections - .<String, String>singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); + Map<String, String> directives = Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter); Map<String, Boolean> attributes = Collections.singletonMap(Capabilities.SYNTHETIC_REQUIREMENT, Boolean.TRUE); Collection<BundleCapability> packages = frameworkWiring.findProviders( ModuleContainer.createRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, attributes)); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java index ec13c9096..c5c7f36e7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2020 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -874,7 +874,7 @@ public class ClasspathManager { for (FragmentClasspath fragmentClasspath : currentFragments) generations.add(fragmentClasspath.getGeneration()); - List<URL> result = Collections.<URL> emptyList(); + List<URL> result = Collections.emptyList(); // now search over all the bundle files Enumeration<URL> eURLs = Storage.findEntries(generations, path, filePattern, options); if (eURLs == null) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java index 3e8c15125..3525cb4af 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/NullPackageSource.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -69,6 +69,6 @@ public class NullPackageSource extends PackageSource { @Override public List<String> listResources(String path, String filePattern) { - return Collections.<String> emptyList(); + return Collections.emptyList(); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java index a2d73193b..d3a15018d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 IBM Corporation and others. + * Copyright (c) 2017, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,9 +13,20 @@ *******************************************************************************/ package org.eclipse.osgi.internal.log; -import java.lang.reflect.*; -import java.util.*; -import org.osgi.framework.*; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; import org.osgi.service.log.LogLevel; import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; @@ -191,7 +202,7 @@ class ConfigAdminListener implements ServiceTrackerCustomizer<Object, ServiceReg String contextName = getContextName(pid); if (type == CM_DELETED) { - setLogLevels(contextName, Collections.<String, LogLevel> emptyMap()); + setLogLevels(contextName, Collections.emptyMap()); return null; } @@ -199,7 +210,7 @@ class ConfigAdminListener implements ServiceTrackerCustomizer<Object, ServiceReg Dictionary<String, Object> configDictionary = findConfiguration(pid); if (configDictionary == null) { // Configuration got deleted before we could get it so treat as deleted - setLogLevels(contextName, Collections.<String, LogLevel> emptyMap()); + setLogLevels(contextName, Collections.emptyMap()); return null; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java index a6c3987cb..ff7249cf1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2020 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2021 Cognos Incorporated, IBM Corporation and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 which @@ -210,7 +210,7 @@ public class ExtendedLogServiceFactory implements ServiceFactory<ExtendedLogServ @Override public void clear() { - setLogLevels(Collections.<String, LogLevel> emptyMap()); + setLogLevels(Collections.emptyMap()); } @Override diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java index ad2fa6978..3e1c36da5 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2021 Cognos Incorporated, IBM Corporation and others * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 which @@ -31,8 +31,8 @@ public class ExtendedLogServiceImpl implements ExtendedLogService { public ExtendedLogServiceImpl(ExtendedLogServiceFactory factory, Bundle bundle) { this.factory = factory; this.bundle = bundle; - loggerCache.put(org.osgi.service.log.Logger.class, new HashMap<String, LoggerImpl>()); - loggerCache.put(org.osgi.service.log.FormatterLogger.class, new HashMap<String, LoggerImpl>()); + loggerCache.put(org.osgi.service.log.Logger.class, new HashMap<>()); + loggerCache.put(org.osgi.service.log.FormatterLogger.class, new HashMap<>()); } @SuppressWarnings("deprecation") diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java index 7d0505834..9f9f691fd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2020 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -795,11 +795,11 @@ public class ServiceRegistry { if (oldFilteredListener != null) { oldFilteredListener.markRemoved(); - Collection<ListenerInfo> removedListeners = Collections.<ListenerInfo> singletonList(oldFilteredListener); + Collection<ListenerInfo> removedListeners = Collections.singletonList(oldFilteredListener); notifyListenerHooks(removedListeners, false); } - Collection<ListenerInfo> addedListeners = Collections.<ListenerInfo> singletonList(filteredListener); + Collection<ListenerInfo> addedListeners = Collections.singletonList(filteredListener); notifyListenerHooks(addedListeners, true); } @@ -828,7 +828,7 @@ public class ServiceRegistry { return; } oldFilteredListener.markRemoved(); - Collection<ListenerInfo> removedListeners = Collections.<ListenerInfo> singletonList(oldFilteredListener); + Collection<ListenerInfo> removedListeners = Collections.singletonList(oldFilteredListener); notifyListenerHooks(removedListeners, false); } @@ -1080,8 +1080,7 @@ public class ServiceRegistry { } if ((result == null) || result.isEmpty()) { - List<ServiceRegistrationImpl<?>> empty = Collections.<ServiceRegistrationImpl<?>> emptyList(); - return empty; + return Collections.emptyList(); } result = new LinkedList<>(result); /* make a new list since we don't want to change the real list */ @@ -1117,8 +1116,7 @@ public class ServiceRegistry { List<ServiceRegistrationImpl<?>> result = publishedServicesByContext.get(context); if ((result == null) || result.isEmpty()) { - List<ServiceRegistrationImpl<?>> empty = Collections.<ServiceRegistrationImpl<?>> emptyList(); - return empty; + return Collections.emptyList(); } return new ArrayList<>(result); /* make a new list since we don't want to change the real list */ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableCollection.java index f770d9d6e..728bcfbd9 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableCollection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableCollection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2016 IBM Corporation and others. + * Copyright (c) 2008, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,7 +14,11 @@ package org.eclipse.osgi.internal.serviceregistry; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; /** * A Shrinkable Collection. This class provides a wrapper for a list of collections @@ -40,7 +44,7 @@ public class ShrinkableCollection<E> implements Collection<E> { if (c == null) { throw new NullPointerException(); } - List<Collection<? extends E>> empty = Collections.<Collection<? extends E>> emptyList(); + List<Collection<? extends E>> empty = Collections.emptyList(); list = empty; collection = c; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java index 1d903dc81..e23951d91 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2018 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -85,7 +85,7 @@ public final class BundleInfo { Generation(long generationId) { this.generationId = generationId; - this.cachedHeaders = new CachedManifest(this, Collections.<String, String> emptyMap()); + this.cachedHeaders = new CachedManifest(this, Collections.emptyMap()); } Generation(long generationId, File content, boolean isDirectory, Type contentType, boolean hasPackageInfo, Map<String, String> cached, long lastModified, boolean isMRJar) { @@ -149,14 +149,14 @@ public final class BundleInfo { rawHeaders = Collections.emptyMap(); } else { try { - Map<String, String> merged = ManifestElement.parseBundleManifest(manifest.getInputStream(), new CaseInsensitiveDictionaryMap<String, String>()); + Map<String, String> merged = ManifestElement.parseBundleManifest(manifest.getInputStream(), new CaseInsensitiveDictionaryMap<>()); // For MRJARs only replace Import-Package and Require-Capability if the versioned values are non-null if (Boolean.parseBoolean(merged.get(MULTI_RELEASE_HEADER))) { for (int i = getStorage().getRuntimeVersion().getMajor(); i > 8; i--) { String versionManifest = "META-INF/versions/" + i + "/OSGI-INF/MANIFEST.MF"; //$NON-NLS-1$ //$NON-NLS-2$ BundleEntry versionEntry = getBundleFile().getEntry(versionManifest); if (versionEntry != null) { - Map<String, String> versioned = ManifestElement.parseBundleManifest(versionEntry.getInputStream(), new CaseInsensitiveDictionaryMap<String, String>()); + Map<String, String> versioned = ManifestElement.parseBundleManifest(versionEntry.getInputStream(), new CaseInsensitiveDictionaryMap<>()); String versionedImport = versioned.get(Constants.IMPORT_PACKAGE); String versionedRequireCap = versioned.get(Constants.REQUIRE_CAPABILITY); if (versionedImport != null) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index 19f988b41..81c924a83 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 IBM Corporation and others. + * Copyright (c) 2012, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -467,7 +467,7 @@ public class Storage { } private Version findFrameworkVersion() { - Requirement osgiPackageReq = ModuleContainer.createRequirement(PackageNamespace.PACKAGE_NAMESPACE, Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(" + PackageNamespace.PACKAGE_NAMESPACE + "=org.osgi.framework)"), Collections.<String, String> emptyMap()); //$NON-NLS-1$ //$NON-NLS-2$ + Requirement osgiPackageReq = ModuleContainer.createRequirement(PackageNamespace.PACKAGE_NAMESPACE, Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(" + PackageNamespace.PACKAGE_NAMESPACE + "=org.osgi.framework)"), Collections.emptyMap()); //$NON-NLS-1$ //$NON-NLS-2$ Collection<BundleCapability> osgiPackages = moduleContainer.getFrameworkWiring().findProviders(osgiPackageReq); for (BundleCapability packageCapability : osgiPackages) { if (packageCapability.getRevision().getBundle().getBundleId() == 0) { @@ -1209,7 +1209,7 @@ public class Storage { } public BundleFile createNestedBundleFile(String nestedDir, BundleFile bundleFile, Generation generation) { - return createNestedBundleFile(nestedDir, bundleFile, generation, Collections.<String> emptyList()); + return createNestedBundleFile(nestedDir, bundleFile, generation, Collections.emptyList()); } public BundleFile createNestedBundleFile(String nestedDir, BundleFile bundleFile, Generation generation, Collection<String> filterPrefixes) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java index c679185e0..ed4981119 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2017 IBM Corporation and others. + * Copyright (c) 2013, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,7 +13,9 @@ *******************************************************************************/ package org.eclipse.osgi.storage; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Map; @@ -102,7 +104,7 @@ public class SystemBundleFile extends BundleFile { URL url = manifests.nextElement(); try { // check each manifest until we find one with the Eclipse-SystemBundle: true header - Map<String, String> headers = ManifestElement.parseBundleManifest(url.openStream(), new CaseInsensitiveDictionaryMap<String, String>()); + Map<String, String> headers = ManifestElement.parseBundleManifest(url.openStream(), new CaseInsensitiveDictionaryMap<>()); if ("true".equals(headers.get(Storage.ECLIPSE_SYSTEMBUNDLE))) //$NON-NLS-1$ return url; } catch (BundleException e) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java index 15d6ac979..799d08f03 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2018 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -63,7 +63,7 @@ public class MRUBundleFileList implements EventDispatcher<Object, Object, Bundle if (fileLimit >= MIN) { this.bundleFileList = new BundleFile[fileLimit]; this.useStampList = new long[fileLimit]; - this.bundleFileCloser = Collections.<Object, Object> singletonMap(this, this); + this.bundleFileCloser = Collections.singletonMap(this, this); } else { this.bundleFileList = null; this.useStampList = null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java index b37922b63..100037a47 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2018 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -42,7 +42,7 @@ public class NestedDirBundleFile extends BundleFile { * @param nestedDirName */ public NestedDirBundleFile(BundleFile baseBundlefile, String nestedDirName) { - this(baseBundlefile, nestedDirName, Collections.<String> emptyList()); + this(baseBundlefile, nestedDirName, Collections.emptyList()); } /** diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java index ab48fd5f4..14e6635ff 100755 --- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java +++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java @@ -18,19 +18,50 @@ */ package org.apache.felix.resolver; -import java.security.*; -import java.util.*; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.*; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicReference; - import org.apache.felix.resolver.reason.ReasonException; import org.apache.felix.resolver.util.ArrayMap; import org.apache.felix.resolver.util.CandidateSelector; import org.apache.felix.resolver.util.OpenHashMap; -import org.osgi.framework.namespace.*; -import org.osgi.resource.*; -import org.osgi.service.resolver.*; +import org.osgi.framework.namespace.BundleNamespace; +import org.osgi.framework.namespace.ExecutionEnvironmentNamespace; +import org.osgi.framework.namespace.HostNamespace; +import org.osgi.framework.namespace.IdentityNamespace; +import org.osgi.framework.namespace.PackageNamespace; +import org.osgi.resource.Capability; +import org.osgi.resource.Namespace; +import org.osgi.resource.Requirement; +import org.osgi.resource.Resource; +import org.osgi.resource.Wire; +import org.osgi.resource.Wiring; +import org.osgi.service.resolver.HostedCapability; +import org.osgi.service.resolver.ResolutionException; +import org.osgi.service.resolver.ResolveContext; +import org.osgi.service.resolver.Resolver; public class ResolverImpl implements Resolver { @@ -325,7 +356,7 @@ public class ResolverImpl implements Resolver public Collection<Resource> getRelatedResources(Resource resource) { Collection<Resource> related = m_relatedResources.get(resource); - return related == null ? Collections.<Resource> emptyList() : related; + return related == null ? Collections.emptyList() : related; } public void setRelatedResources(Resource resource, Collection<Resource> related) { @@ -800,8 +831,8 @@ public class ResolverImpl implements Resolver resourcePkgs, wire.requirement, wire.capability, - new HashSet<Capability>(), - new HashSet<Resource>()); + new HashSet<>(), + new HashSet<>()); } return resourcePkgs; @@ -1811,7 +1842,7 @@ public class ResolverImpl implements Resolver } else { - sources.put(sourceCap, Collections.<Capability>emptySet()); + sources.put(sourceCap, Collections.emptySet()); } } } @@ -1877,7 +1908,7 @@ public class ResolverImpl implements Resolver if (!session.getContext().getWirings().containsKey(unwrappedResource) && !wireMap.containsKey(unwrappedResource)) { - wireMap.put(unwrappedResource, Collections.<Wire>emptyList()); + wireMap.put(unwrappedResource, Collections.emptyList()); List<Wire> packageWires = new ArrayList<>(); List<Wire> bundleWires = new ArrayList<>(); @@ -1952,8 +1983,7 @@ public class ResolverImpl implements Resolver // creating duplicate non-payload wires if the fragment // is attached to more than one host. List<Wire> fragmentWires = wireMap.get(fragment); - fragmentWires = (fragmentWires == null) - ? new ArrayList<>() : fragmentWires; + fragmentWires = (fragmentWires == null) ? new ArrayList<>() : fragmentWires; // Loop through all of the fragment's requirements and create // any necessary wires for non-payload requirements. @@ -2036,7 +2066,7 @@ public class ResolverImpl implements Resolver ResolveSession session, Map<Resource, List<Wire>> wireMap, Candidates allCandidates) { - wireMap.put(session.getDynamicHost(), Collections.<Wire>emptyList()); + wireMap.put(session.getDynamicHost(), Collections.emptyList()); List<Wire> packageWires = new ArrayList<>(); @@ -2250,7 +2280,7 @@ public class ResolverImpl implements Resolver return Collections.emptySet(); } Set<Capability> result = m_rootCauses.get(req); - return result == null ? Collections.<Capability>emptySet() : result; + return result == null ? Collections.emptySet() : result; } @Override diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/dto/DTO.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/dto/DTO.java index ffcb6416b..95caf5a3c 100644 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/dto/DTO.java +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/dto/DTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2020). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2021). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,8 +53,7 @@ public abstract class DTO { */ @Override public String toString() { - return appendValue(new StringBuilder(), - new IdentityHashMap<Object,String>(), "#", this).toString(); + return appendValue(new StringBuilder(), new IdentityHashMap<>(), "#", this).toString(); } /** |