From 61d4d356b63091bb27ea0c7be0a6daaf06b74c28 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 29 Sep 2016 08:27:28 -0500 Subject: Bug 502425 - Refactor code for Java 7 Change-Id: I64d3a28a743a0292db27fd421294421dc51eb2e1 Signed-off-by: Thomas Watson --- .../compatibility/plugins/PluginConverterImpl.java | 26 ++-- .../osgi/compatibility/plugins/PluginParser.java | 18 +-- .../compatibility/state/PlatformAdminImpl.java | 4 +- .../state/PlatformBundleListener.java | 6 +- .../osgi/compatibility/state/StateConverter.java | 20 +-- .../osgi/internal/module/GroupingChecker.java | 20 +-- .../eclipse/osgi/internal/module/MappedList.java | 8 +- .../osgi/internal/module/ResolverBundle.java | 36 ++--- .../eclipse/osgi/internal/module/ResolverImpl.java | 150 ++++++++++----------- .../internal/resolver/BaseDescriptionImpl.java | 4 +- .../internal/resolver/BundleDescriptionImpl.java | 38 +++--- .../internal/resolver/BundleSpecificationImpl.java | 4 +- .../resolver/ExportPackageDescriptionImpl.java | 8 +- .../internal/resolver/GenericDescriptionImpl.java | 8 +- .../resolver/GenericSpecificationImpl.java | 6 +- .../internal/resolver/HostSpecificationImpl.java | 4 +- .../resolver/ImportPackageSpecificationImpl.java | 6 +- .../osgi/internal/resolver/StateBuilder.java | 46 +++---- .../osgi/internal/resolver/StateDeltaImpl.java | 6 +- .../osgi/internal/resolver/StateHelperImpl.java | 52 +++---- .../eclipse/osgi/internal/resolver/StateImpl.java | 50 +++---- .../internal/resolver/StateObjectFactoryImpl.java | 14 +- .../osgi/internal/resolver/StateReader.java | 23 ++-- .../osgi/internal/resolver/StateWriter.java | 8 +- .../core/runtime/adaptor/EclipseStarter.java | 24 ++-- .../eclipse/osgi/container/ModuleCapability.java | 2 +- .../eclipse/osgi/container/ModuleContainer.java | 72 +++++----- .../org/eclipse/osgi/container/ModuleDatabase.java | 54 ++++---- .../eclipse/osgi/container/ModuleRequirement.java | 2 +- .../osgi/container/ModuleResolutionReport.java | 14 +- .../org/eclipse/osgi/container/ModuleResolver.java | 96 ++++++------- .../org/eclipse/osgi/container/ModuleRevision.java | 10 +- .../osgi/container/ModuleRevisionBuilder.java | 14 +- .../eclipse/osgi/container/ModuleRevisions.java | 6 +- .../org/eclipse/osgi/container/ModuleWiring.java | 24 ++-- .../org/eclipse/osgi/container/SystemModule.java | 4 +- .../builders/OSGiManifestBuilderFactory.java | 50 +++---- .../org/eclipse/osgi/framework/util/ArrayMap.java | 14 +- .../org/eclipse/osgi/framework/util/Headers.java | 8 +- .../eclipse/osgi/framework/util/ObjectPool.java | 2 +- .../internal/container/AtomicLazyInitializer.java | 4 +- .../osgi/internal/container/Capabilities.java | 18 +-- .../osgi/internal/container/ComputeNodeOrder.java | 16 +-- .../eclipse/osgi/internal/container/LockSet.java | 4 +- .../osgi/internal/debug/FrameworkDebugOptions.java | 10 +- .../osgi/internal/framework/AliasMapper.java | 22 +-- .../osgi/internal/framework/BundleContextImpl.java | 14 +- .../osgi/internal/framework/ContextFinder.java | 6 +- .../osgi/internal/framework/DTOBuilder.java | 42 +++--- .../osgi/internal/framework/EquinoxBundle.java | 10 +- .../internal/framework/EquinoxConfiguration.java | 8 +- .../osgi/internal/framework/EquinoxContainer.java | 6 +- .../framework/EquinoxContainerAdaptor.java | 4 +- .../internal/framework/EquinoxEventPublisher.java | 26 ++-- .../osgi/internal/framework/FilterImpl.java | 20 +-- .../internal/framework/OSGiFrameworkHooks.java | 12 +- .../internal/framework/SystemBundleActivator.java | 8 +- .../framework/legacy/PackageAdminImpl.java | 20 +-- .../osgi/internal/hookregistry/HookRegistry.java | 14 +- .../osgi/internal/hooks/EclipseLazyStarter.java | 10 +- .../eclipse/osgi/internal/loader/BundleLoader.java | 32 ++--- .../osgi/internal/loader/ModuleClassLoader.java | 2 +- .../internal/loader/buddy/DependentPolicy.java | 4 +- .../osgi/internal/loader/buddy/PolicyHandler.java | 10 +- .../internal/loader/classpath/ClasspathEntry.java | 2 +- .../loader/classpath/ClasspathManager.java | 22 +-- .../loader/sources/MultiSourcePackage.java | 4 +- .../osgi/internal/log/BasicReadWriteLock.java | 4 +- .../osgi/internal/log/EquinoxLogServices.java | 4 +- .../osgi/internal/log/EventAdminAdapter.java | 8 +- .../osgi/internal/log/EventAdminLogListener.java | 4 +- .../osgi/internal/log/ExtendedLogEntryImpl.java | 4 +- .../log/ExtendedLogReaderServiceFactory.java | 16 +-- .../internal/log/ExtendedLogReaderServiceImpl.java | 4 +- .../internal/log/ExtendedLogServiceFactory.java | 4 +- .../osgi/internal/log/ExtendedLogServiceImpl.java | 4 +- .../osgi/internal/log/LogServiceManager.java | 6 +- .../osgi/internal/log/SerializedTaskQueue.java | 4 +- .../internal/permadmin/EquinoxSecurityManager.java | 16 +-- .../internal/permadmin/PermissionAdminTable.java | 4 +- .../permadmin/PermissionInfoCollection.java | 4 +- .../osgi/internal/permadmin/PermissionsHash.java | 4 +- .../osgi/internal/permadmin/SecurityAdmin.java | 18 +-- .../osgi/internal/permadmin/SecurityRow.java | 10 +- .../internal/permadmin/SecurityTableUpdate.java | 4 +- .../service/security/AuthorizationEngine.java | 8 +- .../service/security/KeyStoreTrustEngine.java | 7 +- .../serviceregistry/ServiceRegistrationImpl.java | 14 +- .../internal/serviceregistry/ServiceRegistry.java | 40 +++--- .../serviceregistry/ShrinkableCollection.java | 8 +- .../ShrinkableEntrySetValueCollection.java | 4 +- .../ShrinkableValueCollectionMap.java | 8 +- .../internal/signedcontent/PKCS7Processor.java | 10 +- .../signedcontent/SignatureBlockProcessor.java | 12 +- .../internal/signedcontent/SignedBundleHook.java | 10 +- .../internal/signedcontent/SignedContentFile.java | 4 +- .../internal/signedcontent/SignedContentImpl.java | 6 +- .../internal/signedcontent/SignedStorageHook.java | 8 +- .../signedcontent/TrustEngineListener.java | 6 +- .../internal/url/ContentHandlerFactoryImpl.java | 6 +- .../osgi/internal/url/ContentHandlerProxy.java | 4 +- .../osgi/internal/url/MultiplexingFactory.java | 8 +- .../internal/url/URLStreamHandlerFactoryImpl.java | 10 +- .../osgi/internal/url/URLStreamHandlerProxy.java | 4 +- .../osgi/internal/weaving/DynamicImportList.java | 4 +- .../internal/weaving/WeavingHookConfigurator.java | 6 +- .../src/org/eclipse/osgi/storage/BundleInfo.java | 4 +- .../osgi/storage/FrameworkExtensionInstaller.java | 8 +- .../eclipse/osgi/storage/ManifestLocalization.java | 8 +- .../org/eclipse/osgi/storage/NativeCodeFinder.java | 4 +- .../org/eclipse/osgi/storage/PermissionData.java | 4 +- .../src/org/eclipse/osgi/storage/Storage.java | 48 +++---- .../src/org/eclipse/osgi/storage/StorageUtil.java | 4 +- .../osgi/storage/bundlefile/DirBundleFile.java | 4 +- .../osgi/storage/bundlefile/MRUBundleFileList.java | 8 +- .../osgi/storage/bundlefile/ZipBundleFile.java | 4 +- .../framework/eventmgr/CopyOnWriteIdentityMap.java | 12 +- .../osgi/framework/eventmgr/EventListeners.java | 4 +- .../osgi/framework/eventmgr/EventManager.java | 6 +- .../osgi/framework/eventmgr/ListenerQueue.java | 4 +- .../internal/reliablefile/ReliableFile.java | 6 +- .../org/eclipse/osgi/internal/util/Tokenizer.java | 4 +- .../src/org/eclipse/osgi/util/ManifestElement.java | 12 +- .../supplement/src/org/eclipse/osgi/util/NLS.java | 6 +- 124 files changed, 879 insertions(+), 891 deletions(-) diff --git a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java index 26744fbd9..7bba1320d 100644 --- a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java @@ -127,7 +127,7 @@ public class PluginConverterImpl implements PluginConverter { pluginInfo = null; pluginManifestLocation = null; pluginZip = null; - generatedManifest = new Hashtable(10); + generatedManifest = new Hashtable<>(10); manifestType = MANIFEST_TYPE_UNKNOWN; target = null; devProperties = null; @@ -165,7 +165,7 @@ public class PluginConverterImpl implements PluginConverter { private Set filterExport(Set exportToFilter, Collection filter) { if (filter == null || filter.contains("*")) //$NON-NLS-1$ return exportToFilter; - Set filteredExport = new HashSet(exportToFilter.size()); + Set filteredExport = new HashSet<>(exportToFilter.size()); for (String anExport : exportToFilter) { for (String aFilter : filter) { int dotStar = aFilter.indexOf(".*"); //$NON-NLS-1$ @@ -182,7 +182,7 @@ public class PluginConverterImpl implements PluginConverter { private List findOSJars(File pluginRoot, String path, boolean filter) { path = path.substring(4); - List found = new ArrayList(0); + List found = new ArrayList<>(0); for (int i = 0; i < OS_LIST.length; i++) { //look for os/osname/path String searchedPath = "os/" + OS_LIST[i] + "/" + path; //$NON-NLS-1$ //$NON-NLS-2$ @@ -246,7 +246,7 @@ public class PluginConverterImpl implements PluginConverter { private List findWSJars(File pluginRoot, String path, boolean filter) { path = path.substring(4); - List found = new ArrayList(0); + List found = new ArrayList<>(0); for (int i = 0; i < WS_LIST.length; i++) { String searchedPath = "ws/" + WS_LIST[i] + path; //$NON-NLS-1$ if (new File(pluginRoot, searchedPath).exists()) { @@ -275,7 +275,7 @@ public class PluginConverterImpl implements PluginConverter { private Map convertDictionaryToMap(Dictionary dictionary) { if (dictionary == null) return Collections.emptyMap(); - Map result = new HashMap(dictionary.size()); + Map result = new HashMap<>(dictionary.size()); Enumeration keys = dictionary.keys(); while (keys.hasMoreElements()) { K key = keys.nextElement(); @@ -295,7 +295,7 @@ public class PluginConverterImpl implements PluginConverter { throw new PluginConversionException(message); } // replaces any eventual existing file - manifestToWrite = new Hashtable(convertDictionaryToMap(manifestToWrite)); + manifestToWrite = new Hashtable<>(convertDictionaryToMap(manifestToWrite)); // MANIFEST.MF files must be written using UTF-8 out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(generationLocation), UTF_8)); writeEntry(MANIFEST_VERSION, manifestToWrite.remove(MANIFEST_VERSION)); @@ -473,7 +473,7 @@ public class PluginConverterImpl implements PluginConverter { if (devProperties != null || configuration.inDevelopmentMode()) { String[] devClassPath = configuration.getDevClassPath(pluginInfo.getUniqueId(), devProperties); // collect export clauses - List allExportClauses = new ArrayList(libs.size()); + List allExportClauses = new ArrayList<>(libs.size()); Set>> libEntries = libs.entrySet(); for (Iterator>> iter = libEntries.iterator(); iter.hasNext();) { Map.Entry> element = iter.next(); @@ -491,7 +491,7 @@ public class PluginConverterImpl implements PluginConverter { } } - Set result = new TreeSet(); + Set result = new TreeSet<>(); Set>> libEntries = libs.entrySet(); for (Iterator>> iter = libEntries.iterator(); iter.hasNext();) { Map.Entry> element = iter.next(); @@ -515,7 +515,7 @@ public class PluginConverterImpl implements PluginConverter { exports = filterExport(getExportsFromDir(libraryLocation), filter); } else { List expandedLibs = getLibrariesExpandingVariables(element.getKey(), false); - exports = new HashSet(); + exports = new HashSet<>(); for (Iterator iterator = expandedLibs.iterator(); iterator.hasNext();) { String libName = iterator.next(); File libFile = new File(pluginManifestLocation, libName); @@ -537,7 +537,7 @@ public class PluginConverterImpl implements PluginConverter { private Set getExportsFromDir(File location, String packageName) { String prefix = (packageName.length() > 0) ? (packageName + '.') : ""; //$NON-NLS-1$ String[] files = location.list(); - Set exportedPaths = new HashSet(); + Set exportedPaths = new HashSet<>(); boolean containsFile = false; if (files != null) for (int i = 0; i < files.length; i++) { @@ -560,7 +560,7 @@ public class PluginConverterImpl implements PluginConverter { } private Set getExportsFromJAR(File jarFile) { - Set names = new HashSet(); + Set names = new HashSet<>(); ZipFile file = null; try { file = new ZipFile(jarFile); @@ -597,7 +597,7 @@ public class PluginConverterImpl implements PluginConverter { private List getLibrariesExpandingVariables(String libraryPath, boolean filter) { String var = hasPrefix(libraryPath); if (var == null) { - List returnValue = new ArrayList(1); + List returnValue = new ArrayList<>(1); returnValue.add(libraryPath); return returnValue; } @@ -607,7 +607,7 @@ public class PluginConverterImpl implements PluginConverter { if (var.equals("os")) { //$NON-NLS-1$ return findOSJars(pluginManifestLocation, libraryPath, filter); } - return new ArrayList(0); + return new ArrayList<>(0); } //return a String representing the string found between the $s diff --git a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java index e6cb4d3a5..933114d3b 100644 --- a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java +++ b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java @@ -70,7 +70,7 @@ public class PluginParser extends DefaultHandler implements IModel { public Map> getLibraries() { if (libraries == null) - return new HashMap>(0); + return new HashMap<>(0); return libraries; } @@ -78,7 +78,7 @@ public class PluginParser extends DefaultHandler implements IModel { if (!TARGET21.equals(target) && schemaVersion == null && !requiresExpanded) { requiresExpanded = true; if (requires == null) { - requires = new ArrayList(1); + requires = new ArrayList<>(1); requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME, TARGET21_STRING, false, false, IModel.PLUGIN_REQUIRES_MATCH_GREATER_OR_EQUAL)); requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME_COMPATIBILITY, null, false, false, null)); } else { @@ -108,7 +108,7 @@ public class PluginParser extends DefaultHandler implements IModel { } } if (requires == null) - return requires = new ArrayList(0); + return requires = new ArrayList<>(0); return requires; } @@ -187,10 +187,10 @@ public class PluginParser extends DefaultHandler implements IModel { } // Current State Information - Stack stateStack = new Stack(); + Stack stateStack = new Stack<>(); // Current object stack (used to hold the current object we are populating in this plugin info - Stack objectStack = new Stack(); + Stack objectStack = new Stack<>(); Locator locator = null; // Valid States @@ -273,8 +273,8 @@ public class PluginParser extends DefaultHandler implements IModel { @SuppressWarnings("unchecked") List exports = (List) objectStack.pop(); if (manifestInfo.libraries == null) { - manifestInfo.libraries = new HashMap>(3); - manifestInfo.libraryPaths = new ArrayList(3); + manifestInfo.libraries = new HashMap<>(3); + manifestInfo.libraryPaths = new ArrayList<>(3); } manifestInfo.libraries.put(curLibrary, exports); manifestInfo.libraryPaths.add(curLibrary.replace('\\', '/')); @@ -477,7 +477,7 @@ public class PluginParser extends DefaultHandler implements IModel { public static SAXParserFactory acquireXMLParsing(BundleContext context) { if (xmlTracker == null) { - xmlTracker = new ServiceTracker(context, "javax.xml.parsers.SAXParserFactory", null); //$NON-NLS-1$ + xmlTracker = new ServiceTracker<>(context, "javax.xml.parsers.SAXParserFactory", null); //$NON-NLS-1$ xmlTracker.open(); } SAXParserFactory result = xmlTracker.getService(); @@ -595,7 +595,7 @@ public class PluginParser extends DefaultHandler implements IModel { public void parsePluginRequiresImport(Attributes attributes) { if (manifestInfo.requires == null) { - manifestInfo.requires = new ArrayList(); + manifestInfo.requires = new ArrayList<>(); // to avoid cycles // if (!manifestInfo.pluginId.equals(PluginConverterImpl.PI_RUNTIME)) //$NON-NLS-1$ // manifestInfo.requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME, null, false, false, null)); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java index 55ace736b..77113e4f9 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformAdminImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2012, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -103,7 +103,7 @@ public class PlatformAdminImpl implements PlatformAdmin { } private Dictionary asDictionary(Map map) { - return new Hashtable(map); + return new Hashtable<>(map); } @Override diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java index 361c30b5c..cc6d41936 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/PlatformBundleListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2013, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -82,7 +82,7 @@ class PlatformBundleListener implements SynchronousBundleListener, FrameworkList if (lastResolveStamp != database.getRevisionsTimestamp()) { Collection containerRemovalPending = container.getRemovalPending(); BundleDescription[] stateRemovalPendingDescs = systemState.getRemovalPending(); - Collection stateRemovalPending = new ArrayList(stateRemovalPendingDescs.length); + Collection stateRemovalPending = new ArrayList<>(stateRemovalPendingDescs.length); for (BundleDescription description : stateRemovalPendingDescs) { if (!containerRemovalPending.contains(description.getUserObject())) { stateRemovalPending.add(description); @@ -150,7 +150,7 @@ class PlatformBundleListener implements SynchronousBundleListener, FrameworkList candidates.clear(); return; } - Collection wirings = new ArrayList(1); + Collection wirings = new ArrayList<>(1); if ((reqRevision.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) { if (ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(namespace) || HostNamespace.HOST_NAMESPACE.equals(namespace)) { wirings.add(reqWiring); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java index 56b59211c..afea17e11 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/compatibility/state/StateConverter.java @@ -35,18 +35,18 @@ class StateConverter { throw new IllegalArgumentException("Bogus osgi.identity: " + idList); //$NON-NLS-1$ } else if (idList.size() == 1) { Capability id = idList.iterator().next(); - Map idAttrs = new HashMap(id.getAttributes()); + Map idAttrs = new HashMap<>(id.getAttributes()); String symbolicName = (String) idAttrs.remove(IdentityNamespace.IDENTITY_NAMESPACE); symbolicNameSpecification = symbolicName + toString(idAttrs, "=", true) + toString(id.getDirectives(), ":=", true); //$NON-NLS-1$ //$NON-NLS-2$ version = (Version) idAttrs.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); } - List exportPackages = new ArrayList(); - List provideCapabilities = new ArrayList(); - List importPackages = new ArrayList(); - List requireCapabilities = new ArrayList(); - List fragmentHost = new ArrayList(0); - List requireBundles = new ArrayList(); + List exportPackages = new ArrayList<>(); + List provideCapabilities = new ArrayList<>(); + List importPackages = new ArrayList<>(); + List requireCapabilities = new ArrayList<>(); + List fragmentHost = new ArrayList<>(0); + List requireBundles = new ArrayList<>(); Collection capabilities = resource.getCapabilities(null); @@ -90,7 +90,7 @@ class StateConverter { } private List creatExportPackage(Capability capability) { - Map attributes = new HashMap(capability.getAttributes()); + Map attributes = new HashMap<>(capability.getAttributes()); Map directives = capability.getDirectives(); String packageName = (String) attributes.remove(PackageNamespace.PACKAGE_NAMESPACE); // remove invalid attributes @@ -144,7 +144,7 @@ class StateConverter { } private List createRequireCapability(Requirement requirement) { - Map directives = new HashMap(requirement.getDirectives()); + Map directives = new HashMap<>(requirement.getDirectives()); String filter = directives.get(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (filter != null) { directives.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, escapeFilterInput(filter)); @@ -185,7 +185,7 @@ class StateConverter { } private String createOSGiRequirement(Requirement requirement, String namespace, String... versions) { - Map directives = new HashMap(requirement.getDirectives()); + Map directives = new HashMap<>(requirement.getDirectives()); String filter = directives.remove(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (filter == null) throw new IllegalArgumentException("No filter directive found:" + requirement); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java index 0acce4bd7..97136b1a2 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. All rights reserved. + * Copyright (c) 2004, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -20,7 +20,7 @@ public class GroupingChecker { // a mapping of bundles to their package roots; keyed by // ResolverBundle -> HashMap of packages; keyed by // package name -> PackageRoots - private Map> bundles = new HashMap>(); + private Map> bundles = new HashMap<>(); /* * This method fully populates a bundles package roots for the purpose of resolving @@ -108,7 +108,7 @@ public class GroupingChecker { String[] uses = matchingCapability.getUsesDirective(); if (uses == null) return null; - ArrayList results = new ArrayList(0); + ArrayList results = new ArrayList<>(0); for (String usedPackage : uses) { PackageRoots providingRoots = getPackageRoots(matchingCapability.getResolverBundle(), usedPackage, null); providingRoots.addConflicts(requiringBundle, usedPackage, null, results); @@ -167,7 +167,7 @@ public class GroupingChecker { PackageRoots getPackageRoots(ResolverBundle bundle, String packageName, List visited) { Map packages = bundles.get(bundle); if (packages == null) { - packages = new HashMap(5); + packages = new HashMap<>(5); bundles.put(bundle, packages); } PackageRoots packageRoots = packages.get(packageName); @@ -209,7 +209,7 @@ public class GroupingChecker { } // check if the bundle exports the package ResolverExport[] exports = bundle.getExports(packageName); - List roots = new ArrayList(0); + List roots = new ArrayList<>(0); // check roots from required bundles BundleConstraint[] requires = bundle.getRequires(); for (int i = 0; i < requires.length; i++) { @@ -326,7 +326,7 @@ public class GroupingChecker { if (roots == null) return results; if (visited == null) - visited = new ArrayList(1); + visited = new ArrayList<>(1); if (visited.contains(this)) return results; visited.add(this); @@ -346,7 +346,7 @@ public class GroupingChecker { if (thisUsedRoots != nullPackageRoots && importingUsedRoots != nullPackageRoots) if (!(subSet(thisUsedRoots.roots, importingUsedRoots.roots) || subSet(importingUsedRoots.roots, thisUsedRoots.roots))) { if (results == null) - results = new ArrayList(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, importingUsedRoots}); } // need to check the usedRoots consistency for transitive closure @@ -366,7 +366,7 @@ public class GroupingChecker { if (uses == null) continue; if (visited == null) - visited = new ArrayList(1); + visited = new ArrayList<>(1); if (visited.contains(this)) return results; visited.add(this); @@ -380,7 +380,7 @@ public class GroupingChecker { if (thisUsedRoots != nullPackageRoots && exportingUsedRoots != nullPackageRoots) if (!(subSet(thisUsedRoots.roots, exportingUsedRoots.roots) || subSet(exportingUsedRoots.roots, thisUsedRoots.roots))) { if (results == null) - results = new ArrayList(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, exportingUsedRoots}); } // need to check the usedRoots consistency for transitive closure @@ -397,7 +397,7 @@ public class GroupingChecker { if (this != nullPackageRoots && bundleUsedRoots != nullPackageRoots) if (!(subSet(this.roots, bundleUsedRoots.roots) || subSet(bundleUsedRoots.roots, this.roots))) { if (results == null) - results = new ArrayList(1); + results = new ArrayList<>(1); results.add(new PackageRoots[] {this, bundleUsedRoots}); } // need to check the usedRoots consistency for transitive closure diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java index 6c9482788..92880fb2f 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/MappedList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,13 +19,13 @@ import java.util.*; */ public class MappedList { // the mapping with key -> Object[] mapping - protected final HashMap> internal = new HashMap>(); + protected final HashMap> internal = new HashMap<>(); protected final List empty = Collections. emptyList(); public void put(K key, V value) { List existing = internal.get(key); if (existing == null) { - existing = new ArrayList(1); + existing = new ArrayList<>(1); existing.add(value); internal.put(key, existing); return; @@ -66,7 +66,7 @@ public class MappedList { public List getAllValues() { if (getSize() == 0) return empty; - ArrayList results = new ArrayList(getSize()); + ArrayList results = new ArrayList<>(getSize()); Iterator> iter = internal.values().iterator(); while (iter.hasNext()) results.addAll(iter.next()); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java index 8f16f561d..4502c1992 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,7 +62,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable constraints = new ArrayList(); + List constraints = new ArrayList<>(); for (GenericSpecification requirement : requirements) { if (StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getType())) constraints.add(new GenericConstraint(this, requirement)); @@ -83,7 +83,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable importList = new ArrayList(actualImports.length); + List importList = new ArrayList<>(actualImports.length); for (int i = actualImports.length - 1; i >= 0; i--) if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(actualImports[i].getDirective(Constants.RESOLUTION_DIRECTIVE))) importList.add(new ResolverImport(this, actualImports[i])); @@ -125,7 +125,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable results = new ArrayList(1); // rare to have more than one + List results = new ArrayList<>(1); // rare to have more than one // it is faster to ask the VersionHashMap for this package name and then compare the exporter to this List resolverExports = resolver.getResolverExports().get(name); for (ResolverExport export : resolverExports) @@ -172,7 +172,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable List getAll(T[] hostEntries, Map> fragmentMap) { - List result = new ArrayList(hostEntries.length); + List result = new ArrayList<>(hostEntries.length); for (T entry : hostEntries) result.add(entry); for (ResolverBundle fragment : fragments) { @@ -281,17 +281,17 @@ public class ResolverBundle extends VersionSupplier implements Comparable(1); + fragments = new ArrayList<>(1); if (fragmentExports == null) - fragmentExports = new HashMap>(1); + fragmentExports = new HashMap<>(1); if (fragmentImports == null) - fragmentImports = new HashMap>(1); + fragmentImports = new HashMap<>(1); if (fragmentRequires == null) - fragmentRequires = new HashMap>(1); + fragmentRequires = new HashMap<>(1); if (fragmentGenericCapabilities == null) - fragmentGenericCapabilities = new HashMap>(1); + fragmentGenericCapabilities = new HashMap<>(1); if (fragmentGenericRequires == null) - fragmentGenericRequires = new HashMap>(1); + fragmentGenericRequires = new HashMap<>(1); } private boolean isImported(String packageName) { @@ -342,7 +342,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable 0) { - ArrayList hostImports = new ArrayList(newImports.length); + ArrayList hostImports = new ArrayList<>(newImports.length); for (int i = 0; i < newImports.length; i++) if (!isImported(newImports[i].getName())) hostImports.add(new ResolverImport(this, newImports[i])); @@ -350,7 +350,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable 0) { - ArrayList hostRequires = new ArrayList(newRequires.length); + ArrayList hostRequires = new ArrayList<>(newRequires.length); for (int i = 0; i < newRequires.length; i++) if (!isRequired(newRequires[i].getName())) hostRequires.add(new BundleConstraint(this, newRequires[i])); @@ -358,7 +358,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable 0) { - ArrayList hostGenericRequires = new ArrayList(newGenericRequires.length); + ArrayList hostGenericRequires = new ArrayList<>(newGenericRequires.length); for (int i = 0; i < newGenericRequires.length; i++) { // only add namespaces that are not osgi.ee if (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequires[i].getType())) @@ -368,7 +368,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable hostExports = new ArrayList(newExports.length); + ArrayList hostExports = new ArrayList<>(newExports.length); if (newExports.length > 0 && dynamicAttach) { for (int i = 0; i < newExports.length; i++) { ResolverExport currentExports[] = getExports(newExports[i].getName()); @@ -385,7 +385,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable hostCapabilities = new ArrayList(newGenericCapabilities.length); + List hostCapabilities = new ArrayList<>(newGenericCapabilities.length); if (newGenericCapabilities.length > 0 && dynamicAttach) { for (GenericDescription capability : newGenericCapabilities) { if (!IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) { @@ -536,8 +536,8 @@ public class ResolverBundle extends VersionSupplier implements Comparable additionalImports = new ArrayList(0); - List additionalRequires = new ArrayList(0); + List additionalImports = new ArrayList<>(0); + List additionalRequires = new ArrayList<>(0); if (hasUnresolvedConstraint(reason, fragment, remainingFrag, oldImports, oldRequires, additionalImports, additionalRequires)) continue; // merge back the additional imports or requires which the detached fragment has in common with the remaining fragment diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java index 9118adb6e..f215c1b9b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2004, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -53,7 +53,7 @@ public class ResolverImpl implements Resolver { // Used to check permissions for import/export, provide/require, host/fragment private final PermissionChecker permissionChecker; // Set of bundles that are pending removal - private MappedList removalPending = new MappedList(); + private MappedList removalPending = new MappedList<>(); // Indicates whether this resolver has been initialized private boolean initialized = false; @@ -85,15 +85,15 @@ public class ResolverImpl implements Resolver { // Initializes the resolver private void initialize() { - resolverExports = new VersionHashMap(this); - resolverBundles = new VersionHashMap(this); - resolverGenerics = new HashMap>(); - unresolvedBundles = new HashSet(); - bundleMapping = new HashMap(); + resolverExports = new VersionHashMap<>(this); + resolverBundles = new VersionHashMap<>(this); + resolverGenerics = new HashMap<>(); + unresolvedBundles = new HashSet<>(); + bundleMapping = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); groupingChecker = new GroupingChecker(); - ArrayList fragmentBundles = new ArrayList(); + ArrayList fragmentBundles = new ArrayList<>(); // Add each bundle to the resolver's internal state for (int i = 0; i < bundles.length; i++) initResolverBundle(bundles[i], fragmentBundles, false); @@ -137,7 +137,7 @@ public class ResolverImpl implements Resolver { // Re-wire previously resolved bundles private void rewireBundles() { - List visited = new ArrayList(bundleMapping.size()); + List visited = new ArrayList<>(bundleMapping.size()); for (ResolverBundle rb : bundleMapping.values()) { if (!rb.getBundleDescription().isResolved()) continue; @@ -350,8 +350,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName()); - candidates = new ArrayList(hosts); - List hostCapabilities = new ArrayList(hosts.size()); + candidates = new ArrayList<>(hosts); + List hostCapabilities = new ArrayList<>(hosts.size()); // Must remove candidates that do not match before calling hooks. for (Iterator iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverBundle host = iCandidates.next(); @@ -365,7 +365,7 @@ public class ResolverImpl implements Resolver { } if (hook != null) - hook.filterMatches(hostConstraint.getRequirement(), asCapabilities(new ArrayMap(hostCapabilities, candidates))); + hook.filterMatches(hostConstraint.getRequirement(), asCapabilities(new ArrayMap<>(hostCapabilities, candidates))); } while (timestamp != state.getTimeStamp()); // we are left with only candidates that satisfy the host constraint for (ResolverBundle host : candidates) { @@ -443,24 +443,24 @@ public class ResolverImpl implements Resolver { // attempt to resolve all unresolved bundles Collection hookDisabled = Collections.EMPTY_LIST; if (hook != null) { - List resolvableBundles = new ArrayList(unresolvedBundles); - List resolvableRevisions = new ArrayList(resolvableBundles.size()); + List resolvableBundles = new ArrayList<>(unresolvedBundles); + List resolvableRevisions = new ArrayList<>(resolvableBundles.size()); for (ResolverBundle bundle : resolvableBundles) resolvableRevisions.add(bundle.getBundleDescription()); - ArrayMap resolvable = new ArrayMap(resolvableRevisions, resolvableBundles); + ArrayMap resolvable = new ArrayMap<>(resolvableRevisions, resolvableBundles); int size = resolvableBundles.size(); hook.filterResolvable(resolvable); if (resolvable.size() < size) { - hookDisabled = new ArrayList(unresolvedBundles); + hookDisabled = new ArrayList<>(unresolvedBundles); hookDisabled.removeAll(resolvableBundles); } } usesCalculationTimeout = false; - List toResolve = new ArrayList(unresolvedBundles); + List toResolve = new ArrayList<>(unresolvedBundles); // first resolve the system bundle to allow osgi.ee capabilities to be resolved - List unresolvedSystemBundles = new ArrayList(1); + List unresolvedSystemBundles = new ArrayList<>(1); String systemBSN = getSystemBundle(); for (Iterator iToResolve = toResolve.iterator(); iToResolve.hasNext();) { ResolverBundle rb = iToResolve.next(); @@ -549,7 +549,7 @@ public class ResolverImpl implements Resolver { return reRefresh; // we don't care about this unless we are in development mode // when in develoment mode we need to reRefresh hosts of unresolved fragments that add new constraints // and reRefresh and unresolved bundles that have dependents - Set additionalRefresh = new HashSet(); + Set additionalRefresh = new HashSet<>(); ResolverBundle[] unresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]); for (int i = 0; i < unresolved.length; i++) { addUnresolvedWithDependents(unresolved[i], additionalRefresh); @@ -588,7 +588,7 @@ public class ResolverImpl implements Resolver { } private Collection resolveOptionalConstraints(ResolverBundle[] bundles) { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (int i = 0; i < bundles.length; i++) { if (bundles[i] != null && resolveOptionalConstraints(bundles[i])) { result.add(bundles[i]); @@ -600,7 +600,7 @@ public class ResolverImpl implements Resolver { // TODO this does not do proper uses constraint verification. private boolean resolveOptionalConstraints(ResolverBundle bundle) { BundleConstraint[] requires = bundle.getRequires(); - List cycle = new ArrayList(); + List cycle = new ArrayList<>(); boolean resolvedOptional = false; for (int i = 0; i < requires.length; i++) if (requires[i].isOptional() && requires[i].getSelectedSupplier() == null) { @@ -647,7 +647,7 @@ public class ResolverImpl implements Resolver { private void selectSingletons(ResolverBundle[] bundles) { if (developmentMode) return; // want all singletons to resolve in devmode - Map> selectedSingletons = new HashMap>(bundles.length); + Map> selectedSingletons = new HashMap<>(bundles.length); for (ResolverBundle bundle : bundles) { if (!bundle.getBundleDescription().isSingleton() || !bundle.isResolvable()) continue; @@ -655,7 +655,7 @@ public class ResolverImpl implements Resolver { Collection selected = selectedSingletons.get(bsn); if (selected != null) continue; // already processed the bsn - selected = new ArrayList(1); + selected = new ArrayList<>(1); selectedSingletons.put(bsn, selected); List sameBSN = resolverBundles.get(bsn); @@ -677,7 +677,7 @@ public class ResolverImpl implements Resolver { Collection collisions = collisionMap.get(singleton); if (collisions == null || !singleton.isResolvable()) continue; // not a singleton or not resolvable - Collection pickOneToResolve = new ArrayList(); + Collection pickOneToResolve = new ArrayList<>(); for (ResolverBundle collision : collisions) { if (selected.contains(collision)) { // Must fail since there is already a selected bundle which is a collision of the singleton bundle @@ -729,12 +729,12 @@ public class ResolverImpl implements Resolver { } private Map> getCollisionMap(List sameBSN) { - Map> result = new HashMap>(); + Map> result = new HashMap<>(); for (ResolverBundle singleton : sameBSN) { if (!singleton.getBundleDescription().isSingleton() || !singleton.isResolvable()) continue; // ignore non-singleton and non-resolvable - List collisionCandidates = new ArrayList(sameBSN.size() - 1); - List capabilities = new ArrayList(sameBSN.size() - 1); + List collisionCandidates = new ArrayList<>(sameBSN.size() - 1); + List capabilities = new ArrayList<>(sameBSN.size() - 1); for (ResolverBundle collision : sameBSN) { if (collision == singleton || !collision.getBundleDescription().isSingleton() || !collision.isResolvable()) continue; // Ignore the bundle we are checking and non-singletons and non-resolvable @@ -742,7 +742,7 @@ public class ResolverImpl implements Resolver { capabilities.add(getIdentity(collision)); } if (hook != null) - hook.filterSingletonCollisions(getIdentity(singleton), asCapabilities(new ArrayMap(capabilities, collisionCandidates))); + hook.filterSingletonCollisions(getIdentity(singleton), asCapabilities(new ArrayMap<>(capabilities, collisionCandidates))); result.put(singleton, collisionCandidates); } return result; @@ -758,12 +758,12 @@ public class ResolverImpl implements Resolver { // need to sort bundles to keep consistent order for fragment attachment (bug 174930) Arrays.sort(bundles); // First attach all fragments to the matching hosts - Collection processedFragments = new HashSet(bundles.length); + Collection processedFragments = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) attachFragment(bundles[i], processedFragments); // Lists of cyclic dependencies recording during resolving - List cycle = new ArrayList(1); // start small + List cycle = new ArrayList<>(1); // start small // Attempt to resolve all unresolved bundles for (int i = 0; i < bundles.length; i++) { if (DEBUG) @@ -801,7 +801,7 @@ public class ResolverImpl implements Resolver { // We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561) setBundleUnresolved(bundles[i], false, false); if (exclude == null) - exclude = new HashSet(1); + exclude = new HashSet<>(1); exclude.add(bundles[i]); } } @@ -819,7 +819,7 @@ public class ResolverImpl implements Resolver { continue; } if (conflictedBundles == null) - conflictedBundles = new HashSet(conflictingConstraints.size()); + conflictedBundles = new HashSet<>(conflictingConstraints.size()); ResolverBundle conflictedBundle; if (conflict.isFromFragment()) conflictedBundle = bundleMapping.get(conflict.getVersionConstraint().getBundle()); @@ -842,7 +842,7 @@ public class ResolverImpl implements Resolver { private void reResolveBundles(Set exclude, ResolverBundle[] bundles, Dictionary[] platformProperties) { if (exclude == null || exclude.size() == 0) return; - List remainingUnresolved = new ArrayList(); + List remainingUnresolved = new ArrayList<>(); for (int i = 0; i < bundles.length; i++) { if (!exclude.contains(bundles[i])) { // We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561) @@ -859,9 +859,9 @@ public class ResolverImpl implements Resolver { usesMode = secureAction.getProperty("osgi.resolver.usesMode"); //$NON-NLS-1$ if ("ignore".equals(usesMode) || developmentMode) //$NON-NLS-1$ return null; - Set bundleConstraints = new HashSet(); - Set packageConstraints = new HashSet(); - Collection multiRequirementWithMultiSuppliers = new ArrayList(); + Set bundleConstraints = new HashSet<>(); + Set packageConstraints = new HashSet<>(); + Collection multiRequirementWithMultiSuppliers = new ArrayList<>(); // first try out the initial selections List initialConflicts = getConflicts(bundles, packageConstraints, bundleConstraints, multiRequirementWithMultiSuppliers); if (initialConflicts == null || "tryFirst".equals(usesMode) || usesCalculationTimeout) { //$NON-NLS-1$ @@ -991,7 +991,7 @@ public class ResolverImpl implements Resolver { private ResolverBundle[] getConflictedBundles(List bestConflicts) { if (bestConflicts == null) return new ResolverBundle[0]; - List conflictedBundles = new ArrayList(bestConflicts.size()); + List conflictedBundles = new ArrayList<>(bestConflicts.size()); for (ResolverConstraint constraint : bestConflicts) if (!conflictedBundles.contains(constraint.getBundle())) conflictedBundles.add(constraint.getBundle()); @@ -1044,7 +1044,7 @@ public class ResolverImpl implements Resolver { printConflict(conflict, requires[i], bundle); if (conflicts == null) - conflicts = new ArrayList(1); + conflicts = new ArrayList<>(1); conflicts.add(requires[i]); } } @@ -1059,7 +1059,7 @@ public class ResolverImpl implements Resolver { printConflict(conflict, imports[i], bundle); if (conflicts == null) - conflicts = new ArrayList(1); + conflicts = new ArrayList<>(1); conflicts.add(imports[i]); } } @@ -1081,7 +1081,7 @@ public class ResolverImpl implements Resolver { PackageRoots[][] conflict = groupingChecker.isConsistent(bundle, (GenericCapability) supplier); if (conflict != null) { if (capabilityConflicts == null) - capabilityConflicts = new ArrayList(1); + capabilityConflicts = new ArrayList<>(1); capabilityConflicts.add(conflict); } } @@ -1092,7 +1092,7 @@ public class ResolverImpl implements Resolver { if (capabilityConflicts.size() == suppliers.length) { // every capability conflicted if (conflicts == null) - conflicts = new ArrayList(1); + conflicts = new ArrayList<>(1); conflicts.add(capabilityRequirement); } } @@ -1136,9 +1136,9 @@ public class ResolverImpl implements Resolver { // get a list of resolver constraints that have multiple suppliers // a 2 demensional array is used each entry is a list of identical constraints that have identical suppliers. private ResolverConstraint[][] getMultipleSuppliers(ResolverBundle[] bundles, Set packageConstraints, Set bundleConstraints) { - List multipleImportSupplierList = new ArrayList(1); - List multipleRequireSupplierList = new ArrayList(1); - List multipleGenericSupplierList = new ArrayList(1); + List multipleImportSupplierList = new ArrayList<>(1); + List multipleRequireSupplierList = new ArrayList<>(1); + List multipleGenericSupplierList = new ArrayList<>(1); for (ResolverBundle bundle : bundles) { BundleConstraint[] requires = bundle.getRequires(); for (BundleConstraint require : requires) @@ -1176,17 +1176,17 @@ public class ResolverImpl implements Resolver { if (genericRequire.getNumPossibleSuppliers() > 1 && !genericRequire.isMultiple()) multipleGenericSupplierList.add(genericRequire); } - List results = new ArrayList(); + List results = new ArrayList<>(); if (multipleImportSupplierList.size() + multipleRequireSupplierList.size() + multipleGenericSupplierList.size() > usesMultipleSuppliersLimit) { // we have hit a max on the multiple suppliers in the lists without merging. // first merge the identical constraints that have identical suppliers - Map>> multipleImportSupplierMaps = new HashMap>>(); + Map>> multipleImportSupplierMaps = new HashMap<>(); for (ResolverImport importPkg : multipleImportSupplierList) addMutipleSupplierConstraint(multipleImportSupplierMaps, importPkg, importPkg.getName()); - Map>> multipleRequireSupplierMaps = new HashMap>>(); + Map>> multipleRequireSupplierMaps = new HashMap<>(); for (BundleConstraint requireBundle : multipleRequireSupplierList) addMutipleSupplierConstraint(multipleRequireSupplierMaps, requireBundle, requireBundle.getName()); - Map>> multipleGenericSupplierMaps = new HashMap>>(); + Map>> multipleGenericSupplierMaps = new HashMap<>(); for (GenericConstraint genericRequire : multipleGenericSupplierList) addMutipleSupplierConstraint(multipleGenericSupplierMaps, genericRequire, genericRequire.getNameSpace()); addMergedSuppliers(results, multipleImportSupplierMaps); @@ -1196,7 +1196,7 @@ public class ResolverImpl implements Resolver { if (results.size() > usesMultipleSuppliersLimit && packageConstraints != null && bundleConstraints != null) { // we still have too big of a list; filter out constraints that are not in conflict List tooBig = results; - results = new ArrayList(); + results = new ArrayList<>(); for (ResolverConstraint[] constraints : tooBig) { ResolverConstraint constraint = constraints.length > 0 ? constraints[0] : null; if (constraint instanceof ResolverImport) { @@ -1240,8 +1240,8 @@ public class ResolverImpl implements Resolver { private void addMutipleSupplierConstraint(Map>> constraints, ResolverConstraint constraint, String key) { List> mergedConstraintLists = constraints.get(key); if (mergedConstraintLists == null) { - mergedConstraintLists = new ArrayList>(0); - List constraintList = new ArrayList(1); + mergedConstraintLists = new ArrayList<>(0); + List constraintList = new ArrayList<>(1); constraintList.add(constraint); mergedConstraintLists.add(constraintList); constraints.put(key, mergedConstraintLists); @@ -1259,7 +1259,7 @@ public class ResolverImpl implements Resolver { constraintList.add(constraint); return; } - List constraintList = new ArrayList(1); + List constraintList = new ArrayList<>(1); constraintList.add(constraint); mergedConstraintLists.add(constraintList); } @@ -1299,7 +1299,7 @@ public class ResolverImpl implements Resolver { ResolverBundle cycleBundle = cycle.get(i); cycleBundle.clearWires(); } - List innerCycle = new ArrayList(cycle.size()); + List innerCycle = new ArrayList<>(cycle.size()); for (int i = 0; i < cycle.size(); i++) resolveBundle(cycle.get(i), innerCycle); checkCycle(innerCycle); @@ -1494,8 +1494,8 @@ public class ResolverImpl implements Resolver { capabilities = Collections.EMPTY_LIST; else capabilities = name == null || name.indexOf('*') >= 0 ? namespace.getAllValues() : namespace.get(name); - candidates = new ArrayList(capabilities); - List genCapabilities = new ArrayList(candidates.size()); + candidates = new ArrayList<>(capabilities); + List genCapabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator iCandidates = candidates.iterator(); iCandidates.hasNext();) { GenericCapability capability = iCandidates.next(); @@ -1506,7 +1506,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(constraint.getRequirement(), asCapabilities(new ArrayMap(genCapabilities, candidates))); + hook.filterMatches(constraint.getRequirement(), asCapabilities(new ArrayMap<>(genCapabilities, candidates))); } while (timestamp != state.getTimeStamp()); boolean result = false; // We are left with only capabilities that satisfy the constraint. @@ -1576,8 +1576,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List bundles = resolverBundles.get(req.getVersionConstraint().getName()); - candidates = new ArrayList(bundles); - List capabilities = new ArrayList(candidates.size()); + candidates = new ArrayList<>(bundles); + List capabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverBundle bundle = iCandidates.next(); @@ -1588,7 +1588,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(req.getRequirement(), asCapabilities(new ArrayMap(capabilities, candidates))); + hook.filterMatches(req.getRequirement(), asCapabilities(new ArrayMap<>(capabilities, candidates))); } while (timestamp != state.getTimeStamp()); // We are left with only capabilities that satisfy the require bundle. boolean result = false; @@ -1648,8 +1648,8 @@ public class ResolverImpl implements Resolver { do { timestamp = state.getTimeStamp(); List exports = resolverExports.get(imp.getName()); - candidates = new ArrayList(exports); - List capabilities = new ArrayList(candidates.size()); + candidates = new ArrayList<>(exports); + List capabilities = new ArrayList<>(candidates.size()); // Must remove candidates that do not match before calling hooks. for (Iterator iCandidates = candidates.iterator(); iCandidates.hasNext();) { ResolverExport export = iCandidates.next(); @@ -1660,7 +1660,7 @@ public class ResolverImpl implements Resolver { } } if (hook != null) - hook.filterMatches(imp.getRequirement(), asCapabilities(new ArrayMap(capabilities, candidates))); + hook.filterMatches(imp.getRequirement(), asCapabilities(new ArrayMap<>(capabilities, candidates))); } while (timestamp != state.getTimeStamp()); // We are left with only capabilities that satisfy the import. for (ResolverExport export : candidates) { @@ -1827,11 +1827,11 @@ public class ResolverImpl implements Resolver { stateResolveConstraints(rb); // Build up the state wires - Map> stateWires = new HashMap>(); + Map> stateWires = new HashMap<>(); // Gather selected exports ResolverExport[] exports = rb.getSelectedExports(); - List selectedExports = new ArrayList(exports.length); + List selectedExports = new ArrayList<>(exports.length); for (int i = 0; i < exports.length; i++) { if (permissionChecker.checkPackagePermission(exports[i].getExportPackageDescription())) selectedExports.add(exports[i].getExportPackageDescription()); @@ -1840,7 +1840,7 @@ public class ResolverImpl implements Resolver { // Gather substitute exports ResolverExport[] substituted = rb.getSubstitutedExports(); - List substitutedExports = new ArrayList(substituted.length); + List substitutedExports = new ArrayList<>(substituted.length); for (int i = 0; i < substituted.length; i++) { substitutedExports.add(substituted[i].getExportPackageDescription()); } @@ -1851,8 +1851,8 @@ public class ResolverImpl implements Resolver { // Gather bundles that have been wired to BundleConstraint[] requires = rb.getRequires(); - List bundlesWiredTo = new ArrayList(requires.length); - List requireWires = new ArrayList(requires.length); + List bundlesWiredTo = new ArrayList<>(requires.length); + List requireWires = new ArrayList<>(requires.length); for (int i = 0; i < requires.length; i++) if (requires[i].getSelectedSupplier() != null) { BundleDescription supplier = (BundleDescription) requires[i].getSelectedSupplier().getBaseDescription(); @@ -1865,14 +1865,14 @@ public class ResolverImpl implements Resolver { stateWires.put(BundleRevision.BUNDLE_NAMESPACE, requireWires); GenericCapability[] capabilities = rb.getGenericCapabilities(); - List selectedCapabilities = new ArrayList(capabilities.length); + List selectedCapabilities = new ArrayList<>(capabilities.length); for (GenericCapability capability : capabilities) if (capability.isEffective() && permissionChecker.checkCapabilityPermission(capability.getGenericDescription())) selectedCapabilities.add(capability.getGenericDescription()); GenericDescription[] selectedCapabilitiesArray = selectedCapabilities.toArray(new GenericDescription[selectedCapabilities.size()]); GenericConstraint[] genericRequires = rb.getGenericRequires(); - List resolvedGenericRequires = new ArrayList(genericRequires.length); + List resolvedGenericRequires = new ArrayList<>(genericRequires.length); for (GenericConstraint genericConstraint : genericRequires) { VersionSupplier[] matching = genericConstraint.getMatchingCapabilities(); if (matching != null) @@ -1882,7 +1882,7 @@ public class ResolverImpl implements Resolver { StateWire genericWire = newStateWire(rb.getBundleDescription(), genericConstraint.getVersionConstraint(), supplier.getSupplier(), supplier); List genericWires = stateWires.get(genericConstraint.getNameSpace()); if (genericWires == null) { - genericWires = new ArrayList(); + genericWires = new ArrayList<>(); stateWires.put(genericConstraint.getNameSpace(), genericWires); } genericWires.add(genericWire); @@ -1895,7 +1895,7 @@ public class ResolverImpl implements Resolver { VersionSupplier[] matchingBundles = rb.getHost().getPossibleSuppliers(); if (matchingBundles != null && matchingBundles.length > 0) { hostBundles = new BundleDescription[matchingBundles.length]; - List hostWires = new ArrayList(matchingBundles.length); + List hostWires = new ArrayList<>(matchingBundles.length); stateWires.put(BundleRevision.HOST_NAMESPACE, hostWires); for (int i = 0; i < matchingBundles.length; i++) { hostBundles[i] = matchingBundles[i].getBundleDescription(); @@ -1937,8 +1937,8 @@ public class ResolverImpl implements Resolver { private static ExportPackageDescription[] getExportsWiredTo(ResolverBundle rb, Map> stateWires) { // Gather exports that have been wired to ResolverImport[] imports = rb.getImportPackages(); - List exportsWiredTo = new ArrayList(imports.length); - List importWires = new ArrayList(imports.length); + List exportsWiredTo = new ArrayList<>(imports.length); + List importWires = new ArrayList<>(imports.length); for (int i = 0; i < imports.length; i++) if (imports[i].getSelectedSupplier() != null) { ExportPackageDescription supplier = (ExportPackageDescription) imports[i].getSelectedSupplier().getBaseDescription(); @@ -2003,7 +2003,7 @@ public class ResolverImpl implements Resolver { Map> wires = ((BundleDescriptionImpl) importingBundle).getWires(); List imports = wires.get(BundleRevision.PACKAGE_NAMESPACE); if (imports == null) { - imports = new ArrayList(); + imports = new ArrayList<>(); wires.put(BundleRevision.PACKAGE_NAMESPACE, imports); } imports.add(newStateWire(importingBundle, requirement, capabilityHost, capability)); @@ -2294,7 +2294,7 @@ public class ResolverImpl implements Resolver { String type = capability.getGenericDescription().getType(); VersionHashMap namespace = resolverGenerics.get(type); if (namespace == null) { - namespace = new VersionHashMap(this); + namespace = new VersionHashMap<>(this); resolverGenerics.put(type, namespace); } namespace.put(capability.getName(), capability); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java index 3abcdfdb6..1eddc7035 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BaseDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -140,7 +140,7 @@ public abstract class BaseDescriptionImpl implements BaseDescription { if (namespace.equals(internalName)) return attrs; // we are doing an alias, must remove internal Name and add alias - attrs = new HashMap(attrs); + attrs = new HashMap<>(attrs); Object nameValue = attrs.remove(internalName); if (nameValue != null) attrs.put(namespace, nameValue); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java index e460d9c91..d16b510d2 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -258,7 +258,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements LazyData currentData = loadLazyData(); synchronized (this.monitor) { if (currentData.stateWires == null) { - currentData.stateWires = new HashMap>(0); + currentData.stateWires = new HashMap<>(0); } return currentData.stateWires; } @@ -535,7 +535,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (newDependencies == null) return; if (!checkDups && dependencies == null) - dependencies = new ArrayList(newDependencies.length); + dependencies = new ArrayList<>(newDependencies.length); for (int i = 0; i < newDependencies.length; i++) { addDependency((BaseDescriptionImpl) newDependencies[i], checkDups); } @@ -548,7 +548,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (bundle == this) return; if (dependencies == null) - dependencies = new ArrayList(10); + dependencies = new ArrayList<>(10); if (!checkDups || !dependencies.contains(bundle)) { bundle.addDependent(this); dependencies.add(bundle); @@ -563,8 +563,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List getBundleDependencies() { synchronized (this.monitor) { if (dependencies == null) - return new ArrayList(0); - ArrayList required = new ArrayList(dependencies.size()); + return new ArrayList<>(0); + ArrayList required = new ArrayList<>(dependencies.size()); for (Iterator iter = dependencies.iterator(); iter.hasNext();) { BundleDescription dep = iter.next(); if (dep != this && dep.getHost() == null) @@ -577,7 +577,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements protected void addDependent(BundleDescription dependent) { synchronized (this.monitor) { if (dependents == null) - dependents = new ArrayList(10); + dependents = new ArrayList<>(10); // no need to check for duplicates here; this is only called in addDepenency which already checks for dups. dependents.add(dependent); } @@ -684,7 +684,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements LazyData currentData = loadLazyData(); synchronized (this.monitor) { if (currentData.addedDynamicImports == null) - currentData.addedDynamicImports = new ArrayList(); + currentData.addedDynamicImports = new ArrayList<>(); for (ImportPackageSpecification addImport : dynamicImport) { if (!ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(addImport.getDirective(Constants.RESOLUTION_DIRECTIVE))) throw new IllegalArgumentException("Import must be a dynamic import."); //$NON-NLS-1$ @@ -746,7 +746,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (lazyData.dynamicStamps == null) { if (timestamp == null) return; - lazyData.dynamicStamps = new HashMap(); + lazyData.dynamicStamps = new HashMap<>(); } if (timestamp == null) lazyData.dynamicStamps.remove(requestedPackage); @@ -858,7 +858,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public Map getDeclaredDirectives() { - Map result = new HashMap(2); + Map result = new HashMap<>(2); Map arbitrary = getArbitraryDirectives(); if (arbitrary != null) result.putAll(arbitrary); @@ -879,7 +879,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public Map getDeclaredAttributes() { - Map result = new HashMap(1); + Map result = new HashMap<>(1); synchronized (this.monitor) { if (attributes != null) result.putAll(attributes); @@ -890,7 +890,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public List getDeclaredRequirements(String namespace) { - List result = new ArrayList(); + List result = new ArrayList<>(); if (namespace == null || BundleRevision.BUNDLE_NAMESPACE.equals(namespace)) { BundleSpecification[] requires = getRequiredBundles(); for (BundleSpecification require : requires) { @@ -914,7 +914,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements } public List getDeclaredCapabilities(String namespace) { - List result = new ArrayList(); + List result = new ArrayList<>(); if (host == null) { if (getSymbolicName() != null) { if (namespace == null || BundleRevision.BUNDLE_NAMESPACE.equals(namespace)) { @@ -1083,7 +1083,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements public List getCapabilities(String namespace) { if (!isInUse()) return null; - List result = new ArrayList(); + List result = new ArrayList<>(); GenericDescription[] genericCapabilities = getSelectedGenericCapabilities(); for (GenericDescription capabilitiy : genericCapabilities) { if (namespace == null || namespace.equals(capabilitiy.getType())) @@ -1116,7 +1116,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (requiredWires == null) // happens if not in use return null; - List requirements = new ArrayList(requiredWires.size()); + List requirements = new ArrayList<>(requiredWires.size()); for (BundleWire wire : requiredWires) { if (!requirements.contains(wire.getRequirement())) requirements.add(wire.getRequirement()); @@ -1152,7 +1152,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements if (!isInUse()) return null; BundleDescription[] dependentBundles = getDependents(); - List unorderedResult = new ArrayList(); + List unorderedResult = new ArrayList<>(); for (BundleDescription dependent : dependentBundles) { List dependentWires = dependent.getWiring().getRequiredWires(namespace); if (dependentWires != null) @@ -1161,7 +1161,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements unorderedResult.add(bundleWire); } } - List orderedResult = new ArrayList(unorderedResult.size()); + List orderedResult = new ArrayList<>(unorderedResult.size()); List capabilities = getCapabilities(namespace); for (BundleCapability capability : capabilities) { for (Iterator wires = unorderedResult.iterator(); wires.hasNext();) { @@ -1185,7 +1185,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List result = Collections. emptyList(); Map> wireMap = getWires(); if (namespace == null) { - result = new ArrayList(); + result = new ArrayList<>(); for (List wires : wireMap.values()) { for (StateWire wire : wires) { result.add(new BundleWireImpl(wire)); @@ -1196,7 +1196,7 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements List wires = wireMap.get(namespace); if (wires == null) return result; - result = new ArrayList(wires.size()); + result = new ArrayList<>(wires.size()); for (StateWire wire : wires) { result.add(new BundleWireImpl(wire)); } diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java index c0776d788..7fbe25896 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -118,7 +118,7 @@ public class BundleSpecificationImpl extends VersionConstraintImpl implements Bu @Override protected Map getInternalDirectives() { - Map result = new HashMap(2); + Map result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java index 121d14dea..a7467ba58 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements public Map getDirectives() { synchronized (this.monitor) { - Map result = new HashMap(7); + Map result = new HashMap<>(7); if (uses != null) result.put(Constants.USES_DIRECTIVE, uses); if (exclude != null) @@ -68,7 +68,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements } public Map getDeclaredDirectives() { - Map result = new HashMap(6); + Map result = new HashMap<>(6); synchronized (this.monitor) { Map arbitrary = getArbitraryDirectives(); if (arbitrary != null) @@ -90,7 +90,7 @@ public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements } public Map getDeclaredAttributes() { - Map result = new HashMap(2); + Map result = new HashMap<>(2); synchronized (this.monitor) { if (attributes != null) result.putAll(attributes); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java index d6ce6d87b..b5adf213b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericDescriptionImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,7 +31,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener setType(fragmentDeclaration.getType()); Dictionary origAttrs = fragmentDeclaration.getAttributes(); if (origAttrs != null) { - Hashtable copyAttrs = new Hashtable(); + Hashtable copyAttrs = new Hashtable<>(); for (Enumeration keys = origAttrs.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); copyAttrs.put(key, origAttrs.get(key)); @@ -39,7 +39,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener setAttributes(copyAttrs); } Map origDirectives = fragmentDeclaration.getDeclaredDirectives(); - Map copyDirectives = new HashMap(origDirectives); + Map copyDirectives = new HashMap<>(origDirectives); setDirectives(copyDirectives); setSupplier(host); this.fragmentDeclaration = fragmentDeclaration; @@ -118,7 +118,7 @@ public class GenericDescriptionImpl extends BaseDescriptionImpl implements Gener public Map getDeclaredAttributes() { synchronized (this.monitor) { - Map result = new HashMap(5); + Map result = new HashMap<>(5); if (attributes != null) for (Enumeration keys = attributes.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java index f53e941b9..45fed239f 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -169,7 +169,7 @@ public class GenericSpecificationImpl extends VersionConstraintImpl implements G @Override protected Map getInternalDirectives() { - Map result = new HashMap(2); + Map result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); @@ -187,7 +187,7 @@ public class GenericSpecificationImpl extends VersionConstraintImpl implements G @Override protected Map getInteralAttributes() { synchronized (this.monitor) { - return attributes == null ? Collections. 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 2b2f2f6ff..cc66a8770 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/HostSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -137,7 +137,7 @@ public class HostSpecificationImpl extends VersionConstraintImpl implements Host @Override protected Map getInternalDirectives() { - Map result = new HashMap(2); + Map result = new HashMap<>(2); synchronized (this.monitor) { if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java index a81392533..8348ae2f0 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2012 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,7 +27,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem public Map getDirectives() { synchronized (this.monitor) { - Map result = new HashMap(5); + Map result = new HashMap<>(5); if (resolution != null) result.put(Constants.RESOLUTION_DIRECTIVE, resolution); return result; @@ -216,7 +216,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem @Override protected Map getInternalDirectives() { synchronized (this.monitor) { - Map result = new HashMap(5); + Map result = new HashMap<>(5); if (arbitraryDirectives != null) result.putAll(arbitraryDirectives); if (resolution != null) { diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java index 7689ad400..0ae88cc40 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,7 +112,7 @@ public class StateBuilder { ManifestElement[] exports = ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE)); ManifestElement[] provides = ManifestElement.parseHeader(StateImpl.PROVIDE_PACKAGE, manifest.get(StateImpl.PROVIDE_PACKAGE)); boolean strict = state != null && state.inStrictMode(); - List providedExports = new ArrayList(provides == null ? 0 : provides.length); + List providedExports = new ArrayList<>(provides == null ? 0 : provides.length); result.setExportPackages(createExportPackages(exports, provides, providedExports, strict)); ManifestElement[] imports = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, manifest.get(Constants.IMPORT_PACKAGE)); ManifestElement[] dynamicImports = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE, manifest.get(Constants.DYNAMICIMPORT_PACKAGE)); @@ -135,7 +135,7 @@ public class StateBuilder { ManifestElement[] genericRequires = ManifestElement.parseHeader(GENERIC_REQUIRE, manifest.get(GENERIC_REQUIRE)); List aliasList = null; if (genericAliases.length > 0) { - aliasList = new ArrayList(genericRequires == null ? 0 : genericRequires.length); + aliasList = new ArrayList<>(genericRequires == null ? 0 : genericRequires.length); for (int i = 0; i < genericAliases.length; i++) { ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAliases[i][1], manifest.get(genericAliases[i][1])); if (aliasReqs == null) @@ -163,7 +163,7 @@ public class StateBuilder { ManifestElement[] genericCapabilities = ManifestElement.parseHeader(GENERIC_CAPABILITY, manifest.get(GENERIC_CAPABILITY)); List aliasList = null; if (genericAliases.length > 0) { - aliasList = new ArrayList(genericCapabilities == null ? 0 : genericCapabilities.length); + aliasList = new ArrayList<>(genericCapabilities == null ? 0 : genericCapabilities.length); for (int i = 0; i < genericAliases.length; i++) { ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAliases[i][0], manifest.get(genericAliases[i][0])); if (aliasCapabilities == null) @@ -250,7 +250,7 @@ public class StateBuilder { // add implicit imports for each exported package if manifest verions is less than 2. if (exported.length == 0 && imported == null && dynamicImported == null) return null; - allImports = new ArrayList(exported.length + (imported == null ? 0 : imported.length)); + allImports = new ArrayList<>(exported.length + (imported == null ? 0 : imported.length)); for (int i = 0; i < exported.length; i++) { if (providedExports.contains(exported[i].getName())) continue; @@ -261,7 +261,7 @@ public class StateBuilder { allImports.add(result); } } else { - allImports = new ArrayList(imported == null ? 0 : imported.length); + allImports = new ArrayList<>(imported == null ? 0 : imported.length); } // add dynamics first so they will get overriden by static imports if @@ -320,7 +320,7 @@ public class StateBuilder { int numExports = (exported == null ? 0 : exported.length) + (provides == null ? 0 : provides.length); if (numExports == 0) return null; - List allExports = new ArrayList(numExports); + List allExports = new ArrayList<>(numExports); if (exported != null) for (int i = 0; i < exported.length; i++) addExportPackages(exported[i], allExports, strict); @@ -384,7 +384,7 @@ public class StateBuilder { continue keyloop; } if (arbitraryDirectives == null) - arbitraryDirectives = new HashMap(); + arbitraryDirectives = new HashMap<>(); arbitraryDirectives.put(key, element.getDirective(key)); } return arbitraryDirectives; @@ -413,7 +413,7 @@ public class StateBuilder { } if (!definedAttr) { if (arbitraryAttrs == null) - arbitraryAttrs = new HashMap(); + arbitraryAttrs = new HashMap<>(); arbitraryAttrs.put(key, convertValue(type, value)); } } @@ -461,7 +461,7 @@ public class StateBuilder { throw new RuntimeException("Invalid type, missing ending '>' : " + type); //$NON-NLS-1$ } List tokens = new Tokenizer(value).getEscapedTokens(","); //$NON-NLS-1$ - List components = new ArrayList(); + List components = new ArrayList<>(); for (String component : tokens) { components.add(convertValue(componentType, component)); } @@ -494,8 +494,8 @@ public class StateBuilder { if (brees == null || brees.length == 0) return result; if (result == null) - result = new ArrayList(brees.length); - List breeFilters = new ArrayList(); + result = new ArrayList<>(brees.length); + List breeFilters = new ArrayList<>(); for (String bree : brees) breeFilters.add(createOSGiEERequirementFilter(bree)); String filterSpec; @@ -609,7 +609,7 @@ public class StateBuilder { if (osgiRequires == null) return result; if (result == null) - result = new ArrayList(); + result = new ArrayList<>(); for (ManifestElement element : osgiRequires) { String[] namespaces = element.getValueComponents(); for (String namespace : namespaces) { @@ -647,7 +647,7 @@ public class StateBuilder { private static List createEquinoxRequires(ManifestElement[] equinoxRequires) throws BundleException { if (equinoxRequires == null) return null; - ArrayList results = new ArrayList(equinoxRequires.length); + ArrayList results = new ArrayList<>(equinoxRequires.length); for (int i = 0; i < equinoxRequires.length; i++) { String[] genericNames = equinoxRequires[i].getValueComponents(); for (int j = 0; j < genericNames.length; j++) { @@ -686,7 +686,7 @@ public class StateBuilder { static List createOSGiCapabilities(ManifestElement[] osgiCapabilities, List result, BundleDescription description) throws BundleException { if (result == null) - result = new ArrayList(osgiCapabilities == null ? 1 : osgiCapabilities.length + 1); + result = new ArrayList<>(osgiCapabilities == null ? 1 : osgiCapabilities.length + 1); // Always have an osgi.identity capability if there is a symbolic name. GenericDescription osgiIdentity = createOsgiIdentityCapability(description); if (osgiIdentity != null) @@ -699,7 +699,7 @@ public class StateBuilder { if (osgiCapabilities == null) return result; if (result == null) - result = new ArrayList(osgiCapabilities.length); + result = new ArrayList<>(osgiCapabilities.length); for (ManifestElement element : osgiCapabilities) { String[] namespaces = element.getValueComponents(); @@ -712,9 +712,9 @@ public class StateBuilder { Map mapAttrs = getAttributes(element, new String[0]); if (profileIndex != null) mapAttrs.put(ExportPackageDescriptionImpl.EQUINOX_EE, profileIndex); - Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable(mapAttrs); + Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable<>(mapAttrs); desc.setAttributes(attrs); - Map directives = new HashMap(); + Map directives = new HashMap<>(); Enumeration keys = element.getDirectiveKeys(); if (keys != null) for (keys = element.getDirectiveKeys(); keys.hasMoreElements();) { @@ -731,7 +731,7 @@ public class StateBuilder { private static List createEquinoxCapabilities(ManifestElement[] equinoxCapabilities) throws BundleException { if (equinoxCapabilities == null) return null; - ArrayList results = new ArrayList(equinoxCapabilities.length); + ArrayList results = new ArrayList<>(equinoxCapabilities.length); for (int i = 0; i < equinoxCapabilities.length; i++) { String[] genericNames = equinoxCapabilities[i].getValueComponents(); for (int j = 0; j < genericNames.length; j++) { @@ -745,7 +745,7 @@ public class StateBuilder { throw new BundleException("A bundle is not allowed to define a capability in the " + IdentityNamespace.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$ } Map mapAttrs = getAttributes(equinoxCapabilities[i], new String[] {Constants.VERSION_ATTRIBUTE}); - Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable(mapAttrs); + Dictionary attrs = mapAttrs == null ? new Hashtable() : new Hashtable<>(mapAttrs); attrs.put(desc.getType(), name); String versionString = equinoxCapabilities[i].getAttribute(Constants.VERSION_ATTRIBUTE); if (versionString != null) @@ -811,7 +811,7 @@ public class StateBuilder { if (elements == null) return; int length = elements.length; - Set packages = new HashSet(length); + Set packages = new HashSet<>(length); for (int i = 0; i < length; i++) { // check for duplicate imports String[] packageNames = elements[i].getValueComponents(); @@ -893,7 +893,7 @@ public class StateBuilder { return null; GenericDescriptionImpl result = new GenericDescriptionImpl(); result.setType(IdentityNamespace.IDENTITY_NAMESPACE); - Dictionary attributes = new Hashtable(description.getDeclaredAttributes()); + Dictionary attributes = new Hashtable<>(description.getDeclaredAttributes()); // remove osgi.wiring.bundle and bundle-version attributes attributes.remove(BundleNamespace.BUNDLE_NAMESPACE); attributes.remove(Constants.BUNDLE_VERSION_ATTRIBUTE); @@ -901,7 +901,7 @@ public class StateBuilder { attributes.put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, description.getHost() == null ? IdentityNamespace.TYPE_BUNDLE : IdentityNamespace.TYPE_FRAGMENT); attributes.put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, description.getVersion()); result.setAttributes(attributes); - Map directives = new HashMap(description.getDeclaredDirectives()); + Map directives = new HashMap<>(description.getDeclaredDirectives()); // remove defaults directive values if (!description.isSingleton()) directives.remove(Constants.SINGLETON_DIRECTIVE); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java index 966a0224d..1e269f4a4 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateDeltaImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,7 @@ final class StateDeltaImpl implements StateDelta { private final State state; - private final Map changes = new HashMap(); + private final Map changes = new HashMap<>(); private ResolverHookException error; public StateDeltaImpl(State state) { @@ -37,7 +37,7 @@ final class StateDeltaImpl implements StateDelta { public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Iterator changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java index 29f4e2b26..ad13c790a 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,7 +37,7 @@ public final class StateHelperImpl implements StateHelper { if (bundles == null || bundles.length == 0) return new BundleDescription[0]; - Set reachable = new HashSet(bundles.length); + Set reachable = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) { if (!bundles[i].isResolved()) continue; @@ -58,7 +58,7 @@ public final class StateHelperImpl implements StateHelper { public BundleDescription[] getPrerequisites(BundleDescription[] bundles) { if (bundles == null || bundles.length == 0) return new BundleDescription[0]; - Set reachable = new HashSet(bundles.length); + Set reachable = new HashSet<>(bundles.length); for (int i = 0; i < bundles.length; i++) addPrerequisites(bundles[i], reachable); return reachable.toArray(new BundleDescription[reachable.size()]); @@ -75,7 +75,7 @@ public final class StateHelperImpl implements StateHelper { } private Map> getExportedPackageMap(State state) { - Map> result = new HashMap>(); + Map> result = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); for (int i = 0; i < bundles.length; i++) { ExportPackageDescription[] packages = bundles[i].getExportPackages(); @@ -83,7 +83,7 @@ public final class StateHelperImpl implements StateHelper { ExportPackageDescription description = packages[j]; List exports = result.get(description.getName()); if (exports == null) { - exports = new ArrayList(); + exports = new ArrayList<>(); result.put(description.getName(), exports); } exports.add(description); @@ -93,7 +93,7 @@ public final class StateHelperImpl implements StateHelper { } private Map> getGenericsMap(State state, boolean resolved) { - Map> result = new HashMap>(); + Map> result = new HashMap<>(); BundleDescription[] bundles = state.getBundles(); for (int i = 0; i < bundles.length; i++) { if (resolved && !bundles[i].isResolved()) @@ -103,7 +103,7 @@ public final class StateHelperImpl implements StateHelper { GenericDescription description = generics[j]; List genericList = result.get(description.getName()); if (genericList == null) { - genericList = new ArrayList(1); + genericList = new ArrayList<>(1); result.put(description.getName(), genericList); } genericList.add(description); @@ -115,8 +115,8 @@ public final class StateHelperImpl implements StateHelper { private VersionConstraint[] getUnsatisfiedLeaves(State state, BundleDescription[] bundles, ResolverHook hook) { Map> packages = getExportedPackageMap(state); Map> generics = getGenericsMap(state, false); - Set result = new HashSet(); - List bundleList = new ArrayList(bundles.length); + Set result = new HashSet<>(); + List bundleList = new ArrayList<>(bundles.length); for (int i = 0; i < bundles.length; i++) bundleList.add(bundles[i]); for (int i = 0; i < bundleList.size(); i++) { @@ -193,7 +193,7 @@ public final class StateHelperImpl implements StateHelper { if (containingState == null) // it is a bug in the client to call this method when not attached to a state throw new IllegalStateException("Does not belong to a state"); //$NON-NLS-1$ - List unsatisfied = new ArrayList(); + List unsatisfied = new ArrayList<>(); HostSpecification host = bundle.getHost(); if (host != null) if (!host.isResolved() && !isBundleConstraintResolvable(host, BundleRevision.HOST_NAMESPACE, hook)) @@ -225,14 +225,14 @@ public final class StateHelperImpl implements StateHelper { } private ArrayMap asArrayMap(List descriptions, String namespace) { - List capabilities = new ArrayList(descriptions.size()); + List capabilities = new ArrayList<>(descriptions.size()); for (BaseDescription description : descriptions) capabilities.add(((BaseDescriptionImpl) description).getCapability(namespace)); - return new ArrayMap(capabilities, descriptions); + return new ArrayMap<>(capabilities, descriptions); } private List getPossibleCandidates(VersionConstraint constraint, BaseDescription[] descriptions, String namespace, ResolverHook hook, boolean resolved) { - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); for (int i = 0; i < descriptions.length; i++) if ((!resolved || descriptions[i].getSupplier().isResolved()) && constraint.isSatisfiedBy(descriptions[i])) candidates.add(descriptions[i]); @@ -300,7 +300,7 @@ public final class StateHelperImpl implements StateHelper { } public Object[][] sortBundles(BundleDescription[] toSort) { - List references = new ArrayList(toSort.length); + List references = new ArrayList<>(toSort.length); for (int i = 0; i < toSort.length; i++) if (toSort[i].isResolved()) buildReferences(toSort[i], references); @@ -391,9 +391,9 @@ public final class StateHelperImpl implements StateHelper { if (state != null) strict = state.inStrictMode(); BundleDescription host = (BundleDescription) (bundle.getHost() == null ? bundle : bundle.getHost().getSupplier()); - List orderedPkgList = new ArrayList(); // list of all ExportPackageDescriptions that are visible (ArrayList is used to keep order) - Set pkgSet = new HashSet(); - Set importList = new HashSet(); // list of package names which are directly imported + List orderedPkgList = new ArrayList<>(); // list of all ExportPackageDescriptions that are visible (ArrayList is used to keep order) + Set pkgSet = new HashSet<>(); + Set importList = new HashSet<>(); // list of package names which are directly imported // get the list of directly imported packages first. ImportsHolder imports = new ImportsHolder(bundle, options); for (int i = 0; i < imports.getSize(); i++) { @@ -406,9 +406,9 @@ public final class StateHelperImpl implements StateHelper { } // get the sources of the required bundles of the exporter BundleSpecification[] requires = pkgSupplier.getExporter().getRequiredBundles(); - Set visited = new HashSet(); + Set visited = new HashSet<>(); visited.add(bundle); // always add self to prevent recursing into self - Set importNames = new HashSet(1); + Set importNames = new HashSet<>(1); importNames.add(imports.getName(i)); for (int j = 0; j < requires.length; j++) { BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier(); @@ -420,7 +420,7 @@ public final class StateHelperImpl implements StateHelper { } // now find all the packages that are visible from required bundles RequiresHolder requires = new RequiresHolder(bundle, options); - Set visited = new HashSet(requires.getSize()); + Set visited = new HashSet<>(requires.getSize()); visited.add(bundle); // always add self to prevent recursing into self for (int i = 0; i < requires.getSize(); i++) { BundleDescription bundleSupplier = requires.getSupplier(i); @@ -443,7 +443,7 @@ public final class StateHelperImpl implements StateHelper { for (int j = 0; j < imports.length; j++) { if (substitutedExports[i].getName().equals(imports[j].getName()) && !pkgSet.contains(imports[j])) { if (substituteNames == null) - substituteNames = new HashSet(1); + substituteNames = new HashSet<>(1); else substituteNames.clear(); // substituteNames is a set of one package containing the single substitute we are trying to get the source for @@ -453,13 +453,13 @@ public final class StateHelperImpl implements StateHelper { } } } - importList = substitutedExports.length == 0 ? importList : new HashSet(importList); + importList = substitutedExports.length == 0 ? importList : new HashSet<>(importList); for (int i = 0; i < substitutedExports.length; i++) // we add the package name to the import list to prevent required bundles from adding more sources importList.add(substitutedExports[i].getName()); ExportPackageDescription[] exports = requiredBundle.getSelectedExports(); - HashSet exportNames = new HashSet(exports.length); // set is used to improve performance of duplicate check. + HashSet exportNames = new HashSet<>(exports.length); // set is used to improve performance of duplicate check. for (int i = 0; i < exports.length; i++) if ((pkgNames == null || pkgNames.contains(exports[i].getName())) && !isSystemExport(exports[i], options) && isFriend(symbolicName, exports[i], strict) && !importList.contains(exports[i].getName()) && !pkgSet.contains(exports[i])) { if (!exportNames.contains(exports[i].getName())) { @@ -479,7 +479,7 @@ public final class StateHelperImpl implements StateHelper { getPackages(requiredBundles.getSupplier(i), symbolicName, importList, orderedPkgList, pkgSet, visited, strict, pkgNames, options); } else if (exportNames.size() > 0) { // adding any exports from required bundles which we also export - Set tmpVisited = new HashSet(); + Set tmpVisited = new HashSet<>(); getPackages(requiredBundles.getSupplier(i), symbolicName, importList, orderedPkgList, pkgSet, tmpVisited, strict, exportNames, options); } } @@ -577,7 +577,7 @@ class RequiresHolder { isUsingResolved = (options & StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES) != 0; if (isUsingResolved) { requiredBundles = null; - resolvedBundlesExported = new HashMap(); + resolvedBundlesExported = new HashMap<>(); resolvedRequires = bundle.getResolvedRequires(); determineRequiresVisibility(bundle); } else { @@ -611,7 +611,7 @@ class RequiresHolder { */ private void determineRequiresVisibility(BundleDescription bundle) { BundleSpecification[] required = bundle.getRequiredBundles(); - Set resolved = new HashSet(); + Set resolved = new HashSet<>(); for (int i = 0; i < resolvedRequires.length; i++) { resolved.add(resolvedRequires[i]); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java index 5972e4363..163c88a4d 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,15 +112,15 @@ public abstract class StateImpl implements State { transient private Resolver resolver; transient private StateDeltaImpl changes; transient private boolean resolving = false; - transient private LinkedList removalPendings = new LinkedList(); + transient private LinkedList removalPendings = new LinkedList<>(); private boolean resolved = true; private long timeStamp = System.currentTimeMillis(); private final KeyedHashSet bundleDescriptions = new KeyedHashSet(false); - private final Map> resolverErrors = new HashMap>(); + private final Map> resolverErrors = new HashMap<>(); private StateObjectFactory factory; private final KeyedHashSet resolvedBundles = new KeyedHashSet(); - private final Map> disabledBundles = new HashMap>(); + private final Map> disabledBundles = new HashMap<>(); private boolean fullyLoaded = false; private boolean dynamicCacheChanged = false; // only used for lazy loading of BundleDescriptions @@ -128,7 +128,7 @@ public abstract class StateImpl implements State { @SuppressWarnings("unchecked") private Dictionary[] platformProperties = new Dictionary[] {new Hashtable(PROPS.length)}; // Dictionary here because of Filter API private long highestBundleId = -1; - private final Set platformPropertyKeys = new HashSet(PROPS.length); + private final Set platformPropertyKeys = new HashSet<>(PROPS.length); private ResolverHookFactory hookFactory; private ResolverHook hook; private boolean developmentMode = false; @@ -185,7 +185,7 @@ public abstract class StateImpl implements State { resolvedBundles.remove(existing); List infos = disabledBundles.remove(existing); if (infos != null) { - List newInfos = new ArrayList(infos.size()); + List newInfos = new ArrayList<>(infos.size()); for (Iterator iInfos = infos.iterator(); iInfos.hasNext();) { DisabledInfo info = iInfos.next(); newInfos.add(new DisabledInfo(info.getPolicyName(), info.getMessage(), newDescription)); @@ -282,7 +282,7 @@ public abstract class StateImpl implements State { synchronized (this.monitor) { if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName)) symbolicName = getSystemBundle(); - final List bundles = new ArrayList(); + final List bundles = new ArrayList<>(); for (Iterator iter = bundleDescriptions.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); if (symbolicName.equals(bundle.getSymbolicName())) @@ -513,7 +513,7 @@ public abstract class StateImpl implements State { if (reResolve == null) reResolve = internalGetRemovalPending(); if (triggers == null) { - Set triggerSet = new HashSet(); + Set triggerSet = new HashSet<>(); Collection closure = getDependencyClosure(Arrays.asList(reResolve)); for (BundleDescription toRefresh : closure) { Bundle bundle = toRefresh.getBundle(); @@ -527,7 +527,7 @@ public abstract class StateImpl implements State { @SuppressWarnings("unchecked") Headers[] tmpPlatformProperties = new Headers[platformProperties.length]; for (int i = 0; i < platformProperties.length; i++) { - tmpPlatformProperties[i] = new Headers(platformProperties[i].size()); + tmpPlatformProperties[i] = new Headers<>(platformProperties[i].size()); for (Enumeration keys = platformProperties[i].keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); tmpPlatformProperties[i].put(key, platformProperties[i].get(key)); @@ -568,7 +568,7 @@ public abstract class StateImpl implements State { if (reResolve.length == 0) return reResolve; // if reResolve length==0 then we want to prevent pending removal // merge in all removal pending bundles that are not already in the list - List result = new ArrayList(reResolve.length + removed.length); + List result = new ArrayList<>(reResolve.length + removed.length); for (int i = 0; i < reResolve.length; i++) result.add(reResolve[i]); for (int i = 0; i < removed.length; i++) { @@ -699,7 +699,7 @@ public abstract class StateImpl implements State { public ExportPackageDescription[] getExportedPackages() { fullyLoad(); synchronized (this.monitor) { - List allExportedPackages = new ArrayList(); + List allExportedPackages = new ArrayList<>(); for (Iterator iter = resolvedBundles.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); ExportPackageDescription[] bundlePackages = bundle.getSelectedExports(); @@ -721,7 +721,7 @@ public abstract class StateImpl implements State { } BundleDescription[] getFragments(final BundleDescription host) { - final List fragments = new ArrayList(); + final List fragments = new ArrayList<>(); synchronized (this.monitor) { for (Iterator iter = bundleDescriptions.iterator(); iter.hasNext();) { BundleDescription bundle = (BundleDescription) iter.next(); @@ -812,7 +812,7 @@ public abstract class StateImpl implements State { @SuppressWarnings("unchecked") Dictionary[] newPlatformProperties = new Dictionary[platformProperties.length]; for (int i = 0; i < platformProperties.length; i++) { - newPlatformProperties[i] = new Hashtable(platformProperties[i].size()); + newPlatformProperties[i] = new Hashtable<>(platformProperties[i].size()); synchronized (platformProperties[i]) { for (Enumeration keys = platformProperties[i].keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); @@ -876,7 +876,7 @@ public abstract class StateImpl implements State { for (int idx = 0; idx < systemBundles.length; idx++) { BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[idx]; ExportPackageDescription[] exports = systemBundle.getExportPackages(); - List newExports = new ArrayList(exports.length); + List newExports = new ArrayList<>(exports.length); for (int i = 0; i < exports.length; i++) if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0) newExports.add(exports[i]); @@ -910,7 +910,7 @@ public abstract class StateImpl implements State { BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); for (BundleDescription systemBundle : systemBundles) { GenericDescription[] capabilities = systemBundle.getGenericCapabilities(); - List newCapabilities = new ArrayList(capabilities.length); + List newCapabilities = new ArrayList<>(capabilities.length); for (GenericDescription capability : capabilities) { Object equinoxEEIndex = capability.getDeclaredAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE); if (equinoxEEIndex == null) @@ -940,14 +940,14 @@ public abstract class StateImpl implements State { if (OSGI_EE_NAMESPACE.equals(capability.getType()) && profileIndex.equals(capability.getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE))) return; // profile already specifies osgi.ee capabilities } - Map> eeVersions = new HashMap>(); + Map> eeVersions = new HashMap<>(); String[] ees = ManifestElement.getArrayFromList(profileEE); for (String ee : ees) { String[] eeNameVersion = StateBuilder.getOSGiEENameVersion(ee); List versions = eeVersions.get(eeNameVersion[0]); if (versions == null) { - versions = new ArrayList(); + versions = new ArrayList<>(); eeVersions.put(eeNameVersion[0], versions); } if (eeNameVersion[1] != null && !versions.contains(eeNameVersion[1])) @@ -956,10 +956,10 @@ public abstract class StateImpl implements State { for (Map.Entry> eeVersion : eeVersions.entrySet()) { GenericDescriptionImpl capability = new GenericDescriptionImpl(); capability.setType(OSGI_EE_NAMESPACE); - Dictionary attributes = new Hashtable(); + Dictionary attributes = new Hashtable<>(); attributes.put(capability.getType(), eeVersion.getKey()); if (eeVersion.getValue().size() > 0) { - List versions = new ArrayList(eeVersion.getValue().size()); + List versions = new ArrayList<>(eeVersion.getValue().size()); for (String version : eeVersion.getValue()) { versions.add(new Version(version)); } @@ -1036,7 +1036,7 @@ public abstract class StateImpl implements State { public Collection getDependencyClosure(Collection bundles) { BundleDescription[] removals = getRemovalPending(); - Set result = new HashSet(); + Set result = new HashSet<>(); for (BundleDescription bundle : bundles) { addDependents(bundle, result, removals); } @@ -1086,7 +1086,7 @@ public abstract class StateImpl implements State { resolving = true; ResolverHookFactory currentFactory = hookFactory; if (currentFactory != null) { - Collection triggers = new ArrayList(1); + Collection triggers = new ArrayList<>(1); triggers.add(importingBundle); triggers = Collections.unmodifiableCollection(triggers); currentHook = begin(triggers); @@ -1165,7 +1165,7 @@ public abstract class StateImpl implements State { public ExportPackageDescription[] getSystemPackages() { synchronized (this.monitor) { - List result = new ArrayList(); + List result = new ArrayList<>(); BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); if (systemBundles.length > 0) { BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[0]; @@ -1199,7 +1199,7 @@ public abstract class StateImpl implements State { throw new IllegalStateException(); // TODO need error message here! List errors = resolverErrors.get(bundle); if (errors == null) { - errors = new ArrayList(1); + errors = new ArrayList<>(1); resolverErrors.put(bundle, errors); } errors.add(new ResolverErrorImpl((BundleDescriptionImpl) bundle, type, data, unsatisfied)); @@ -1266,7 +1266,7 @@ public abstract class StateImpl implements State { throw new IllegalArgumentException(NLS.bind(StateMsg.BUNDLE_NOT_IN_STATE, disabledInfo.getBundle())); List currentInfos = disabledBundles.get(disabledInfo.getBundle()); if (currentInfos == null) { - currentInfos = new ArrayList(1); + currentInfos = new ArrayList<>(1); currentInfos.add(disabledInfo); disabledBundles.put(disabledInfo.getBundle(), currentInfos); } else { @@ -1324,7 +1324,7 @@ public abstract class StateImpl implements State { * Used by StateWriter to get all the DisabledInfo objects to persist */ DisabledInfo[] getDisabledInfos() { - List results = new ArrayList(); + List results = new ArrayList<>(); synchronized (this.monitor) { for (Iterator> allDisabledInfos = disabledBundles.values().iterator(); allDisabledInfos.hasNext();) results.addAll(allDisabledInfos.next()); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java index 3561689e6..d5201f667 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,7 +112,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { bundle.setExecutionEnvironments(executionEnvironments); bundle.setGenericRequires(genericRequires); - List includeIdentity = new ArrayList(genericCapabilities == null ? 1 : genericCapabilities.length + 1); + List includeIdentity = new ArrayList<>(genericCapabilities == null ? 1 : genericCapabilities.length + 1); GenericDescription genericIdentity = StateBuilder.createOsgiIdentityCapability(bundle); if (genericIdentity != null) { includeIdentity.add(genericIdentity); @@ -332,7 +332,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { private GenericDescription createGenericDescription(String name, String type, Version version, Map attributes, Map directives, BundleDescription supplier) { GenericDescriptionImpl result = new GenericDescriptionImpl(); result.setType(type); - Dictionary attrs = attributes == null ? new Hashtable() : new Hashtable(attributes); + Dictionary attrs = attributes == null ? new Hashtable() : new Hashtable<>(attributes); if (version != null) { Object versionObj = attrs.get(Constants.VERSION_ATTRIBUTE); if (!(versionObj instanceof Version) && version != null) @@ -509,7 +509,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, declaration); if (elements == null) return Collections. emptyList(); - List result = new ArrayList(elements.length); + List result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createRequiredBundle(element)); return result; @@ -523,7 +523,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, declaration); if (elements == null) return Collections. emptyList(); - List result = new ArrayList(elements.length); + List result = new ArrayList<>(elements.length); for (ManifestElement element : elements) result.add(StateBuilder.createHostSpecification(element, null)); return result; @@ -537,7 +537,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) return Collections. emptyList(); - List result = new ArrayList(elements.length); + List result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addImportPackages(element, result, 2, false); return result; @@ -573,7 +573,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory { ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration); if (elements == null) return Collections. emptyList(); - List result = new ArrayList(elements.length); + List result = new ArrayList<>(elements.length); for (ManifestElement element : elements) StateBuilder.addExportPackages(element, result, false); return result; diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java index 149c0cb7d..a139e6252 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -104,7 +104,7 @@ final class StateReader { int numSets = in.readInt(); Dictionary[] platformProps = new Dictionary[numSets]; for (int i = 0; i < numSets; i++) { - Hashtable props = new Hashtable(platformPropKeys.length); + Hashtable props = new Hashtable<>(platformPropKeys.length); int numProps = in.readInt(); for (int j = 0; j < numProps; j++) { Object value = readPlatformProp(in); @@ -164,7 +164,7 @@ final class StateReader { int numSets = in.readInt(); Dictionary[] platformProps = new Dictionary[numSets]; for (int i = 0; i < numSets; i++) { - Hashtable props = new Hashtable(platformPropKeys.length); + Hashtable props = new Hashtable<>(platformPropKeys.length); int numProps = in.readInt(); for (int j = 0; j < numProps; j++) { Object value = readPlatformProp(in); @@ -335,7 +335,7 @@ final class StateReader { int dynamicPkgCnt = in.readInt(); if (dynamicPkgCnt > 0) { - HashMap dynamicStamps = new HashMap(dynamicPkgCnt); + HashMap dynamicStamps = new HashMap<>(dynamicPkgCnt); for (int i = 0; i < dynamicPkgCnt; i++) { String pkg = readString(in, false); Long stamp = new Long(in.readLong()); @@ -432,7 +432,7 @@ final class StateReader { int count = in.readInt(); if (count == 0) return null; - HashMap result = new HashMap(count); + HashMap result = new HashMap<>(count); for (int i = 0; i < count; i++) { String key = readString(in, false); Object value = null; @@ -467,7 +467,7 @@ final class StateReader { } else if (type == 8) { int listType = in.readByte(); int size = in.readInt(); - List list = new ArrayList(size); + List list = new ArrayList<>(size); for (int j = 0; j < size; j++) { switch (listType) { case 0 : @@ -607,7 +607,7 @@ final class StateReader { result.setSupplier(readBundleDescription(in)); result.setType(readString(in, false)); Map mapAttrs = readMap(in); - Dictionary attrs = new Hashtable(); + Dictionary attrs = new Hashtable<>(); if (mapAttrs != null) { for (Iterator keys = mapAttrs.keySet().iterator(); keys.hasNext();) { String key = keys.next(); @@ -718,8 +718,7 @@ final class StateReader { int minorComponent = in.readInt(); int serviceComponent = in.readInt(); String qualifierComponent = readString(in, false); - Version result = (Version) ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent)); - //Version result = new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent); + Version result = ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent)); return result; } @@ -763,12 +762,12 @@ final class StateReader { if (intern) return string.intern(); - return (String) ObjectPool.intern(string); + return ObjectPool.intern(string); } if (intern) return in.readUTF().intern(); - return (String) ObjectPool.intern(in.readUTF()); + return ObjectPool.intern(in.readUTF()); } private byte readTag(DataInputStream in) throws IOException { @@ -818,7 +817,7 @@ final class StateReader { try { in = openLazyFile(); // get the set of bundles that must be loaded according to dependencies - List toLoad = new ArrayList(); + List toLoad = new ArrayList<>(); addDependencies(target, toLoad); int skipBytes[] = getSkipBytes(toLoad); // look for the lazy data of the toLoad list diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java index 28ebabc70..be522861b 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,9 +27,9 @@ class StateWriter { // like BundleDescription, ExportPackageDescription, Version etc.. The integer // index value will be used in the cache to allow cross-references in the // cached state. - private final Map objectTable = new HashMap(); + private final Map objectTable = new HashMap<>(); - private final List forcedWrite = new ArrayList(); + private final List forcedWrite = new ArrayList<>(); private int addToObjectTable(Object object) { Integer cur = objectTable.get(object); @@ -383,7 +383,7 @@ class StateWriter { writeBundleDescription(description.getSupplier(), out, false); writeStringOrNull(description.getType() == GenericDescription.DEFAULT_TYPE ? null : description.getType(), out); Dictionary attrs = description.getAttributes(); - Map mapAttrs = new HashMap(attrs.size()); + Map mapAttrs = new HashMap<>(attrs.size()); for (Enumeration keys = attrs.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); mapAttrs.put(key, attrs.get(key)); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java index 1492cff74..60b24eb3c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -137,7 +137,7 @@ public class EclipseStarter { private static FrameworkLog log; // directory of serch candidates keyed by directory abs path -> directory listing (bug 122024) - private static Map searchCandidates = new HashMap(4); + private static Map searchCandidates = new HashMap<>(4); private static EclipseAppLauncher appLauncher; private static List shutdownHandlers; @@ -184,7 +184,7 @@ public class EclipseStarter { private synchronized static Map getConfiguration() { if (configuration == null) { - configuration = new HashMap(); + configuration = new HashMap<>(); // TODO hack to set these to defaults for EclipseStarter // Note that this hack does not allow this property to be specified in config.ini configuration.put(EquinoxConfiguration.PROP_USE_SYSTEM_PROPERTIES, System.getProperty(EquinoxConfiguration.PROP_USE_SYSTEM_PROPERTIES, "true")); //$NON-NLS-1$ @@ -476,7 +476,7 @@ public class EclipseStarter { Method method = endSplashHandler.getClass().getMethod("getOutputStream", new Class[0]); //$NON-NLS-1$ Object outputStream = method.invoke(endSplashHandler, new Object[0]); if (outputStream instanceof OutputStream) { - Dictionary osProperties = new Hashtable(); + Dictionary osProperties = new Hashtable<>(); osProperties.put("name", "splashstream"); //$NON-NLS-1$//$NON-NLS-2$ splashStreamRegistration = context.registerService(OutputStream.class.getName(), outputStream, osProperties); } @@ -485,7 +485,7 @@ public class EclipseStarter { } // keep this splash handler as the default startup monitor try { - Dictionary monitorProps = new Hashtable(); + Dictionary monitorProps = new Hashtable<>(); monitorProps.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MIN_VALUE)); defaultMonitorRegistration = context.registerService(StartupMonitor.class.getName(), new DefaultStartupMonitor(endSplashHandler, equinoxConfig), monitorProps); } catch (IllegalStateException e) { @@ -572,14 +572,14 @@ public class EclipseStarter { Bundle[] curInitBundles = getCurrentBundles(true); // list of bundles to be refreshed - List toRefresh = new ArrayList(curInitBundles.length); + List toRefresh = new ArrayList<>(curInitBundles.length); // uninstall any of the currently installed bundles that do not exist in the // initial bundle list from installEntries. uninstallBundles(curInitBundles, initialBundles, toRefresh); // install the initialBundles that are not already installed. - List startBundles = new ArrayList(installEntries.length); - List lazyActivationBundles = new ArrayList(installEntries.length); + List startBundles = new ArrayList<>(installEntries.length); + List lazyActivationBundles = new ArrayList<>(installEntries.length); installBundles(initialBundles, curInitBundles, startBundles, lazyActivationBundles, toRefresh); // If we installed/uninstalled something, force a refresh of all installed/uninstalled bundles @@ -598,7 +598,7 @@ public class EclipseStarter { private static InitialBundle[] getInitialBundles(String[] installEntries) { searchCandidates.clear(); - List result = new ArrayList(installEntries.length); + List result = new ArrayList<>(installEntries.length); int defaultStartLevel = Integer.parseInt(getProperty(PROP_BUNDLES_STARTLEVEL, DEFAULT_BUNDLES_STARTLEVEL)); String syspath = getSysPath(); // should canonicalize the syspath. @@ -922,7 +922,7 @@ public class EclipseStarter { private static Bundle[] getCurrentBundles(boolean includeInitial) { Bundle[] installed = context.getBundles(); - List initial = new ArrayList(); + List initial = new ArrayList<>(); for (int i = 0; i < installed.length; i++) { Bundle bundle = installed[i]; if (bundle.getLocation().startsWith(INITIAL_LOCATION)) { @@ -1156,7 +1156,7 @@ public class EclipseStarter { } private static void updateSplash(Semaphore semaphore, StartupEventListener listener) throws InterruptedException { - ServiceTracker monitorTracker = new ServiceTracker(context, StartupMonitor.class.getName(), null); + ServiceTracker monitorTracker = new ServiceTracker<>(context, StartupMonitor.class.getName(), null); try { monitorTracker.open(); } catch (IllegalStateException e) { @@ -1386,7 +1386,7 @@ public class EclipseStarter { throw new IllegalStateException(Msg.ECLIPSE_STARTUP_ALREADY_RUNNING); if (shutdownHandlers == null) - shutdownHandlers = new ArrayList(); + shutdownHandlers = new ArrayList<>(); shutdownHandlers.add(handler); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleCapability.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleCapability.java index b9a414e39..967e9bc40 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleCapability.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleCapability.java @@ -52,7 +52,7 @@ public final class ModuleCapability implements BundleCapability { public Map getAttributes() { if (transientAttrs == null) return attributes; - Map result = new HashMap(transientAttrs); + Map result = new HashMap<>(transientAttrs); result.putAll(attributes); return Collections.unmodifiableMap(result); } 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 a3c29c16f..802b9f6a1 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 @@ -50,12 +50,12 @@ public final class ModuleContainer implements DebugOptionsListener { /** * Used by install operations to establish a write lock on an install location */ - private final LockSet locationLocks = new LockSet(); + private final LockSet locationLocks = new LockSet<>(); /** * Used by install and update operations to establish a write lock for a name */ - private final LockSet nameLocks = new LockSet(); + private final LockSet nameLocks = new LockSet<>(); /** * An implementation of FrameworkWiring for this container @@ -86,7 +86,7 @@ public final class ModuleContainer implements DebugOptionsListener { /** * Holds the system module while it is being refreshed */ - private final AtomicReference refreshingSystemModule = new AtomicReference(); + private final AtomicReference refreshingSystemModule = new AtomicReference<>(); private final long moduleLockTimeout; @@ -229,7 +229,7 @@ public final class ModuleContainer implements DebugOptionsListener { // This is to perform the collision check below List sameIdentity = moduleDatabase.findCapabilities(getIdentityRequirement(name, builder.getVersion())); if (!sameIdentity.isEmpty()) { - collisionCandidates = new ArrayList(1); + collisionCandidates = new ArrayList<>(1); for (ModuleCapability identity : sameIdentity) { ModuleRevision equinoxRevision = identity.getRevision(); if (!equinoxRevision.isCurrent()) @@ -313,7 +313,7 @@ public final class ModuleContainer implements DebugOptionsListener { // This is to perform the collision check below List sameIdentity = moduleDatabase.findCapabilities(getIdentityRequirement(name, builder.getVersion())); if (!sameIdentity.isEmpty()) { - collisionCandidates = new ArrayList(1); + collisionCandidates = new ArrayList<>(1); for (ModuleCapability identity : sameIdentity) { ModuleRevision equinoxRevision = identity.getRevision(); if (!equinoxRevision.isCurrent()) @@ -464,9 +464,9 @@ public final class ModuleContainer implements DebugOptionsListener { private ResolutionReport resolveAndApply(Collection triggers, boolean triggersMandatory, boolean restartTriggers) { if (triggers == null) - triggers = new ArrayList(0); - Collection triggerRevisions = new ArrayList(triggers.size()); - Collection unresolved = new ArrayList(); + triggers = new ArrayList<>(0); + Collection triggerRevisions = new ArrayList<>(triggers.size()); + Collection unresolved = new ArrayList<>(); Map wiringClone; long timestamp; moduleDatabase.readLock(); @@ -496,7 +496,7 @@ public final class ModuleContainer implements DebugOptionsListener { if (deltaWiring.isEmpty()) return report; // nothing to do - Collection modulesResolved = new ArrayList(); + Collection modulesResolved = new ArrayList<>(); for (ModuleRevision deltaRevision : deltaWiring.keySet()) { if (!wiringClone.containsKey(deltaRevision)) modulesResolved.add(deltaRevision.getRevisions().getModule()); @@ -521,7 +521,7 @@ public final class ModuleContainer implements DebugOptionsListener { result = null; Map wiringClone = null; List dynamicReqs = null; - Collection unresolved = new ArrayList(); + Collection unresolved = new ArrayList<>(); moduleDatabase.readLock(); try { ModuleWiring wiring = revision.getWiring(); @@ -591,7 +591,7 @@ public final class ModuleContainer implements DebugOptionsListener { return null; // nothing to do } - modulesResolved = new ArrayList(); + modulesResolved = new ArrayList<>(); for (ModuleRevision deltaRevision : deltaWiring.keySet()) { if (!wiringClone.containsKey(deltaRevision)) modulesResolved.add(deltaRevision.getRevisions().getModule()); @@ -627,7 +627,7 @@ public final class ModuleContainer implements DebugOptionsListener { private final Object stateLockMonitor = new Object(); private boolean applyDelta(Map deltaWiring, Collection modulesResolved, Collection triggers, long timestamp, boolean restartTriggers) { - List modulesLocked = new ArrayList(modulesResolved.size()); + List modulesLocked = new ArrayList<>(modulesResolved.size()); // now attempt to apply the delta try { synchronized (stateLockMonitor) { @@ -655,7 +655,7 @@ public final class ModuleContainer implements DebugOptionsListener { } } } - Map> hostsWithDynamicFrags = new HashMap>(0); + Map> hostsWithDynamicFrags = new HashMap<>(0); moduleDatabase.writeLock(); try { if (timestamp != moduleDatabase.getRevisionsTimestamp()) @@ -680,7 +680,7 @@ public final class ModuleContainer implements DebugOptionsListener { if (hostWiring != null) { Collection dynamicFragments = hostsWithDynamicFrags.get(hostWiring); if (dynamicFragments == null) { - dynamicFragments = new ArrayList(); + dynamicFragments = new ArrayList<>(); hostsWithDynamicFrags.put(hostWiring, dynamicFragments); } dynamicFragments.add(hostWire.getRequirer()); @@ -714,7 +714,7 @@ public final class ModuleContainer implements DebugOptionsListener { } // If there are any triggers re-start them now if requested - Set triggerSet = restartTriggers ? new HashSet(triggers) : Collections. emptySet(); + Set triggerSet = restartTriggers ? new HashSet<>(triggers) : Collections. emptySet(); if (restartTriggers) { for (Module module : triggers) { if (module.getId() != 0 && Module.RESOLVED_SET.contains(module.getState())) { @@ -768,7 +768,7 @@ public final class ModuleContainer implements DebugOptionsListener { // not resolved! return Collections.emptyList(); } - List result = new ArrayList(1); + List result = new ArrayList<>(1); // check the dynamic import packages DynamicModuleRequirement dynamicRequirement; for (ModuleRequirement requirement : wiring.getModuleRequirements(PackageNamespace.PACKAGE_NAMESPACE)) { @@ -810,10 +810,10 @@ public final class ModuleContainer implements DebugOptionsListener { checkSystemExtensionRefresh(initial); timestamp = moduleDatabase.getRevisionsTimestamp(); wiringCopy = moduleDatabase.getWiringsCopy(); - refreshTriggers = new ArrayList(getRefreshClosure(initial, wiringCopy)); - toRemoveRevisions = new ArrayList(); - toRemoveWirings = new ArrayList(); - toRemoveWireLists = new HashMap>(); + refreshTriggers = new ArrayList<>(getRefreshClosure(initial, wiringCopy)); + toRemoveRevisions = new ArrayList<>(); + toRemoveWirings = new ArrayList<>(); + toRemoveWireLists = new HashMap<>(); for (Iterator iTriggers = refreshTriggers.iterator(); iTriggers.hasNext();) { Module module = iTriggers.next(); boolean first = true; @@ -825,7 +825,7 @@ public final class ModuleContainer implements DebugOptionsListener { for (ModuleWire wire : removedWires) { Collection providerWires = toRemoveWireLists.get(wire.getProviderWiring()); if (providerWires == null) { - providerWires = new ArrayList(); + providerWires = new ArrayList<>(); toRemoveWireLists.put(wire.getProviderWiring(), providerWires); } providerWires.add(wire); @@ -850,8 +850,8 @@ public final class ModuleContainer implements DebugOptionsListener { refreshSystemModule(); return Collections.emptyList(); } - Collection modulesLocked = new ArrayList(refreshTriggers.size()); - Collection modulesUnresolved = new ArrayList(); + Collection modulesLocked = new ArrayList<>(refreshTriggers.size()); + Collection modulesUnresolved = new ArrayList<>(); try { // Acquire the module state change locks. // Note this is done while holding a global lock to avoid multiple threads trying to compete over @@ -989,7 +989,7 @@ public final class ModuleContainer implements DebugOptionsListener { * @see FrameworkWiring#refreshBundles(Collection, FrameworkListener...) */ public ResolutionReport refresh(Collection initial) { - initial = initial == null ? null : new ArrayList(initial); + initial = initial == null ? null : new ArrayList<>(initial); Collection refreshTriggers = unresolve(initial); if (!isRefreshingSystemModule()) { return resolve(refreshTriggers, false, true); @@ -1161,9 +1161,9 @@ public final class ModuleContainer implements DebugOptionsListener { } Set getRefreshClosure(Collection initial, Map wiringCopy) { - Set refreshClosure = new HashSet(); + Set refreshClosure = new HashSet<>(); if (initial == null) { - initial = new HashSet(); + initial = new HashSet<>(); Collection removalPending = moduleDatabase.getRemovalPending(); for (ModuleRevision revision : removalPending) { initial.add(revision.getRevisions().getModule()); @@ -1200,7 +1200,7 @@ public final class ModuleContainer implements DebugOptionsListener { } static Collection getDependencyClosure(ModuleRevision initial, Map wiringCopy) { - Set dependencyClosure = new HashSet(); + Set dependencyClosure = new HashSet<>(); addDependents(initial, wiringCopy, dependencyClosure); return dependencyClosure; } @@ -1291,9 +1291,9 @@ public final class ModuleContainer implements DebugOptionsListener { // queue to refresh in the background // notice that we only do one refresh operation at a time - CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap(); + CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap<>(); dispatchListeners.put(this, listeners); - ListenerQueue> queue = new ListenerQueue>(getManager()); + ListenerQueue> queue = new ListenerQueue<>(getManager()); queue.queueListeners(dispatchListeners.entrySet(), this); // dispatch the refresh job @@ -1320,7 +1320,7 @@ public final class ModuleContainer implements DebugOptionsListener { public Collection getRemovalPendingBundles() { moduleDatabase.readLock(); try { - Collection removalPendingBundles = new HashSet(); + Collection removalPendingBundles = new HashSet<>(); Collection removalPending = moduleDatabase.getRemovalPending(); for (ModuleRevision moduleRevision : removalPending) { removalPendingBundles.add(moduleRevision.getBundle()); @@ -1337,7 +1337,7 @@ public final class ModuleContainer implements DebugOptionsListener { moduleDatabase.readLock(); try { Collection closure = getRefreshClosure(modules, moduleDatabase.getWiringsCopy()); - Collection result = new ArrayList(closure.size()); + Collection result = new ArrayList<>(closure.size()); for (Module module : closure) { result.add(module.getBundle()); } @@ -1358,7 +1358,7 @@ public final class ModuleContainer implements DebugOptionsListener { return AccessController.doPrivileged(new PrivilegedAction>() { @Override public Collection run() { - Collection result = new ArrayList(bundles.size()); + Collection result = new ArrayList<>(bundles.size()); for (Bundle bundle : bundles) { Module module = bundle.adapt(Module.class); if (module == null) @@ -1467,9 +1467,9 @@ public final class ModuleContainer implements DebugOptionsListener { if (currentLevel < startlevel || module.isPersistentlyStarted()) { // queue start level operation in the background // notice that we only do one start level operation at a time - CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap(); + CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap<>(); dispatchListeners.put(module, new FrameworkListener[0]); - ListenerQueue queue = new ListenerQueue(getManager()); + ListenerQueue queue = new ListenerQueue<>(getManager()); queue.queueListeners(dispatchListeners.entrySet(), this); // dispatch the start level job @@ -1492,9 +1492,9 @@ public final class ModuleContainer implements DebugOptionsListener { } // queue start level operation in the background // notice that we only do one start level operation at a time - CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap(); + CopyOnWriteIdentityMap dispatchListeners = new CopyOnWriteIdentityMap<>(); dispatchListeners.put(moduleDatabase.getModule(0), listeners); - ListenerQueue queue = new ListenerQueue(getManager()); + ListenerQueue queue = new ListenerQueue<>(getManager()); queue.queueListeners(dispatchListeners.entrySet(), this); // dispatch the start level job diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java index 70a26dd36..001e020dc 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java @@ -140,16 +140,16 @@ public class ModuleDatabase { */ public ModuleDatabase(ModuleContainerAdaptor adaptor) { this.adaptor = adaptor; - this.modulesByLocations = new HashMap(); - this.modulesById = new HashMap(); - this.wirings = new HashMap(); + this.modulesByLocations = new HashMap<>(); + this.modulesById = new HashMap<>(); + this.wirings = new HashMap<>(); // Start at id 1 because 0 is reserved for the system bundle this.nextId = new AtomicLong(1); // seed with current time to avoid duplicate timestamps after using -clean this.constructionTime = System.currentTimeMillis(); this.revisionsTimeStamp = new AtomicLong(constructionTime); this.allTimeStamp = new AtomicLong(constructionTime); - this.moduleSettings = new HashMap>(); + this.moduleSettings = new HashMap<>(); this.capabilities = new Capabilities(); } @@ -355,8 +355,8 @@ public class ModuleDatabase { } } if (allPendingRemoval) { - Collection toRemoveWirings = new ArrayList(); - Map> toRemoveWireLists = new HashMap>(); + Collection toRemoveWirings = new ArrayList<>(); + Map> toRemoveWireLists = new HashMap<>(); for (ModuleRevision pendingRemoval : dependencyClosure) { ModuleWiring removedWiring = wirings.get(pendingRemoval); if (removedWiring == null) { @@ -367,7 +367,7 @@ public class ModuleDatabase { for (ModuleWire wire : removedWires) { Collection providerWires = toRemoveWireLists.get(wire.getProviderWiring()); if (providerWires == null) { - providerWires = new ArrayList(); + providerWires = new ArrayList<>(); toRemoveWireLists.put(wire.getProviderWiring(), providerWires); } providerWires.add(wire); @@ -404,7 +404,7 @@ public class ModuleDatabase { * @return all revisions with a removal pending wiring. */ final Collection getRemovalPending() { - Collection removalPending = new ArrayList(); + Collection removalPending = new ArrayList<>(); readLock(); try { for (ModuleWiring wiring : wirings.values()) { @@ -444,7 +444,7 @@ public class ModuleDatabase { final Map getWiringsCopy() { readLock(); try { - return new HashMap(wirings); + return new HashMap<>(wirings); } finally { readUnlock(); } @@ -472,7 +472,7 @@ public class ModuleDatabase { final Map getWiringsClone() { readLock(); try { - Map clonedWirings = new HashMap(); + Map clonedWirings = new HashMap<>(); for (Map.Entry entry : wirings.entrySet()) { ModuleWiring wiring = new ModuleWiring(entry.getKey(), entry.getValue().getModuleCapabilities(null), entry.getValue().getModuleRequirements(null), entry.getValue().getProvidedModuleWires(null), entry.getValue().getRequiredModuleWires(null), entry.getValue().getSubstitutedNames()); clonedWirings.put(entry.getKey(), wiring); @@ -537,7 +537,7 @@ public class ModuleDatabase { final List getSortedModules(Sort... sortOptions) { readLock(); try { - List modules = new ArrayList(modulesByLocations.values()); + List modules = new ArrayList<>(modulesByLocations.values()); sortModules(modules, sortOptions); return modules; } finally { @@ -590,7 +590,7 @@ public class ModuleDatabase { private Collection> sortByDependencies(List toSort) { // Build references so we can sort - List references = new ArrayList(toSort.size()); + List references = new ArrayList<>(toSort.size()); for (Module module : toSort) { ModuleRevision current = module.getCurrentRevision(); if (current == null) { @@ -623,9 +623,9 @@ public class ModuleDatabase { if (cycles.length == 0) return Collections.emptyList(); - Collection> moduleCycles = new ArrayList>(cycles.length); + Collection> moduleCycles = new ArrayList<>(cycles.length); for (Object[] cycle : cycles) { - List moduleCycle = new ArrayList(cycle.length); + List moduleCycle = new ArrayList<>(cycle.length); for (Object module : cycle) { moduleCycle.add((Module) module); } @@ -964,9 +964,9 @@ public class ModuleDatabase { out.writeInt(moduleDatabase.getInitialModuleStartLevel()); // prime the object table with all the strings, versions and maps - Set allStrings = new HashSet(); - Set allVersions = new HashSet(); - Set> allMaps = new HashSet>(); + Set allStrings = new HashSet<>(); + Set allVersions = new HashSet<>(); + Set> allMaps = new HashSet<>(); // first gather all the strings, versions and maps from the modules List modules = moduleDatabase.getModules(); @@ -983,7 +983,7 @@ public class ModuleDatabase { } // Now persist all the Strings - Map objectTable = new HashMap(); + Map objectTable = new HashMap<>(); allStrings.remove(null); out.writeInt(allStrings.size()); for (String string : allStrings) { @@ -1106,7 +1106,7 @@ public class ModuleDatabase { moduleDatabase.nextId.set(in.readLong()); moduleDatabase.setInitialModuleStartLevel(in.readInt()); - Map objectTable = new HashMap(); + Map objectTable = new HashMap<>(); if (version >= 2) { int numStrings = in.readInt(); for (int i = 0; i < numStrings; i++) { @@ -1141,7 +1141,7 @@ public class ModuleDatabase { } // now read all the info about each wiring using only indexes - Map wirings = new HashMap(); + Map wirings = new HashMap<>(); for (int i = 0; i < numWirings; i++) { ModuleWiring wiring = readWiring(in, objectTable); wirings.put(wiring.getRevision(), wiring); @@ -1346,31 +1346,31 @@ public class ModuleDatabase { throw new NullPointerException("Could not find revision for wiring."); //$NON-NLS-1$ int numCapabilities = in.readInt(); - List capabilities = new ArrayList(numCapabilities); + List capabilities = new ArrayList<>(numCapabilities); for (int i = 0; i < numCapabilities; i++) { capabilities.add((ModuleCapability) objectTable.get(in.readInt())); } int numRequirements = in.readInt(); - List requirements = new ArrayList(numRequirements); + List requirements = new ArrayList<>(numRequirements); for (int i = 0; i < numRequirements; i++) { requirements.add((ModuleRequirement) objectTable.get(in.readInt())); } int numProvidedWires = in.readInt(); - List providedWires = new ArrayList(numProvidedWires); + List providedWires = new ArrayList<>(numProvidedWires); for (int i = 0; i < numProvidedWires; i++) { providedWires.add((ModuleWire) objectTable.get(in.readInt())); } int numRequiredWires = in.readInt(); - List requiredWires = new ArrayList(numRequiredWires); + List requiredWires = new ArrayList<>(numRequiredWires); for (int i = 0; i < numRequiredWires; i++) { requiredWires.add((ModuleWire) objectTable.get(in.readInt())); } int numSubstitutedNames = in.readInt(); - Collection substituted = new ArrayList(numSubstitutedNames); + Collection substituted = new ArrayList<>(numSubstitutedNames); for (int i = 0; i < numSubstitutedNames; i++) { substituted.add(readString(in, objectTable)); } @@ -1456,7 +1456,7 @@ public class ModuleDatabase { Object value = readMapValue(in, type, objectTable); result = Collections.singletonMap(key, value); } else { - result = new HashMap(count); + result = new HashMap<>(count); for (int i = 0; i < count; i++) { String key = readString(in, objectTable); byte type = in.readByte(); @@ -1544,7 +1544,7 @@ public class ModuleDatabase { if (size == 1) { return Collections.singletonList(readListValue(listType, in, objectTable)); } - List list = new ArrayList(size); + List list = new ArrayList<>(size); for (int i = 0; i < size; i++) { list.add(readListValue(listType, in, objectTable)); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRequirement.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRequirement.java index 9bcc3d0bc..a0ccd36db 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRequirement.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRequirement.java @@ -123,7 +123,7 @@ public class ModuleRequirement implements BundleRequirement { } if (specificPackageFilter != null) { - Map dynamicDirectives = new HashMap(directives); + Map dynamicDirectives = new HashMap<>(directives); dynamicDirectives.put(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, specificPackageFilter); return new DynamicModuleRequirement(host, dynamicDirectives); } 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 eba7c0d90..359ef9ec2 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, 2014 IBM Corporation and others. + * Copyright (c) 2013, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,12 +28,12 @@ import org.osgi.service.resolver.ResolutionException; class ModuleResolutionReport implements ResolutionReport { static class Builder { - private final Map> resourceToEntries = new HashMap>(); + private final Map> resourceToEntries = new HashMap<>(); public void addEntry(Resource resource, Entry.Type type, Object data) { List entries = resourceToEntries.get(resource); if (entries == null) { - entries = new ArrayList(); + entries = new ArrayList<>(); resourceToEntries.put(resource, entries); } entries.add(new EntryImpl(type, data)); @@ -69,7 +69,7 @@ class ModuleResolutionReport implements ResolutionReport { private final Map> resolutionResult; ModuleResolutionReport(Map> resolutionResult, Map> entries, ResolutionException cause) { - this.entries = entries == null ? Collections.> emptyMap() : Collections.unmodifiableMap(new HashMap>(entries)); + this.entries = entries == null ? Collections.> emptyMap() : Collections.unmodifiableMap(new HashMap<>(entries)); this.resolutionResult = resolutionResult == null ? Collections.> emptyMap() : Collections.unmodifiableMap(resolutionResult); this.resolutionException = cause; } @@ -93,7 +93,7 @@ class ModuleResolutionReport implements ResolutionReport { prepend = ""; //$NON-NLS-1$ } if (visited == null) { - visited = new HashSet(); + visited = new HashSet<>(); } if (visited.contains(revision)) { return ""; //$NON-NLS-1$ @@ -164,7 +164,7 @@ class ModuleResolutionReport implements ResolutionReport { } private static String createOSGiCapability(Capability cap) { - Map attributes = new HashMap(cap.getAttributes()); + Map attributes = new HashMap<>(cap.getAttributes()); Map directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); @@ -186,7 +186,7 @@ class ModuleResolutionReport implements ResolutionReport { } private static String createOSGiRequirement(Requirement requirement, String... versions) { - Map directives = new HashMap(requirement.getDirectives()); + Map directives = new HashMap<>(requirement.getDirectives()); String filter = directives.remove(Namespace.REQUIREMENT_FILTER_DIRECTIVE); if (filter == null) throw new IllegalArgumentException("No filter directive found:" + requirement); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java index 9a829516b..fb3920413 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 @@ -80,7 +80,7 @@ final class ModuleResolver { private static final Collection NON_PAYLOAD_CAPABILITIES = Arrays.asList(IdentityNamespace.IDENTITY_NAMESPACE); static final Collection NON_PAYLOAD_REQUIREMENTS = Arrays.asList(HostNamespace.HOST_NAMESPACE, ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE); - final ThreadLocal threadResolving = new ThreadLocal(); + final ThreadLocal threadResolving = new ThreadLocal<>(); final ModuleContainerAdaptor adaptor; /** @@ -137,24 +137,24 @@ final class ModuleResolver { } Map generateDelta(Map> result, Map wiringCopy) { - Map>> provided = new HashMap>>(); - Map> required = new HashMap>(); + Map>> provided = new HashMap<>(); + Map> required = new HashMap<>(); // First populate the list of provided and required wires for revision // This is done this way to share the wire object between both the provider and requirer for (Map.Entry> resultEntry : result.entrySet()) { ModuleRevision revision = (ModuleRevision) resultEntry.getKey(); - List requiredWires = new ArrayList(resultEntry.getValue().size()); + List requiredWires = new ArrayList<>(resultEntry.getValue().size()); for (Wire wire : resultEntry.getValue()) { ModuleWire moduleWire = new ModuleWire((ModuleCapability) wire.getCapability(), (ModuleRevision) wire.getProvider(), (ModuleRequirement) wire.getRequirement(), (ModuleRevision) wire.getRequirer()); requiredWires.add(moduleWire); Map> providedWiresMap = provided.get(moduleWire.getProvider()); if (providedWiresMap == null) { - providedWiresMap = new HashMap>(); + providedWiresMap = new HashMap<>(); provided.put(moduleWire.getProvider(), providedWiresMap); } List providedWires = providedWiresMap.get(moduleWire.getCapability()); if (providedWires == null) { - providedWires = new ArrayList(); + providedWires = new ArrayList<>(); providedWiresMap.put(moduleWire.getCapability(), providedWires); } providedWires.add(moduleWire); @@ -162,7 +162,7 @@ final class ModuleResolver { required.put(revision, requiredWires); } - Map delta = new HashMap(); + Map delta = new HashMap<>(); // now create the ModuleWiring for the newly resolved revisions for (ModuleRevision revision : required.keySet()) { ModuleWiring existingWiring = wiringCopy.get(revision); @@ -193,9 +193,9 @@ final class ModuleResolver { if (requiredWires == null) requiredWires = Collections.emptyList(); - List capabilities = new ArrayList(revision.getModuleCapabilities(null)); + List capabilities = new ArrayList<>(revision.getModuleCapabilities(null)); ListIterator iCapabilities = capabilities.listIterator(capabilities.size()); - List requirements = new ArrayList(revision.getModuleRequirements(null)); + List requirements = new ArrayList<>(revision.getModuleRequirements(null)); ListIterator iRequirements = requirements.listIterator(requirements.size()); // if revision is a fragment remove payload requirements and capabilities @@ -214,7 +214,7 @@ final class ModuleResolver { removeNonEffectiveRequirements(iRequirements, requiredWires); Collection substituted = removeSubstitutedCapabilities(iCapabilities, requiredWires); - List providedWires = new ArrayList(); + List providedWires = new ArrayList<>(); addProvidedWires(providedWireMap, providedWires, capabilities); InternalUtils.filterCapabilityPermissions(capabilities); @@ -252,7 +252,7 @@ final class ModuleResolver { // this indicates a substitution iCapabilities.remove(); if (substituted == null) { - substituted = new ArrayList(); + substituted = new ArrayList<>(); } if (!substituted.contains(packageName)) { substituted.add(packageName); @@ -266,7 +266,7 @@ final class ModuleResolver { private static void removeNonEffectiveRequirements(ListIterator iRequirements, List requiredWires) { - Set wireRequirements = new HashSet(); + Set wireRequirements = new HashSet<>(); for (ModuleWire mw : requiredWires) { wireRequirements.add(mw.getRequirement()); } @@ -488,7 +488,7 @@ final class ModuleResolver { @Override public void logUsesConstraintViolation(Resource resource, ResolutionError error) { if (errors == null) { - errors = new HashMap(); + errors = new HashMap<>(); } errors.put(resource, error.toException()); if (DEBUG_USES) { @@ -550,8 +550,8 @@ final class ModuleResolver { private volatile Map> byName = null; private volatile List currentlyResolving = null; private volatile boolean currentlyResolvingMandatory = false; - private final Set transitivelyResolveFailures = new LinkedHashSet(); - private final Set failedToResolve = new HashSet(); + private final Set transitivelyResolveFailures = new LinkedHashSet<>(); + private final Set failedToResolve = new HashSet<>(); private final long resolveTimeout = System.currentTimeMillis() + resolverBatchTimeout; private volatile boolean checkTimeout = true; /* @@ -563,36 +563,36 @@ final class ModuleResolver { * up from the set of unresolved resources, if any, after the resolution * has occurred. */ - private final Map>> unresolvedProviders = new HashMap>>(); + private final Map>> unresolvedProviders = new HashMap<>(); ResolveProcess(Collection unresolved, Collection triggers, boolean triggersMandatory, Map wirings, ModuleDatabase moduleDatabase) { this.unresolved = unresolved; - this.disabled = new HashSet(unresolved); - this.triggers = new ArrayList(triggers); + this.disabled = new HashSet<>(unresolved); + this.triggers = new ArrayList<>(triggers); this.triggersMandatory = triggersMandatory; - this.optionals = new LinkedHashSet(unresolved); + this.optionals = new LinkedHashSet<>(unresolved); if (this.triggersMandatory) { // do this the hard way because the 'optimization' in removeAll hurts us for (ModuleRevision triggerRevision : triggers) { this.optionals.remove(triggerRevision); } } - this.wirings = new HashMap(wirings); - this.previouslyResolved = new HashSet(wirings.keySet()); + this.wirings = new HashMap<>(wirings); + this.previouslyResolved = new HashSet<>(wirings.keySet()); this.moduleDatabase = moduleDatabase; this.dynamicReq = null; } ResolveProcess(Collection unresolved, DynamicModuleRequirement dynamicReq, Map wirings, ModuleDatabase moduleDatabase) { this.unresolved = unresolved; - this.disabled = new HashSet(unresolved); + this.disabled = new HashSet<>(unresolved); ModuleRevision revision = dynamicReq.getRevision(); - this.triggers = new ArrayList(1); + this.triggers = new ArrayList<>(1); this.triggers.add(revision); this.triggersMandatory = false; - this.optionals = new ArrayList(unresolved); + this.optionals = new ArrayList<>(unresolved); this.wirings = wirings; - this.previouslyResolved = new HashSet(wirings.keySet()); + this.previouslyResolved = new HashSet<>(wirings.keySet()); this.moduleDatabase = moduleDatabase; this.dynamicReq = dynamicReq; } @@ -645,7 +645,7 @@ final class ModuleResolver { List filteredMatches = null; if (DEBUG_PROVIDERS || DEBUG_HOOKS) { - filteredMatches = new ArrayList(candidates); + filteredMatches = new ArrayList<>(candidates); } hook.filterMatches((BundleRequirement) requirement, InternalUtils.asListBundleCapability(candidates)); if (DEBUG_PROVIDERS || DEBUG_HOOKS) { @@ -851,7 +851,7 @@ final class ModuleResolver { return Collections.emptyList(); } - Collection ondemandFragments = new ArrayList(); + Collection ondemandFragments = 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. singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections. emptyMap()); @@ -878,7 +878,7 @@ final class ModuleResolver { // optimization and likely the only case since you are not supposed to have multiple host caps return getHostBSNs(hostCaps.get(0)); } - Set result = new HashSet(); + Set result = new HashSet<>(); for (ModuleCapability hostCap : hostCaps) { result.addAll(getHostBSNs(hostCap)); } @@ -934,7 +934,7 @@ final class ModuleResolver { if (dynamicReq != null) { result = resolveDynamic(); } else { - result = new HashMap>(); + result = new HashMap<>(); Map> dynamicAttachWirings = resolveNonPayLoadFragments(); applyInterimResultToWiringCopy(dynamicAttachWirings); if (!dynamicAttachWirings.isEmpty()) { @@ -1013,8 +1013,8 @@ final class ModuleResolver { long maxUsedMemory = 0; // make a copy so we do not modify the input - revisions = new LinkedList(revisions); - List toResolve = new ArrayList(); + revisions = new LinkedList<>(revisions); + List toResolve = new ArrayList<>(); try { for (Iterator iResources = revisions.iterator(); iResources.hasNext();) { ModuleRevision single = iResources.next(); @@ -1183,12 +1183,12 @@ final class ModuleResolver { Resource requirer = requirement.getResource(); Map> requirementToCapabilities = unresolvedProviders.get(requirer); if (requirementToCapabilities == null) { - requirementToCapabilities = new HashMap>(); + requirementToCapabilities = new HashMap<>(); unresolvedProviders.put(requirer, requirementToCapabilities); } Set value = requirementToCapabilities.get(requirement); if (value == null) { - value = new HashSet(capabilities.size()); + value = new HashSet<>(capabilities.size()); requirementToCapabilities.put(requirement, value); } for (Capability capability : capabilities) @@ -1203,7 +1203,7 @@ final class ModuleResolver { // host is always resolved. // It is also useful for things like NLS fragments that are installed later // without the need to refresh the host. - Collection nonPayLoadFrags = new ArrayList(); + Collection nonPayLoadFrags = new ArrayList<>(); if (triggersMandatory) { for (ModuleRevision moduleRevision : triggers) { if (nonPayLoad(moduleRevision)) { @@ -1220,12 +1220,12 @@ final class ModuleResolver { if (nonPayLoadFrags.isEmpty()) { return Collections.emptyMap(); } - Map> dynamicAttachment = new HashMap>(0); + Map> dynamicAttachment = new HashMap<>(0); for (ModuleRevision nonPayLoad : nonPayLoadFrags) { - List allNonPayloadWires = new ArrayList(0); + List allNonPayloadWires = new ArrayList<>(0); for (ModuleRequirement requirement : nonPayLoad.getModuleRequirements(null)) { List matching = moduleDatabase.findCapabilities(requirement); - List newWires = new ArrayList(0); + List newWires = new ArrayList<>(0); filterProviders(requirement, matching, false); for (ModuleCapability candidate : matching) { if (HostNamespace.HOST_NAMESPACE.equals(requirement.getNamespace())) { @@ -1280,7 +1280,7 @@ final class ModuleResolver { } private void filterResolvable() { - Collection enabledCandidates = new ArrayList(unresolved); + Collection enabledCandidates = new ArrayList<>(unresolved); hook.filterResolvable(InternalUtils.asListBundleRevision((List) enabledCandidates)); // do this the hard way because the 'optimization' in removeAll hurts us for (ModuleRevision enabledRevision : enabledCandidates) { @@ -1295,7 +1295,7 @@ final class ModuleResolver { } private void selectSingletons() { - Map> selectedSingletons = new HashMap>(); + Map> selectedSingletons = new HashMap<>(); for (ModuleRevision revision : unresolved) { if (!isSingleton(revision) || disabled.contains(revision)) continue; @@ -1303,7 +1303,7 @@ final class ModuleResolver { Collection selected = selectedSingletons.get(bsn); if (selected != null) continue; // already processed the bsn - selected = new ArrayList(1); + selected = new ArrayList<>(1); selectedSingletons.put(bsn, selected); Collection sameBSN = getRevisions(bsn); @@ -1325,7 +1325,7 @@ final class ModuleResolver { Collection collisions = collisionMap.get(singleton); if (collisions == null || disabled.contains(singleton)) continue; // not a singleton or not resolvable - Collection pickOneToResolve = new ArrayList(); + Collection pickOneToResolve = new ArrayList<>(); for (ModuleRevision collision : collisions) { if (selected.contains(collision)) { // Must fail since there is already a selected bundle which is a collision of the singleton bundle @@ -1364,14 +1364,14 @@ final class ModuleResolver { if (current == null) { // generate the map using unresolved collection and wiring snap shot // this is to avoid interacting with the module database - Set revisions = new HashSet(); + Set revisions = new HashSet<>(); revisions.addAll(unresolved); revisions.addAll(previouslyResolved); - current = new HashMap>(); + current = new HashMap<>(); for (ModuleRevision revision : revisions) { Collection sameName = current.get(revision.getSymbolicName()); if (sameName == null) { - sameName = new ArrayList(); + sameName = new ArrayList<>(); current.put(revision.getSymbolicName(), sameName); } sameName.add(revision); @@ -1405,23 +1405,23 @@ final class ModuleResolver { } private Map> getCollisionMap(Collection sameBSN) { - Map> result = new HashMap>(); + Map> result = new HashMap<>(); for (ModuleRevision singleton : sameBSN) { if (!isSingleton(singleton) || disabled.contains(singleton)) continue; // ignore non-singleton and non-resolvable - List capabilities = new ArrayList(sameBSN.size() - 1); + List capabilities = new ArrayList<>(sameBSN.size() - 1); for (ModuleRevision collision : sameBSN) { if (collision == singleton || !isSingleton(collision) || disabled.contains(collision)) continue; // Ignore the bundle we are checking and non-singletons and non-resolvable capabilities.add(getIdentity(collision)); } hook.filterSingletonCollisions(getIdentity(singleton), capabilities); - Collection collisionCandidates = new ArrayList(capabilities.size()); + Collection collisionCandidates = new ArrayList<>(capabilities.size()); for (BundleCapability identity : capabilities) { collisionCandidates.add((ModuleRevision) identity.getRevision()); } if (DEBUG_HOOKS) { - Collection filteredSingletons = new ArrayList(sameBSN); + Collection filteredSingletons = new ArrayList<>(sameBSN); filteredSingletons.removeAll(collisionCandidates); filteredSingletons.remove(singleton); if (!filteredSingletons.isEmpty()) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java index b8e452fc4..be20ea351 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,7 +49,7 @@ public final class ModuleRevision implements BundleRevision { private List createCapabilities(List capabilityInfos) { if (capabilityInfos == null || capabilityInfos.isEmpty()) return Collections.emptyList(); - List result = new ArrayList(capabilityInfos.size()); + List result = new ArrayList<>(capabilityInfos.size()); for (GenericInfo info : capabilityInfos) { result.add(new ModuleCapability(info.namespace, info.directives, info.attributes, this)); } @@ -59,7 +59,7 @@ public final class ModuleRevision implements BundleRevision { private List createRequirements(List requirementInfos) { if (requirementInfos == null || requirementInfos.isEmpty()) return Collections.emptyList(); - List result = new ArrayList(requirementInfos.size()); + List result = new ArrayList<>(requirementInfos.size()); for (GenericInfo info : requirementInfos) { result.add(new ModuleRequirement(info.namespace, info.directives, info.attributes, this)); } @@ -100,7 +100,7 @@ public final class ModuleRevision implements BundleRevision { public List getModuleCapabilities(String namespace) { if (namespace == null) return Collections.unmodifiableList(capabilities); - List result = new ArrayList(); + List result = new ArrayList<>(); for (ModuleCapability capability : capabilities) { if (namespace.equals(capability.getNamespace())) { result.add(capability); @@ -118,7 +118,7 @@ public final class ModuleRevision implements BundleRevision { public List getModuleRequirements(String namespace) { if (namespace == null) return Collections.unmodifiableList(requirements); - List result = new ArrayList(); + List result = new ArrayList<>(); for (ModuleRequirement requirement : requirements) { if (namespace.equals(requirement.getNamespace())) { result.add(requirement); 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 c3cd310ba..ebad63049 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 @@ -73,8 +73,8 @@ public final class ModuleRevisionBuilder { private String symbolicName = null; private Version version = Version.emptyVersion; private int types = 0; - private final List capabilityInfos = new ArrayList(); - private final List requirementInfos = new ArrayList(); + private final List capabilityInfos = new ArrayList<>(); + private final List requirementInfos = new ArrayList<>(); /** * Constructs a new module builder @@ -122,7 +122,7 @@ public final class ModuleRevisionBuilder { * @return the capabilities */ public List getCapabilities() { - return new ArrayList(capabilityInfos); + return new ArrayList<>(capabilityInfos); } /** @@ -140,7 +140,7 @@ public final class ModuleRevisionBuilder { * @return the requirements */ public List getRequirements() { - return new ArrayList(requirementInfos); + return new ArrayList<>(requirementInfos); } /** @@ -232,7 +232,7 @@ public final class ModuleRevisionBuilder { private static void addGenericInfo(List infos, String namespace, Map directives, Map attributes) { if (infos == null) { - infos = new ArrayList(); + infos = new ArrayList<>(); } infos.add(new GenericInfo(namespace, copyUnmodifiableMap(directives), copyUnmodifiableMap(attributes))); } @@ -246,7 +246,7 @@ public final class ModuleRevisionBuilder { Map.Entry entry = map.entrySet().iterator().next(); return Collections.singletonMap(entry.getKey(), entry.getValue()); } - return Collections.unmodifiableMap(new HashMap(map)); + return Collections.unmodifiableMap(new HashMap<>(map)); } void basicAddCapability(String namespace, Map directives, Map attributes) { @@ -259,7 +259,7 @@ public final class ModuleRevisionBuilder { private static void basicAddGenericInfo(List infos, String namespace, Map directives, Map attributes) { if (infos == null) { - infos = new ArrayList(); + infos = new ArrayList<>(); } infos.add(new GenericInfo(namespace, unmodifiableMap(directives), unmodifiableMap(attributes))); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisions.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisions.java index a7cfa37b3..907a05dbe 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisions.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,7 +30,7 @@ public final class ModuleRevisions implements BundleRevisions { private final Module module; private final ModuleContainer container; /* @GuardedBy("monitor") */ - private final List revisions = new ArrayList(1); + private final List revisions = new ArrayList<>(1); /* @GuardedBy("monitor") */ private boolean uninstalled = false; /* @GuardedBy("monitor") */ @@ -68,7 +68,7 @@ public final class ModuleRevisions implements BundleRevisions { */ public List getModuleRevisions() { synchronized (monitor) { - return new ArrayList(revisions); + return new ArrayList<>(revisions); } } 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 8a26639be..18d17b902 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 @@ -45,12 +45,12 @@ public final class ModuleWiring implements BundleWiring { private volatile List capabilities; private volatile List requirements; private final Collection substitutedPkgNames; - private final AtomicLazyInitializer loader = new AtomicLazyInitializer(); + private final AtomicLazyInitializer loader = new AtomicLazyInitializer<>(); private final LoaderInitializer loaderInitializer = new LoaderInitializer(); private volatile List providedWires; private volatile List requiredWires; volatile boolean isValid = true; - private final AtomicReference> dynamicMissRef = new AtomicReference>(); + private final AtomicReference> dynamicMissRef = new AtomicReference<>(); ModuleWiring(ModuleRevision revision, List capabilities, List requirements, List providedWires, List requiredWires, Collection substitutedPkgNames) { super(); @@ -102,8 +102,8 @@ public final class ModuleWiring implements BundleWiring { if (!isValid) return null; if (namespace == null) - return new ArrayList(allCapabilities); - List result = new ArrayList(); + return new ArrayList<>(allCapabilities); + List result = new ArrayList<>(); for (ModuleCapability capability : allCapabilities) { if (namespace.equals(capability.getNamespace())) { result.add(capability); @@ -143,8 +143,8 @@ public final class ModuleWiring implements BundleWiring { if (!isValid) return null; if (namespace == null) - return new ArrayList(allRequirements); - List result = new ArrayList(); + return new ArrayList<>(allRequirements); + List result = new ArrayList<>(); for (ModuleRequirement requirement : allRequirements) { if (namespace.equals(requirement.getNamespace())) { result.add(requirement); @@ -224,8 +224,8 @@ public final class ModuleWiring implements BundleWiring { if (!isValid) return null; if (namespace == null) - return new ArrayList(allWires); - List result = new ArrayList(); + return new ArrayList<>(allWires); + List result = new ArrayList<>(); for (ModuleWire moduleWire : allWires) { if (namespace.equals(moduleWire.getCapability().getNamespace())) { result.add(moduleWire); @@ -410,13 +410,13 @@ public final class ModuleWiring implements BundleWiring { */ public void addDynamicImports(ModuleRevisionBuilder builder) { List newImports = builder.getRequirements(); - List newRequirements = new ArrayList(); + List newRequirements = new ArrayList<>(); for (GenericInfo info : newImports) { if (!PackageNamespace.PACKAGE_NAMESPACE.equals(info.getNamespace())) { throw new IllegalArgumentException("Invalid namespace for package imports: " + info.getNamespace()); //$NON-NLS-1$ } - Map attributes = new HashMap(info.getAttributes()); - Map directives = new HashMap(info.getDirectives()); + Map attributes = new HashMap<>(info.getAttributes()); + Map directives = new HashMap<>(info.getDirectives()); directives.put(DYNAMICALLY_ADDED_IMPORT_DIRECTIVE, "true"); //$NON-NLS-1$ directives.put(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE, PackageNamespace.RESOLUTION_DYNAMIC); newRequirements.add(new ModuleRequirement(info.getNamespace(), directives, attributes, revision)); @@ -424,7 +424,7 @@ public final class ModuleWiring implements BundleWiring { ModuleDatabase moduleDatabase = revision.getRevisions().getContainer().moduleDatabase; moduleDatabase.writeLock(); try { - List updatedRequirements = new ArrayList(requirements); + List updatedRequirements = new ArrayList<>(requirements); updatedRequirements.addAll(newRequirements); requirements = updatedRequirements; } finally { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/SystemModule.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/SystemModule.java index 0f4b65e2b..27a0e8b95 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/SystemModule.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/SystemModule.java @@ -30,7 +30,7 @@ import org.osgi.service.resolver.ResolutionException; * @since 3.10 */ public abstract class SystemModule extends Module { - private volatile AtomicReference forStop = new AtomicReference(); + private volatile AtomicReference forStop = new AtomicReference<>(); public SystemModule(ModuleContainer container) { super(new Long(0), Constants.SYSTEM_BUNDLE_LOCATION, container, EnumSet.of(Settings.AUTO_START, Settings.USE_ACTIVATION_POLICY), Integer.valueOf(0)); @@ -87,7 +87,7 @@ public abstract class SystemModule extends Module { AtomicReference existingForStop = forStop; if (existingForStop.get() != null) { // There was a previous launch, reset the reference forStop - forStop = new AtomicReference(); + forStop = new AtomicReference<>(); } publishEvent(ModuleEvent.STARTING); try { 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 8a08c2dd9..4b8256e2e 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 @@ -78,7 +78,7 @@ public final class OSGiManifestBuilderFactory { Object symbolicName = getSymbolicNameAndVersion(builder, manifest, symbolicNameAlias, manifestVersion); - Collection> exportedPackages = new ArrayList>(); + Collection> exportedPackages = new ArrayList<>(); getPackageExports(builder, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE)), symbolicName, exportedPackages); getPackageExports(builder, ManifestElement.parseHeader(HEADER_OLD_PROVIDE_PACKAGE, manifest.get(HEADER_OLD_PROVIDE_PACKAGE)), symbolicName, exportedPackages); if (extraExports != null && !extraExports.isEmpty()) { @@ -131,7 +131,7 @@ public final class OSGiManifestBuilderFactory { if (elements == null) return; int length = elements.length; - Set packages = new HashSet(length); + Set packages = new HashSet<>(length); for (int i = 0; i < length; i++) { // check for duplicate imports String[] packageNames = elements[i].getValueComponents(); @@ -259,7 +259,7 @@ public final class OSGiManifestBuilderFactory { ManifestElement bsnElement = symbolicNameElements[0]; builder.setSymbolicName(bsnElement.getValue()); if (symbolicNameAlias != null) { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add(builder.getSymbolicName()); result.add(symbolicNameAlias); symbolicName = result; @@ -279,7 +279,7 @@ public final class OSGiManifestBuilderFactory { } if (!isFragment) { // create the bundle namespace - Map bundleAttributes = new HashMap(attributes); + Map bundleAttributes = new HashMap<>(attributes); bundleAttributes.put(BundleNamespace.BUNDLE_NAMESPACE, symbolicName); bundleAttributes.put(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, builder.getVersion()); builder.addCapability(BundleNamespace.BUNDLE_NAMESPACE, directives, bundleAttributes); @@ -287,7 +287,7 @@ public final class OSGiManifestBuilderFactory { // create the host namespace // only if the directive is not never if (!HostNamespace.FRAGMENT_ATTACHMENT_NEVER.equals(directives.get(HostNamespace.CAPABILITY_FRAGMENT_ATTACHMENT_DIRECTIVE))) { - Map hostAttributes = new HashMap(attributes); + Map hostAttributes = new HashMap<>(attributes); hostAttributes.put(HostNamespace.HOST_NAMESPACE, symbolicName); hostAttributes.put(HostNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, builder.getVersion()); builder.addCapability(HostNamespace.HOST_NAMESPACE, directives, hostAttributes); @@ -295,7 +295,7 @@ public final class OSGiManifestBuilderFactory { } // every bundle that has a symbolic name gets an identity; // never use the symbolic name alias for the identity namespace - Map identityAttributes = new HashMap(attributes); + Map identityAttributes = new HashMap<>(attributes); identityAttributes.put(IdentityNamespace.IDENTITY_NAMESPACE, builder.getSymbolicName()); identityAttributes.put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, builder.getVersion()); identityAttributes.put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, isFragment ? IdentityNamespace.TYPE_FRAGMENT : IdentityNamespace.TYPE_BUNDLE); @@ -324,7 +324,7 @@ public final class OSGiManifestBuilderFactory { } attributes.put(PackageNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, builder.getVersion()); for (String packageName : packageNames) { - Map packageAttrs = new HashMap(attributes); + Map packageAttrs = new HashMap<>(attributes); packageAttrs.put(PackageNamespace.PACKAGE_NAMESPACE, packageName); builder.addCapability(PackageNamespace.PACKAGE_NAMESPACE, directives, packageAttrs); exportedPackages.add(packageAttrs); @@ -333,7 +333,7 @@ public final class OSGiManifestBuilderFactory { } private static void getPackageImports(ModuleRevisionBuilder builder, Map manifest, Collection> exportedPackages, int manifestVersion) throws BundleException { - Collection importPackageNames = new ArrayList(); + Collection importPackageNames = new ArrayList<>(); ManifestElement[] importElements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, manifest.get(Constants.IMPORT_PACKAGE)); ManifestElement[] dynamicImportElements = ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE, manifest.get(Constants.DYNAMICIMPORT_PACKAGE)); addPackageImports(builder, importElements, importPackageNames, false); @@ -368,7 +368,7 @@ public final class OSGiManifestBuilderFactory { importPackageNames.add(packageName); } // fill in the filter directive based on the attributes - Map packageDirectives = new HashMap(directives); + Map packageDirectives = new HashMap<>(directives); StringBuilder filter = new StringBuilder(); filter.append('(').append(PackageNamespace.PACKAGE_NAMESPACE).append('=').append(packageName).append(')'); int size = filter.length(); @@ -406,14 +406,14 @@ public final class OSGiManifestBuilderFactory { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(PackageNamespace.PACKAGE_NAMESPACE).append('=').append(packageName).append(')'); //$NON-NLS-1$ filter.append('(').append(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE).append(">=").append(packageVersion).append("))"); //$NON-NLS-1$//$NON-NLS-2$ - Map directives = new HashMap(1); + Map directives = new HashMap<>(1); directives.put(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()); builder.addRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, new HashMap(0)); } } private static Map getDirectives(ManifestElement element) { - Map directives = new HashMap(); + Map directives = new HashMap<>(); Enumeration keys = element.getDirectiveKeys(); if (keys == null) return directives; @@ -445,7 +445,7 @@ public final class OSGiManifestBuilderFactory { continue; } // fill in the filter directive based on the attributes - Map bundleDirectives = new HashMap(directives); + Map bundleDirectives = new HashMap<>(directives); StringBuilder filter = new StringBuilder(); filter.append('(').append(BundleNamespace.BUNDLE_NAMESPACE).append('=').append(bundleName).append(')'); int size = filter.length(); @@ -537,14 +537,14 @@ public final class OSGiManifestBuilderFactory { return; } // only support one - HashMap directives = new HashMap(); + HashMap directives = new HashMap<>(); directives.put(EclipsePlatformNamespace.REQUIREMENT_FILTER_DIRECTIVE, platformFilter); builder.addRequirement(EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE, directives, Collections. emptyMap()); } @SuppressWarnings("deprecation") private static void getEquinoxDataCapability(ModuleRevisionBuilder builder, Map manifest) throws BundleException { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); // Get the activation policy attributes ManifestElement[] policyElements = ManifestElement.parseHeader(Constants.BUNDLE_ACTIVATIONPOLICY, manifest.get(Constants.BUNDLE_ACTIVATIONPOLICY)); @@ -600,7 +600,7 @@ public final class OSGiManifestBuilderFactory { // Get the class path ManifestElement[] classpathElements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, manifest.get(Constants.BUNDLE_CLASSPATH)); if (classpathElements != null) { - List classpath = new ArrayList(); + List classpath = new ArrayList<>(); for (ManifestElement element : classpathElements) { String[] components = element.getValueComponents(); for (String component : components) { @@ -613,7 +613,7 @@ public final class OSGiManifestBuilderFactory { // Get the buddy policy list ManifestElement[] buddyPolicies = ManifestElement.parseHeader(EquinoxModuleDataNamespace.BUDDY_POLICY_HEADER, manifest.get(EquinoxModuleDataNamespace.BUDDY_POLICY_HEADER)); if (buddyPolicies != null) { - List policies = new ArrayList(); + List policies = new ArrayList<>(); for (ManifestElement element : buddyPolicies) { for (String component : element.getValueComponents()) { policies.add(component); @@ -625,7 +625,7 @@ public final class OSGiManifestBuilderFactory { // Get the registered buddy list ManifestElement[] registeredBuddies = ManifestElement.parseHeader(EquinoxModuleDataNamespace.REGISTERED_BUDDY_HEADER, manifest.get(EquinoxModuleDataNamespace.REGISTERED_BUDDY_HEADER)); if (registeredBuddies != null) { - List buddies = new ArrayList(); + List buddies = new ArrayList<>(); for (ManifestElement element : registeredBuddies) { for (String component : element.getValueComponents()) { buddies.add(component); @@ -643,7 +643,7 @@ public final class OSGiManifestBuilderFactory { private static Map getAttributes(ManifestElement element) throws BundleException { Enumeration keys = element.getKeys(); - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); if (keys == null) return attributes; while (keys.hasMoreElements()) { @@ -697,7 +697,7 @@ public final class OSGiManifestBuilderFactory { throw new BundleException("Invalid type, missing ending '>' : " + type, BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } List tokens = new Tokenizer(value).getEscapedTokens(","); //$NON-NLS-1$ - List components = new ArrayList(); + List components = new ArrayList<>(); for (String component : tokens) { components.add(convertValue(componentType, component)); } @@ -709,7 +709,7 @@ public final class OSGiManifestBuilderFactory { String[] brees = ManifestElement.getArrayFromList(manifest.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)); if (brees == null || brees.length == 0) return; - List breeFilters = new ArrayList(); + List breeFilters = new ArrayList<>(); for (String bree : brees) breeFilters.add(createOSGiEERequirementFilter(bree)); String filterSpec; @@ -723,7 +723,7 @@ public final class OSGiManifestBuilderFactory { filterSpec = filterBuf.append(")").toString(); //$NON-NLS-1$ } - Map directives = new HashMap(1); + Map directives = new HashMap<>(1); directives.put(ExecutionEnvironmentNamespace.REQUIREMENT_FILTER_DIRECTIVE, filterSpec); builder.addRequirement(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, directives, new HashMap(0)); } @@ -847,7 +847,7 @@ public final class OSGiManifestBuilderFactory { NativeClause(int manifestIndex, ManifestElement clause) throws BundleException { this.manifestIndex = manifestIndex; - this.nativePaths = new ArrayList(Arrays.asList(clause.getValueComponents())); + this.nativePaths = new ArrayList<>(Arrays.asList(clause.getValueComponents())); StringBuilder sb = new StringBuilder(); sb.append("(&"); //$NON-NLS-1$ addToNativeCodeFilter(sb, clause, Constants.BUNDLE_NATIVECODE_OSNAME); @@ -943,7 +943,7 @@ public final class OSGiManifestBuilderFactory { boolean optional = false; - List nativeClauses = new ArrayList(); + List nativeClauses = new ArrayList<>(); for (int i = 0; i < elements.length; i++) { if (i == elements.length - 1) { optional = elements[i].getValue().equals("*"); //$NON-NLS-1$ @@ -963,7 +963,7 @@ public final class OSGiManifestBuilderFactory { if (numNativePaths > 1) { allNativeFilters.append("(|"); //$NON-NLS-1$ } - Map attributes = new HashMap(2); + Map attributes = new HashMap<>(2); for (int i = 0; i < numNativePaths; i++) { NativeClause nativeClause = nativeClauses.get(i); if (numNativePaths == 1) { @@ -977,7 +977,7 @@ public final class OSGiManifestBuilderFactory { allNativeFilters.append(')'); } - Map directives = new HashMap(2); + Map directives = new HashMap<>(2); directives.put(NativeNamespace.REQUIREMENT_FILTER_DIRECTIVE, allNativeFilters.toString()); if (optional) { directives.put(NativeNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE, NativeNamespace.RESOLUTION_OPTIONAL); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ArrayMap.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ArrayMap.java index 6fb04c520..e6f1865a5 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ArrayMap.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/ArrayMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,8 +24,8 @@ public class ArrayMap implements Collection { final List values; public ArrayMap(int initialCapacity) { - keys = new ArrayList(initialCapacity); - values = new ArrayList(initialCapacity); + keys = new ArrayList<>(initialCapacity); + values = new ArrayList<>(initialCapacity); } /** @@ -73,11 +73,11 @@ public class ArrayMap implements Collection { } public List getKeys() { - return new ArrayList(keys); + return new ArrayList<>(keys); } public List getValues() { - return new ArrayList(values); + return new ArrayList<>(values); } public int size() { @@ -159,9 +159,9 @@ public class ArrayMap implements Collection { } public void sort(Comparator comparator) { - List sortedKeys = new ArrayList(keys); + List sortedKeys = new ArrayList<>(keys); Collections.sort(sortedKeys, comparator); - List sortedValues = new ArrayList(sortedKeys.size()); + List sortedValues = new ArrayList<>(sortedKeys.size()); for (K key : sortedKeys) { sortedValues.add(getByIdentity(key)); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/Headers.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/Headers.java index 755331f6e..4bc302fa1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/Headers.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/Headers.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,14 +72,14 @@ public class Headers extends Dictionary implements Map { * Case-preserved keys. */ public synchronized Enumeration keys() { - return new ArrayEnumeration(headers, size); + return new ArrayEnumeration<>(headers, size); } /** * Values. */ public synchronized Enumeration elements() { - return new ArrayEnumeration(values, size); + return new ArrayEnumeration<>(values, size); } private int getIndex(Object key) { @@ -275,7 +275,7 @@ public class Headers extends Dictionary implements Map { } public static Headers parseManifest(InputStream in) throws BundleException { - Headers headers = new Headers(10); + Headers headers = new Headers<>(10); try { ManifestElement.parseBundleManifest(in, headers); } catch (IOException e) { 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 548ba1615..9e394475e 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 @@ -21,7 +21,7 @@ public class ObjectPool { // TODO need to set these private static final boolean DEBUG_OBJECTPOOL_ADDS = false; private static final boolean DEBUG_OBJECTPOOL_DUPS = false; - private static Map> objectCache = new WeakHashMap>(); + private static Map> objectCache = new WeakHashMap<>(); @SuppressWarnings("unchecked") public static T intern(T obj) { 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 bb72070d5..c0de1429f 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 IBM Corporation and others. + * Copyright (c) 2014, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReference; * @param the type of object to lazy initialize */ public class AtomicLazyInitializer { - private final AtomicReference holder = new AtomicReference(); + private final AtomicReference holder = new AtomicReference<>(); /** * Gets the current value. If the value has not been initialized then 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 424d3624a..9732b87c3 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, 2013 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,9 +25,9 @@ import org.osgi.resource.*; public class Capabilities { static class NamespaceSet { private final String name; - private final Map> indexes = new HashMap>(); - private final Set all = new HashSet(); - private final Set nonStringIndexes = new HashSet(0); + private final Map> indexes = new HashMap<>(); + private final Set all = new HashSet<>(); + private final Set nonStringIndexes = new HashSet<>(0); private final boolean matchMandatory; NamespaceSet(String name) { @@ -66,7 +66,7 @@ public class Capabilities { } else { Set capabilities = indexes.get(indexKey); if (capabilities == null) { - capabilities = new HashSet(1); + capabilities = new HashSet<>(1); indexes.put((String) indexKey, capabilities); } capabilities.add(capability); @@ -135,7 +135,7 @@ public class Capabilities { } else { Set indexed = indexes.get(indexKey); if (indexed == null) { - result = new ArrayList(0); + result = new ArrayList<>(0); } else { result = match(f, indexed, synthetic); } @@ -153,7 +153,7 @@ public class Capabilities { } private List match(Filter f, Set candidates, boolean synthetic) { - List result = new ArrayList(1); + List result = new ArrayList<>(1); for (ModuleCapability candidate : candidates) { if (matches(f, candidate, !synthetic && matchMandatory)) { result.add(candidate); @@ -200,7 +200,7 @@ public class Capabilities { return true; } - Map namespaceSets = new HashMap(); + Map namespaceSets = new HashMap<>(); /** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} @@ -225,7 +225,7 @@ public class Capabilities { Object packageName = capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); if (packageName instanceof String) { if (packageNames == null) { - packageNames = new ArrayList(); + packageNames = new ArrayList<>(); } packageNames.add((String) packageName); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java index 12ec3dd41..e4e02a560 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -93,7 +93,7 @@ public class ComputeNodeOrder { * * Element type: Vertex */ - public List adjacent = new ArrayList(3); + public List adjacent = new ArrayList<>(3); /** * Creates a new vertex with the given id. @@ -110,14 +110,14 @@ public class ComputeNodeOrder { * * Element type: Vertex */ - private List vertexList = new ArrayList(100); + private List vertexList = new ArrayList<>(100); /** * Map from id to vertex. * * Key type: Object; value type: Vertex */ - private Map vertexMap = new HashMap(100); + private Map vertexMap = new HashMap<>(100); /** * DFS visit time. Non-negative. @@ -270,7 +270,7 @@ public class ComputeNodeOrder { } // find the roots of each component // Map> components - Map> components = new HashMap>(); + Map> components = new HashMap<>(); for (Iterator it = vertexList.iterator(); it.hasNext();) { Vertex vertex = it.next(); if (vertex.predecessor == null) { @@ -284,14 +284,14 @@ public class ComputeNodeOrder { } List component = components.get(root); if (component == null) { - component = new ArrayList(2); + component = new ArrayList<>(2); component.add(root.id); components.put(root, component); } component.add(vertex.id); } } - List result = new ArrayList(components.size()); + List result = new ArrayList<>(components.size()); for (Iterator> it = components.values().iterator(); it.hasNext();) { List component = it.next(); if (component.size() > 1) { @@ -369,7 +369,7 @@ public class ComputeNodeOrder { // all vertex.predecessor initially null; time = 0; // for a stack, append to the end of an array-based list - List stack = new ArrayList(Math.max(1, vertexList.size())); + List stack = new ArrayList<>(Math.max(1, vertexList.size())); Iterator allAdjacent = null; Vertex vertex = null; Iterator allV = vertexList.iterator(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java index 1e9925f95..fe6a64b1e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2015 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,7 @@ public class LockSet { } } - private final Map locks = new HashMap(); + private final Map locks = new HashMap<>(); public boolean tryLock(T t, long time, TimeUnit unit) throws InterruptedException { final boolean previousInterruption = Thread.interrupted(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java index 73b3147d9..e1f347be1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,7 +44,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom /** A map of all the disabled options with values set at the time debug was disabled */ private Properties disabledOptions = null; /** A cache of all of the bundles DebugTrace in the format --> */ - protected final Map debugTraceCache = new HashMap(); + protected final Map debugTraceCache = new HashMap<>(); /** The File object to store messages. This value may be null. */ protected File outFile = null; /** Is verbose debugging enabled? Changing this value causes a new tracing session to start. */ @@ -104,7 +104,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom public void start(BundleContext bc) { this.context = bc; - listenerTracker = new ServiceTracker(bc, DebugOptionsListener.class.getName(), this); + listenerTracker = new ServiceTracker<>(bc, DebugOptionsListener.class.getName(), this); listenerTracker.open(); } @@ -185,7 +185,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom @SuppressWarnings({"unchecked", "rawtypes"}) public Map getOptions() { - Map snapShot = new HashMap(); + Map snapShot = new HashMap<>(); synchronized (lock) { if (options != null) snapShot.putAll((Map) options); @@ -301,7 +301,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom // no events to fire return; } - fireChangesTo = new HashSet(); + fireChangesTo = new HashSet<>(); // first check for removals for (Iterator keys = options.keySet().iterator(); keys.hasNext();) { String key = (String) keys.next(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java index e1b3d1a94..67be8107b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,10 +20,10 @@ import org.eclipse.osgi.internal.util.Tokenizer; * This class maps aliases. */ public class AliasMapper { - private static final Map> processorAliasTable = new HashMap>(); - private static final Map processorCanonicalTable = new HashMap(); - private static final Map> osnameAliasTable = new HashMap>(); - private static final Map osnameCanonicalTable = new HashMap(); + private static final Map> processorAliasTable = new HashMap<>(); + private static final Map processorCanonicalTable = new HashMap<>(); + private static final Map> osnameAliasTable = new HashMap<>(); + private static final Map osnameCanonicalTable = new HashMap<>(); static { getTables("osname.aliases", osnameAliasTable, osnameCanonicalTable); //$NON-NLS-1$ getTables("processor.aliases", processorAliasTable, processorCanonicalTable); //$NON-NLS-1$ @@ -99,10 +99,10 @@ public class AliasMapper { } catch (UnsupportedEncodingException e) { br = new BufferedReader(new InputStreamReader(in)); } - Map> multiMaster = new HashMap>(); + Map> multiMaster = new HashMap<>(); while (true) { String line = br.readLine(); - if (line == null) /* EOF */{ + if (line == null) /* EOF */ { break; /* done */ } Tokenizer tokenizer = new Tokenizer(line); @@ -110,7 +110,7 @@ public class AliasMapper { if (master != null) { String masterLower = master.toLowerCase(); canonicalTable.put(masterLower, master); - Collection aliasLine = new ArrayList(1); + Collection aliasLine = new ArrayList<>(1); aliasLine.add(master); parseloop: while (true) { String alias = tokenizer.getString("# \t"); //$NON-NLS-1$ @@ -126,7 +126,7 @@ public class AliasMapper { String existingMaster = canonicalTable.put(aliasLower, alias); Set masters = multiMaster.get(aliasLower); if (masters == null) { - masters = new HashSet(); + masters = new HashSet<>(); multiMaster.put(aliasLower, masters); masters.add(existingMaster.toLowerCase()); } @@ -136,9 +136,9 @@ public class AliasMapper { aliasTable.put(masterLower, aliasLine); } } - Map> multiMasterAliases = new HashMap>(multiMaster.size()); + Map> multiMasterAliases = new HashMap<>(multiMaster.size()); for (Entry> entry : multiMaster.entrySet()) { - Set aliases = new HashSet(); + Set aliases = new HashSet<>(); for (String master : entry.getValue()) { aliases.addAll(aliasTable.get(master)); } 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 673d01883..a65bbe426 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, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -164,7 +164,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher bundles = new ArrayList(1); + List bundles = new ArrayList<>(1); bundles.add(m.getBundle()); notifyFindHooks(this, bundles); if (bundles.isEmpty()) { @@ -189,7 +189,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher modules = container.getStorage().getModuleContainer().getModules(); - List bundles = new ArrayList(modules.size()); + List bundles = new ArrayList<>(modules.size()); for (Module module : modules) { bundles.add(module.getBundle()); } @@ -202,9 +202,9 @@ public class BundleContextImpl implements BundleContext, EventDispatcher(allBundles); + allBundles = new ArrayList<>(allBundles); } - final Collection shrinkable = new ShrinkableCollection(allBundles); + final Collection shrinkable = new ShrinkableCollection<>(allBundles); if (System.getSecurityManager() == null) { notifyFindHooksPriviledged(context, shrinkable); } else { @@ -873,7 +873,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher, ServiceUse>(10); + servicesInUse = new HashMap<>(10); } } @@ -1019,7 +1019,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher> empty = Collections.> emptyList(); return empty; } - List> result = new ArrayList>(refs.length); + List> result = new ArrayList<>(refs.length); for (ServiceReference b : refs) { result.add(b); } 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 07dbd791f..3be84911e 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 @@ -27,7 +27,7 @@ public class ContextFinder extends ClassLoader implements PrivilegedAction> cycleDetector = new ThreadLocal>(); + private static ThreadLocal> cycleDetector = new ThreadLocal<>(); static ClassLoader finderClassLoader; static Finder contextFinder; static { @@ -55,7 +55,7 @@ public class ContextFinder extends ClassLoader implements PrivilegedAction basicFindClassLoaders() { Class[] stack = contextFinder.getClassContext(); - List result = new ArrayList(1); + List result = new ArrayList<>(1); ClassLoader previousLoader = null; for (int i = 1; i < stack.length; i++) { ClassLoader tmp = stack[i].getClassLoader(); @@ -104,7 +104,7 @@ public class ContextFinder extends ClassLoader implements PrivilegedAction(3); + classesAndResources = new HashSet<>(3); cycleDetector.set(classesAndResources); } classesAndResources.add(name); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java index a6a3f920d..ddf4a7409 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,8 @@ public class DTOBuilder { private final Map wiringnodes; private DTOBuilder() { - resources = new IdentityHashMap(); - wiringnodes = new IdentityHashMap(); + resources = new IdentityHashMap<>(); + wiringnodes = new IdentityHashMap<>(); } public static BundleDTO newBundleDTO(Bundle bundle) { @@ -209,8 +209,8 @@ public class DTOBuilder { BundleWiringDTO dto = new BundleWiringDTO(); dto.bundle = wiring.getBundle().getBundleId(); dto.root = getWiringId(wiring); - dto.nodes = new HashSet(wiringnodes.values()); - dto.resources = new HashSet(resources.values()); + dto.nodes = new HashSet<>(wiringnodes.values()); + dto.resources = new HashSet<>(resources.values()); return dto; } @@ -274,7 +274,7 @@ public class DTOBuilder { } List revs = revisions.getRevisions(); final int size = revs.size(); - List dtos = new ArrayList(size); + List dtos = new ArrayList<>(size); for (int i = 0; i < size; i++) { BundleWiring wiring = revs.get(i).getWiring(); if (wiring != null) { @@ -367,7 +367,7 @@ public class DTOBuilder { return null; } final int length = references.length; - List refDTOs = new ArrayList(length); + List refDTOs = new ArrayList<>(length); for (int i = 0; i < length; i++) { ServiceReferenceDTO dto = getServiceReferenceDTO(references[i]); if (dto != null) { @@ -378,12 +378,7 @@ public class DTOBuilder { } private static Object mapValue(Object v) { - if ((v == null) - || v instanceof Number - || v instanceof Boolean - || v instanceof Character - || v instanceof String - || v instanceof DTO) { + if ((v == null) || v instanceof Number || v instanceof Boolean || v instanceof Character || v instanceof String || v instanceof DTO) { return v; } if (v instanceof Map) { @@ -423,14 +418,7 @@ public class DTOBuilder { } private static Class mapComponentType(Class componentType) { - if (componentType.isPrimitive() - || componentType.isArray() - || Object.class.equals(componentType) - || Number.class.isAssignableFrom(componentType) - || Boolean.class.isAssignableFrom(componentType) - || Character.class.isAssignableFrom(componentType) - || String.class.isAssignableFrom(componentType) - || DTO.class.isAssignableFrom(componentType)) { + if (componentType.isPrimitive() || componentType.isArray() || Object.class.equals(componentType) || Number.class.isAssignableFrom(componentType) || Boolean.class.isAssignableFrom(componentType) || Character.class.isAssignableFrom(componentType) || String.class.isAssignableFrom(componentType) || DTO.class.isAssignableFrom(componentType)) { return componentType; } if (Map.class.isAssignableFrom(componentType)) { @@ -446,22 +434,22 @@ public class DTOBuilder { } private static List newList(int size) { - return new ArrayList(size); + return new ArrayList<>(size); } private static Set newSet(int size) { - return new HashSet(size); + return new HashSet<>(size); } private static Map newMap(int size) { - return new HashMap(size); + return new HashMap<>(size); } /** * Assumes the input map is always . */ private static Map newDirectivesMapDTO(Map map) { - Map dto = new HashMap(map); + Map dto = new HashMap<>(map); return dto; } @@ -471,7 +459,7 @@ public class DTOBuilder { * and Version objects are converted to String objects. */ private static Map newAttributesMapDTO(Map map) { - Map dto = new HashMap(map); + Map dto = new HashMap<>(map); /* Lists are copied and Version objects are converted to String objects. */ for (Map.Entry entry : dto.entrySet()) { Object value = entry.getValue(); @@ -480,7 +468,7 @@ public class DTOBuilder { continue; } if (value instanceof List) { - List newList = new ArrayList((List) value); + List newList = new ArrayList<>((List) value); for (ListIterator iter = newList.listIterator(); iter.hasNext();) { Object element = iter.next(); if (element instanceof Version) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java index 7aa5a6c57..75dc1a3d6 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java @@ -113,7 +113,7 @@ public class EquinoxBundle implements Bundle, BundleReference { } - final List initListeners = new ArrayList(0); + final List initListeners = new ArrayList<>(0); class EquinoxSystemModule extends SystemModule { public EquinoxSystemModule(ModuleContainer container) { @@ -387,7 +387,7 @@ public class EquinoxBundle implements Bundle, BundleReference { if (options == 0) { return new StartOptions[0]; } - Collection result = new ArrayList(2); + Collection result = new ArrayList<>(2); if ((options & Bundle.START_TRANSIENT) != 0) { result.add(StartOptions.TRANSIENT); } @@ -706,14 +706,14 @@ public class EquinoxBundle implements Bundle, BundleReference { } if (infos.length == 0) return Collections.emptyMap(); - Map> results = new HashMap>(infos.length); + Map> results = new HashMap<>(infos.length); for (int i = 0; i < infos.length; i++) { if (signersType == SIGNERS_TRUSTED && !infos[i].isTrusted()) continue; Certificate[] certs = infos[i].getCertificateChain(); if (certs == null || certs.length == 0) continue; - List certChain = new ArrayList(); + List certChain = new ArrayList<>(); for (int j = 0; j < certs.length; j++) certChain.add((X509Certificate) certs[j]); results.put((X509Certificate) certs[0], certChain); @@ -961,7 +961,7 @@ public class EquinoxBundle implements Bundle, BundleReference { } List getGenerations() { - List result = new ArrayList(); + List result = new ArrayList<>(); ModuleRevision current = getModule().getCurrentRevision(); result.add((Generation) current.getRevisionInfo()); ModuleWiring wiring = current.getWiring(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index 619a1c0e6..bf22b309e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -228,7 +228,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { private final Properties localConfig; public ConfigValues(Map initialConfiguration) { - this.initialConfig = initialConfiguration == null ? new HashMap(0) : new HashMap(initialConfiguration); + this.initialConfig = initialConfiguration == null ? new HashMap(0) : new HashMap<>(initialConfiguration); Object useSystemPropsValue = initialConfig.get(PROP_USE_SYSTEM_PROPERTIES); this.useSystemProperties = useSystemPropsValue == null ? false : Boolean.parseBoolean(useSystemPropsValue.toString()); Properties tempConfiguration = useSystemProperties ? EquinoxContainer.secureAction.getProperties() : new Properties(); @@ -470,7 +470,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { Properties props = useSystemProperties ? EquinoxContainer.secureAction.getProperties() : localConfig; // must sync on props to avoid concurrent modification exception synchronized (props) { - Map result = new HashMap(props.size()); + Map result = new HashMap<>(props.size()); for (Object key : props.keySet()) { if (key instanceof String) { String skey = (String) key; @@ -603,7 +603,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { } private static List buildEclipseLibraryVariants(String ws, String os, String arch, String nl) { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add("ws/" + ws + "/"); //$NON-NLS-1$ //$NON-NLS-2$ result.add("os/" + os + "/" + arch + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ result.add("os/" + os + "/"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -618,7 +618,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { } private static List buildNLJarVariants(String nl) { - List result = new ArrayList(); + List result = new ArrayList<>(); nl = nl.replace('_', '/'); while (nl.length() > 0) { result.add("nl/" + nl + "/"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java index 87011f38b..5f42a20bc 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java @@ -78,8 +78,8 @@ public class EquinoxContainer implements ThreadFactory, Runnable { // TODO ideally this should be in equinox configuration or perhaps in storage String bootDelegationProp = equinoxConfig.getConfiguration(Constants.FRAMEWORK_BOOTDELEGATION); String[] bootPackages = ManifestElement.getArrayFromList(bootDelegationProp, ","); //$NON-NLS-1$ - HashSet exactMatch = new HashSet(bootPackages.length); - List stemMatch = new ArrayList(bootPackages.length); + HashSet exactMatch = new HashSet<>(bootPackages.length); + List stemMatch = new ArrayList<>(bootPackages.length); boolean delegateAllValue = false; for (int i = 0; i < bootPackages.length; i++) { if (bootPackages[i].equals("*")) { //$NON-NLS-1$ @@ -243,7 +243,7 @@ public class EquinoxContainer implements ThreadFactory, Runnable { void systemStart(BundleContext bc) { synchronized (this.monitor) { - signedContentFactory = new ServiceTracker(bc, SignedContentFactory.class, null); + signedContentFactory = new ServiceTracker<>(bc, SignedContentFactory.class, null); } signedContentFactory.open(); } 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 84c8cbd42..560392b4b 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 @@ -38,7 +38,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { private final ClassLoader moduleClassLoaderParent; private final AtomicLong lastSecurityAdminFlush; - final AtomicLazyInitializer executor = new AtomicLazyInitializer(); + final AtomicLazyInitializer executor = new AtomicLazyInitializer<>(); final Callable lazyExecutorCreator; public EquinoxContainerAdaptor(EquinoxContainer container, Storage storage, Map initial) { @@ -77,7 +77,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { // idle timeout; make it short to get rid of threads quickly after resolve int idleTimeout = 10; // use sync queue to force thread creation - BlockingQueue queue = new SynchronousQueue(); + BlockingQueue queue = new SynchronousQueue<>(); // try to name the threads with useful name ThreadFactory threadFactory = new ThreadFactory() { @Override diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java index 203197461..232c8de0c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,13 +45,13 @@ public class EquinoxEventPublisher { * installed in the Framework. */ // Map of BundleContexts for bundle's BundleListeners. - private final Map> allBundleListeners = new HashMap>(); + private final Map> allBundleListeners = new HashMap<>(); // Map of BundleContexts for bundle's SynchronousBundleListeners. - private final Map> allSyncBundleListeners = new HashMap>(); + private final Map> allSyncBundleListeners = new HashMap<>(); // Map of BundleContexts for bundle's FrameworkListeners. - private final Map> allFrameworkListeners = new HashMap>(); + private final Map> allFrameworkListeners = new HashMap<>(); public EquinoxEventPublisher(EquinoxContainer container) { this.container = container; @@ -86,7 +86,7 @@ public class EquinoxEventPublisher { public ListenerQueue newListenerQueue() { synchronized (this.monitor) { - return new ListenerQueue(eventManager); + return new ListenerQueue<>(eventManager); } } @@ -142,7 +142,7 @@ public class EquinoxEventPublisher { BundleContextImpl systemContext = null; Set> systemBundleListenersSync = null; synchronized (allSyncBundleListeners) { - listenersSync = new HashMap>>(allSyncBundleListeners.size()); + listenersSync = new HashMap<>(allSyncBundleListeners.size()); for (Map.Entry> entry : allSyncBundleListeners.entrySet()) { CopyOnWriteIdentityMap listeners = entry.getValue(); if (!listeners.isEmpty()) { @@ -162,7 +162,7 @@ public class EquinoxEventPublisher { Set> systemBundleListenersAsync = null; if ((event.getType() & (BundleEvent.STARTING | BundleEvent.STOPPING | BundleEvent.LAZY_ACTIVATION)) == 0) { synchronized (allBundleListeners) { - listenersAsync = new HashMap>>(allBundleListeners.size()); + listenersAsync = new HashMap<>(allBundleListeners.size()); for (Map.Entry> entry : allBundleListeners.entrySet()) { CopyOnWriteIdentityMap listeners = entry.getValue(); if (!listeners.isEmpty()) { @@ -188,7 +188,7 @@ public class EquinoxEventPublisher { if (listenersAsync == null) { shrinkable = asBundleContexts(listenersSync.keySet()); } else { - shrinkable = new ShrinkableCollection(asBundleContexts(listenersSync.keySet()), asBundleContexts(listenersAsync.keySet())); + shrinkable = new ShrinkableCollection<>(asBundleContexts(listenersSync.keySet()), asBundleContexts(listenersAsync.keySet())); } notifyEventHooksPrivileged(event, shrinkable); @@ -288,7 +288,7 @@ public class EquinoxEventPublisher { // Build the listener snapshot Map>> listenerSnapshot; synchronized (allFrameworkListeners) { - listenerSnapshot = new HashMap>>(allFrameworkListeners.size()); + listenerSnapshot = new HashMap<>(allFrameworkListeners.size()); for (Map.Entry> entry : allFrameworkListeners.entrySet()) { CopyOnWriteIdentityMap listeners = entry.getValue(); if (!listeners.isEmpty()) { @@ -303,7 +303,7 @@ public class EquinoxEventPublisher { // add the listeners specified by the caller first if (callerListeners != null && callerListeners.length > 0) { - Map listeners = new HashMap(); + Map listeners = new HashMap<>(); for (FrameworkListener listener : callerListeners) { if (listener != null) listeners.put(listener, listener); @@ -348,7 +348,7 @@ public class EquinoxEventPublisher { synchronized (allSyncBundleListeners) { CopyOnWriteIdentityMap listeners = allSyncBundleListeners.get(context); if (listeners == null) { - listeners = new CopyOnWriteIdentityMap(); + listeners = new CopyOnWriteIdentityMap<>(); allSyncBundleListeners.put(context, listeners); } listeners.put((SynchronousBundleListener) listener, (SynchronousBundleListener) listener); @@ -357,7 +357,7 @@ public class EquinoxEventPublisher { synchronized (allBundleListeners) { CopyOnWriteIdentityMap listeners = allBundleListeners.get(context); if (listeners == null) { - listeners = new CopyOnWriteIdentityMap(); + listeners = new CopyOnWriteIdentityMap<>(); allBundleListeners.put(context, listeners); } listeners.put(listener, listener); @@ -386,7 +386,7 @@ public class EquinoxEventPublisher { synchronized (allFrameworkListeners) { CopyOnWriteIdentityMap listeners = allFrameworkListeners.get(context); if (listeners == null) { - listeners = new CopyOnWriteIdentityMap(); + listeners = new CopyOnWriteIdentityMap<>(); allFrameworkListeners.put(context, listeners); } listeners.put(listener, listener); 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 35846321c..7a2f5a1e0 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, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -180,7 +180,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { */ public boolean match(Dictionary dictionary) { if (dictionary != null) { - dictionary = new Headers(dictionary); + dictionary = new Headers<>(dictionary); } return matchCase(dictionary); @@ -1406,7 +1406,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { public List getChildren() { if (value instanceof FilterImpl[]) { - return new ArrayList(Arrays.asList((FilterImpl[]) value)); + return new ArrayList<>(Arrays.asList((FilterImpl[]) value)); } return Collections.emptyList(); } @@ -1416,7 +1416,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { * @return all the attributes contained within this filter */ public String[] getAttributes() { - List results = new ArrayList(); + List results = new ArrayList<>(); getAttributesInternal(results); return results.toArray(new String[results.size()]); } @@ -1525,7 +1525,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { return parse_item(); } - List operands = new ArrayList(10); + List operands = new ArrayList<>(10); while (filterChars[pos] == '(') { FilterImpl child = parse_filter(); @@ -1544,7 +1544,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { return parse_item(); } - List operands = new ArrayList(10); + List operands = new ArrayList<>(10); while (filterChars[pos] == '(') { FilterImpl child = parse_filter(); @@ -1685,7 +1685,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { private Object parse_substring() throws InvalidSyntaxException { StringBuffer sb = new StringBuffer(filterChars.length - pos); - List operands = new ArrayList(10); + List operands = new ArrayList<>(10); parseloop: while (true) { char c = filterChars[pos]; @@ -1818,7 +1818,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { private Version leftVersion; private Version rightVersion; private char rightRule = 0; - private Collection excludes = new ArrayList(0); + private Collection excludes = new ArrayList<>(0); public String toString() { if (rightVersion == null) { @@ -1853,8 +1853,8 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { public Map getStandardOSGiAttributes(String... versions) { if (op != AND && op != EQUAL && op != SUBSTRING && op != PRESENT) throw new IllegalArgumentException("Invalid filter for Starndard OSGi Attributes: " + op); //$NON-NLS-1$ - Map result = new HashMap(); - Map versionAttrs = new HashMap(); + Map result = new HashMap<>(); + Map versionAttrs = new HashMap<>(); if (versions != null) { for (String versionAttr : versions) { versionAttrs.put(versionAttr, null); 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 ad5439650..464e9dc20 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, 2013 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -67,7 +67,7 @@ class OSGiFrameworkHooks { } case EquinoxConfiguration.BSN_VERSION_MANAGED : { Bundle targetBundle = target.getBundle(); - ArrayMap candidateBundles = new ArrayMap(collisionCandidates.size()); + ArrayMap candidateBundles = new ArrayMap<>(collisionCandidates.size()); for (Module module : collisionCandidates) { candidateBundles.put(module.getBundle(), module); } @@ -82,7 +82,7 @@ class OSGiFrameworkHooks { private void notifyCollisionHooks(final int operationType, final Bundle target, Collection collisionCandidates) { // Note that collision hook results are honored for the system bundle. - final Collection shrinkable = new ShrinkableCollection(collisionCandidates); + final Collection shrinkable = new ShrinkableCollection<>(collisionCandidates); if (System.getSecurityManager() == null) { notifyCollisionHooksPriviledged(operationType, target, shrinkable); } else { @@ -250,7 +250,7 @@ class OSGiFrameworkHooks { } if (hooks.isEmpty()) return; - candidates = new ShrinkableCollection(candidates); + candidates = new ShrinkableCollection<>(candidates); for (Iterator iHooks = hooks.iterator(); iHooks.hasNext();) { HookReference hookRef = iHooks.next(); if (hookRef.reference.getBundle() == null) { @@ -275,7 +275,7 @@ class OSGiFrameworkHooks { } if (hooks.isEmpty()) return; - collisionCandidates = new ShrinkableCollection(collisionCandidates); + collisionCandidates = new ShrinkableCollection<>(collisionCandidates); for (Iterator iHooks = hooks.iterator(); iHooks.hasNext();) { HookReference hookRef = iHooks.next(); if (hookRef.reference.getBundle() == null) { @@ -296,7 +296,7 @@ class OSGiFrameworkHooks { } if (hooks.isEmpty()) return; - candidates = new ShrinkableCollection(candidates); + candidates = new ShrinkableCollection<>(candidates); for (Iterator iHooks = hooks.iterator(); iHooks.hasNext();) { HookReference hookRef = iHooks.next(); if (hookRef.reference.getBundle() == null) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java index 1c61c3188..c868f7dd8 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/SystemBundleActivator.java @@ -42,7 +42,7 @@ import org.osgi.service.startlevel.StartLevel; public class SystemBundleActivator implements BundleActivator { private EquinoxFactoryManager urlFactoryManager; - private List> registrations = new ArrayList>(10); + private List> registrations = new ArrayList<>(10); private SecurityManager setSecurityManagner; @SuppressWarnings("deprecation") @@ -73,7 +73,7 @@ public class SystemBundleActivator implements BundleActivator { register(bc, PermissionAdmin.class, sa, null); register(bc, ConditionalPermissionAdmin.class, sa, null); - Hashtable props = new Hashtable(7); + Hashtable props = new Hashtable<>(7); props.clear(); props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE); register(bc, Resolver.class, new ResolverImpl(new Logger(0), null), false, props); @@ -152,7 +152,7 @@ public class SystemBundleActivator implements BundleActivator { } private void registerLocations(BundleContext bc, EquinoxLocations equinoxLocations) { - Dictionary locationProperties = new Hashtable(1); + Dictionary locationProperties = new Hashtable<>(1); Location location = equinoxLocations.getUserLocation(); if (location != null) { locationProperties.put("type", EquinoxLocations.PROP_USER_AREA); //$NON-NLS-1$ @@ -216,7 +216,7 @@ public class SystemBundleActivator implements BundleActivator { private void register(BundleContext context, String serviceClass, Object service, boolean setRanking, Dictionary properties) { if (properties == null) - properties = new Hashtable(7); + properties = new Hashtable<>(7); Dictionary headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); if (setRanking) { 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 04d573372..03808ba23 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, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -69,7 +69,7 @@ public class PackageAdminImpl implements PackageAdmin { Module module = StartLevelImpl.getModule(bundle); Collection revisions = module == null ? Collections. emptyList() : module.getRevisions().getModuleRevisions(); - Collection allExports = new ArrayList(); + Collection allExports = new ArrayList<>(); for (ModuleRevision revision : revisions) { ModuleWiring wiring = revision.getWiring(); if (wiring != null) { @@ -111,7 +111,7 @@ public class PackageAdminImpl implements PackageAdmin { Requirement packageReq = ModuleContainer.createRequirement(PackageNamespace.PACKAGE_NAMESPACE, directives, attributes); Collection packageCaps = container.getFrameworkWiring().findProviders(packageReq); InternalUtils.filterCapabilityPermissions(packageCaps); - List result = new ArrayList(); + List result = new ArrayList<>(); for (BundleCapability capability : packageCaps) { ModuleWiring wiring = (ModuleWiring) capability.getRevision().getWiring(); if (wiring != null) { @@ -120,7 +120,7 @@ public class PackageAdminImpl implements PackageAdmin { // This is a fragment, just get all the host wirings List hostWires = wiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE); if (hostWires != null && !hostWires.isEmpty()) { - wirings = new ArrayList(hostWires.size()); + wirings = new ArrayList<>(hostWires.size()); for (ModuleWire hostWire : hostWires) { ModuleWiring hostWiring = hostWire.getProviderWiring(); if (hostWiring != null) { @@ -157,7 +157,7 @@ public class PackageAdminImpl implements PackageAdmin { Requirement bundleReq = ModuleContainer.createRequirement(BundleNamespace.BUNDLE_NAMESPACE, directives, attributes); Collection bundleCaps = container.getFrameworkWiring().findProviders(bundleReq); InternalUtils.filterCapabilityPermissions(bundleCaps); - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (BundleCapability capability : bundleCaps) { BundleWiring wiring = capability.getRevision().getWiring(); if (wiring != null) { @@ -183,7 +183,7 @@ public class PackageAdminImpl implements PackageAdmin { if (identityCaps.isEmpty()) { return null; } - List sorted = new ArrayList(identityCaps.size()); + List sorted = new ArrayList<>(identityCaps.size()); for (BundleCapability capability : identityCaps) { Bundle b = capability.getRevision().getBundle(); // a sanity check incase this is an old revision @@ -215,7 +215,7 @@ public class PackageAdminImpl implements PackageAdmin { // we don't hold locks while checking the graph, just return if no longer valid return null; } - Collection fragments = new ArrayList(hostWires.size()); + Collection fragments = new ArrayList<>(hostWires.size()); for (ModuleWire wire : hostWires) { Bundle fragment = wire.getRequirer().getBundle(); if (fragment != null) { @@ -235,7 +235,7 @@ public class PackageAdminImpl implements PackageAdmin { // we don't hold locks while checking the graph, just return if no longer valid return null; } - Collection hosts = new ArrayList(hostWires.size()); + Collection hosts = new ArrayList<>(hostWires.size()); for (ModuleWire wire : hostWires) { Bundle host = wire.getProvider().getBundle(); if (host != null) { @@ -320,7 +320,7 @@ public class PackageAdminImpl implements PackageAdmin { if (!providerWiring.isInUse()) { return null; } - Set importing = new HashSet(); + Set importing = new HashSet<>(); String packageName = getName(); addRequirers(importing, providerWiring, packageName); @@ -424,7 +424,7 @@ public class PackageAdminImpl implements PackageAdmin { if (!providerWiring.isInUse()) { return null; } - Set requiring = new HashSet(); + Set requiring = new HashSet<>(); addRequirers(requiring, providerWiring); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java index 19354f7a1..f9d881dd4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -69,13 +69,13 @@ public final class HookRegistry { private final EquinoxContainer container; private volatile boolean initialized = false; - private final List classLoaderHooks = new ArrayList(); + private final List classLoaderHooks = new ArrayList<>(); private final List classLoaderHooksRO = Collections.unmodifiableList(classLoaderHooks); - private final List> storageHookFactories = new ArrayList>(); + private final List> storageHookFactories = new ArrayList<>(); private final List> storageHookFactoriesRO = Collections.unmodifiableList(storageHookFactories); - private final List bundleFileWrapperFactoryHooks = new ArrayList(); + private final List bundleFileWrapperFactoryHooks = new ArrayList<>(); private final List bundleFileWrapperFactoryHooksRO = Collections.unmodifiableList(bundleFileWrapperFactoryHooks); - private final List activatorHookFactories = new ArrayList(); + private final List activatorHookFactories = new ArrayList<>(); private final List activatorHookFactoriesRO = Collections.unmodifiableList(activatorHookFactories); public HookRegistry(EquinoxContainer container) { @@ -94,8 +94,8 @@ public final class HookRegistry { * 5. Set this HookRegistry object to read only to prevent any other hooks from being added.

*/ public void initialize() { - List configurators = new ArrayList(5); - List errors = new ArrayList(0); // optimistic that no errors will occur + List configurators = new ArrayList<>(5); + List errors = new ArrayList<>(0); // optimistic that no errors will occur mergeFileHookConfigurators(configurators, errors); mergePropertyHookConfigurators(configurators); synchronized (this) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java index db636e962..7312f8fc0 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,9 +31,9 @@ public class EclipseLazyStarter extends ClassLoaderHook { private static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction()); // holds the initiating class name - private final ThreadLocal initiatingClassName = new ThreadLocal(); + private final ThreadLocal initiatingClassName = new ThreadLocal<>(); // holds the ClasspathManagers that need to be activated - private final ThreadLocal> activationStack = new ThreadLocal>(); + private final ThreadLocal> activationStack = new ThreadLocal<>(); // used to store exceptions that occurred while activating a bundle // keyed by ClasspathManager->Exception // WeakHashMap is used to prevent pinning the ClasspathManager objects. @@ -61,7 +61,7 @@ public class EclipseLazyStarter extends ClassLoaderHook { return; Deque stack = activationStack.get(); if (stack == null) { - stack = new ArrayDeque(6); + stack = new ArrayDeque<>(6); activationStack.set(stack); } // each element is a classpath manager that must be activated after @@ -82,7 +82,7 @@ public class EclipseLazyStarter extends ClassLoaderHook { return; // if we have a stack we must clear it even if (clazz == null) - List managers = new ArrayList(stack); + List managers = new ArrayList<>(stack); stack.clear(); if (clazz == null) return; 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 d3baf0273..0652ba7a9 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 @@ -95,7 +95,7 @@ public class BundleLoader extends ModuleLoader { /* If not null, list of package names to import dynamically. */ private String[] dynamicImportPackages; - private final AtomicReference classloader = new AtomicReference(); + private final AtomicReference classloader = new AtomicReference<>(); private final ClassLoader parent; private final AtomicBoolean triggerClassLoaded = new AtomicBoolean(false); @@ -208,7 +208,7 @@ public class BundleLoader extends ModuleLoader { private static PackageSource createMultiSource(String packageName, PackageSource[] sources) { if (sources.length == 1) return sources[0]; - List sourceList = new ArrayList(sources.length); + List sourceList = new ArrayList<>(sources.length); for (int i = 0; i < sources.length; i++) { SingleSourcePackage[] innerSources = sources[i].getSuppliers(); for (int j = 0; j < innerSources.length; j++) @@ -732,7 +732,7 @@ public class BundleLoader extends ModuleLoader { if ((path.length() > 1) && (path.charAt(0) == '/')) /* if name has a leading slash */ path = path.substring(1); /* remove leading slash before search */ boolean subPackages = (options & BundleWiring.LISTRESOURCES_RECURSE) != 0; - List packages = new ArrayList(); + List packages = new ArrayList<>(); // search imported package names KeyedHashSet importSources = getImportedSources(null); KeyedElement[] imports; @@ -746,7 +746,7 @@ public class BundleLoader extends ModuleLoader { } // now add package names from required bundles - Collection visited = new ArrayList(); + Collection visited = new ArrayList<>(); visited.add(this); // always add ourselves so we do not recurse back to ourselves for (ModuleWire bundleWire : requiredBundleWires) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); @@ -758,8 +758,8 @@ public class BundleLoader extends ModuleLoader { boolean localSearch = (options & BundleWiring.LISTRESOURCES_LOCAL) != 0; // Use LinkedHashSet for optimized performance of contains() plus // ordering guarantees. - LinkedHashSet result = new LinkedHashSet(); - Set importedPackages = new HashSet(0); + LinkedHashSet result = new LinkedHashSet<>(); + Set importedPackages = new HashSet<>(0); for (String name : packages) { // look for import source PackageSource externalSource = findImportedSource(name, null); @@ -801,7 +801,7 @@ public class BundleLoader extends ModuleLoader { return list1 == null ? BundleLoader. emptyEnumeration() : list1; if (list1 == null || !list1.hasMoreElements()) return list2 == null ? BundleLoader. emptyEnumeration() : list2; - List compoundResults = new ArrayList(); + List compoundResults = new ArrayList<>(); while (list1.hasMoreElements()) compoundResults.add(list1.nextElement()); while (list2.hasMoreElements()) { @@ -952,7 +952,7 @@ public class BundleLoader extends ModuleLoader { if (packageImports == null || packageImports.isEmpty()) { return; } - List dynamicImports = new ArrayList(packageImports.size()); + List dynamicImports = new ArrayList<>(packageImports.size()); for (ModuleRequirement packageImport : packageImports) { if (PackageNamespace.RESOLUTION_DYNAMIC.equals(packageImport.getDirectives().get(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE))) { Matcher matcher = PACKAGENAME_FILTER.matcher(packageImport.getDirectives().get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE)); @@ -983,9 +983,9 @@ public class BundleLoader extends ModuleLoader { int size = packages.length; List stems; if (dynamicImportPackageStems == null) { - stems = new ArrayList(size); + stems = new ArrayList<>(size); } else { - stems = new ArrayList(size + dynamicImportPackageStems.length); + stems = new ArrayList<>(size + dynamicImportPackageStems.length); for (int i = 0; i < dynamicImportPackageStems.length; i++) { stems.add(dynamicImportPackageStems[i]); } @@ -993,9 +993,9 @@ public class BundleLoader extends ModuleLoader { List names; if (dynamicImportPackages == null) { - names = new ArrayList(size); + names = new ArrayList<>(size); } else { - names = new ArrayList(size + dynamicImportPackages.length); + names = new ArrayList<>(size + dynamicImportPackages.length); for (int i = 0; i < dynamicImportPackages.length; i++) { names.add(dynamicImportPackages[i]); } @@ -1036,7 +1036,7 @@ public class BundleLoader extends ModuleLoader { public final void addDynamicImportPackage(ManifestElement[] packages) { if (packages == null) return; - List dynamicImports = new ArrayList(packages.length); + List dynamicImports = new ArrayList<>(packages.length); StringBuilder importSpec = new StringBuilder(); for (ManifestElement dynamicImportElement : packages) { String[] names = dynamicImportElement.getValueComponents(); @@ -1051,7 +1051,7 @@ public class BundleLoader extends ModuleLoader { if (dynamicImports.size() > 0) { addDynamicImportPackage(dynamicImports.toArray(new String[dynamicImports.size()])); - Map dynamicImportMap = new HashMap(); + Map dynamicImportMap = new HashMap<>(); dynamicImportMap.put(Constants.DYNAMICIMPORT_PACKAGE, importSpec.toString()); try { @@ -1132,10 +1132,10 @@ public class BundleLoader extends ModuleLoader { return result.isNullSource() ? null : result; } if (visited == null) - visited = new ArrayList(); + visited = new ArrayList<>(); if (!visited.contains(this)) visited.add(this); // always add ourselves so we do not recurse back to ourselves - List result = new ArrayList(3); + List result = new ArrayList<>(3); for (ModuleWire bundleWire : requiredBundleWires) { BundleLoader loader = (BundleLoader) bundleWire.getProviderWiring().getModuleLoader(); if (loader != null) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java index 1c81488f1..20a065bbe 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java @@ -91,7 +91,7 @@ public abstract class ModuleClassLoader extends ClassLoader implements BundleRef } } - private final Map classNameLocks = new HashMap(5); + private final Map classNameLocks = new HashMap<>(5); private final Object pkgLock = new Object(); /** diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/DependentPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/DependentPolicy.java index cd3d16020..0770945f1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/DependentPolicy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/DependentPolicy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,7 +34,7 @@ public class DependentPolicy implements IBuddyPolicy { buddyRequester = requester; //Initialize with the first level of dependent the list - allDependents = new ArrayList(); + allDependents = new ArrayList<>(); basicAddImmediateDependents(requester.getWiring()); //If there is no dependent, reset to null if (allDependents.size() == 0) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/PolicyHandler.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/PolicyHandler.java index c08e0ef97..d65e0e6d1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/PolicyHandler.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/PolicyHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,14 +42,14 @@ public class PolicyHandler implements SynchronousBundleListener { policedLoader = loader; this.originalBuddyList = buddyList; policies = buddyList.toArray(); - beingLoaded = new ThreadLocal>(); + beingLoaded = new ThreadLocal<>(); this.packageAdmin = packageAdmin; } static Object[] getArrayFromList(String stringList) { if (stringList == null || stringList.trim().equals("")) //$NON-NLS-1$ return null; - List list = new ArrayList(); + List list = new ArrayList<>(); StringTokenizer tokens = new StringTokenizer(stringList, ","); //$NON-NLS-1$ while (tokens.hasMoreTokens()) { String token = tokens.nextToken().trim(); @@ -174,7 +174,7 @@ public class PolicyHandler implements SynchronousBundleListener { Enumeration result = policy.loadResources(name); if (result != null) { if (results == null) - results = new ArrayList(policyCount); + results = new ArrayList<>(policyCount); while (result.hasMoreElements()) { URL url = result.nextElement(); if (!results.contains(url)) //only add if not already added @@ -192,7 +192,7 @@ public class PolicyHandler implements SynchronousBundleListener { return false; if (classesAndResources == null) { - classesAndResources = new HashSet(3); + classesAndResources = new HashSet<>(3); beingLoaded.set(classesAndResources); } classesAndResources.add(name); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java index 168b49154..fc6783104 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java @@ -89,7 +89,7 @@ public class ClasspathEntry { if (name != null && name.endsWith("/")) { //$NON-NLS-1$ String packageName = name.substring(0, name.length() - 1).replace('/', '.'); if (result == null) { - result = new HashMap(4); + result = new HashMap<>(4); } result.put(packageName, manifestPackageAttributesFor(attributes, defaultAttributes)); } 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 b41fcc1cd..8139ded11 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 @@ -63,7 +63,7 @@ public class ClasspathManager { // a Map where "libname" is the key and libpath" is the value private ArrayMap loadedLibraries = null; // used to detect recusive defineClass calls for the same class on the same class loader (bug 345500) - private ThreadLocal> currentlyDefining = new ThreadLocal>(); + private ThreadLocal> currentlyDefining = new ThreadLocal<>(); /** * Constructs a classpath manager for the given generation and module class loader @@ -97,7 +97,7 @@ public class ClasspathManager { // we don't hold locks while checking the graph, just return if no longer valid return emptyFragments; } - List result = new ArrayList(fragmentWires.size()); + List result = new ArrayList<>(fragmentWires.size()); for (ModuleWire fragmentWire : fragmentWires) { ModuleRevision revision = fragmentWire.getRequirer(); Generation fragGeneration = (Generation) revision.getRevisionInfo(); @@ -146,7 +146,7 @@ public class ClasspathManager { } private ClasspathEntry[] buildClasspath(String[] cp, ClasspathManager hostloader, Generation source) { - ArrayList result = new ArrayList(cp.length); + ArrayList result = new ArrayList<>(cp.length); // add the regular classpath entries. for (int i = 0; i < cp.length; i++) findClassPathEntry(result, cp[i], hostloader, source); @@ -299,7 +299,7 @@ public class ClasspathManager { } public synchronized void loadFragments(Collection addedFragments) { - List result = new ArrayList(Arrays.asList(fragments)); + List result = new ArrayList<>(Arrays.asList(fragments)); for (ModuleRevision addedFragment : addedFragments) { Generation fragGeneration = (Generation) addedFragment.getRevisionInfo(); @@ -388,7 +388,7 @@ public class ClasspathManager { * @return an enumeration of the the requested resources */ public Enumeration findLocalResources(String resource) { - List resources = new ArrayList(6); + List resources = new ArrayList<>(6); int classPathIndex = 0; for (int i = 0; i < entries.length; i++) { if (entries[i] != null) { @@ -465,7 +465,7 @@ public class ClasspathManager { * @return an enumeration of the the requested entries or null if the entries do not exist */ public Enumeration findLocalEntries(String path) { - List objects = new ArrayList(6); + List objects = new ArrayList<>(6); for (int i = 0; i < entries.length; i++) { if (entries[i] != null) { BundleEntry result = findEntryImpl(path, entries[i].getBundleFile()); @@ -576,7 +576,7 @@ public class ClasspathManager { Collection current = currentlyDefining.get(); if (current == null) { - current = new ArrayList(5); + current = new ArrayList<>(5); currentlyDefining.set(current); } if (current.contains(name)) @@ -697,7 +697,7 @@ public class ClasspathManager { public String findLibrary(String libname) { synchronized (this) { if (loadedLibraries == null) - loadedLibraries = new ArrayMap(1); + loadedLibraries = new ArrayMap<>(1); } synchronized (loadedLibraries) { // we assume that each classloader will load a small number of of libraries @@ -755,7 +755,7 @@ public class ClasspathManager { * @see ModuleClassLoader#findEntries(String, String, int) */ public List findEntries(String path, String filePattern, int options) { - List generations = new ArrayList(); + List generations = new ArrayList<>(); // first get the host bundle file generations.add(generation); // next get the attached fragments bundle files @@ -768,7 +768,7 @@ public class ClasspathManager { Enumeration eURLs = Storage.findEntries(generations, path, filePattern, options); if (eURLs == null) return result; - result = new ArrayList(); + result = new ArrayList<>(); while (eURLs.hasMoreElements()) result.add(eURLs.nextElement()); return Collections.unmodifiableList(result); @@ -778,7 +778,7 @@ public class ClasspathManager { * @see ModuleClassLoader#listLocalResources(String, String, int) */ public Collection listLocalResources(String path, String filePattern, int options) { - List bundleFiles = new ArrayList(); + List bundleFiles = new ArrayList<>(); ClasspathEntry[] cpEntries = getHostClasspathEntries(); for (ClasspathEntry cpEntry : cpEntries) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java index a323f063e..b9546865e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -55,7 +55,7 @@ public class MultiSourcePackage extends PackageSource { @Override public Collection listResources(String path, String filePattern) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (SingleSourcePackage source : suppliers) { Collection sourceResources = source.listResources(path, filePattern); for (String resource : sourceResources) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/BasicReadWriteLock.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/BasicReadWriteLock.java index 12c8d613d..b402f58bb 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/BasicReadWriteLock.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/BasicReadWriteLock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others + * Copyright (c) 2008, 2016 IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; public class BasicReadWriteLock { - private List currentReaders = new ArrayList(2); + private List currentReaders = new ArrayList<>(2); private int writersWaiting = 0; private Thread writing = null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java index 122b4dbaf..c97cdde0d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -114,7 +114,7 @@ public class EquinoxLogServices { private ServiceRegistration registerPerformanceLog(BundleContext context) { Object service = createPerformanceLog(context.getBundle()); String serviceName = FrameworkLog.class.getName(); - Dictionary serviceProperties = new Hashtable(7); + Dictionary serviceProperties = new Hashtable<>(7); Dictionary headers = context.getBundle().getHeaders(); serviceProperties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java index 3ad412ab4..b9e13447f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,7 +19,7 @@ public class EventAdminAdapter implements ServiceTrackerCustomizer logTopics = new HashSet(Arrays.asList(LOG_TOPICS_ARRAY)); + private static Collection logTopics = new HashSet<>(Arrays.asList(LOG_TOPICS_ARRAY)); private static Collection eventAdminObjectClass = Arrays.asList("org.osgi.service.event.EventAdmin"); //$NON-NLS-1$ private static Collection eventHandlerObjectClass = Arrays.asList("org.osgi.service.event.EventHandler"); //$NON-NLS-1$ @@ -34,8 +34,8 @@ public class EventAdminAdapter implements ServiceTrackerCustomizer(context, "org.osgi.service.event.EventAdmin", this); //$NON-NLS-1$ - eventHandlerTracker = new ServiceTracker(context, "org.osgi.service.event.EventHandler", this); //$NON-NLS-1$ + eventAdminTracker = new ServiceTracker<>(context, "org.osgi.service.event.EventAdmin", this); //$NON-NLS-1$ + eventHandlerTracker = new ServiceTracker<>(context, "org.osgi.service.event.EventHandler", this); //$NON-NLS-1$ } public void start() { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java index e8ef9de41..6aba51942 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation + * Copyright (c) 2007, 2016 IBM Corporation * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -98,7 +98,7 @@ public class EventAdminLogListener implements SynchronousLogListener { default : // other log levels are represented by LOG_OTHER topic += TOPIC_SEPARATOR + LOG_OTHER; } - Hashtable properties = new Hashtable(); + Hashtable properties = new Hashtable<>(); Bundle bundle = entry.getBundle(); if (bundle == null) { throw new RuntimeException("LogEntry.getBundle() returns null"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogEntryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogEntryImpl.java index acee8a384..eb30db5ee 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogEntryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogEntryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -35,7 +35,7 @@ public class ExtendedLogEntryImpl implements ExtendedLogEntry, LogEntry { try { Thread.class.getMethod("getId", (Class[]) null); //$NON-NLS-1$ } catch (NoSuchMethodException e) { - return new WeakHashMap(); + return new WeakHashMap<>(); } return null; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java index 5fbf296aa..2813efc2d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -50,9 +50,9 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory listeners = new ArrayMap(5); + private ArrayMap listeners = new ArrayMap<>(5); private LogFilter[] filters = null; - private final ThreadLocal nestedCallCount = new ThreadLocal(); + private final ThreadLocal nestedCallCount = new ThreadLocal<>(); private final LinkedList history; private final int maxHistory; @@ -101,7 +101,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory 0) { - history = new LinkedList(); + history = new LinkedList<>(); } else { history = null; } @@ -237,7 +237,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory listenersCopy = new ArrayMap(listeners.getKeys(), listeners.getValues()); + ArrayMap listenersCopy = new ArrayMap<>(listeners.getKeys(), listeners.getValues()); Object[] listenerObjects = listenersCopy.get(listener); if (listenerObjects == null) { // Only create a task queue for non-SynchronousLogListeners @@ -256,7 +256,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory listenersCopy) { - List filtersList = new ArrayList(); + List filtersList = new ArrayList<>(); int size = listenersCopy.size(); for (int i = 0; i < size; i++) { Object[] listenerObjects = listenersCopy.getValue(i); @@ -277,7 +277,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory listenersCopy = new ArrayMap(listeners.getKeys(), listeners.getValues()); + ArrayMap listenersCopy = new ArrayMap<>(listeners.getKeys(), listeners.getValues()); listenersCopy.remove(listener); recalculateFilters(listenersCopy); listeners = listenersCopy; @@ -291,7 +291,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory(history)); + return Collections.enumeration(new ArrayList<>(history)); } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceImpl.java index 868a31603..8ee48f5d9 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -15,7 +15,7 @@ import org.osgi.service.log.LogListener; public class ExtendedLogReaderServiceImpl implements ExtendedLogReaderService { private final ExtendedLogReaderServiceFactory factory; - private Set listeners = new HashSet(); + private Set listeners = new HashSet<>(); ExtendedLogReaderServiceImpl(ExtendedLogReaderServiceFactory factory) { this.factory = factory; 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 82b8bdf8b..ab8bcf025 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, 2012 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -18,7 +18,7 @@ public class ExtendedLogServiceFactory implements ServiceFactory logServices = new HashMap(); + private final Map logServices = new HashMap<>(); public ExtendedLogServiceFactory(ExtendedLogReaderServiceFactory logReaderServiceFactory) { this.logReaderServiceFactory = logReaderServiceFactory; 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 d7bddb066..606a52b90 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, 2012 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -18,7 +18,7 @@ public class ExtendedLogServiceImpl implements ExtendedLogService, LogService { private final ExtendedLogServiceFactory factory; private volatile Bundle bundle; - private final HashMap loggerCache = new HashMap(); + private final HashMap loggerCache = new HashMap<>(); public ExtendedLogServiceImpl(ExtendedLogServiceFactory factory, Bundle bundle) { this.factory = factory; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java index 788091b97..25a54c758 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -236,7 +236,7 @@ public class LogServiceManager implements BundleListener, FrameworkListener, Ser } public Dictionary getHeaders() { - return new Hashtable(); + return new Hashtable<>(); } public long getBundleId() { @@ -300,7 +300,7 @@ public class LogServiceManager implements BundleListener, FrameworkListener, Ser } public Map> getSignerCertificates(int signersType) { - return new HashMap>(); + return new HashMap<>(); } public Version getVersion() { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java index 11d691816..4226421a9 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -15,7 +15,7 @@ import java.util.LinkedList; public class SerializedTaskQueue { private static final int MAX_WAIT = 5000; - private final LinkedList tasks = new LinkedList(); + private final LinkedList tasks = new LinkedList<>(); private Thread thread; private final String queueName; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java index b764f34f8..8c4f3e684 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,8 +36,8 @@ public class EquinoxSecurityManager extends SecurityManager { static class CheckContext { // A non zero depth indicates that we are doing a recursive permission check. - List> depthCondSets = new ArrayList>(2); - List accs = new ArrayList(2); + List> depthCondSets = new ArrayList<>(2); + List accs = new ArrayList<>(2); List> CondClassSet; public int getDepth() { @@ -62,7 +62,7 @@ public class EquinoxSecurityManager extends SecurityManager { } } - private final ThreadLocal localCheckContext = new ThreadLocal(); + private final ThreadLocal localCheckContext = new ThreadLocal<>(); boolean addConditionsForDomain(Decision[] results) { CheckContext cc = localCheckContext.get(); @@ -73,7 +73,7 @@ public class EquinoxSecurityManager extends SecurityManager { } List condSets = cc.depthCondSets.get(cc.getDepth()); if (condSets == null) { - condSets = new ArrayList(1); + condSets = new ArrayList<>(1); cc.depthCondSets.set(cc.getDepth(), condSets); } condSets.add(results); @@ -120,7 +120,7 @@ public class EquinoxSecurityManager extends SecurityManager { if (conditionSets == null) return; // TODO the spec seems impossible to implement just doing the simple thing for now - Map, Dictionary> conditionDictionaries = new HashMap, Dictionary>(); + Map, Dictionary> conditionDictionaries = new HashMap<>(); for (Decision[] domainDecisions : conditionSets) { boolean grant = false; for (int i = 0; i < domainDecisions.length; i++) { @@ -158,12 +158,12 @@ public class EquinoxSecurityManager extends SecurityManager { for (int i = 0; i < postponed.length; i++) { Dictionary condContext = conditionDictionaries.get(postponed[i].getClass()); if (condContext == null) { - condContext = new Hashtable(); + condContext = new Hashtable<>(); conditionDictionaries.put(postponed[i].getClass(), condContext); } // prevent recursion into Condition if (cc.CondClassSet == null) - cc.CondClassSet = new ArrayList>(2); + cc.CondClassSet = new ArrayList<>(2); if (cc.CondClassSet.contains(postponed[i].getClass())) return SecurityTable.ABSTAIN; cc.CondClassSet.add(postponed[i].getClass()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionAdminTable.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionAdminTable.java index d660b8bc8..de95214c4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionAdminTable.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionAdminTable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,7 @@ import java.util.Map; import org.osgi.service.permissionadmin.PermissionInfo; public class PermissionAdminTable { - private final Map locations = new HashMap(); + private final Map locations = new HashMap<>(); String[] getLocations() { return locations.keySet().toArray(new String[locations.size()]); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java index e00277735..f7d982619 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,7 +26,7 @@ public final class PermissionInfoCollection extends PermissionCollection { static private final Class[][] permClassArrayArgs = new Class[][] {noArgClassArray, oneStringClassArray, twoStringClassArray}; /* @GuardedBy(cachedPermisssionCollections) */ - private final Map, PermissionCollection> cachedPermissionCollections = new HashMap, PermissionCollection>(); + private final Map, PermissionCollection> cachedPermissionCollections = new HashMap<>(); private final boolean hasAllPermission; private final PermissionInfo[] permInfos; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionsHash.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionsHash.java index 51e37623d..ae0a58bb4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionsHash.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionsHash.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,7 +35,7 @@ class PermissionsHash extends PermissionCollection { /** * A hashtable to store the elements of the collection. */ - Hashtable perms = new Hashtable(8); + Hashtable perms = new Hashtable<>(8); /** * Constructs a new instance of this class. diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java index 09eeaaca1..3a05f2977 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -250,7 +250,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi // could implement our own Enumeration, but we don't care about performance here. Just do something simple: synchronized (lock) { SecurityRow[] rows = condAdminTable.getRows(); - List vRows = new ArrayList(rows.length); + List vRows = new ArrayList<>(rows.length); for (int i = 0; i < rows.length; i++) vRows.add(rows[i]); return Collections.enumeration(vRows); @@ -313,7 +313,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi if (updateStamp != timeStamp) return false; SecurityRow[] newRows = new SecurityRow[rows.size()]; - Collection names = new ArrayList(); + Collection names = new ArrayList<>(); for (int i = 0; i < newRows.length; i++) { Object rowObj = rows.get(i); if (!(rowObj instanceof ConditionalPermissionInfo)) @@ -426,7 +426,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi DataInputStream in = null; try { in = new DataInputStream(resource.openStream()); - List permissions = new ArrayList(); + List permissions = new ArrayList<>(); BufferedReader reader; try { reader = new BufferedReader(new InputStreamReader(in, "UTF8")); //$NON-NLS-1$ @@ -466,10 +466,10 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi } private static Bundle createMockBundle(String[] signers) { - Map> signersMap = new HashMap>(); + Map> signersMap = new HashMap<>(); for (int i = 0; i < signers.length; i++) { List chain = parseDNchain(signers[i]); - List signersList = new ArrayList(); + List signersList = new ArrayList<>(); Principal subject = null, issuer = null; X509Certificate first = null; for (Iterator iChain = chain.iterator(); iChain.hasNext();) { @@ -515,7 +515,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi } public Dictionary getHeaders() { - return new Hashtable(); + return new Hashtable<>(); } public Dictionary getHeaders(String locale) { @@ -550,7 +550,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi } public Map> getSignerCertificates(int signersType) { - return new HashMap>(signers); + return new HashMap<>(signers); } public int getState() { @@ -826,7 +826,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi if (dnChain == null) { throw new IllegalArgumentException("The DN chain must not be null."); //$NON-NLS-1$ } - List parsed = new ArrayList(); + List parsed = new ArrayList<>(); int startIndex = 0; startIndex = skipSpaces(dnChain, startIndex); while (startIndex < dnChain.length()) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java index 106933a8a..49431e63e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,7 @@ public final class SecurityRow implements ConditionalPermissionInfo { if (conditionInfos == null || conditionInfos.length == 0) bundleConditions = null; else - bundleConditions = new HashMap(); + bundleConditions = new HashMap<>(); } static SecurityRowSnapShot createSecurityRowSnapShot(String encoded) { @@ -103,8 +103,8 @@ public final class SecurityRow implements ConditionalPermissionInfo { if (decision.length() == 0 || (!ConditionalPermissionInfo.DENY.equalsIgnoreCase(decision) && !ConditionalPermissionInfo.ALLOW.equalsIgnoreCase(decision))) throw new IllegalArgumentException(encoded); - List condList = new ArrayList(); - List permList = new ArrayList(); + List condList = new ArrayList<>(); + List permList = new ArrayList<>(); int pos = start + 1; while (pos < end) { while (pos < end && chars[pos] != '[' && chars[pos] != '(') @@ -327,7 +327,7 @@ public final class SecurityRow implements ConditionalPermissionInfo { return postponedPermCheck; // no need to postpone the condition if the row abstains // this row will deny or allow the permission; must queue the postponed condition if (postponedConditions == null) - postponedConditions = new ArrayList(1); + postponedConditions = new ArrayList<>(1); postponedConditions.add(condition); } empty &= conditions[i] == null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java index f1ab80ae9..e0cff1823 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ public class SecurityTableUpdate implements ConditionalPermissionUpdate { this.securityAdmin = securityAdmin; this.timeStamp = timeStamp; // must make a snap shot of the security rows. - this.rows = new ArrayList(rows.length); + this.rows = new ArrayList<>(rows.length); for (int i = 0; i < rows.length; i++) // Use SecurityRowSnapShot to prevent modification before commit // and to throw exceptions from delete diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/provisional/service/security/AuthorizationEngine.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/provisional/service/security/AuthorizationEngine.java index d8ab8390b..6693625b5 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/provisional/service/security/AuthorizationEngine.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/provisional/service/security/AuthorizationEngine.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,7 +30,7 @@ public abstract class AuthorizationEngine { private final ServiceTracker listenerTracker; public AuthorizationEngine(BundleContext context) { - listenerTracker = new ServiceTracker(context, AuthorizationListener.class.getName(), null); + listenerTracker = new ServiceTracker<>(context, AuthorizationListener.class.getName(), null); listenerTracker.open(); } @@ -52,11 +52,11 @@ public abstract class AuthorizationEngine { Object[] services = listenerTracker.getServices(); if (services == null) return; - Map listeners = new HashMap(); + Map listeners = new HashMap<>(); for (Object service : services) { listeners.put((AuthorizationListener) service, service); } - ListenerQueue queue = new ListenerQueue(manager); + ListenerQueue queue = new ListenerQueue<>(manager); queue.queueListeners(listeners.entrySet(), dispatcher); queue.dispatchEventSynchronous(0, event); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java index 26436f8d8..d60277919 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/service/security/KeyStoreTrustEngine.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. + * Copyright (c) 2007, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,8 +12,9 @@ package org.eclipse.osgi.internal.service.security; import java.io.*; import java.security.*; -import java.security.cert.*; import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.*; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.internal.signedcontent.SignedBundleHook; @@ -262,7 +263,7 @@ public class KeyStoreTrustEngine extends TrustEngine { public String[] getAliases() throws IOException, GeneralSecurityException { - List returnList = new ArrayList(); + List returnList = new ArrayList<>(); try { KeyStore store = getKeyStore(); synchronized (store) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java index 18c3c181d..f39463924 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -93,7 +93,7 @@ public class ServiceRegistrationImpl implements ServiceRegistration, Compa this.clazzes = clazzes; /* must be set before calling createProperties. */ this.service = service; /* must be set before calling createProperties. */ this.serviceid = registry.getNextServiceId(); /* must be set before calling createProperties. */ - this.contextsUsing = new ArrayList(10); + this.contextsUsing = new ArrayList<>(10); synchronized (registrationLock) { this.state = REGISTERED; @@ -102,7 +102,7 @@ public class ServiceRegistrationImpl implements ServiceRegistration, Compa * stores the value in a final field without * otherwise using it. */ - this.reference = new ServiceReferenceImpl(this); + this.reference = new ServiceReferenceImpl<>(this); } } @@ -524,7 +524,7 @@ public class ServiceRegistrationImpl implements ServiceRegistration, Compa Debug.println("getServiceObjects[" + user.getBundleImpl() + "](" + this + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - return new ServiceObjectsImpl(user, this); + return new ServiceObjectsImpl<>(user, this); } /** @@ -536,11 +536,11 @@ public class ServiceRegistrationImpl implements ServiceRegistration, Compa private ServiceUse newServiceUse(BundleContextImpl user) { if (service instanceof ServiceFactory) { if (service instanceof PrototypeServiceFactory) { - return new PrototypeServiceFactoryUse(user, this); + return new PrototypeServiceFactoryUse<>(user, this); } - return new ServiceFactoryUse(user, this); + return new ServiceFactoryUse<>(user, this); } - return new ServiceUse(user, this); + return new ServiceUse<>(user, this); } /** 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 c16852de3..cc24fe06c 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, 2014 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -91,10 +91,10 @@ public class ServiceRegistry { this.container = container; this.debug = container.getConfiguration().getDebug(); serviceid = 1; - publishedServicesByClass = new HashMap>>(initialCapacity); - publishedServicesByContext = new HashMap>>(initialCapacity); - allPublishedServices = new ArrayList>(initialCapacity); - serviceEventListeners = new HashMap>(initialCapacity); + publishedServicesByClass = new HashMap<>(initialCapacity); + publishedServicesByContext = new HashMap<>(initialCapacity); + allPublishedServices = new ArrayList<>(initialCapacity); + serviceEventListeners = new HashMap<>(initialCapacity); Module systemModule = container.getStorage().getModuleContainer().getModule(0); systemBundleContext = (BundleContextImpl) systemModule.getBundle().getBundleContext(); systemBundleContext.provisionServicesInUseMap(); @@ -197,7 +197,7 @@ public class ServiceRegistry { } /* copy the array so that changes to the original will not affect us. */ - List copy = new ArrayList(size); + List copy = new ArrayList<>(size); // intern the strings and remove duplicates for (int i = 0; i < size; i++) { String clazz = clazzes[i].intern(); @@ -221,7 +221,7 @@ public class ServiceRegistry { } } - ServiceRegistrationImpl registration = new ServiceRegistrationImpl(this, context, clazzes, service); + ServiceRegistrationImpl registration = new ServiceRegistrationImpl<>(this, context, clazzes, service); registration.register(properties); if (copy.contains(listenerHookName)) { notifyNewListenerHook(registration); @@ -307,7 +307,7 @@ public class ServiceRegistry { } Filter filter = (filterstring == null) ? null : context.createFilter(filterstring); List> registrations = lookupServiceRegistrations(clazz, filter); - List> references = new ArrayList>(registrations.size()); + List> references = new ArrayList<>(registrations.size()); for (ServiceRegistrationImpl registration : registrations) { ServiceReferenceImpl reference; try { @@ -331,7 +331,7 @@ public class ServiceRegistry { if (context.getBundleImpl().getBundleId() == 0) { // Make a copy for the purposes of calling the hooks; // The the removals from the hooks are ignored for the system bundle - copyReferences = new ArrayList>(references); + copyReferences = new ArrayList<>(references); } Collection> shrinkable = new ShrinkableCollection>(copyReferences); notifyFindHooks(context, clazz, filterstring, allservices, shrinkable); @@ -567,7 +567,7 @@ public class ServiceRegistry { */ public ServiceReferenceImpl[] getRegisteredServices(BundleContextImpl context) { List> registrations = lookupServiceRegistrations(context); - List> references = new ArrayList>(registrations.size()); + List> references = new ArrayList<>(registrations.size()); for (ServiceRegistrationImpl registration : registrations) { ServiceReferenceImpl reference; try { @@ -627,9 +627,9 @@ public class ServiceRegistry { if (servicesInUse.isEmpty()) { return null; } - registrations = new ArrayList>(servicesInUse.keySet()); + registrations = new ArrayList<>(servicesInUse.keySet()); } - List> references = new ArrayList>(registrations.size()); + List> references = new ArrayList<>(registrations.size()); for (ServiceRegistrationImpl registration : registrations) { ServiceReferenceImpl reference; try { @@ -686,7 +686,7 @@ public class ServiceRegistry { if (servicesInUse.isEmpty()) { return; } - registrations = new ArrayList>(servicesInUse.keySet()); + registrations = new ArrayList<>(servicesInUse.keySet()); } if (debug.DEBUG_SERVICES) { Debug.println("Releasing services"); //$NON-NLS-1$ @@ -715,7 +715,7 @@ public class ServiceRegistry { synchronized (serviceEventListeners) { CopyOnWriteIdentityMap listeners = serviceEventListeners.get(context); if (listeners == null) { - listeners = new CopyOnWriteIdentityMap(); + listeners = new CopyOnWriteIdentityMap<>(); serviceEventListeners.put(context, listeners); } oldFilteredListener = listeners.put(listener, filteredListener); @@ -815,7 +815,7 @@ public class ServiceRegistry { Set> systemServiceListenersOrig = null; BundleContextImpl systemContext = null; synchronized (serviceEventListeners) { - listenerSnapshot = new HashMap>>(serviceEventListeners.size()); + listenerSnapshot = new HashMap<>(serviceEventListeners.size()); for (Map.Entry> entry : serviceEventListeners.entrySet()) { Map listeners = entry.getValue(); if (!listeners.isEmpty()) { @@ -896,7 +896,7 @@ public class ServiceRegistry { // Add the ServiceRegistrationImpl to the list of Services published by BundleContextImpl. List> contextServices = publishedServicesByContext.get(context); if (contextServices == null) { - contextServices = new ArrayList>(initialSubCapacity); + contextServices = new ArrayList<>(initialSubCapacity); publishedServicesByContext.put(context, contextServices); } // The list is NOT sorted, so we just add @@ -908,7 +908,7 @@ public class ServiceRegistry { List> services = publishedServicesByClass.get(clazz); if (services == null) { - services = new ArrayList>(initialSubCapacity); + services = new ArrayList<>(initialSubCapacity); publishedServicesByClass.put(clazz, services); } @@ -1005,7 +1005,7 @@ public class ServiceRegistry { return empty; } - result = new LinkedList>(result); /* make a new list since we don't want to change the real list */ + result = new LinkedList<>(result); /* make a new list since we don't want to change the real list */ } if (filter == null) { @@ -1042,7 +1042,7 @@ public class ServiceRegistry { return empty; } - return new ArrayList>(result); /* make a new list since we don't want to change the real list */ + return new ArrayList<>(result); /* make a new list since we don't want to change the real list */ } /** @@ -1318,7 +1318,7 @@ public class ServiceRegistry { } // snapshot the listeners - Collection addedListeners = new ArrayList(initialCapacity); + Collection addedListeners = new ArrayList<>(initialCapacity); synchronized (serviceEventListeners) { for (CopyOnWriteIdentityMap listeners : serviceEventListeners.values()) { if (!listeners.isEmpty()) { 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 7a093f84d..f47e23fa1 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, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,14 +43,14 @@ public class ShrinkableCollection implements Collection { } public ShrinkableCollection(Collection c1, Collection c2) { - list = new ArrayList>(2); + list = new ArrayList<>(2); list.add(c1); list.add(c2); collection = initComposite(list); } public ShrinkableCollection(List> l) { - list = new ArrayList>(l); + list = new ArrayList<>(l); collection = initComposite(list); } @@ -60,7 +60,7 @@ public class ShrinkableCollection implements Collection { assert verifyNoDuplicates(c); size += c.size(); } - Collection result = new ArrayList(size); + Collection result = new ArrayList<>(size); for (Collection c : collections) { for (E e : c) { if (!result.contains(e)) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableEntrySetValueCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableEntrySetValueCollection.java index a255c086c..04e668e49 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableEntrySetValueCollection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableEntrySetValueCollection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,7 +32,7 @@ public class ShrinkableEntrySetValueCollection extends AbstractCollection } public Iterator iterator() { - return new ValueIterator(entrySet.iterator()); + return new ValueIterator<>(entrySet.iterator()); } public int size() { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableValueCollectionMap.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableValueCollectionMap.java index 59d6c034a..3be680213 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableValueCollectionMap.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ShrinkableValueCollectionMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,9 +61,9 @@ public class ShrinkableValueCollectionMap extends AbstractMap(entrySet); + value = new ShrinkableEntrySetValueCollection<>(entrySet); if (values == null) { - values = new HashMap>(map.size()); + values = new HashMap<>(map.size()); } values.put(key, value); } @@ -81,7 +81,7 @@ public class ShrinkableValueCollectionMap extends AbstractMap(entrySet); + value = new ShrinkableEntrySetValueCollection<>(entrySet); } return value; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java index 177aad357..6b59d9667 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -229,7 +229,7 @@ public class PKCS7Processor implements SignedContentConstants { } private List constructCertPath(List certs, Certificate targetCert) { - List certsList = new ArrayList(); + List certsList = new ArrayList<>(); certsList.add(targetCert); X509Certificate currentCert = (X509Certificate) targetCert; @@ -360,7 +360,7 @@ public class PKCS7Processor implements SignedContentConstants { if (bp.classOfTag == BERProcessor.CONTEXTSPECIFIC_TAGCLASS && bp.tag == 1) { // there are some unsignedAttrs are found!! - unsignedAttrs = new HashMap(); + unsignedAttrs = new HashMap<>(); // step into a set of unsigned attributes, I believe, when steps // into here, the 'poiter' is pointing to the first element @@ -389,7 +389,7 @@ public class PKCS7Processor implements SignedContentConstants { if (bp.classOfTag == BERProcessor.CONTEXTSPECIFIC_TAGCLASS) { // process the signed attributes - signedAttrs = new HashMap(); + signedAttrs = new HashMap<>(); BERProcessor signedAttrsBERS = bp.stepInto(); do { @@ -449,7 +449,7 @@ public class PKCS7Processor implements SignedContentConstants { * @throws SignatureException */ private List processCertificates(BERProcessor bp) throws CertificateException, SignatureException { - List rtvList = new ArrayList(3); + List rtvList = new ArrayList<>(3); // Step into the first certificate-element BERProcessor certsBERS = bp.stepInto(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java index 03afd0e30..7b8536ef2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java @@ -22,8 +22,8 @@ import org.eclipse.osgi.util.NLS; public class SignatureBlockProcessor implements SignedContentConstants { private final SignedBundleFile signedBundle; - private List signerInfos = new ArrayList(); - private Map contentMDResults = new HashMap(); + private List signerInfos = new ArrayList<>(); + private Map contentMDResults = new HashMap<>(); // map of tsa singers keyed by SignerInfo -> {tsa_SignerInfo, signingTime} private Map tsaSignerInfos; private final int supportFlags; @@ -43,7 +43,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { // read all the signature block file names into a list Enumeration en = wrappedBundleFile.getEntryPaths(META_INF); - List signers = new ArrayList(2); + List signers = new ArrayList<>(2); while (en.hasMoreElements()) { String name = en.nextElement(); if ((name.endsWith(DOT_DSA) || name.endsWith(DOT_RSA)) && name.indexOf('/') == name.lastIndexOf('/')) @@ -117,7 +117,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { if (tsaCerts != null && signingTime != null) { SignerInfoImpl tsaSignerInfo = new SignerInfoImpl(tsaCerts, null, digAlg); if (tsaSignerInfos == null) - tsaSignerInfos = new HashMap(2); + tsaSignerInfos = new HashMap<>(2); tsaSignerInfos.put(signerInfo, new Object[] {tsaSignerInfo, signingTime}); } } @@ -225,8 +225,8 @@ public class SignatureBlockProcessor implements SignedContentConstants { @SuppressWarnings("unchecked") List[] arrayLists = new ArrayList[2]; mdResult = arrayLists; - mdResult[0] = new ArrayList(); - mdResult[1] = new ArrayList(); + mdResult[0] = new ArrayList<>(); + mdResult[1] = new ArrayList<>(); contentMDResults.put(entryName, mdResult); } mdResult[0].add(signerInfo); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java index 0d4de3be6..b390741e0 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java @@ -94,7 +94,7 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper // initialize the trust engine listener only if trust is being established with a trust engine trustEngineListener = new TrustEngineListener(context, this); // always register the trust engine - Dictionary trustEngineProps = new Hashtable(7); + Dictionary trustEngineProps = new Hashtable<>(7); trustEngineProps.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MIN_VALUE)); trustEngineProps.put(SignedContentConstants.TRUST_ENGINE, SignedContentConstants.DEFAULT_TRUST_ENGINE); KeyStoreTrustEngine systemTrustEngine = new KeyStoreTrustEngine(CACERTS_PATH, CACERTS_TYPE, null, "System", this); //$NON-NLS-1$ @@ -106,7 +106,7 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper if ("file".equals(url.getProtocol())) { //$NON-NLS-1$ trustEngineProps.put(SignedContentConstants.TRUST_ENGINE, OSGI_KEYSTORE); String path = url.getPath(); - osgiTrustEngineReg = new ArrayList>(1); + osgiTrustEngineReg = new ArrayList<>(1); osgiTrustEngineReg.add(context.registerService(TrustEngine.class.getName(), new KeyStoreTrustEngine(path, CACERTS_TYPE, null, OSGI_KEYSTORE, this), trustEngineProps)); } } catch (MalformedURLException e) { @@ -117,7 +117,7 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper if (osgiTrustRepoPaths != null) { trustEngineProps.put(SignedContentConstants.TRUST_ENGINE, Constants.FRAMEWORK_TRUST_REPOSITORIES); StringTokenizer st = new StringTokenizer(osgiTrustRepoPaths, File.pathSeparator); - osgiTrustEngineReg = new ArrayList>(1); + osgiTrustEngineReg = new ArrayList<>(1); while (st.hasMoreTokens()) { String trustRepoPath = st.nextToken(); osgiTrustEngineReg.add(context.registerService(TrustEngine.class.getName(), new KeyStoreTrustEngine(trustRepoPath, CACERTS_TYPE, null, OSGI_KEYSTORE, this), trustEngineProps)); @@ -280,9 +280,9 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper log("Invalid trust engine filter", FrameworkLogEntry.WARNING, e); //$NON-NLS-1$ } if (filter != null) { - trustEngineTracker = new ServiceTracker(context, filter, new TrustEngineCustomizer()); + trustEngineTracker = new ServiceTracker<>(context, filter, new TrustEngineCustomizer()); } else - trustEngineTracker = new ServiceTracker(context, TrustEngine.class.getName(), new TrustEngineCustomizer()); + trustEngineTracker = new ServiceTracker<>(context, TrustEngine.class.getName(), new TrustEngineCustomizer()); trustEngineTracker.open(); } Object[] services = trustEngineTracker.getServices(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentFile.java index e20a82aed..6e262e058 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -88,7 +88,7 @@ public class SignedContentFile implements SignedContent { synchronized Map getEntryExceptions(boolean create) { if (create && entryExceptions == null) - entryExceptions = new HashMap(5); + entryExceptions = new HashMap<>(5); return entryExceptions; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java index ac403ccc8..fc18afd8e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. All rights reserved. + * Copyright (c) 2007, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -38,7 +38,7 @@ public class SignedContentImpl implements SignedContent { public SignedContentEntry[] getSignedEntries() { if (contentMDResults == null) return new SignedContentEntry[0]; - List results = new ArrayList(contentMDResults.size()); + List results = new ArrayList<>(contentMDResults.size()); for (Map.Entry entry : contentMDResults.entrySet()) { String entryName = entry.getKey(); Object[] mdResult = (Object[]) entry.getValue(); @@ -105,7 +105,7 @@ public class SignedContentImpl implements SignedContent { if (!containsInfo(baseInfo)) throw new IllegalArgumentException("The baseInfo is not found"); //$NON-NLS-1$ if (tsaSignerInfos == null) - tsaSignerInfos = new HashMap(signerInfos.length); + tsaSignerInfos = new HashMap<>(signerInfos.length); tsaSignerInfos.put(baseInfo, new Object[] {tsaSignerInfo, signingTime}); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java index 4d369ad36..39af2ad6c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -26,12 +26,12 @@ public class SignedStorageHook extends StorageHookFactory, List @Override public List createSaveContext() { - return new ArrayList(); + return new ArrayList<>(); } @Override public List createLoadContext(int version) { - return new ArrayList(); + return new ArrayList<>(); } @Override @@ -64,7 +64,7 @@ public class SignedStorageHook extends StorageHookFactory, List int resultsSize = is.readInt(); Map contentMDResults = null; if (resultsSize > 0) { - contentMDResults = new HashMap(resultsSize); + contentMDResults = new HashMap<>(resultsSize); for (int i = 0; i < resultsSize; i++) { String path = is.readUTF(); int numEntrySigners = is.readInt(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java index 565454f5e..5f662858a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. All rights reserved. + * Copyright (c) 2007, 2016 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -54,8 +54,8 @@ public class TrustEngineListener { // find any signed content that has signerinfos with the supplied anchor // re-evaluate trust and check authorization again. Bundle[] bundles = context.getBundles(); - Set usingAnchor = new HashSet(); - Set untrustedSigners = new HashSet(); + Set usingAnchor = new HashSet<>(); + Set untrustedSigners = new HashSet<>(); for (int i = 0; i < bundles.length; i++) { SignedContentImpl signedContent = getSignedContent(bundles[i]); if (signedContent != null && signedContent.isSigned()) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java index ba234761d..f83b6008c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2012 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,10 +46,10 @@ public class ContentHandlerFactoryImpl extends MultiplexingFactory implements ja public ContentHandlerFactoryImpl(BundleContext context, EquinoxContainer container) { super(context, container); - proxies = new Hashtable(5); + proxies = new Hashtable<>(5); //We need to track content handler registrations - contentHandlerTracker = new ServiceTracker(context, contentHandlerClazz, null); + contentHandlerTracker = new ServiceTracker<>(context, contentHandlerClazz, null); contentHandlerTracker.open(); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java index f3b000242..e63855d14 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -48,7 +48,7 @@ public class ContentHandlerProxy extends ContentHandler implements ServiceTracke // until a real ContentHandler for this mime-type is registered setNewHandler(reference, getRank(reference)); - contentHandlerServiceTracker = new ServiceTracker>(context, ContentHandler.class.getName(), this); + contentHandlerServiceTracker = new ServiceTracker<>(context, ContentHandler.class.getName(), this); URLStreamHandlerFactoryImpl.secureAction.open(contentHandlerServiceTracker); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java index 3ec5d5afa..edccf78a3 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Cognos Incorporated, IBM Corporation and others. + * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -151,19 +151,19 @@ public abstract class MultiplexingFactory { if (factories == null) return null; - List released = new LinkedList(factories); + List released = new LinkedList<>(factories); factories = null; return released; } private synchronized void addFactory(Object factory) { - List updated = (factories == null) ? new LinkedList() : new LinkedList(factories); + List updated = (factories == null) ? new LinkedList<>() : new LinkedList<>(factories); updated.add(factory); factories = updated; } private synchronized void removeFactory(Object factory) { - List updated = new LinkedList(factories); + List updated = new LinkedList<>(factories); updated.remove(factory); factories = updated.isEmpty() ? null : updated; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java index 0c496a472..fcf6ce6ed 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ public class URLStreamHandlerFactoryImpl extends MultiplexingFactory implements private static final List> ignoredClasses = Arrays.asList(new Class[] {MultiplexingURLStreamHandler.class, URLStreamHandlerFactoryImpl.class, URL.class}); private Map proxies; private URLStreamHandlerFactory parentFactory; - private ThreadLocal> creatingProtocols = new ThreadLocal>(); + private ThreadLocal> creatingProtocols = new ThreadLocal<>(); /** * Create the factory. @@ -52,8 +52,8 @@ public class URLStreamHandlerFactoryImpl extends MultiplexingFactory implements public URLStreamHandlerFactoryImpl(BundleContext context, EquinoxContainer container) { super(context, container); - proxies = new Hashtable(15); - handlerTracker = new ServiceTracker(context, URLSTREAMHANDLERCLASS, null); + proxies = new Hashtable<>(15); + handlerTracker = new ServiceTracker<>(context, URLSTREAMHANDLERCLASS, null); handlerTracker.open(); } @@ -119,7 +119,7 @@ public class URLStreamHandlerFactoryImpl extends MultiplexingFactory implements private boolean isRecursive(String protocol) { List protocols = creatingProtocols.get(); if (protocols == null) { - protocols = new ArrayList(1); + protocols = new ArrayList<>(1); creatingProtocols.set(protocols); } if (protocols.contains(protocol)) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java index c4295534c..85c904771 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2015 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -55,7 +55,7 @@ public class URLStreamHandlerProxy extends URLStreamHandler implements ServiceTr //set the handler and ranking setNewHandler(reference, getRank(reference)); - urlStreamHandlerServiceTracker = new ServiceTracker>(context, URLStreamHandlerFactoryImpl.URLSTREAMHANDLERCLASS, this); + urlStreamHandlerServiceTracker = new ServiceTracker<>(context, URLStreamHandlerFactoryImpl.URLSTREAMHANDLERCLASS, this); URLStreamHandlerFactoryImpl.secureAction.open(urlStreamHandlerServiceTracker); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/DynamicImportList.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/DynamicImportList.java index 7c6f4f070..2a22840c4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/DynamicImportList.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/DynamicImportList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2013 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,7 @@ import org.osgi.framework.PackagePermission; */ public class DynamicImportList extends AbstractList implements RandomAccess { // the collection of valid DynamicImport-Package statments. - private final List imports = new ArrayList(0); + private final List imports = new ArrayList<>(0); private final WovenClassImpl wovenClass; public DynamicImportList(WovenClassImpl wovenClass) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WeavingHookConfigurator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WeavingHookConfigurator.java index 2030659b9..e37e2670b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WeavingHookConfigurator.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WeavingHookConfigurator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ public class WeavingHookConfigurator extends ClassLoaderHook { // holds the map of black listed hooks. Use weak map to avoid pinning and simplify cleanup. private final Map, Boolean> blackList = Collections.synchronizedMap(new WeakHashMap, Boolean>()); // holds the stack of WovenClass objects currently being used to define classes - private final ThreadLocal> wovenClassStack = new ThreadLocal>(); + private final ThreadLocal> wovenClassStack = new ThreadLocal<>(); private final EquinoxContainer container; @@ -47,7 +47,7 @@ public class WeavingHookConfigurator extends ClassLoaderHook { WovenClassImpl wovenClass = new WovenClassImpl(name, classbytes, entry, classpathEntry, loader, container, blackList); List wovenClasses = wovenClassStack.get(); if (wovenClasses == null) { - wovenClasses = new ArrayList(6); + wovenClasses = new ArrayList<>(6); wovenClassStack.set(wovenClasses); } wovenClasses.add(wovenClass); 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 cab25c713..9a569bfbf 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 @@ -103,7 +103,7 @@ public final class BundleInfo { if (rawHeaders == null) { BundleEntry manifest = getBundleFile().getEntry(OSGI_BUNDLE_MANIFEST); if (manifest == null) { - rawHeaders = new Headers(0); + rawHeaders = new Headers<>(0); rawHeaders.setReadOnly(); } else { try { @@ -393,7 +393,7 @@ public final class BundleInfo { Generation createGeneration() throws BundleException { synchronized (this.infoMonitor) { if (generationLocks == null) { - generationLocks = new LockSet(); + generationLocks = new LockSet<>(); } boolean lockedID; try { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java index c7db7fe8f..794fa5c62 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java @@ -34,7 +34,7 @@ import org.osgi.resource.Capability; public class FrameworkExtensionInstaller { private static final ClassLoader CL = FrameworkExtensionInstaller.class.getClassLoader(); private static final Method ADD_FWK_URL_METHOD = findAddURLMethod(CL, "addURL"); //$NON-NLS-1$ - private final ArrayMap hookActivators = new ArrayMap(5); + private final ArrayMap hookActivators = new ArrayMap<>(5); private static Method findAddURLMethod(ClassLoader cl, String name) { if (cl == null) @@ -143,7 +143,7 @@ public class FrameworkExtensionInstaller { @SuppressWarnings("unchecked") List paths = metaDatas.isEmpty() ? null : (List) metaDatas.get(0).getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_CLASSPATH); if (paths == null) { - paths = new ArrayList(1); + paths = new ArrayList<>(1); paths.add("."); //$NON-NLS-1$ } if (configuration.inDevelopmentMode()) { @@ -152,7 +152,7 @@ public class FrameworkExtensionInstaller { paths.add(devPath); } } - List results = new ArrayList(paths.size()); + List results = new ArrayList<>(paths.size()); for (String path : paths) { if (".".equals(path)) { //$NON-NLS-1$ results.add(((Generation) revision.getRevisionInfo()).getBundleFile().getBaseFile()); @@ -193,7 +193,7 @@ public class FrameworkExtensionInstaller { public void stopExtensionActivators(BundleContext context) { ArrayMap current; synchronized (hookActivators) { - current = new ArrayMap(hookActivators.getKeys(), hookActivators.getValues()); + current = new ArrayMap<>(hookActivators.getKeys(), hookActivators.getValues()); hookActivators.clear(); } for (BundleActivator activator : current) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java index 8f20d1756..a67ec5309 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2015 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,7 @@ public class ManifestLocalization { private final Generation generation; private final Dictionary rawHeaders; private volatile Dictionary defaultLocaleHeaders = null; - private final Hashtable cache = new Hashtable(5); + private final Hashtable cache = new Hashtable<>(5); public ManifestLocalization(Generation generation, Dictionary rawHeaders, String defaultRoot) { this.generation = generation; @@ -62,7 +62,7 @@ public class ManifestLocalization { } ResourceBundle localeProperties = getResourceBundle(localeString, isDefaultLocale); Enumeration eKeys = this.rawHeaders.keys(); - Headers localeHeaders = new Headers(this.rawHeaders.size()); + Headers localeHeaders = new Headers<>(this.rawHeaders.size()); while (eKeys.hasMoreElements()) { String key = eKeys.nextElement(); String value = this.rawHeaders.get(key); @@ -84,7 +84,7 @@ public class ManifestLocalization { } private String[] buildNLVariants(String nl) { - List result = new ArrayList(); + List result = new ArrayList<>(); while (nl.length() > 0) { result.add(nl); int i = nl.lastIndexOf('_'); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java index 13a495116..729f83cf7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/NativeCodeFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,7 +32,7 @@ public class NativeCodeFinder { private final Generation generation; private final Debug debug; // This is only used to keep track of when the same native library is loaded more than once - private final Collection loadedNativeCode = new ArrayList(1); + private final Collection loadedNativeCode = new ArrayList<>(1); public NativeCodeFinder(Generation generation) { this.generation = generation; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java index a7f29d1dd..e74561447 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2012 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,7 @@ import java.util.*; */ public class PermissionData { private static final int PERMDATA_VERSION = 1; - private final Map locations = new HashMap(); + private final Map locations = new HashMap<>(); private String[] defaultInfos; private String[] condPermInfos; private boolean dirty; 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 b4e3051d5..0bcbfdd7f 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 @@ -78,7 +78,7 @@ public class Storage { private final ModuleContainer moduleContainer; private final Object saveMonitor = new Object(); private long lastSavedTimestamp = -1; - private final LockSet idLocks = new LockSet(); + private final LockSet idLocks = new LockSet<>(); private final MRUBundleFileList mruList; private final FrameworkExtensionInstaller extensionInstaller; private final List cachedHeaderKeys = Arrays.asList(Constants.BUNDLE_SYMBOLICNAME, Constants.BUNDLE_ACTIVATIONPOLICY, "Service-Component"); //$NON-NLS-1$ @@ -140,7 +140,7 @@ public class Storage { generations = loadGenerations(data); } catch (IllegalArgumentException e) { equinoxContainer.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, "The persistent format for the framework data has changed. The framework will be reinitialized: " + e.getMessage(), null); //$NON-NLS-1$ - generations = new HashMap(0); + generations = new HashMap<>(0); data = null; cleanOSGiStorage(osgiLocation, childRoot); } @@ -192,7 +192,7 @@ public class Storage { if (systemWiring == null) { return; } - Collection fragments = new ArrayList(); + Collection fragments = new ArrayList<>(); for (ModuleWire hostWire : systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE)) { fragments.add(hostWire.getRequirer()); } @@ -212,7 +212,7 @@ public class Storage { } private void discardBundlesOnLoad() throws BundleException { - Collection discarded = new ArrayList(0); + Collection discarded = new ArrayList<>(0); for (Module module : moduleContainer.getModules()) { if (module.getId() == Constants.SYSTEM_BUNDLE_ID) continue; @@ -585,8 +585,8 @@ public class Storage { if (generation.getBundleInfo().getBundleId() == 0) { return; // ignore system bundle } - List> factories = new ArrayList>(getConfiguration().getHookRegistry().getStorageHookFactories()); - List> hooks = new ArrayList>(factories.size()); + List> factories = new ArrayList<>(getConfiguration().getHookRegistry().getStorageHookFactories()); + List> hooks = new ArrayList<>(factories.size()); for (Iterator> iFactories = factories.iterator(); iFactories.hasNext();) { @SuppressWarnings("unchecked") StorageHookFactory> next = (StorageHookFactory>) iFactories.next(); @@ -607,7 +607,7 @@ public class Storage { Map unchecked = (Map) headers; mapHeaders = unchecked; } else { - mapHeaders = new HashMap(); + mapHeaders = new HashMap<>(); for (Enumeration eKeys = headers.keys(); eKeys.hasMoreElements();) { String key = eKeys.nextElement(); mapHeaders.put(key, headers.get(key)); @@ -912,7 +912,7 @@ public class Storage { if (commandProp == null) return; String[] temp = ManifestElement.getArrayFromList(commandProp, " "); //$NON-NLS-1$ - List command = new ArrayList(temp.length + 1); + List command = new ArrayList<>(temp.length + 1); boolean foundFullPath = false; for (int i = 0; i < temp.length; i++) { if ("[fullpath]".equals(temp[i]) || "${abspath}".equals(temp[i])) { //$NON-NLS-1$ //$NON-NLS-2$ @@ -1098,7 +1098,7 @@ public class Storage { private void saveGenerations(DataOutputStream out) throws IOException { List modules = moduleContainer.getModules(); - List generations = new ArrayList(); + List generations = new ArrayList<>(); for (Module module : modules) { ModuleRevision revision = module.getCurrentRevision(); if (revision != null) { @@ -1183,21 +1183,21 @@ public class Storage { private Map loadGenerations(DataInputStream in) throws IOException { if (in == null) { - return new HashMap(0); + return new HashMap<>(0); } int version = in.readInt(); if (version != VERSION) { throw new IllegalArgumentException("Found persistent version \"" + version + "\" expecting \"" + VERSION + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } int numCachedHeaders = in.readInt(); - List storedCachedHeaderKeys = new ArrayList(numCachedHeaders); + List storedCachedHeaderKeys = new ArrayList<>(numCachedHeaders); for (int i = 0; i < numCachedHeaders; i++) { storedCachedHeaderKeys.add(ObjectPool.intern(in.readUTF())); } int numInfos = in.readInt(); - Map result = new HashMap(numInfos); - List generations = new ArrayList(numInfos); + Map result = new HashMap<>(numInfos); + List generations = new ArrayList<>(numInfos); for (int i = 0; i < numInfos; i++) { long infoId = in.readLong(); String infoLocation = ObjectPool.intern(in.readUTF()); @@ -1209,7 +1209,7 @@ public class Storage { String contentPath = in.readUTF(); long lastModified = in.readLong(); - Map cachedHeaders = new HashMap(storedCachedHeaderKeys.size()); + Map cachedHeaders = new HashMap<>(storedCachedHeaderKeys.size()); for (String headerKey : storedCachedHeaderKeys) { String value = in.readUTF(); if (NUL.equals(value)) { @@ -1250,8 +1250,8 @@ public class Storage { } private void loadStorageHookData(List generations, DataInputStream in) throws IOException { - List> factories = new ArrayList>(getConfiguration().getHookRegistry().getStorageHookFactories()); - Map>> hookMap = new HashMap>>(); + List> factories = new ArrayList<>(getConfiguration().getHookRegistry().getStorageHookFactories()); + Map>> hookMap = new HashMap<>(); int numFactories = in.readInt(); for (int i = 0; i < numFactories; i++) { String factoryName = in.readUTF(); @@ -1327,7 +1327,7 @@ public class Storage { private static List> getHooks(Map>> hookMap, Generation generation) { List> result = hookMap.get(generation); if (result == null) { - result = new ArrayList>(); + result = new ArrayList<>(); hookMap.put(generation, result); } return result; @@ -1544,7 +1544,7 @@ public class Storage { } public static Enumeration findEntries(List generations, String path, String filePattern, int options) { - List bundleFiles = new ArrayList(generations.size()); + List bundleFiles = new ArrayList<>(generations.size()); for (Generation generation : generations) bundleFiles.add(generation.getBundleFile()); // search all the bundle files @@ -1611,7 +1611,7 @@ public class Storage { public static List listEntryPaths(List bundleFiles, String path, String filePattern, int options) { // Use LinkedHashSet for optimized performance of contains() plus // ordering guarantees. - LinkedHashSet pathList = new LinkedHashSet(); + LinkedHashSet pathList = new LinkedHashSet<>(); Filter patternFilter = null; Hashtable patternProps = null; if (filePattern != null) { @@ -1626,26 +1626,26 @@ public class Storage { if (bundleFile.getEntry(path) != null && !pathList.contains(path)) pathList.add(path); } - return new ArrayList(pathList); + return new ArrayList<>(pathList); } // For when the file pattern includes a wildcard. try { // create a file pattern filter with 'filename' as the key patternFilter = FilterImpl.newInstance("(filename=" + sanitizeFilterInput(filePattern) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ // create a single hashtable to be shared during the recursive search - patternProps = new Hashtable(2); + patternProps = new Hashtable<>(2); } catch (InvalidSyntaxException e) { // TODO something unexpected happened; log error and return nothing // Bundle b = context == null ? null : context.getBundle(); // eventPublisher.publishFrameworkEvent(FrameworkEvent.ERROR, b, e); - return new ArrayList(pathList); + return new ArrayList<>(pathList); } } // find the entry paths for the datas for (BundleFile bundleFile : bundleFiles) { listEntryPaths(bundleFile, path, patternFilter, patternProps, options, pathList); } - return new ArrayList(pathList); + return new ArrayList<>(pathList); } public static String sanitizeFilterInput(String filePattern) throws InvalidSyntaxException { @@ -1692,7 +1692,7 @@ public class Storage { // guarantees. private static LinkedHashSet listEntryPaths(BundleFile bundleFile, String path, Filter patternFilter, Hashtable patternProps, int options, LinkedHashSet pathList) { if (pathList == null) - pathList = new LinkedHashSet(); + pathList = new LinkedHashSet<>(); Enumeration entryPaths; if ((options & BundleWiring.FINDENTRIES_RECURSE) != 0) entryPaths = bundleFile.getEntryPaths(path, true); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java index 8277e8fa5..d8b74b01b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -151,7 +151,7 @@ public class StorageUtil { * @return the service registration object */ public static ServiceRegistration register(String name, Object service, BundleContext context) { - Dictionary properties = new Hashtable(7); + Dictionary properties = new Hashtable<>(7); Dictionary headers = context.getBundle().getHeaders(); properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/DirBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/DirBundleFile.java index d3243b517..dec2b4cd4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/DirBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/DirBundleFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -125,7 +125,7 @@ public class DirBundleFile extends BundleFile { return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; - LinkedHashSet entries = new LinkedHashSet(); + LinkedHashSet entries = new LinkedHashSet<>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); 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 06885d5e9..acdcf4fdc 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, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,7 @@ import org.eclipse.osgi.framework.eventmgr.*; */ public class MRUBundleFileList implements EventDispatcher { private static final int MIN = 10; - private static final ThreadLocal closingBundleFile = new ThreadLocal(); + private static final ThreadLocal closingBundleFile = new ThreadLocal<>(); // list of open bundle files final private BundleFile[] bundleFileList; @@ -46,7 +46,7 @@ public class MRUBundleFileList implements EventDispatcher= MIN) { this.bundleFileList = new BundleFile[fileLimit]; this.useStampList = new long[fileLimit]; - this.bundleFileCloser = new CopyOnWriteIdentityMap(); + this.bundleFileCloser = new CopyOnWriteIdentityMap<>(); this.bundleFileCloser.put(this, this); } else { this.bundleFileList = null; @@ -181,7 +181,7 @@ public class MRUBundleFileList implements EventDispatcher queue = new ListenerQueue(manager); + ListenerQueue queue = new ListenerQueue<>(manager); /* add bundle file closer to the queue */ queue.queueListeners(bundleFileCloser.entrySet(), this); /* dispatch event to set of listeners */ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java index 2f7816065..dfbea86ff 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2014 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -268,7 +268,7 @@ public class ZipBundleFile extends BundleFile { if (path.length() > 0 && path.charAt(path.length() - 1) != '/') path = new StringBuilder(path).append("/").toString(); //$NON-NLS-1$ - LinkedHashSet result = new LinkedHashSet(); + LinkedHashSet result = new LinkedHashSet<>(); // Get all zip file entries and add the ones of interest. Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java index 9b575fc25..4564f32db 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -84,7 +84,7 @@ public class CopyOnWriteIdentityMap implements Map { @SuppressWarnings("unchecked") Entry[] newEntries = new Entry[size]; System.arraycopy(entries, 0, newEntries, 0, size); - newEntries[i] = new Entry(key, value); + newEntries[i] = new Entry<>(key, value); entries = newEntries; return v; } @@ -95,7 +95,7 @@ public class CopyOnWriteIdentityMap implements Map { if (size > 0) { System.arraycopy(entries, 0, newEntries, 0, size); } - newEntries[size] = new Entry(key, value); + newEntries[size] = new Entry<>(key, value); entries = newEntries; return null; } @@ -337,7 +337,7 @@ public class CopyOnWriteIdentityMap implements Map { * The entries returned by the set cannot be modified. */ public Set> entrySet() { - return new Snapshot(entries()).entrySet(); + return new Snapshot<>(entries()).entrySet(); } /** @@ -347,7 +347,7 @@ public class CopyOnWriteIdentityMap implements Map { * @return A Set of the key objects in this map */ public Set keySet() { - return new Snapshot(entries()).keySet(); + return new Snapshot<>(entries()).keySet(); } /** @@ -357,7 +357,7 @@ public class CopyOnWriteIdentityMap implements Map { * @return A Collection of the value objects in this map. */ public Collection values() { - return new Snapshot(entries()).values(); + return new Snapshot<>(entries()).values(); } /** diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventListeners.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventListeners.java index 431e4be94..e40ce2920 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventListeners.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventListeners.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,7 +26,7 @@ import java.util.Set; * @noextend This class is not intended to be subclassed by clients. */ public class EventListeners { - private final CopyOnWriteIdentityMap list = new CopyOnWriteIdentityMap(); + private final CopyOnWriteIdentityMap list = new CopyOnWriteIdentityMap<>(); /** * Creates an empty listener list. diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java index 9e371ee34..900eaf5aa 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -194,7 +194,7 @@ public class EventManager { /* if there is no thread, then create a new one */ thread = AccessController.doPrivileged(new PrivilegedAction>() { public EventThread run() { - EventThread t = new EventThread(threadGroup, threadName); + EventThread t = new EventThread<>(threadGroup, threadName); return t; } }); @@ -371,7 +371,7 @@ public class EventManager { throw new IllegalStateException(); } - Queued item = new Queued(l, d, a, o); + Queued item = new Queued<>(l, d, a, o); if (head == null) /* if the queue was empty */ { diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/ListenerQueue.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/ListenerQueue.java index 40fbf99d3..7e78bac01 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/ListenerQueue.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/ListenerQueue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -63,7 +63,7 @@ public class ListenerQueue { } this.manager = manager; - queue = new CopyOnWriteIdentityMap>, EventDispatcher>(); + queue = new CopyOnWriteIdentityMap<>(); readOnly = false; } diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java index f0b0ffb5c..6fd13b2e4 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java @@ -125,7 +125,7 @@ public class ReliableFile { private File referenceFile; /** List of checksum file objects: File => specific ReliableFile generation */ - private static Hashtable cacheFiles = new Hashtable(20); + private static Hashtable cacheFiles = new Hashtable<>(20); private File inputFile = null; private File outputFile = null; @@ -192,7 +192,7 @@ public class ReliableFile { String[] files = parent.list(); if (files == null) return null; - List list = new ArrayList(defaultMaxGenerations); + List list = new ArrayList<>(defaultMaxGenerations); if (file.exists()) list.add(Integer.valueOf(0)); //base file exists for (int i = 0; i < files.length; i++) { @@ -637,7 +637,7 @@ public class ReliableFile { if (!directory.isDirectory()) throw new IOException("Not a valid directory"); //$NON-NLS-1$ String files[] = directory.list(); - Set list = new HashSet(files.length / 2); + Set list = new HashSet<>(files.length / 2); for (int idx = 0; idx < files.length; idx++) { String file = files[idx]; int pos = file.lastIndexOf('.'); diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/util/Tokenizer.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/util/Tokenizer.java index 893e72a44..62c48749d 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/util/Tokenizer.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/util/Tokenizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. + * Copyright (c) 2003, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -91,7 +91,7 @@ public class Tokenizer { } public List getEscapedTokens(String terminals) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (String token = getEscapedToken(terminals); token != null; token = getEscapedToken(terminals)) { result.add(token); getChar(); // consume terminal diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java index 10616c3a9..87095cf44 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java @@ -310,7 +310,7 @@ public class ManifestElement { @SuppressWarnings("unchecked") private Hashtable addTableValue(Hashtable table, String key, String value) { if (table == null) { - table = new Hashtable(7); + table = new Hashtable<>(7); } Object curValue = table.get(key); if (curValue != null) { @@ -319,7 +319,7 @@ public class ManifestElement { if (curValue instanceof List) { newList = (List) curValue; } else { - newList = new ArrayList(5); + newList = new ArrayList<>(5); newList.add((String) curValue); } newList.add(value); @@ -345,13 +345,13 @@ public class ManifestElement { public static ManifestElement[] parseHeader(String header, String value) throws BundleException { if (value == null) return (null); - List headerElements = new ArrayList(10); + List headerElements = new ArrayList<>(10); Tokenizer tokenizer = new Tokenizer(value); parseloop: while (true) { String next = tokenizer.getString(";,"); //$NON-NLS-1$ if (next == null) throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR); - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); StringBuffer headerValue = new StringBuffer(next); headerValues.add(next); @@ -473,7 +473,7 @@ public class ManifestElement { public static String[] getArrayFromList(String stringList, String separator) { if (stringList == null || stringList.trim().length() == 0) return new String[0]; - List list = new ArrayList(); + List list = new ArrayList<>(); StringTokenizer tokens = new StringTokenizer(stringList, separator); while (tokens.hasMoreTokens()) { String token = tokens.nextToken().trim(); @@ -500,7 +500,7 @@ public class ManifestElement { */ public static Map parseBundleManifest(InputStream manifest, Map headers) throws IOException, BundleException { if (headers == null) - headers = new HashMap(); + headers = new HashMap<>(); manifest = new BufferedInputStream(manifest); try { diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java index 3a454094a..a95afd5e9 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2014 IBM Corporation and others. + * Copyright (c) 2005, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -247,7 +247,7 @@ public abstract class NLS { if (nlSuffixes == null) { //build list of suffixes for loading resource bundles String nl = Locale.getDefault().toString(); - List result = new ArrayList(4); + List result = new ArrayList<>(4); int lastSeparator; while (true) { result.add('_' + nl + EXTENSION); @@ -309,7 +309,7 @@ public abstract class NLS { //build a map of field names to Field objects final int len = fieldArray.length; - Map fields = new HashMap(len * 2); + Map fields = new HashMap<>(len * 2); for (int i = 0; i < len; i++) fields.put(fieldArray[i].getName(), fieldArray[i]); -- cgit v1.2.3