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 --- .../osgi/framework/eventmgr/CopyOnWriteIdentityMap.java | 12 ++++++------ .../org/eclipse/osgi/framework/eventmgr/EventListeners.java | 4 ++-- .../org/eclipse/osgi/framework/eventmgr/EventManager.java | 6 +++--- .../org/eclipse/osgi/framework/eventmgr/ListenerQueue.java | 4 ++-- .../osgi/framework/internal/reliablefile/ReliableFile.java | 6 +++--- .../src/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 +++--- 8 files changed, 27 insertions(+), 27 deletions(-) (limited to 'bundles/org.eclipse.osgi/supplement') 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