提交 741c9607 编写于 作者: S smarks

6880112: Project Coin: Port JDK core library code to use diamond operator

Reviewed-by: darcy, lancea, alanb, briangoetz, mduigou, mchung
上级 ecf74ffd
...@@ -1704,7 +1704,7 @@ class BandStructure { ...@@ -1704,7 +1704,7 @@ class BandStructure {
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) { for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
assert(attrIndexLimit[i] == 0); assert(attrIndexLimit[i] == 0);
attrIndexLimit[i] = 32; // just for the sake of predefs. attrIndexLimit[i] = 32; // just for the sake of predefs.
attrDefs.set(i, new ArrayList<Attribute.Layout>(Collections.nCopies( attrDefs.set(i, new ArrayList<>(Collections.nCopies(
attrIndexLimit[i], (Attribute.Layout)null))); attrIndexLimit[i], (Attribute.Layout)null)));
} }
......
...@@ -1137,7 +1137,7 @@ class ConstantPool { ...@@ -1137,7 +1137,7 @@ class ConstantPool {
void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) { void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) {
cpRefs.remove(null); cpRefs.remove(null);
for (ListIterator<Entry> work = for (ListIterator<Entry> work =
new ArrayList<Entry>(cpRefs).listIterator(cpRefs.size()); new ArrayList<>(cpRefs).listIterator(cpRefs.size());
work.hasPrevious(); ) { work.hasPrevious(); ) {
Entry e = work.previous(); Entry e = work.previous();
work.remove(); // pop stack work.remove(); // pop stack
......
...@@ -322,7 +322,7 @@ class Package { ...@@ -322,7 +322,7 @@ class Package {
} }
public void setInnerClasses(Collection<InnerClass> ics) { public void setInnerClasses(Collection<InnerClass> ics) {
innerClasses = (ics == null) ? null : new ArrayList<InnerClass>(ics); innerClasses = (ics == null) ? null : new ArrayList<>(ics);
// Edit the attribute list, if necessary. // Edit the attribute list, if necessary.
Attribute a = getAttribute(attrInnerClassesEmpty); Attribute a = getAttribute(attrInnerClassesEmpty);
if (innerClasses != null && a == null) if (innerClasses != null && a == null)
......
...@@ -34,7 +34,7 @@ import java.io.File; ...@@ -34,7 +34,7 @@ import java.io.File;
*/ */
class DeleteOnExitHook { class DeleteOnExitHook {
private static LinkedHashSet<String> files = new LinkedHashSet<String>(); private static LinkedHashSet<String> files = new LinkedHashSet<>();
static { static {
// DeleteOnExitHook must be the last shutdown hook to be invoked. // DeleteOnExitHook must be the last shutdown hook to be invoked.
// Application shutdown hooks may add the first file to the // Application shutdown hooks may add the first file to the
...@@ -71,7 +71,7 @@ class DeleteOnExitHook { ...@@ -71,7 +71,7 @@ class DeleteOnExitHook {
files = null; files = null;
} }
ArrayList<String> toBeDeleted = new ArrayList<String>(theFiles); ArrayList<String> toBeDeleted = new ArrayList<>(theFiles);
// reverse the list to maintain previous jdk deletion order. // reverse the list to maintain previous jdk deletion order.
// Last in first deleted. // Last in first deleted.
......
...@@ -1067,7 +1067,7 @@ public class File ...@@ -1067,7 +1067,7 @@ public class File
if ((names == null) || (filter == null)) { if ((names == null) || (filter == null)) {
return names; return names;
} }
List<String> v = new ArrayList<String>(); List<String> v = new ArrayList<>();
for (int i = 0 ; i < names.length ; i++) { for (int i = 0 ; i < names.length ; i++) {
if (filter.accept(this, names[i])) { if (filter.accept(this, names[i])) {
v.add(names[i]); v.add(names[i]);
...@@ -1158,7 +1158,7 @@ public class File ...@@ -1158,7 +1158,7 @@ public class File
public File[] listFiles(FilenameFilter filter) { public File[] listFiles(FilenameFilter filter) {
String ss[] = list(); String ss[] = list();
if (ss == null) return null; if (ss == null) return null;
ArrayList<File> files = new ArrayList<File>(); ArrayList<File> files = new ArrayList<>();
for (String s : ss) for (String s : ss)
if ((filter == null) || filter.accept(this, s)) if ((filter == null) || filter.accept(this, s))
files.add(new File(s, this)); files.add(new File(s, this));
...@@ -1195,7 +1195,7 @@ public class File ...@@ -1195,7 +1195,7 @@ public class File
public File[] listFiles(FileFilter filter) { public File[] listFiles(FileFilter filter) {
String ss[] = list(); String ss[] = list();
if (ss == null) return null; if (ss == null) return null;
ArrayList<File> files = new ArrayList<File>(); ArrayList<File> files = new ArrayList<>();
for (String s : ss) { for (String s : ss) {
File f = new File(s, this); File f = new File(s, this);
if ((filter == null) || filter.accept(f)) if ((filter == null) || filter.accept(f))
......
...@@ -56,7 +56,7 @@ class FileInputStream extends InputStream ...@@ -56,7 +56,7 @@ class FileInputStream extends InputStream
private volatile boolean closed = false; private volatile boolean closed = false;
private static final ThreadLocal<Boolean> runningFinalize = private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>(); new ThreadLocal<>();
private static boolean isRunningFinalize() { private static boolean isRunningFinalize() {
Boolean val; Boolean val;
......
...@@ -69,7 +69,7 @@ class FileOutputStream extends OutputStream ...@@ -69,7 +69,7 @@ class FileOutputStream extends OutputStream
private final Object closeLock = new Object(); private final Object closeLock = new Object();
private volatile boolean closed = false; private volatile boolean closed = false;
private static final ThreadLocal<Boolean> runningFinalize = private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>(); new ThreadLocal<>();
private static boolean isRunningFinalize() { private static boolean isRunningFinalize() {
Boolean val; Boolean val;
......
...@@ -725,7 +725,7 @@ implements Serializable { ...@@ -725,7 +725,7 @@ implements Serializable {
*/ */
public FilePermissionCollection() { public FilePermissionCollection() {
perms = new ArrayList<Permission>(); perms = new ArrayList<>();
} }
/** /**
...@@ -830,7 +830,7 @@ implements Serializable { ...@@ -830,7 +830,7 @@ implements Serializable {
// Don't call out.defaultWriteObject() // Don't call out.defaultWriteObject()
// Write out Vector // Write out Vector
Vector<Permission> permissions = new Vector<Permission>(perms.size()); Vector<Permission> permissions = new Vector<>(perms.size());
synchronized (this) { synchronized (this) {
permissions.addAll(perms); permissions.addAll(perms);
} }
...@@ -853,7 +853,7 @@ implements Serializable { ...@@ -853,7 +853,7 @@ implements Serializable {
// Get the one we want // Get the one we want
Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null); Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
perms = new ArrayList<Permission>(permissions.size()); perms = new ArrayList<>(permissions.size());
perms.addAll(permissions); perms.addAll(permissions);
} }
} }
...@@ -213,7 +213,7 @@ public class ObjectInputStream ...@@ -213,7 +213,7 @@ public class ObjectInputStream
/** table mapping primitive type names to corresponding class objects */ /** table mapping primitive type names to corresponding class objects */
private static final HashMap<String, Class<?>> primClasses private static final HashMap<String, Class<?>> primClasses
= new HashMap<String, Class<?>>(8, 1.0F); = new HashMap<>(8, 1.0F);
static { static {
primClasses.put("boolean", boolean.class); primClasses.put("boolean", boolean.class);
primClasses.put("byte", byte.class); primClasses.put("byte", byte.class);
...@@ -229,11 +229,11 @@ public class ObjectInputStream ...@@ -229,11 +229,11 @@ public class ObjectInputStream
private static class Caches { private static class Caches {
/** cache of subclass security audit results */ /** cache of subclass security audit results */
static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits = static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
new ConcurrentHashMap<WeakClassKey,Boolean>(); new ConcurrentHashMap<>();
/** queue for WeakReferences to audited subclasses */ /** queue for WeakReferences to audited subclasses */
static final ReferenceQueue<Class<?>> subclassAuditsQueue = static final ReferenceQueue<Class<?>> subclassAuditsQueue =
new ReferenceQueue<Class<?>>(); new ReferenceQueue<>();
} }
/** filter stream for handling block data conversion */ /** filter stream for handling block data conversion */
......
...@@ -165,11 +165,11 @@ public class ObjectOutputStream ...@@ -165,11 +165,11 @@ public class ObjectOutputStream
private static class Caches { private static class Caches {
/** cache of subclass security audit results */ /** cache of subclass security audit results */
static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits = static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
new ConcurrentHashMap<WeakClassKey,Boolean>(); new ConcurrentHashMap<>();
/** queue for WeakReferences to audited subclasses */ /** queue for WeakReferences to audited subclasses */
static final ReferenceQueue<Class<?>> subclassAuditsQueue = static final ReferenceQueue<Class<?>> subclassAuditsQueue =
new ReferenceQueue<Class<?>>(); new ReferenceQueue<>();
} }
/** filter stream for handling block data conversion */ /** filter stream for handling block data conversion */
...@@ -2413,7 +2413,7 @@ public class ObjectOutputStream ...@@ -2413,7 +2413,7 @@ public class ObjectOutputStream
private final List<String> stack; private final List<String> stack;
DebugTraceInfoStack() { DebugTraceInfoStack() {
stack = new ArrayList<String>(); stack = new ArrayList<>();
} }
/** /**
......
...@@ -84,18 +84,18 @@ public class ObjectStreamClass implements Serializable { ...@@ -84,18 +84,18 @@ public class ObjectStreamClass implements Serializable {
private static class Caches { private static class Caches {
/** cache mapping local classes -> descriptors */ /** cache mapping local classes -> descriptors */
static final ConcurrentMap<WeakClassKey,Reference<?>> localDescs = static final ConcurrentMap<WeakClassKey,Reference<?>> localDescs =
new ConcurrentHashMap<WeakClassKey,Reference<?>>(); new ConcurrentHashMap<>();
/** cache mapping field group/local desc pairs -> field reflectors */ /** cache mapping field group/local desc pairs -> field reflectors */
static final ConcurrentMap<FieldReflectorKey,Reference<?>> reflectors = static final ConcurrentMap<FieldReflectorKey,Reference<?>> reflectors =
new ConcurrentHashMap<FieldReflectorKey,Reference<?>>(); new ConcurrentHashMap<>();
/** queue for WeakReferences to local classes */ /** queue for WeakReferences to local classes */
private static final ReferenceQueue<Class<?>> localDescsQueue = private static final ReferenceQueue<Class<?>> localDescsQueue =
new ReferenceQueue<Class<?>>(); new ReferenceQueue<>();
/** queue for WeakReferences to field reflectors keys */ /** queue for WeakReferences to field reflectors keys */
private static final ReferenceQueue<Class<?>> reflectorsQueue = private static final ReferenceQueue<Class<?>> reflectorsQueue =
new ReferenceQueue<Class<?>>(); new ReferenceQueue<>();
} }
/** class associated with this descriptor (if any) */ /** class associated with this descriptor (if any) */
...@@ -290,7 +290,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -290,7 +290,7 @@ public class ObjectStreamClass implements Serializable {
EntryFuture future = null; EntryFuture future = null;
if (entry == null) { if (entry == null) {
EntryFuture newEntry = new EntryFuture(); EntryFuture newEntry = new EntryFuture();
Reference<?> newRef = new SoftReference<EntryFuture>(newEntry); Reference<?> newRef = new SoftReference<>(newEntry);
do { do {
if (ref != null) { if (ref != null) {
Caches.localDescs.remove(key, ref); Caches.localDescs.remove(key, ref);
...@@ -329,7 +329,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -329,7 +329,7 @@ public class ObjectStreamClass implements Serializable {
entry = th; entry = th;
} }
if (future.set(entry)) { if (future.set(entry)) {
Caches.localDescs.put(key, new SoftReference<Object>(entry)); Caches.localDescs.put(key, new SoftReference<>(entry));
} else { } else {
// nested lookup call already set future // nested lookup call already set future
entry = future.get(); entry = future.get();
...@@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable {
private ClassDataSlot[] getClassDataLayout0() private ClassDataSlot[] getClassDataLayout0()
throws InvalidClassException throws InvalidClassException
{ {
ArrayList<ClassDataSlot> slots = new ArrayList<ClassDataSlot>(); ArrayList<ClassDataSlot> slots = new ArrayList<>();
Class<?> start = cl, end = cl; Class<?> start = cl, end = cl;
// locate closest non-serializable superclass // locate closest non-serializable superclass
...@@ -1566,7 +1566,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1566,7 +1566,7 @@ public class ObjectStreamClass implements Serializable {
ObjectStreamField[] boundFields = ObjectStreamField[] boundFields =
new ObjectStreamField[serialPersistentFields.length]; new ObjectStreamField[serialPersistentFields.length];
Set<String> fieldNames = new HashSet<String>(serialPersistentFields.length); Set<String> fieldNames = new HashSet<>(serialPersistentFields.length);
for (int i = 0; i < serialPersistentFields.length; i++) { for (int i = 0; i < serialPersistentFields.length; i++) {
ObjectStreamField spf = serialPersistentFields[i]; ObjectStreamField spf = serialPersistentFields[i];
...@@ -1604,7 +1604,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -1604,7 +1604,7 @@ public class ObjectStreamClass implements Serializable {
*/ */
private static ObjectStreamField[] getDefaultSerialFields(Class<?> cl) { private static ObjectStreamField[] getDefaultSerialFields(Class<?> cl) {
Field[] clFields = cl.getDeclaredFields(); Field[] clFields = cl.getDeclaredFields();
ArrayList<ObjectStreamField> list = new ArrayList<ObjectStreamField>(); ArrayList<ObjectStreamField> list = new ArrayList<>();
int mask = Modifier.STATIC | Modifier.TRANSIENT; int mask = Modifier.STATIC | Modifier.TRANSIENT;
for (int i = 0; i < clFields.length; i++) { for (int i = 0; i < clFields.length; i++) {
...@@ -1855,8 +1855,8 @@ public class ObjectStreamClass implements Serializable { ...@@ -1855,8 +1855,8 @@ public class ObjectStreamClass implements Serializable {
writeKeys = new long[nfields]; writeKeys = new long[nfields];
offsets = new int[nfields]; offsets = new int[nfields];
typeCodes = new char[nfields]; typeCodes = new char[nfields];
ArrayList<Class<?>> typeList = new ArrayList<Class<?>>(); ArrayList<Class<?>> typeList = new ArrayList<>();
Set<Long> usedKeys = new HashSet<Long>(); Set<Long> usedKeys = new HashSet<>();
for (int i = 0; i < nfields; i++) { for (int i = 0; i < nfields; i++) {
...@@ -2092,7 +2092,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -2092,7 +2092,7 @@ public class ObjectStreamClass implements Serializable {
EntryFuture future = null; EntryFuture future = null;
if (entry == null) { if (entry == null) {
EntryFuture newEntry = new EntryFuture(); EntryFuture newEntry = new EntryFuture();
Reference<?> newRef = new SoftReference<EntryFuture>(newEntry); Reference<?> newRef = new SoftReference<>(newEntry);
do { do {
if (ref != null) { if (ref != null) {
Caches.reflectors.remove(key, ref); Caches.reflectors.remove(key, ref);
...@@ -2118,7 +2118,7 @@ public class ObjectStreamClass implements Serializable { ...@@ -2118,7 +2118,7 @@ public class ObjectStreamClass implements Serializable {
entry = th; entry = th;
} }
future.set(entry); future.set(entry);
Caches.reflectors.put(key, new SoftReference<Object>(entry)); Caches.reflectors.put(key, new SoftReference<>(entry));
} }
if (entry instanceof FieldReflector) { if (entry instanceof FieldReflector) {
......
...@@ -47,7 +47,7 @@ class ApplicationShutdownHooks { ...@@ -47,7 +47,7 @@ class ApplicationShutdownHooks {
} }
} }
); );
hooks = new IdentityHashMap<Thread, Thread>(); hooks = new IdentityHashMap<>();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// application shutdown hooks cannot be added if // application shutdown hooks cannot be added if
// shutdown is in progress. // shutdown is in progress.
......
...@@ -648,8 +648,7 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -648,8 +648,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
*/ */
public static final class UnicodeBlock extends Subset { public static final class UnicodeBlock extends Subset {
private static Map<String, UnicodeBlock> map private static Map<String, UnicodeBlock> map = new HashMap<>(256);
= new HashMap<String, UnicodeBlock>(256);
/** /**
* Creates a UnicodeBlock with the given identifier name. * Creates a UnicodeBlock with the given identifier name.
...@@ -4178,7 +4177,7 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -4178,7 +4177,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
private static HashMap<String, Character.UnicodeScript> aliases; private static HashMap<String, Character.UnicodeScript> aliases;
static { static {
aliases = new HashMap<String, UnicodeScript>(128); aliases = new HashMap<>(128);
aliases.put("ARAB", ARABIC); aliases.put("ARAB", ARABIC);
aliases.put("ARMI", IMPERIAL_ARAMAIC); aliases.put("ARMI", IMPERIAL_ARAMAIC);
aliases.put("ARMN", ARMENIAN); aliases.put("ARMN", ARMENIAN);
......
...@@ -81,7 +81,7 @@ class CharacterName { ...@@ -81,7 +81,7 @@ class CharacterName {
} while (cpOff < cpEnd); } while (cpOff < cpEnd);
strPool = new byte[total - cpEnd]; strPool = new byte[total - cpEnd];
dis.readFully(strPool); dis.readFully(strPool);
refStrPool = new SoftReference<byte[]>(strPool); refStrPool = new SoftReference<>(strPool);
} catch (Exception x) { } catch (Exception x) {
throw new InternalError(x.getMessage()); throw new InternalError(x.getMessage());
} finally { } finally {
......
...@@ -1306,7 +1306,7 @@ public final ...@@ -1306,7 +1306,7 @@ public final
return java.security.AccessController.doPrivileged( return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Class<?>[]>() { new java.security.PrivilegedAction<Class<?>[]>() {
public Class[] run() { public Class[] run() {
List<Class<?>> list = new ArrayList<Class<?>>(); List<Class<?>> list = new ArrayList<>();
Class<?> currentClass = Class.this; Class<?> currentClass = Class.this;
while (currentClass != null) { while (currentClass != null) {
Class<?>[] members = currentClass.getDeclaredClasses(); Class<?>[] members = currentClass.getDeclaredClasses();
...@@ -2306,9 +2306,9 @@ public final ...@@ -2306,9 +2306,9 @@ public final
res = Reflection.filterFields(this, getDeclaredFields0(publicOnly)); res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
declaredPublicFields = new SoftReference<Field[]>(res); declaredPublicFields = new SoftReference<>(res);
} else { } else {
declaredFields = new SoftReference<Field[]>(res); declaredFields = new SoftReference<>(res);
} }
} }
return res; return res;
...@@ -2330,9 +2330,9 @@ public final ...@@ -2330,9 +2330,9 @@ public final
// No cached value available; compute value recursively. // No cached value available; compute value recursively.
// Traverse in correct order for getField(). // Traverse in correct order for getField().
List<Field> fields = new ArrayList<Field>(); List<Field> fields = new ArrayList<>();
if (traversedInterfaces == null) { if (traversedInterfaces == null) {
traversedInterfaces = new HashSet<Class<?>>(); traversedInterfaces = new HashSet<>();
} }
// Local fields // Local fields
...@@ -2358,7 +2358,7 @@ public final ...@@ -2358,7 +2358,7 @@ public final
res = new Field[fields.size()]; res = new Field[fields.size()];
fields.toArray(res); fields.toArray(res);
if (useCaches) { if (useCaches) {
publicFields = new SoftReference<Field[]>(res); publicFields = new SoftReference<>(res);
} }
return res; return res;
} }
...@@ -2403,9 +2403,9 @@ public final ...@@ -2403,9 +2403,9 @@ public final
} }
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
publicConstructors = new SoftReference<Constructor<T>[]>(res); publicConstructors = new SoftReference<>(res);
} else { } else {
declaredConstructors = new SoftReference<Constructor<T>[]>(res); declaredConstructors = new SoftReference<>(res);
} }
} }
return res; return res;
...@@ -2440,9 +2440,9 @@ public final ...@@ -2440,9 +2440,9 @@ public final
res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly)); res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
if (useCaches) { if (useCaches) {
if (publicOnly) { if (publicOnly) {
declaredPublicMethods = new SoftReference<Method[]>(res); declaredPublicMethods = new SoftReference<>(res);
} else { } else {
declaredMethods = new SoftReference<Method[]>(res); declaredMethods = new SoftReference<>(res);
} }
} }
return res; return res;
...@@ -2598,7 +2598,7 @@ public final ...@@ -2598,7 +2598,7 @@ public final
methods.compactAndTrim(); methods.compactAndTrim();
res = methods.getArray(); res = methods.getArray();
if (useCaches) { if (useCaches) {
publicMethods = new SoftReference<Method[]>(res); publicMethods = new SoftReference<>(res);
} }
return res; return res;
} }
...@@ -2977,7 +2977,7 @@ public final ...@@ -2977,7 +2977,7 @@ public final
if (universe == null) if (universe == null)
throw new IllegalArgumentException( throw new IllegalArgumentException(
getName() + " is not an enum type"); getName() + " is not an enum type");
Map<String, T> m = new HashMap<String, T>(2 * universe.length); Map<String, T> m = new HashMap<>(2 * universe.length);
for (T constant : universe) for (T constant : universe)
m.put(((Enum<?>)constant).name(), constant); m.put(((Enum<?>)constant).name(), constant);
enumConstantDirectory = m; enumConstantDirectory = m;
...@@ -3090,7 +3090,7 @@ public final ...@@ -3090,7 +3090,7 @@ public final
if (superClass == null) { if (superClass == null) {
annotations = declaredAnnotations; annotations = declaredAnnotations;
} else { } else {
annotations = new HashMap<Class<? extends Annotation>, Annotation>(); annotations = new HashMap<>();
superClass.initAnnotationsIfNecessary(); superClass.initAnnotationsIfNecessary();
for (Map.Entry<Class<? extends Annotation>, Annotation> e : superClass.annotations.entrySet()) { for (Map.Entry<Class<? extends Annotation>, Annotation> e : superClass.annotations.entrySet()) {
Class<? extends Annotation> annotationClass = e.getKey(); Class<? extends Annotation> annotationClass = e.getKey();
......
...@@ -247,7 +247,7 @@ public abstract class ClassLoader { ...@@ -247,7 +247,7 @@ public abstract class ClassLoader {
// The classes loaded by this class loader. The only purpose of this table // The classes loaded by this class loader. The only purpose of this table
// is to keep the classes from being GC'ed until the loader is GC'ed. // is to keep the classes from being GC'ed until the loader is GC'ed.
private final Vector<Class<?>> classes = new Vector<Class<?>>(); private final Vector<Class<?>> classes = new Vector<>();
// The "default" domain. Set as the default ProtectionDomain on newly // The "default" domain. Set as the default ProtectionDomain on newly
// created classes. // created classes.
...@@ -266,8 +266,7 @@ public abstract class ClassLoader { ...@@ -266,8 +266,7 @@ public abstract class ClassLoader {
// The packages defined in this class loader. Each package name is mapped // The packages defined in this class loader. Each package name is mapped
// to its corresponding Package object. // to its corresponding Package object.
// @GuardedBy("itself") // @GuardedBy("itself")
private final HashMap<String, Package> packages = private final HashMap<String, Package> packages = new HashMap<>();
new HashMap<String, Package>();
private static Void checkCreateClassLoader() { private static Void checkCreateClassLoader() {
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
...@@ -280,16 +279,16 @@ public abstract class ClassLoader { ...@@ -280,16 +279,16 @@ public abstract class ClassLoader {
private ClassLoader(Void unused, ClassLoader parent) { private ClassLoader(Void unused, ClassLoader parent) {
this.parent = parent; this.parent = parent;
if (ParallelLoaders.isRegistered(this.getClass())) { if (ParallelLoaders.isRegistered(this.getClass())) {
parallelLockMap = new ConcurrentHashMap<String, Object>(); parallelLockMap = new ConcurrentHashMap<>();
package2certs = new ConcurrentHashMap<String, Certificate[]>(); package2certs = new ConcurrentHashMap<>();
domains = domains =
Collections.synchronizedSet(new HashSet<ProtectionDomain>()); Collections.synchronizedSet(new HashSet<ProtectionDomain>());
assertionLock = new Object(); assertionLock = new Object();
} else { } else {
// no finer-grained lock; lock on the classloader instance // no finer-grained lock; lock on the classloader instance
parallelLockMap = null; parallelLockMap = null;
package2certs = new Hashtable<String, Certificate[]>(); package2certs = new Hashtable<>();
domains = new HashSet<ProtectionDomain>(); domains = new HashSet<>();
assertionLock = this; assertionLock = this;
} }
} }
...@@ -1182,7 +1181,7 @@ public abstract class ClassLoader { ...@@ -1182,7 +1181,7 @@ public abstract class ClassLoader {
} }
tmp[1] = findResources(name); tmp[1] = findResources(name);
return new CompoundEnumeration<URL>(tmp); return new CompoundEnumeration<>(tmp);
} }
/** /**
...@@ -1657,7 +1656,7 @@ public abstract class ClassLoader { ...@@ -1657,7 +1656,7 @@ public abstract class ClassLoader {
protected Package[] getPackages() { protected Package[] getPackages() {
Map<String, Package> map; Map<String, Package> map;
synchronized (packages) { synchronized (packages) {
map = new HashMap<String, Package>(packages); map = new HashMap<>(packages);
} }
Package[] pkgs; Package[] pkgs;
if (parent != null) { if (parent != null) {
...@@ -1764,20 +1763,17 @@ public abstract class ClassLoader { ...@@ -1764,20 +1763,17 @@ public abstract class ClassLoader {
} }
// All native library names we've loaded. // All native library names we've loaded.
private static Vector<String> loadedLibraryNames private static Vector<String> loadedLibraryNames = new Vector<>();
= new Vector<String>();
// Native libraries belonging to system classes. // Native libraries belonging to system classes.
private static Vector<NativeLibrary> systemNativeLibraries private static Vector<NativeLibrary> systemNativeLibraries
= new Vector<NativeLibrary>(); = new Vector<>();
// Native libraries associated with the class loader. // Native libraries associated with the class loader.
private Vector<NativeLibrary> nativeLibraries private Vector<NativeLibrary> nativeLibraries = new Vector<>();
= new Vector<NativeLibrary>();
// native libraries being loaded/unloaded. // native libraries being loaded/unloaded.
private static Stack<NativeLibrary> nativeLibraryContext private static Stack<NativeLibrary> nativeLibraryContext = new Stack<>();
= new Stack<NativeLibrary>();
// The paths searched for libraries // The paths searched for libraries
private static String usr_paths[]; private static String usr_paths[];
...@@ -2101,8 +2097,8 @@ public abstract class ClassLoader { ...@@ -2101,8 +2097,8 @@ public abstract class ClassLoader {
* them to empty maps, effectively ignoring any present settings. * them to empty maps, effectively ignoring any present settings.
*/ */
synchronized (assertionLock) { synchronized (assertionLock) {
classAssertionStatus = new HashMap<String, Boolean>(); classAssertionStatus = new HashMap<>();
packageAssertionStatus = new HashMap<String, Boolean>(); packageAssertionStatus = new HashMap<>();
defaultAssertionStatus = false; defaultAssertionStatus = false;
} }
} }
...@@ -2164,8 +2160,8 @@ public abstract class ClassLoader { ...@@ -2164,8 +2160,8 @@ public abstract class ClassLoader {
private void initializeJavaAssertionMaps() { private void initializeJavaAssertionMaps() {
// assert Thread.holdsLock(assertionLock); // assert Thread.holdsLock(assertionLock);
classAssertionStatus = new HashMap<String, Boolean>(); classAssertionStatus = new HashMap<>();
packageAssertionStatus = new HashMap<String, Boolean>(); packageAssertionStatus = new HashMap<>();
AssertionStatusDirectives directives = retrieveDirectives(); AssertionStatusDirectives directives = retrieveDirectives();
for(int i = 0; i < directives.classes.length; i++) for(int i = 0; i < directives.classes.length; i++)
......
...@@ -588,16 +588,13 @@ public class Package implements java.lang.reflect.AnnotatedElement { ...@@ -588,16 +588,13 @@ public class Package implements java.lang.reflect.AnnotatedElement {
} }
// The map of loaded system packages // The map of loaded system packages
private static Map<String, Package> pkgs private static Map<String, Package> pkgs = new HashMap<>(31);
= new HashMap<String, Package>(31);
// Maps each directory or zip file name to its corresponding url // Maps each directory or zip file name to its corresponding url
private static Map<String, URL> urls private static Map<String, URL> urls = new HashMap<>(10);
= new HashMap<String, URL>(10);
// Maps each code source url for a jar file to its manifest // Maps each code source url for a jar file to its manifest
private static Map<String, Manifest> mans private static Map<String, Manifest> mans = new HashMap<>(10);
= new HashMap<String, Manifest>(10);
private static native String getSystemPackage0(String name); private static native String getSystemPackage0(String name);
private static native String[] getSystemPackages0(); private static native String[] getSystemPackages0();
......
...@@ -214,7 +214,7 @@ public final class ProcessBuilder ...@@ -214,7 +214,7 @@ public final class ProcessBuilder
* @param command a string array containing the program and its arguments * @param command a string array containing the program and its arguments
*/ */
public ProcessBuilder(String... command) { public ProcessBuilder(String... command) {
this.command = new ArrayList<String>(command.length); this.command = new ArrayList<>(command.length);
for (String arg : command) for (String arg : command)
this.command.add(arg); this.command.add(arg);
} }
...@@ -251,7 +251,7 @@ public final class ProcessBuilder ...@@ -251,7 +251,7 @@ public final class ProcessBuilder
* @return this process builder * @return this process builder
*/ */
public ProcessBuilder command(String... command) { public ProcessBuilder command(String... command) {
this.command = new ArrayList<String>(command.length); this.command = new ArrayList<>(command.length);
for (String arg : command) for (String arg : command)
this.command.add(arg); this.command.add(arg);
return this; return this;
......
...@@ -2330,7 +2330,7 @@ public final class String ...@@ -2330,7 +2330,7 @@ public final class String
int off = 0; int off = 0;
int next = 0; int next = 0;
boolean limited = limit > 0; boolean limited = limit > 0;
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<>();
while ((next = indexOf(ch, off)) != -1) { while ((next = indexOf(ch, off)) != -1) {
if (!limited || list.size() < limit - 1) { if (!limited || list.size() < limit - 1) {
list.add(substring(off, next)); list.add(substring(off, next));
......
...@@ -53,9 +53,9 @@ class StringCoding { ...@@ -53,9 +53,9 @@ class StringCoding {
/** The cached coders for each thread */ /** The cached coders for each thread */
private final static ThreadLocal<SoftReference<StringDecoder>> decoder = private final static ThreadLocal<SoftReference<StringDecoder>> decoder =
new ThreadLocal<SoftReference<StringDecoder>>(); new ThreadLocal<>();
private final static ThreadLocal<SoftReference<StringEncoder>> encoder = private final static ThreadLocal<SoftReference<StringEncoder>> encoder =
new ThreadLocal<SoftReference<StringEncoder>>(); new ThreadLocal<>();
private static boolean warnUnsupportedCharset = true; private static boolean warnUnsupportedCharset = true;
...@@ -67,7 +67,7 @@ class StringCoding { ...@@ -67,7 +67,7 @@ class StringCoding {
} }
private static <T> void set(ThreadLocal<SoftReference<T>> tl, T ob) { private static <T> void set(ThreadLocal<SoftReference<T>> tl, T ob) {
tl.set(new SoftReference<T>(ob)); tl.set(new SoftReference<>(ob));
} }
// Trim the given byte array to the given length // Trim the given byte array to the given length
......
...@@ -1642,8 +1642,7 @@ class Thread implements Runnable { ...@@ -1642,8 +1642,7 @@ class Thread implements Runnable {
// Get a snapshot of the list of all threads // Get a snapshot of the list of all threads
Thread[] threads = getThreads(); Thread[] threads = getThreads();
StackTraceElement[][] traces = dumpThreads(threads); StackTraceElement[][] traces = dumpThreads(threads);
Map<Thread, StackTraceElement[]> m Map<Thread, StackTraceElement[]> m = new HashMap<>(threads.length);
= new HashMap<Thread, StackTraceElement[]>(threads.length);
for (int i = 0; i < threads.length; i++) { for (int i = 0; i < threads.length; i++) {
StackTraceElement[] stackTrace = traces[i]; StackTraceElement[] stackTrace = traces[i];
if (stackTrace != null) { if (stackTrace != null) {
...@@ -1664,11 +1663,11 @@ class Thread implements Runnable { ...@@ -1664,11 +1663,11 @@ class Thread implements Runnable {
private static class Caches { private static class Caches {
/** cache of subclass security audit results */ /** cache of subclass security audit results */
static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits = static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
new ConcurrentHashMap<WeakClassKey,Boolean>(); new ConcurrentHashMap<>();
/** queue for WeakReferences to audited subclasses */ /** queue for WeakReferences to audited subclasses */
static final ReferenceQueue<Class<?>> subclassAuditsQueue = static final ReferenceQueue<Class<?>> subclassAuditsQueue =
new ReferenceQueue<Class<?>>(); new ReferenceQueue<>();
} }
/** /**
......
...@@ -828,7 +828,7 @@ public class Throwable implements Serializable { ...@@ -828,7 +828,7 @@ public class Throwable implements Serializable {
// Use the sentinel for a zero-length list // Use the sentinel for a zero-length list
suppressed = SUPPRESSED_SENTINEL; suppressed = SUPPRESSED_SENTINEL;
} else { // Copy Throwables to new list } else { // Copy Throwables to new list
suppressed = new ArrayList<Throwable>(1); suppressed = new ArrayList<>(1);
for (Throwable t : suppressedExceptions) { for (Throwable t : suppressedExceptions) {
// Enforce constraints on suppressed exceptions in // Enforce constraints on suppressed exceptions in
// case of corrupt or malicious stream. // case of corrupt or malicious stream.
...@@ -911,7 +911,7 @@ public class Throwable implements Serializable { ...@@ -911,7 +911,7 @@ public class Throwable implements Serializable {
return; return;
if (suppressedExceptions == SUPPRESSED_SENTINEL) if (suppressedExceptions == SUPPRESSED_SENTINEL)
suppressedExceptions = new ArrayList<Throwable>(1); suppressedExceptions = new ArrayList<>(1);
assert suppressedExceptions != SUPPRESSED_SENTINEL; assert suppressedExceptions != SUPPRESSED_SENTINEL;
......
...@@ -794,7 +794,7 @@ public class ManagementFactory { ...@@ -794,7 +794,7 @@ public class ManagementFactory {
*/ */
public static List<Class<? extends PlatformManagedObject>> getAllPlatformMXBeanInterfaces() { public static List<Class<? extends PlatformManagedObject>> getAllPlatformMXBeanInterfaces() {
List<Class<? extends PlatformManagedObject>> result = List<Class<? extends PlatformManagedObject>> result =
new ArrayList<Class<? extends PlatformManagedObject>>(); new ArrayList<>();
for (PlatformComponent component: PlatformComponent.values()) { for (PlatformComponent component: PlatformComponent.values()) {
result.add(component.getMXBeanInterface()); result.add(component.getMXBeanInterface());
} }
......
...@@ -267,7 +267,7 @@ enum PlatformComponent { ...@@ -267,7 +267,7 @@ enum PlatformComponent {
List<T> getGcMXBeanList(Class<T> gcMXBeanIntf) { List<T> getGcMXBeanList(Class<T> gcMXBeanIntf) {
List<GarbageCollectorMXBean> list = List<GarbageCollectorMXBean> list =
ManagementFactoryHelper.getGarbageCollectorMXBeans(); ManagementFactoryHelper.getGarbageCollectorMXBeans();
List<T> result = new ArrayList<T>(list.size()); List<T> result = new ArrayList<>(list.size());
for (GarbageCollectorMXBean m : list) { for (GarbageCollectorMXBean m : list) {
if (gcMXBeanIntf.isInstance(m)) { if (gcMXBeanIntf.isInstance(m)) {
result.add(gcMXBeanIntf.cast(m)); result.add(gcMXBeanIntf.cast(m));
...@@ -330,7 +330,7 @@ enum PlatformComponent { ...@@ -330,7 +330,7 @@ enum PlatformComponent {
} }
private static Set<String> keyProperties(String... keyNames) { private static Set<String> keyProperties(String... keyNames) {
Set<String> set = new HashSet<String>(); Set<String> set = new HashSet<>();
set.add("type"); set.add("type");
for (String s : keyNames) { for (String s : keyNames) {
set.add(s); set.add(s);
...@@ -364,7 +364,7 @@ enum PlatformComponent { ...@@ -364,7 +364,7 @@ enum PlatformComponent {
List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface) List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
throws java.io.IOException throws java.io.IOException
{ {
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<>();
for (ObjectName on : getObjectNames(mbs)) { for (ObjectName on : getObjectNames(mbs)) {
result.add(ManagementFactory. result.add(ManagementFactory.
newPlatformMXBeanProxy(mbs, newPlatformMXBeanProxy(mbs,
......
...@@ -144,7 +144,7 @@ public final ...@@ -144,7 +144,7 @@ public final
// which implicitly requires that new java.lang.reflect // which implicitly requires that new java.lang.reflect
// objects be fabricated for each reflective call on Class // objects be fabricated for each reflective call on Class
// objects.) // objects.)
Constructor<T> res = new Constructor<T>(clazz, Constructor<T> res = new Constructor<>(clazz,
parameterTypes, parameterTypes,
exceptionTypes, modifiers, slot, exceptionTypes, modifiers, slot,
signature, signature,
......
...@@ -232,7 +232,7 @@ public class Proxy implements java.io.Serializable { ...@@ -232,7 +232,7 @@ public class Proxy implements java.io.Serializable {
/** maps a class loader to the proxy class cache for that loader */ /** maps a class loader to the proxy class cache for that loader */
private static Map<ClassLoader, Map<List<String>, Object>> loaderToCache private static Map<ClassLoader, Map<List<String>, Object>> loaderToCache
= new WeakHashMap<ClassLoader, Map<List<String>, Object>>(); = new WeakHashMap<>();
/** marks that a particular proxy class is currently being generated */ /** marks that a particular proxy class is currently being generated */
private static Object pendingGenerationMarker = new Object(); private static Object pendingGenerationMarker = new Object();
...@@ -356,7 +356,7 @@ public class Proxy implements java.io.Serializable { ...@@ -356,7 +356,7 @@ public class Proxy implements java.io.Serializable {
String[] interfaceNames = new String[interfaces.length]; String[] interfaceNames = new String[interfaces.length];
// for detecting duplicates // for detecting duplicates
Set<Class<?>> interfaceSet = new HashSet<Class<?>>(); Set<Class<?>> interfaceSet = new HashSet<>();
for (int i = 0; i < interfaces.length; i++) { for (int i = 0; i < interfaces.length; i++) {
/* /*
...@@ -413,7 +413,7 @@ public class Proxy implements java.io.Serializable { ...@@ -413,7 +413,7 @@ public class Proxy implements java.io.Serializable {
synchronized (loaderToCache) { synchronized (loaderToCache) {
cache = loaderToCache.get(loader); cache = loaderToCache.get(loader);
if (cache == null) { if (cache == null) {
cache = new HashMap<List<String>, Object>(); cache = new HashMap<>();
loaderToCache.put(loader, cache); loaderToCache.put(loader, cache);
} }
/* /*
......
...@@ -84,7 +84,7 @@ class ReflectAccess implements sun.reflect.LangReflectAccess { ...@@ -84,7 +84,7 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
byte[] annotations, byte[] annotations,
byte[] parameterAnnotations) byte[] parameterAnnotations)
{ {
return new Constructor<T>(declaringClass, return new Constructor<>(declaringClass,
parameterTypes, parameterTypes,
checkedExceptions, checkedExceptions,
modifiers, modifiers,
......
...@@ -364,7 +364,7 @@ public class DriverManager { ...@@ -364,7 +364,7 @@ public class DriverManager {
* @return the list of JDBC Drivers loaded by the caller's class loader * @return the list of JDBC Drivers loaded by the caller's class loader
*/ */
public static java.util.Enumeration<Driver> getDrivers() { public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<Driver>(); java.util.Vector<Driver> result = new java.util.Vector<>();
java.util.Vector drivers = null; java.util.Vector drivers = null;
if (!initialized) { if (!initialized) {
......
...@@ -482,8 +482,8 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L ...@@ -482,8 +482,8 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
*/ */
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return (this instanceof RandomAccess ? return (this instanceof RandomAccess ?
new RandomAccessSubList<E>(this, fromIndex, toIndex) : new RandomAccessSubList<>(this, fromIndex, toIndex) :
new SubList<E>(this, fromIndex, toIndex)); new SubList<>(this, fromIndex, toIndex));
} }
// Comparison and hashing // Comparison and hashing
...@@ -747,7 +747,7 @@ class SubList<E> extends AbstractList<E> { ...@@ -747,7 +747,7 @@ class SubList<E> extends AbstractList<E> {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new SubList<E>(this, fromIndex, toIndex); return new SubList<>(this, fromIndex, toIndex);
} }
private void rangeCheck(int index) { private void rangeCheck(int index) {
...@@ -776,6 +776,6 @@ class RandomAccessSubList<E> extends SubList<E> implements RandomAccess { ...@@ -776,6 +776,6 @@ class RandomAccessSubList<E> extends SubList<E> implements RandomAccess {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new RandomAccessSubList<E>(this, fromIndex, toIndex); return new RandomAccessSubList<>(this, fromIndex, toIndex);
} }
} }
...@@ -2824,7 +2824,7 @@ public class Arrays { ...@@ -2824,7 +2824,7 @@ public class Arrays {
* @return a list view of the specified array * @return a list view of the specified array
*/ */
public static <T> List<T> asList(T... a) { public static <T> List<T> asList(T... a) {
return new ArrayList<T>(a); return new ArrayList<>(a);
} }
/** /**
......
...@@ -1035,7 +1035,7 @@ public class Collections { ...@@ -1035,7 +1035,7 @@ public class Collections {
* @return an unmodifiable view of the specified collection. * @return an unmodifiable view of the specified collection.
*/ */
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c) { public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c) {
return new UnmodifiableCollection<T>(c); return new UnmodifiableCollection<>(c);
} }
/** /**
...@@ -1109,7 +1109,7 @@ public class Collections { ...@@ -1109,7 +1109,7 @@ public class Collections {
* @return an unmodifiable view of the specified set. * @return an unmodifiable view of the specified set.
*/ */
public static <T> Set<T> unmodifiableSet(Set<? extends T> s) { public static <T> Set<T> unmodifiableSet(Set<? extends T> s) {
return new UnmodifiableSet<T>(s); return new UnmodifiableSet<>(s);
} }
/** /**
...@@ -1141,7 +1141,7 @@ public class Collections { ...@@ -1141,7 +1141,7 @@ public class Collections {
* @return an unmodifiable view of the specified sorted set. * @return an unmodifiable view of the specified sorted set.
*/ */
public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s) { public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s) {
return new UnmodifiableSortedSet<T>(s); return new UnmodifiableSortedSet<>(s);
} }
/** /**
...@@ -1158,13 +1158,13 @@ public class Collections { ...@@ -1158,13 +1158,13 @@ public class Collections {
public Comparator<? super E> comparator() {return ss.comparator();} public Comparator<? super E> comparator() {return ss.comparator();}
public SortedSet<E> subSet(E fromElement, E toElement) { public SortedSet<E> subSet(E fromElement, E toElement) {
return new UnmodifiableSortedSet<E>(ss.subSet(fromElement,toElement)); return new UnmodifiableSortedSet<>(ss.subSet(fromElement,toElement));
} }
public SortedSet<E> headSet(E toElement) { public SortedSet<E> headSet(E toElement) {
return new UnmodifiableSortedSet<E>(ss.headSet(toElement)); return new UnmodifiableSortedSet<>(ss.headSet(toElement));
} }
public SortedSet<E> tailSet(E fromElement) { public SortedSet<E> tailSet(E fromElement) {
return new UnmodifiableSortedSet<E>(ss.tailSet(fromElement)); return new UnmodifiableSortedSet<>(ss.tailSet(fromElement));
} }
public E first() {return ss.first();} public E first() {return ss.first();}
...@@ -1188,8 +1188,8 @@ public class Collections { ...@@ -1188,8 +1188,8 @@ public class Collections {
*/ */
public static <T> List<T> unmodifiableList(List<? extends T> list) { public static <T> List<T> unmodifiableList(List<? extends T> list) {
return (list instanceof RandomAccess ? return (list instanceof RandomAccess ?
new UnmodifiableRandomAccessList<T>(list) : new UnmodifiableRandomAccessList<>(list) :
new UnmodifiableList<T>(list)); new UnmodifiableList<>(list));
} }
/** /**
...@@ -1250,7 +1250,7 @@ public class Collections { ...@@ -1250,7 +1250,7 @@ public class Collections {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new UnmodifiableList<E>(list.subList(fromIndex, toIndex)); return new UnmodifiableList<>(list.subList(fromIndex, toIndex));
} }
/** /**
...@@ -1267,7 +1267,7 @@ public class Collections { ...@@ -1267,7 +1267,7 @@ public class Collections {
*/ */
private Object readResolve() { private Object readResolve() {
return (list instanceof RandomAccess return (list instanceof RandomAccess
? new UnmodifiableRandomAccessList<E>(list) ? new UnmodifiableRandomAccessList<>(list)
: this); : this);
} }
} }
...@@ -1283,7 +1283,7 @@ public class Collections { ...@@ -1283,7 +1283,7 @@ public class Collections {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new UnmodifiableRandomAccessList<E>( return new UnmodifiableRandomAccessList<>(
list.subList(fromIndex, toIndex)); list.subList(fromIndex, toIndex));
} }
...@@ -1296,7 +1296,7 @@ public class Collections { ...@@ -1296,7 +1296,7 @@ public class Collections {
* deserialization. * deserialization.
*/ */
private Object writeReplace() { private Object writeReplace() {
return new UnmodifiableList<E>(list); return new UnmodifiableList<>(list);
} }
} }
...@@ -1315,7 +1315,7 @@ public class Collections { ...@@ -1315,7 +1315,7 @@ public class Collections {
* @return an unmodifiable view of the specified map. * @return an unmodifiable view of the specified map.
*/ */
public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K, ? extends V> m) { public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K, ? extends V> m) {
return new UnmodifiableMap<K,V>(m); return new UnmodifiableMap<>(m);
} }
/** /**
...@@ -1363,7 +1363,7 @@ public class Collections { ...@@ -1363,7 +1363,7 @@ public class Collections {
public Set<Map.Entry<K,V>> entrySet() { public Set<Map.Entry<K,V>> entrySet() {
if (entrySet==null) if (entrySet==null)
entrySet = new UnmodifiableEntrySet<K,V>(m.entrySet()); entrySet = new UnmodifiableEntrySet<>(m.entrySet());
return entrySet; return entrySet;
} }
...@@ -1400,7 +1400,7 @@ public class Collections { ...@@ -1400,7 +1400,7 @@ public class Collections {
return i.hasNext(); return i.hasNext();
} }
public Map.Entry<K,V> next() { public Map.Entry<K,V> next() {
return new UnmodifiableEntry<K,V>(i.next()); return new UnmodifiableEntry<>(i.next());
} }
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
...@@ -1411,7 +1411,7 @@ public class Collections { ...@@ -1411,7 +1411,7 @@ public class Collections {
public Object[] toArray() { public Object[] toArray() {
Object[] a = c.toArray(); Object[] a = c.toArray();
for (int i=0; i<a.length; i++) for (int i=0; i<a.length; i++)
a[i] = new UnmodifiableEntry<K,V>((Map.Entry<K,V>)a[i]); a[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)a[i]);
return a; return a;
} }
...@@ -1422,7 +1422,7 @@ public class Collections { ...@@ -1422,7 +1422,7 @@ public class Collections {
Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0)); Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
for (int i=0; i<arr.length; i++) for (int i=0; i<arr.length; i++)
arr[i] = new UnmodifiableEntry<K,V>((Map.Entry<K,V>)arr[i]); arr[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)arr[i]);
if (arr.length > a.length) if (arr.length > a.length)
return (T[])arr; return (T[])arr;
...@@ -1443,7 +1443,7 @@ public class Collections { ...@@ -1443,7 +1443,7 @@ public class Collections {
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
return c.contains( return c.contains(
new UnmodifiableEntry<Object,Object>((Map.Entry<?,?>) o)); new UnmodifiableEntry<>((Map.Entry<?,?>) o));
} }
/** /**
...@@ -1517,7 +1517,7 @@ public class Collections { ...@@ -1517,7 +1517,7 @@ public class Collections {
* @return an unmodifiable view of the specified sorted map. * @return an unmodifiable view of the specified sorted map.
*/ */
public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K, ? extends V> m) { public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K, ? extends V> m) {
return new UnmodifiableSortedMap<K,V>(m); return new UnmodifiableSortedMap<>(m);
} }
/** /**
...@@ -1535,13 +1535,13 @@ public class Collections { ...@@ -1535,13 +1535,13 @@ public class Collections {
public Comparator<? super K> comparator() {return sm.comparator();} public Comparator<? super K> comparator() {return sm.comparator();}
public SortedMap<K,V> subMap(K fromKey, K toKey) { public SortedMap<K,V> subMap(K fromKey, K toKey) {
return new UnmodifiableSortedMap<K,V>(sm.subMap(fromKey, toKey)); return new UnmodifiableSortedMap<>(sm.subMap(fromKey, toKey));
} }
public SortedMap<K,V> headMap(K toKey) { public SortedMap<K,V> headMap(K toKey) {
return new UnmodifiableSortedMap<K,V>(sm.headMap(toKey)); return new UnmodifiableSortedMap<>(sm.headMap(toKey));
} }
public SortedMap<K,V> tailMap(K fromKey) { public SortedMap<K,V> tailMap(K fromKey) {
return new UnmodifiableSortedMap<K,V>(sm.tailMap(fromKey)); return new UnmodifiableSortedMap<>(sm.tailMap(fromKey));
} }
public K firstKey() {return sm.firstKey();} public K firstKey() {return sm.firstKey();}
...@@ -1583,11 +1583,11 @@ public class Collections { ...@@ -1583,11 +1583,11 @@ public class Collections {
* @return a synchronized view of the specified collection. * @return a synchronized view of the specified collection.
*/ */
public static <T> Collection<T> synchronizedCollection(Collection<T> c) { public static <T> Collection<T> synchronizedCollection(Collection<T> c) {
return new SynchronizedCollection<T>(c); return new SynchronizedCollection<>(c);
} }
static <T> Collection<T> synchronizedCollection(Collection<T> c, Object mutex) { static <T> Collection<T> synchronizedCollection(Collection<T> c, Object mutex) {
return new SynchronizedCollection<T>(c, mutex); return new SynchronizedCollection<>(c, mutex);
} }
/** /**
...@@ -1686,11 +1686,11 @@ public class Collections { ...@@ -1686,11 +1686,11 @@ public class Collections {
* @return a synchronized view of the specified set. * @return a synchronized view of the specified set.
*/ */
public static <T> Set<T> synchronizedSet(Set<T> s) { public static <T> Set<T> synchronizedSet(Set<T> s) {
return new SynchronizedSet<T>(s); return new SynchronizedSet<>(s);
} }
static <T> Set<T> synchronizedSet(Set<T> s, Object mutex) { static <T> Set<T> synchronizedSet(Set<T> s, Object mutex) {
return new SynchronizedSet<T>(s, mutex); return new SynchronizedSet<>(s, mutex);
} }
/** /**
...@@ -1754,7 +1754,7 @@ public class Collections { ...@@ -1754,7 +1754,7 @@ public class Collections {
* @return a synchronized view of the specified sorted set. * @return a synchronized view of the specified sorted set.
*/ */
public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s) { public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s) {
return new SynchronizedSortedSet<T>(s); return new SynchronizedSortedSet<>(s);
} }
/** /**
...@@ -1783,18 +1783,18 @@ public class Collections { ...@@ -1783,18 +1783,18 @@ public class Collections {
public SortedSet<E> subSet(E fromElement, E toElement) { public SortedSet<E> subSet(E fromElement, E toElement) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedSet<E>( return new SynchronizedSortedSet<>(
ss.subSet(fromElement, toElement), mutex); ss.subSet(fromElement, toElement), mutex);
} }
} }
public SortedSet<E> headSet(E toElement) { public SortedSet<E> headSet(E toElement) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedSet<E>(ss.headSet(toElement), mutex); return new SynchronizedSortedSet<>(ss.headSet(toElement), mutex);
} }
} }
public SortedSet<E> tailSet(E fromElement) { public SortedSet<E> tailSet(E fromElement) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedSet<E>(ss.tailSet(fromElement),mutex); return new SynchronizedSortedSet<>(ss.tailSet(fromElement),mutex);
} }
} }
...@@ -1833,14 +1833,14 @@ public class Collections { ...@@ -1833,14 +1833,14 @@ public class Collections {
*/ */
public static <T> List<T> synchronizedList(List<T> list) { public static <T> List<T> synchronizedList(List<T> list) {
return (list instanceof RandomAccess ? return (list instanceof RandomAccess ?
new SynchronizedRandomAccessList<T>(list) : new SynchronizedRandomAccessList<>(list) :
new SynchronizedList<T>(list)); new SynchronizedList<>(list));
} }
static <T> List<T> synchronizedList(List<T> list, Object mutex) { static <T> List<T> synchronizedList(List<T> list, Object mutex) {
return (list instanceof RandomAccess ? return (list instanceof RandomAccess ?
new SynchronizedRandomAccessList<T>(list, mutex) : new SynchronizedRandomAccessList<>(list, mutex) :
new SynchronizedList<T>(list, mutex)); new SynchronizedList<>(list, mutex));
} }
/** /**
...@@ -1903,7 +1903,7 @@ public class Collections { ...@@ -1903,7 +1903,7 @@ public class Collections {
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedList<E>(list.subList(fromIndex, toIndex), return new SynchronizedList<>(list.subList(fromIndex, toIndex),
mutex); mutex);
} }
} }
...@@ -1922,7 +1922,7 @@ public class Collections { ...@@ -1922,7 +1922,7 @@ public class Collections {
*/ */
private Object readResolve() { private Object readResolve() {
return (list instanceof RandomAccess return (list instanceof RandomAccess
? new SynchronizedRandomAccessList<E>(list) ? new SynchronizedRandomAccessList<>(list)
: this); : this);
} }
} }
...@@ -1944,7 +1944,7 @@ public class Collections { ...@@ -1944,7 +1944,7 @@ public class Collections {
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedRandomAccessList<E>( return new SynchronizedRandomAccessList<>(
list.subList(fromIndex, toIndex), mutex); list.subList(fromIndex, toIndex), mutex);
} }
} }
...@@ -1958,7 +1958,7 @@ public class Collections { ...@@ -1958,7 +1958,7 @@ public class Collections {
* deserialization. * deserialization.
*/ */
private Object writeReplace() { private Object writeReplace() {
return new SynchronizedList<E>(list); return new SynchronizedList<>(list);
} }
} }
...@@ -1990,7 +1990,7 @@ public class Collections { ...@@ -1990,7 +1990,7 @@ public class Collections {
* @return a synchronized view of the specified map. * @return a synchronized view of the specified map.
*/ */
public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) { public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) {
return new SynchronizedMap<K,V>(m); return new SynchronizedMap<>(m);
} }
/** /**
...@@ -2051,7 +2051,7 @@ public class Collections { ...@@ -2051,7 +2051,7 @@ public class Collections {
public Set<K> keySet() { public Set<K> keySet() {
synchronized (mutex) { synchronized (mutex) {
if (keySet==null) if (keySet==null)
keySet = new SynchronizedSet<K>(m.keySet(), mutex); keySet = new SynchronizedSet<>(m.keySet(), mutex);
return keySet; return keySet;
} }
} }
...@@ -2059,7 +2059,7 @@ public class Collections { ...@@ -2059,7 +2059,7 @@ public class Collections {
public Set<Map.Entry<K,V>> entrySet() { public Set<Map.Entry<K,V>> entrySet() {
synchronized (mutex) { synchronized (mutex) {
if (entrySet==null) if (entrySet==null)
entrySet = new SynchronizedSet<Map.Entry<K,V>>(m.entrySet(), mutex); entrySet = new SynchronizedSet<>(m.entrySet(), mutex);
return entrySet; return entrySet;
} }
} }
...@@ -2067,7 +2067,7 @@ public class Collections { ...@@ -2067,7 +2067,7 @@ public class Collections {
public Collection<V> values() { public Collection<V> values() {
synchronized (mutex) { synchronized (mutex) {
if (values==null) if (values==null)
values = new SynchronizedCollection<V>(m.values(), mutex); values = new SynchronizedCollection<>(m.values(), mutex);
return values; return values;
} }
} }
...@@ -2129,7 +2129,7 @@ public class Collections { ...@@ -2129,7 +2129,7 @@ public class Collections {
* @return a synchronized view of the specified sorted map. * @return a synchronized view of the specified sorted map.
*/ */
public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m) { public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m) {
return new SynchronizedSortedMap<K,V>(m); return new SynchronizedSortedMap<>(m);
} }
...@@ -2159,18 +2159,18 @@ public class Collections { ...@@ -2159,18 +2159,18 @@ public class Collections {
public SortedMap<K,V> subMap(K fromKey, K toKey) { public SortedMap<K,V> subMap(K fromKey, K toKey) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedMap<K,V>( return new SynchronizedSortedMap<>(
sm.subMap(fromKey, toKey), mutex); sm.subMap(fromKey, toKey), mutex);
} }
} }
public SortedMap<K,V> headMap(K toKey) { public SortedMap<K,V> headMap(K toKey) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedMap<K,V>(sm.headMap(toKey), mutex); return new SynchronizedSortedMap<>(sm.headMap(toKey), mutex);
} }
} }
public SortedMap<K,V> tailMap(K fromKey) { public SortedMap<K,V> tailMap(K fromKey) {
synchronized (mutex) { synchronized (mutex) {
return new SynchronizedSortedMap<K,V>(sm.tailMap(fromKey),mutex); return new SynchronizedSortedMap<>(sm.tailMap(fromKey),mutex);
} }
} }
...@@ -2246,7 +2246,7 @@ public class Collections { ...@@ -2246,7 +2246,7 @@ public class Collections {
*/ */
public static <E> Collection<E> checkedCollection(Collection<E> c, public static <E> Collection<E> checkedCollection(Collection<E> c,
Class<E> type) { Class<E> type) {
return new CheckedCollection<E>(c, type); return new CheckedCollection<>(c, type);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -2378,7 +2378,7 @@ public class Collections { ...@@ -2378,7 +2378,7 @@ public class Collections {
* @since 1.5 * @since 1.5
*/ */
public static <E> Set<E> checkedSet(Set<E> s, Class<E> type) { public static <E> Set<E> checkedSet(Set<E> s, Class<E> type) {
return new CheckedSet<E>(s, type); return new CheckedSet<>(s, type);
} }
/** /**
...@@ -2424,7 +2424,7 @@ public class Collections { ...@@ -2424,7 +2424,7 @@ public class Collections {
*/ */
public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s, public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s,
Class<E> type) { Class<E> type) {
return new CheckedSortedSet<E>(s, type); return new CheckedSortedSet<>(s, type);
} }
/** /**
...@@ -2484,8 +2484,8 @@ public class Collections { ...@@ -2484,8 +2484,8 @@ public class Collections {
*/ */
public static <E> List<E> checkedList(List<E> list, Class<E> type) { public static <E> List<E> checkedList(List<E> list, Class<E> type) {
return (list instanceof RandomAccess ? return (list instanceof RandomAccess ?
new CheckedRandomAccessList<E>(list, type) : new CheckedRandomAccessList<>(list, type) :
new CheckedList<E>(list, type)); new CheckedList<>(list, type));
} }
/** /**
...@@ -2550,7 +2550,7 @@ public class Collections { ...@@ -2550,7 +2550,7 @@ public class Collections {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new CheckedList<E>(list.subList(fromIndex, toIndex), type); return new CheckedList<>(list.subList(fromIndex, toIndex), type);
} }
} }
...@@ -2567,7 +2567,7 @@ public class Collections { ...@@ -2567,7 +2567,7 @@ public class Collections {
} }
public List<E> subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return new CheckedRandomAccessList<E>( return new CheckedRandomAccessList<>(
list.subList(fromIndex, toIndex), type); list.subList(fromIndex, toIndex), type);
} }
} }
...@@ -2609,7 +2609,7 @@ public class Collections { ...@@ -2609,7 +2609,7 @@ public class Collections {
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, public static <K, V> Map<K, V> checkedMap(Map<K, V> m,
Class<K> keyType, Class<K> keyType,
Class<V> valueType) { Class<V> valueType) {
return new CheckedMap<K,V>(m, keyType, valueType); return new CheckedMap<>(m, keyType, valueType);
} }
...@@ -2677,15 +2677,14 @@ public class Collections { ...@@ -2677,15 +2677,14 @@ public class Collections {
// - protection from malicious t // - protection from malicious t
// - correct behavior if t is a concurrent map // - correct behavior if t is a concurrent map
Object[] entries = t.entrySet().toArray(); Object[] entries = t.entrySet().toArray();
List<Map.Entry<K,V>> checked = List<Map.Entry<K,V>> checked = new ArrayList<>(entries.length);
new ArrayList<Map.Entry<K,V>>(entries.length);
for (Object o : entries) { for (Object o : entries) {
Map.Entry<?,?> e = (Map.Entry<?,?>) o; Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Object k = e.getKey(); Object k = e.getKey();
Object v = e.getValue(); Object v = e.getValue();
typeCheck(k, v); typeCheck(k, v);
checked.add( checked.add(
new AbstractMap.SimpleImmutableEntry<K,V>((K) k, (V) v)); new AbstractMap.SimpleImmutableEntry<>((K) k, (V) v));
} }
for (Map.Entry<K,V> e : checked) for (Map.Entry<K,V> e : checked)
m.put(e.getKey(), e.getValue()); m.put(e.getKey(), e.getValue());
...@@ -2695,7 +2694,7 @@ public class Collections { ...@@ -2695,7 +2694,7 @@ public class Collections {
public Set<Map.Entry<K,V>> entrySet() { public Set<Map.Entry<K,V>> entrySet() {
if (entrySet==null) if (entrySet==null)
entrySet = new CheckedEntrySet<K,V>(m.entrySet(), valueType); entrySet = new CheckedEntrySet<>(m.entrySet(), valueType);
return entrySet; return entrySet;
} }
...@@ -2810,7 +2809,7 @@ public class Collections { ...@@ -2810,7 +2809,7 @@ public class Collections {
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
return s.remove(new AbstractMap.SimpleImmutableEntry return s.remove(new AbstractMap.SimpleImmutableEntry
<Object, Object>((Map.Entry<?,?>)o)); <>((Map.Entry<?,?>)o));
} }
public boolean removeAll(Collection<?> c) { public boolean removeAll(Collection<?> c) {
...@@ -2843,7 +2842,7 @@ public class Collections { ...@@ -2843,7 +2842,7 @@ public class Collections {
static <K,V,T> CheckedEntry<K,V,T> checkedEntry(Map.Entry<K,V> e, static <K,V,T> CheckedEntry<K,V,T> checkedEntry(Map.Entry<K,V> e,
Class<T> valueType) { Class<T> valueType) {
return new CheckedEntry<K,V,T>(e, valueType); return new CheckedEntry<>(e, valueType);
} }
/** /**
...@@ -2884,7 +2883,7 @@ public class Collections { ...@@ -2884,7 +2883,7 @@ public class Collections {
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
return e.equals(new AbstractMap.SimpleImmutableEntry return e.equals(new AbstractMap.SimpleImmutableEntry
<Object, Object>((Map.Entry<?,?>)o)); <>((Map.Entry<?,?>)o));
} }
} }
} }
...@@ -2927,7 +2926,7 @@ public class Collections { ...@@ -2927,7 +2926,7 @@ public class Collections {
public static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K, V> m, public static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K, V> m,
Class<K> keyType, Class<K> keyType,
Class<V> valueType) { Class<V> valueType) {
return new CheckedSortedMap<K,V>(m, keyType, valueType); return new CheckedSortedMap<>(m, keyType, valueType);
} }
/** /**
...@@ -2993,7 +2992,7 @@ public class Collections { ...@@ -2993,7 +2992,7 @@ public class Collections {
private static class EmptyIterator<E> implements Iterator<E> { private static class EmptyIterator<E> implements Iterator<E> {
static final EmptyIterator<Object> EMPTY_ITERATOR static final EmptyIterator<Object> EMPTY_ITERATOR
= new EmptyIterator<Object>(); = new EmptyIterator<>();
public boolean hasNext() { return false; } public boolean hasNext() { return false; }
public E next() { throw new NoSuchElementException(); } public E next() { throw new NoSuchElementException(); }
...@@ -3042,7 +3041,7 @@ public class Collections { ...@@ -3042,7 +3041,7 @@ public class Collections {
implements ListIterator<E> implements ListIterator<E>
{ {
static final EmptyListIterator<Object> EMPTY_ITERATOR static final EmptyListIterator<Object> EMPTY_ITERATOR
= new EmptyListIterator<Object>(); = new EmptyListIterator<>();
public boolean hasPrevious() { return false; } public boolean hasPrevious() { return false; }
public E previous() { throw new NoSuchElementException(); } public E previous() { throw new NoSuchElementException(); }
...@@ -3078,7 +3077,7 @@ public class Collections { ...@@ -3078,7 +3077,7 @@ public class Collections {
private static class EmptyEnumeration<E> implements Enumeration<E> { private static class EmptyEnumeration<E> implements Enumeration<E> {
static final EmptyEnumeration<Object> EMPTY_ENUMERATION static final EmptyEnumeration<Object> EMPTY_ENUMERATION
= new EmptyEnumeration<Object>(); = new EmptyEnumeration<>();
public boolean hasMoreElements() { return false; } public boolean hasMoreElements() { return false; }
public E nextElement() { throw new NoSuchElementException(); } public E nextElement() { throw new NoSuchElementException(); }
...@@ -3090,7 +3089,7 @@ public class Collections { ...@@ -3090,7 +3089,7 @@ public class Collections {
* @see #emptySet() * @see #emptySet()
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final Set EMPTY_SET = new EmptySet<Object>(); public static final Set EMPTY_SET = new EmptySet<>();
/** /**
* Returns the empty set (immutable). This set is serializable. * Returns the empty set (immutable). This set is serializable.
...@@ -3150,7 +3149,7 @@ public class Collections { ...@@ -3150,7 +3149,7 @@ public class Collections {
* @see #emptyList() * @see #emptyList()
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final List EMPTY_LIST = new EmptyList<Object>(); public static final List EMPTY_LIST = new EmptyList<>();
/** /**
* Returns the empty list (immutable). This list is serializable. * Returns the empty list (immutable). This list is serializable.
...@@ -3224,7 +3223,7 @@ public class Collections { ...@@ -3224,7 +3223,7 @@ public class Collections {
* @since 1.3 * @since 1.3
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final Map EMPTY_MAP = new EmptyMap<Object,Object>(); public static final Map EMPTY_MAP = new EmptyMap<>();
/** /**
* Returns the empty map (immutable). This map is serializable. * Returns the empty map (immutable). This map is serializable.
...@@ -3286,7 +3285,7 @@ public class Collections { ...@@ -3286,7 +3285,7 @@ public class Collections {
* @return an immutable set containing only the specified object. * @return an immutable set containing only the specified object.
*/ */
public static <T> Set<T> singleton(T o) { public static <T> Set<T> singleton(T o) {
return new SingletonSet<T>(o); return new SingletonSet<>(o);
} }
static <E> Iterator<E> singletonIterator(final E e) { static <E> Iterator<E> singletonIterator(final E e) {
...@@ -3339,7 +3338,7 @@ public class Collections { ...@@ -3339,7 +3338,7 @@ public class Collections {
* @since 1.3 * @since 1.3
*/ */
public static <T> List<T> singletonList(T o) { public static <T> List<T> singletonList(T o) {
return new SingletonList<T>(o); return new SingletonList<>(o);
} }
/** /**
...@@ -3381,7 +3380,7 @@ public class Collections { ...@@ -3381,7 +3380,7 @@ public class Collections {
* @since 1.3 * @since 1.3
*/ */
public static <K,V> Map<K,V> singletonMap(K key, V value) { public static <K,V> Map<K,V> singletonMap(K key, V value) {
return new SingletonMap<K,V>(key, value); return new SingletonMap<>(key, value);
} }
/** /**
...@@ -3423,7 +3422,7 @@ public class Collections { ...@@ -3423,7 +3422,7 @@ public class Collections {
public Set<Map.Entry<K,V>> entrySet() { public Set<Map.Entry<K,V>> entrySet() {
if (entrySet==null) if (entrySet==null)
entrySet = Collections.<Map.Entry<K,V>>singleton( entrySet = Collections.<Map.Entry<K,V>>singleton(
new SimpleImmutableEntry<K,V>(k, v)); new SimpleImmutableEntry<>(k, v));
return entrySet; return entrySet;
} }
...@@ -3455,7 +3454,7 @@ public class Collections { ...@@ -3455,7 +3454,7 @@ public class Collections {
public static <T> List<T> nCopies(int n, T o) { public static <T> List<T> nCopies(int n, T o) {
if (n < 0) if (n < 0)
throw new IllegalArgumentException("List length = " + n); throw new IllegalArgumentException("List length = " + n);
return new CopiesList<T>(n, o); return new CopiesList<>(n, o);
} }
/** /**
...@@ -3529,7 +3528,7 @@ public class Collections { ...@@ -3529,7 +3528,7 @@ public class Collections {
if (fromIndex > toIndex) if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex + throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex + ")"); ") > toIndex(" + toIndex + ")");
return new CopiesList<E>(toIndex - fromIndex, element); return new CopiesList<>(toIndex - fromIndex, element);
} }
} }
...@@ -3595,7 +3594,7 @@ public class Collections { ...@@ -3595,7 +3594,7 @@ public class Collections {
if (cmp instanceof ReverseComparator2) if (cmp instanceof ReverseComparator2)
return ((ReverseComparator2<T>)cmp).cmp; return ((ReverseComparator2<T>)cmp).cmp;
return new ReverseComparator2<T>(cmp); return new ReverseComparator2<>(cmp);
} }
/** /**
...@@ -3674,7 +3673,7 @@ public class Collections { ...@@ -3674,7 +3673,7 @@ public class Collections {
* @see ArrayList * @see ArrayList
*/ */
public static <T> ArrayList<T> list(Enumeration<T> e) { public static <T> ArrayList<T> list(Enumeration<T> e) {
ArrayList<T> l = new ArrayList<T>(); ArrayList<T> l = new ArrayList<>();
while (e.hasMoreElements()) while (e.hasMoreElements())
l.add(e.nextElement()); l.add(e.nextElement());
return l; return l;
...@@ -3819,7 +3818,7 @@ public class Collections { ...@@ -3819,7 +3818,7 @@ public class Collections {
* @since 1.6 * @since 1.6
*/ */
public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) { public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) {
return new SetFromMap<E>(map); return new SetFromMap<>(map);
} }
/** /**
...@@ -3883,7 +3882,7 @@ public class Collections { ...@@ -3883,7 +3882,7 @@ public class Collections {
* @since 1.6 * @since 1.6
*/ */
public static <T> Queue<T> asLifoQueue(Deque<T> deque) { public static <T> Queue<T> asLifoQueue(Deque<T> deque) {
return new AsLIFOQueue<T>(deque); return new AsLIFOQueue<>(deque);
} }
/** /**
......
...@@ -499,7 +499,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -499,7 +499,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
int j = 0; int j = 0;
for (int i = 0; i < vals.length; i++) for (int i = 0; i < vals.length; i++)
if (vals[i] != null) if (vals[i] != null)
a[j++] = new AbstractMap.SimpleEntry<K,V>( a[j++] = new AbstractMap.SimpleEntry<>(
keyUniverse[i], unmaskNull(vals[i])); keyUniverse[i], unmaskNull(vals[i]));
return a; return a;
} }
......
...@@ -110,9 +110,9 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E> ...@@ -110,9 +110,9 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
throw new ClassCastException(elementType + " not an enum"); throw new ClassCastException(elementType + " not an enum");
if (universe.length <= 64) if (universe.length <= 64)
return new RegularEnumSet<E>(elementType, universe); return new RegularEnumSet<>(elementType, universe);
else else
return new JumboEnumSet<E>(elementType, universe); return new JumboEnumSet<>(elementType, universe);
} }
/** /**
...@@ -430,7 +430,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E> ...@@ -430,7 +430,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
} }
Object writeReplace() { Object writeReplace() {
return new SerializationProxy<E>(this); return new SerializationProxy<>(this);
} }
// readObject method for the serialization proxy pattern // readObject method for the serialization proxy pattern
......
...@@ -2490,7 +2490,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2490,7 +2490,7 @@ public final class Formatter implements Closeable, Flushable {
* Finds format specifiers in the format string. * Finds format specifiers in the format string.
*/ */
private FormatString[] parse(String s) { private FormatString[] parse(String s) {
ArrayList<FormatString> al = new ArrayList<FormatString>(); ArrayList<FormatString> al = new ArrayList<>();
Matcher m = fsPattern.matcher(s); Matcher m = fsPattern.matcher(s);
for (int i = 0, len = s.length(); i < len; ) { for (int i = 0, len = s.length(); i < len; ) {
if (m.find(i)) { if (m.find(i)) {
......
...@@ -763,7 +763,7 @@ public class HashMap<K,V> ...@@ -763,7 +763,7 @@ public class HashMap<K,V>
*/ */
void addEntry(int hash, K key, V value, int bucketIndex) { void addEntry(int hash, K key, V value, int bucketIndex) {
Entry<K,V> e = table[bucketIndex]; Entry<K,V> e = table[bucketIndex];
table[bucketIndex] = new Entry<K,V>(hash, key, value, e); table[bucketIndex] = new Entry<>(hash, key, value, e);
if (size++ >= threshold) if (size++ >= threshold)
resize(2 * table.length); resize(2 * table.length);
} }
...@@ -778,7 +778,7 @@ public class HashMap<K,V> ...@@ -778,7 +778,7 @@ public class HashMap<K,V>
*/ */
void createEntry(int hash, K key, V value, int bucketIndex) { void createEntry(int hash, K key, V value, int bucketIndex) {
Entry<K,V> e = table[bucketIndex]; Entry<K,V> e = table[bucketIndex];
table[bucketIndex] = new Entry<K,V>(hash, key, value, e); table[bucketIndex] = new Entry<>(hash, key, value, e);
size++; size++;
} }
......
...@@ -100,7 +100,7 @@ public class HashSet<E> ...@@ -100,7 +100,7 @@ public class HashSet<E>
* default initial capacity (16) and load factor (0.75). * default initial capacity (16) and load factor (0.75).
*/ */
public HashSet() { public HashSet() {
map = new HashMap<E,Object>(); map = new HashMap<>();
} }
/** /**
...@@ -113,7 +113,7 @@ public class HashSet<E> ...@@ -113,7 +113,7 @@ public class HashSet<E>
* @throws NullPointerException if the specified collection is null * @throws NullPointerException if the specified collection is null
*/ */
public HashSet(Collection<? extends E> c) { public HashSet(Collection<? extends E> c) {
map = new HashMap<E,Object>(Math.max((int) (c.size()/.75f) + 1, 16)); map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16));
addAll(c); addAll(c);
} }
...@@ -127,7 +127,7 @@ public class HashSet<E> ...@@ -127,7 +127,7 @@ public class HashSet<E>
* than zero, or if the load factor is nonpositive * than zero, or if the load factor is nonpositive
*/ */
public HashSet(int initialCapacity, float loadFactor) { public HashSet(int initialCapacity, float loadFactor) {
map = new HashMap<E,Object>(initialCapacity, loadFactor); map = new HashMap<>(initialCapacity, loadFactor);
} }
/** /**
...@@ -139,7 +139,7 @@ public class HashSet<E> ...@@ -139,7 +139,7 @@ public class HashSet<E>
* than zero * than zero
*/ */
public HashSet(int initialCapacity) { public HashSet(int initialCapacity) {
map = new HashMap<E,Object>(initialCapacity); map = new HashMap<>(initialCapacity);
} }
/** /**
...@@ -156,7 +156,7 @@ public class HashSet<E> ...@@ -156,7 +156,7 @@ public class HashSet<E>
* than zero, or if the load factor is nonpositive * than zero, or if the load factor is nonpositive
*/ */
HashSet(int initialCapacity, float loadFactor, boolean dummy) { HashSet(int initialCapacity, float loadFactor, boolean dummy) {
map = new LinkedHashMap<E,Object>(initialCapacity, loadFactor); map = new LinkedHashMap<>(initialCapacity, loadFactor);
} }
/** /**
......
...@@ -455,7 +455,7 @@ public class Hashtable<K,V> ...@@ -455,7 +455,7 @@ public class Hashtable<K,V>
// Creates the new entry. // Creates the new entry.
Entry<K,V> e = tab[index]; Entry<K,V> e = tab[index];
tab[index] = new Entry<K,V>(hash, key, value, e); tab[index] = new Entry<>(hash, key, value, e);
count++; count++;
return null; return null;
} }
...@@ -579,7 +579,7 @@ public class Hashtable<K,V> ...@@ -579,7 +579,7 @@ public class Hashtable<K,V>
if (count == 0) { if (count == 0) {
return Collections.emptyEnumeration(); return Collections.emptyEnumeration();
} else { } else {
return new Enumerator<T>(type, false); return new Enumerator<>(type, false);
} }
} }
...@@ -587,7 +587,7 @@ public class Hashtable<K,V> ...@@ -587,7 +587,7 @@ public class Hashtable<K,V>
if (count == 0) { if (count == 0) {
return Collections.emptyIterator(); return Collections.emptyIterator();
} else { } else {
return new Enumerator<T>(type, true); return new Enumerator<>(type, true);
} }
} }
...@@ -929,7 +929,7 @@ public class Hashtable<K,V> ...@@ -929,7 +929,7 @@ public class Hashtable<K,V>
} }
// Creates the new entry. // Creates the new entry.
Entry<K,V> e = tab[index]; Entry<K,V> e = tab[index];
tab[index] = new Entry<K,V>(hash, key, value, e); tab[index] = new Entry<>(hash, key, value, e);
count++; count++;
} }
...@@ -950,7 +950,7 @@ public class Hashtable<K,V> ...@@ -950,7 +950,7 @@ public class Hashtable<K,V>
} }
protected Object clone() { protected Object clone() {
return new Entry<K,V>(hash, key, value, return new Entry<>(hash, key, value,
(next==null ? null : (Entry<K,V>) next.clone())); (next==null ? null : (Entry<K,V>) next.clone()));
} }
......
...@@ -1134,7 +1134,7 @@ public class IdentityHashMap<K,V> ...@@ -1134,7 +1134,7 @@ public class IdentityHashMap<K,V>
Object[] result = new Object[size]; Object[] result = new Object[size];
Iterator<Map.Entry<K,V>> it = iterator(); Iterator<Map.Entry<K,V>> it = iterator();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
result[i] = new AbstractMap.SimpleEntry<K,V>(it.next()); result[i] = new AbstractMap.SimpleEntry<>(it.next());
return result; return result;
} }
...@@ -1146,7 +1146,7 @@ public class IdentityHashMap<K,V> ...@@ -1146,7 +1146,7 @@ public class IdentityHashMap<K,V>
.newInstance(a.getClass().getComponentType(), size); .newInstance(a.getClass().getComponentType(), size);
Iterator<Map.Entry<K,V>> it = iterator(); Iterator<Map.Entry<K,V>> it = iterator();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
a[i] = (T) new AbstractMap.SimpleEntry<K,V>(it.next()); a[i] = (T) new AbstractMap.SimpleEntry<>(it.next());
if (a.length > size) if (a.length > size)
a[size] = null; a[size] = null;
return a; return a;
......
...@@ -89,7 +89,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> { ...@@ -89,7 +89,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
* @return an iterator over the elements contained in this set * @return an iterator over the elements contained in this set
*/ */
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new EnumSetIterator<E>(); return new EnumSetIterator<>();
} }
private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> { private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> {
......
...@@ -237,7 +237,7 @@ public class LinkedHashMap<K,V> ...@@ -237,7 +237,7 @@ public class LinkedHashMap<K,V>
* the chain. * the chain.
*/ */
void init() { void init() {
header = new Entry<K,V>(-1, null, null, null); header = new Entry<>(-1, null, null, null);
header.before = header.after = header; header.before = header.after = header;
} }
...@@ -438,7 +438,7 @@ public class LinkedHashMap<K,V> ...@@ -438,7 +438,7 @@ public class LinkedHashMap<K,V>
*/ */
void createEntry(int hash, K key, V value, int bucketIndex) { void createEntry(int hash, K key, V value, int bucketIndex) {
HashMap.Entry<K,V> old = table[bucketIndex]; HashMap.Entry<K,V> old = table[bucketIndex];
Entry<K,V> e = new Entry<K,V>(hash, key, value, old); Entry<K,V> e = new Entry<>(hash, key, value, old);
table[bucketIndex] = e; table[bucketIndex] = e;
e.addBefore(header); e.addBefore(header);
size++; size++;
......
...@@ -122,7 +122,7 @@ public class LinkedList<E> ...@@ -122,7 +122,7 @@ public class LinkedList<E>
*/ */
private void linkFirst(E e) { private void linkFirst(E e) {
final Node<E> f = first; final Node<E> f = first;
final Node<E> newNode = new Node<E>(null, e, f); final Node<E> newNode = new Node<>(null, e, f);
first = newNode; first = newNode;
if (f == null) if (f == null)
last = newNode; last = newNode;
...@@ -137,7 +137,7 @@ public class LinkedList<E> ...@@ -137,7 +137,7 @@ public class LinkedList<E>
*/ */
void linkLast(E e) { void linkLast(E e) {
final Node<E> l = last; final Node<E> l = last;
final Node<E> newNode = new Node<E>(l, e, null); final Node<E> newNode = new Node<>(l, e, null);
last = newNode; last = newNode;
if (l == null) if (l == null)
first = newNode; first = newNode;
...@@ -153,7 +153,7 @@ public class LinkedList<E> ...@@ -153,7 +153,7 @@ public class LinkedList<E>
void linkBefore(E e, Node<E> succ) { void linkBefore(E e, Node<E> succ) {
// assert succ != null; // assert succ != null;
final Node<E> pred = succ.prev; final Node<E> pred = succ.prev;
final Node<E> newNode = new Node<E>(pred, e, succ); final Node<E> newNode = new Node<>(pred, e, succ);
succ.prev = newNode; succ.prev = newNode;
if (pred == null) if (pred == null)
first = newNode; first = newNode;
...@@ -419,7 +419,7 @@ public class LinkedList<E> ...@@ -419,7 +419,7 @@ public class LinkedList<E>
for (Object o : a) { for (Object o : a) {
@SuppressWarnings("unchecked") E e = (E) o; @SuppressWarnings("unchecked") E e = (E) o;
Node<E> newNode = new Node<E>(pred, e, null); Node<E> newNode = new Node<>(pred, e, null);
if (pred == null) if (pred == null)
first = newNode; first = newNode;
else else
......
...@@ -187,7 +187,7 @@ public abstract class ListResourceBundle extends ResourceBundle { ...@@ -187,7 +187,7 @@ public abstract class ListResourceBundle extends ResourceBundle {
return; return;
Object[][] contents = getContents(); Object[][] contents = getContents();
HashMap<String,Object> temp = new HashMap<String,Object>(contents.length); HashMap<String,Object> temp = new HashMap<>(contents.length);
for (int i = 0; i < contents.length; ++i) { for (int i = 0; i < contents.length; ++i) {
// key must be non-null String, value must be non-null // key must be non-null String, value must be non-null
String key = (String) contents[i][0]; String key = (String) contents[i][0];
......
...@@ -538,7 +538,7 @@ public class PriorityQueue<E> extends AbstractQueue<E> ...@@ -538,7 +538,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
cursor--; cursor--;
else { else {
if (forgetMeNot == null) if (forgetMeNot == null)
forgetMeNot = new ArrayDeque<E>(); forgetMeNot = new ArrayDeque<>();
forgetMeNot.add(moved); forgetMeNot.add(moved);
} }
} else if (lastRetElt != null) { } else if (lastRetElt != null) {
......
...@@ -1011,7 +1011,7 @@ class Properties extends Hashtable<Object,Object> { ...@@ -1011,7 +1011,7 @@ class Properties extends Hashtable<Object,Object> {
* @since 1.6 * @since 1.6
*/ */
public Set<String> stringPropertyNames() { public Set<String> stringPropertyNames() {
Hashtable<String, String> h = new Hashtable<String, String>(); Hashtable<String, String> h = new Hashtable<>();
enumerateStringProperties(h); enumerateStringProperties(h);
return h.keySet(); return h.keySet();
} }
......
...@@ -71,7 +71,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> { ...@@ -71,7 +71,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
* @return an iterator over the elements contained in this set * @return an iterator over the elements contained in this set
*/ */
public Iterator<E> iterator() { public Iterator<E> iterator() {
return new EnumSetIterator<E>(); return new EnumSetIterator<>();
} }
private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> { private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> {
......
...@@ -191,7 +191,7 @@ public final class ServiceLoader<S> ...@@ -191,7 +191,7 @@ public final class ServiceLoader<S>
private ClassLoader loader; private ClassLoader loader;
// Cached providers, in instantiation order // Cached providers, in instantiation order
private LinkedHashMap<String,S> providers = new LinkedHashMap<String,S>(); private LinkedHashMap<String,S> providers = new LinkedHashMap<>();
// The current lazy-lookup iterator // The current lazy-lookup iterator
private LazyIterator lookupIterator; private LazyIterator lookupIterator;
...@@ -291,7 +291,7 @@ public final class ServiceLoader<S> ...@@ -291,7 +291,7 @@ public final class ServiceLoader<S>
{ {
InputStream in = null; InputStream in = null;
BufferedReader r = null; BufferedReader r = null;
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<>();
try { try {
in = u.openStream(); in = u.openStream();
r = new BufferedReader(new InputStreamReader(in, "utf-8")); r = new BufferedReader(new InputStreamReader(in, "utf-8"));
...@@ -463,7 +463,7 @@ public final class ServiceLoader<S> ...@@ -463,7 +463,7 @@ public final class ServiceLoader<S>
public static <S> ServiceLoader<S> load(Class<S> service, public static <S> ServiceLoader<S> load(Class<S> service,
ClassLoader loader) ClassLoader loader)
{ {
return new ServiceLoader<S>(service, loader); return new ServiceLoader<>(service, loader);
} }
/** /**
......
...@@ -196,7 +196,7 @@ class TimSort<T> { ...@@ -196,7 +196,7 @@ class TimSort<T> {
* extending short natural runs to minRun elements, and merging runs * extending short natural runs to minRun elements, and merging runs
* to maintain stack invariant. * to maintain stack invariant.
*/ */
TimSort<T> ts = new TimSort<T>(a, c); TimSort<T> ts = new TimSort<>(a, c);
int minRun = minRunLength(nRemaining); int minRun = minRunLength(nRemaining);
do { do {
// Identify next run // Identify next run
......
...@@ -533,7 +533,7 @@ public class TreeMap<K,V> ...@@ -533,7 +533,7 @@ public class TreeMap<K,V>
// throw NullPointerException // throw NullPointerException
// //
// compare(key, key); // type check // compare(key, key); // type check
root = new Entry<K,V>(key, value, null); root = new Entry<>(key, value, null);
size = 1; size = 1;
modCount++; modCount++;
return null; return null;
...@@ -569,7 +569,7 @@ public class TreeMap<K,V> ...@@ -569,7 +569,7 @@ public class TreeMap<K,V>
return t.setValue(value); return t.setValue(value);
} while (t != null); } while (t != null);
} }
Entry<K,V> e = new Entry<K,V>(key, value, parent); Entry<K,V> e = new Entry<>(key, value, parent);
if (cmp < 0) if (cmp < 0)
parent.left = e; parent.left = e;
else else
...@@ -1069,14 +1069,14 @@ public class TreeMap<K,V> ...@@ -1069,14 +1069,14 @@ public class TreeMap<K,V>
} }
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, public NavigableSet<E> subSet(E fromElement, boolean fromInclusive,
E toElement, boolean toInclusive) { E toElement, boolean toInclusive) {
return new KeySet<E>(m.subMap(fromElement, fromInclusive, return new KeySet<>(m.subMap(fromElement, fromInclusive,
toElement, toInclusive)); toElement, toInclusive));
} }
public NavigableSet<E> headSet(E toElement, boolean inclusive) { public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return new KeySet<E>(m.headMap(toElement, inclusive)); return new KeySet<>(m.headMap(toElement, inclusive));
} }
public NavigableSet<E> tailSet(E fromElement, boolean inclusive) { public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return new KeySet<E>(m.tailMap(fromElement, inclusive)); return new KeySet<>(m.tailMap(fromElement, inclusive));
} }
public SortedSet<E> subSet(E fromElement, E toElement) { public SortedSet<E> subSet(E fromElement, E toElement) {
return subSet(fromElement, true, toElement, false); return subSet(fromElement, true, toElement, false);
...@@ -1205,7 +1205,7 @@ public class TreeMap<K,V> ...@@ -1205,7 +1205,7 @@ public class TreeMap<K,V>
*/ */
static <K,V> Map.Entry<K,V> exportEntry(TreeMap.Entry<K,V> e) { static <K,V> Map.Entry<K,V> exportEntry(TreeMap.Entry<K,V> e) {
return (e == null) ? null : return (e == null) ? null :
new AbstractMap.SimpleImmutableEntry<K,V>(e); new AbstractMap.SimpleImmutableEntry<>(e);
} }
/** /**
...@@ -2406,7 +2406,7 @@ public class TreeMap<K,V> ...@@ -2406,7 +2406,7 @@ public class TreeMap<K,V>
value = (defaultVal != null ? defaultVal : (V) str.readObject()); value = (defaultVal != null ? defaultVal : (V) str.readObject());
} }
Entry<K,V> middle = new Entry<K,V>(key, value, null); Entry<K,V> middle = new Entry<>(key, value, null);
// color nodes in non-full bottommost level red // color nodes in non-full bottommost level red
if (level == redLevel) if (level == redLevel)
......
...@@ -138,7 +138,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -138,7 +138,7 @@ public class TreeSet<E> extends AbstractSet<E>
* ordering} of the elements will be used. * ordering} of the elements will be used.
*/ */
public TreeSet(Comparator<? super E> comparator) { public TreeSet(Comparator<? super E> comparator) {
this(new TreeMap<E,Object>(comparator)); this(new TreeMap<>(comparator));
} }
/** /**
...@@ -195,7 +195,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -195,7 +195,7 @@ public class TreeSet<E> extends AbstractSet<E>
* @since 1.6 * @since 1.6
*/ */
public NavigableSet<E> descendingSet() { public NavigableSet<E> descendingSet() {
return new TreeSet<E>(m.descendingMap()); return new TreeSet<>(m.descendingMap());
} }
/** /**
...@@ -322,7 +322,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -322,7 +322,7 @@ public class TreeSet<E> extends AbstractSet<E>
*/ */
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, public NavigableSet<E> subSet(E fromElement, boolean fromInclusive,
E toElement, boolean toInclusive) { E toElement, boolean toInclusive) {
return new TreeSet<E>(m.subMap(fromElement, fromInclusive, return new TreeSet<>(m.subMap(fromElement, fromInclusive,
toElement, toInclusive)); toElement, toInclusive));
} }
...@@ -335,7 +335,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -335,7 +335,7 @@ public class TreeSet<E> extends AbstractSet<E>
* @since 1.6 * @since 1.6
*/ */
public NavigableSet<E> headSet(E toElement, boolean inclusive) { public NavigableSet<E> headSet(E toElement, boolean inclusive) {
return new TreeSet<E>(m.headMap(toElement, inclusive)); return new TreeSet<>(m.headMap(toElement, inclusive));
} }
/** /**
...@@ -347,7 +347,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -347,7 +347,7 @@ public class TreeSet<E> extends AbstractSet<E>
* @since 1.6 * @since 1.6
*/ */
public NavigableSet<E> tailSet(E fromElement, boolean inclusive) { public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
return new TreeSet<E>(m.tailMap(fromElement, inclusive)); return new TreeSet<>(m.tailMap(fromElement, inclusive));
} }
/** /**
...@@ -477,7 +477,7 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -477,7 +477,7 @@ public class TreeSet<E> extends AbstractSet<E>
throw new InternalError(); throw new InternalError();
} }
clone.m = new TreeMap<E,Object>(m); clone.m = new TreeMap<>(m);
return clone; return clone;
} }
...@@ -524,9 +524,9 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -524,9 +524,9 @@ public class TreeSet<E> extends AbstractSet<E>
// Create backing TreeMap // Create backing TreeMap
TreeMap<E,Object> tm; TreeMap<E,Object> tm;
if (c==null) if (c==null)
tm = new TreeMap<E,Object>(); tm = new TreeMap<>();
else else
tm = new TreeMap<E,Object>(c); tm = new TreeMap<>(c);
m = tm; m = tm;
// Read in size // Read in size
......
...@@ -171,7 +171,7 @@ public class WeakHashMap<K,V> ...@@ -171,7 +171,7 @@ public class WeakHashMap<K,V>
/** /**
* Reference queue for cleared WeakEntries * Reference queue for cleared WeakEntries
*/ */
private final ReferenceQueue<Object> queue = new ReferenceQueue<Object>(); private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
/** /**
* The number of times this WeakHashMap has been structurally modified. * The number of times this WeakHashMap has been structurally modified.
...@@ -439,7 +439,7 @@ public class WeakHashMap<K,V> ...@@ -439,7 +439,7 @@ public class WeakHashMap<K,V>
modCount++; modCount++;
Entry<K,V> e = tab[i]; Entry<K,V> e = tab[i];
tab[i] = new Entry<K,V>(k, value, queue, h, e); tab[i] = new Entry<>(k, value, queue, h, e);
if (++size >= threshold) if (++size >= threshold)
resize(tab.length * 2); resize(tab.length * 2);
return null; return null;
...@@ -955,10 +955,9 @@ public class WeakHashMap<K,V> ...@@ -955,10 +955,9 @@ public class WeakHashMap<K,V>
} }
private List<Map.Entry<K,V>> deepCopy() { private List<Map.Entry<K,V>> deepCopy() {
List<Map.Entry<K,V>> list = List<Map.Entry<K,V>> list = new ArrayList<>(size());
new ArrayList<Map.Entry<K,V>>(size());
for (Map.Entry<K,V> e : this) for (Map.Entry<K,V> e : this)
list.add(new AbstractMap.SimpleEntry<K,V>(e)); list.add(new AbstractMap.SimpleEntry<>(e));
return list; return list;
} }
......
...@@ -127,7 +127,7 @@ public class FileHandler extends StreamHandler { ...@@ -127,7 +127,7 @@ public class FileHandler extends StreamHandler {
private FileOutputStream lockStream; private FileOutputStream lockStream;
private File files[]; private File files[];
private static final int MAX_LOCKS = 100; private static final int MAX_LOCKS = 100;
private static java.util.HashMap<String, String> locks = new java.util.HashMap<String, String>(); private static java.util.HashMap<String, String> locks = new java.util.HashMap<>();
// A metered stream is a subclass of OutputStream that // A metered stream is a subclass of OutputStream that
// (a) forwards all its output to a target stream // (a) forwards all its output to a target stream
......
...@@ -59,7 +59,7 @@ import java.util.ResourceBundle; ...@@ -59,7 +59,7 @@ import java.util.ResourceBundle;
*/ */
public class Level implements java.io.Serializable { public class Level implements java.io.Serializable {
private static java.util.ArrayList<Level> known = new java.util.ArrayList<Level>(); private static java.util.ArrayList<Level> known = new java.util.ArrayList<>();
private static String defaultBundle = "sun.util.logging.resources.logging"; private static String defaultBundle = "sun.util.logging.resources.logging";
/** /**
......
...@@ -156,8 +156,7 @@ public class LogManager { ...@@ -156,8 +156,7 @@ public class LogManager {
private final static Level defaultLevel = Level.INFO; private final static Level defaultLevel = Level.INFO;
// Table of named Loggers that maps names to Loggers. // Table of named Loggers that maps names to Loggers.
private Hashtable<String,LoggerWeakRef> namedLoggers = private Hashtable<String,LoggerWeakRef> namedLoggers = new Hashtable<>();
new Hashtable<String,LoggerWeakRef>();
// Tree of named Loggers // Tree of named Loggers
private LogNode root = new LogNode(null); private LogNode root = new LogNode(null);
private Logger rootLogger; private Logger rootLogger;
...@@ -422,7 +421,7 @@ public class LogManager { ...@@ -422,7 +421,7 @@ public class LogManager {
// loggerRefQueue holds LoggerWeakRef objects for Logger objects // loggerRefQueue holds LoggerWeakRef objects for Logger objects
// that have been GC'ed. // that have been GC'ed.
private final ReferenceQueue<Logger> loggerRefQueue private final ReferenceQueue<Logger> loggerRefQueue
= new ReferenceQueue<Logger>(); = new ReferenceQueue<>();
// Package-level inner class. // Package-level inner class.
// Helper class for managing WeakReferences to Logger objects. // Helper class for managing WeakReferences to Logger objects.
...@@ -672,7 +671,7 @@ public class LogManager { ...@@ -672,7 +671,7 @@ public class LogManager {
name = ""; name = "";
} }
if (node.children == null) { if (node.children == null) {
node.children = new HashMap<String,LogNode>(); node.children = new HashMap<>();
} }
LogNode child = node.children.get(head); LogNode child = node.children.get(head);
if (child == null) { if (child == null) {
...@@ -856,7 +855,7 @@ public class LogManager { ...@@ -856,7 +855,7 @@ public class LogManager {
} }
hands = hands.trim(); hands = hands.trim();
int ix = 0; int ix = 0;
Vector<String> result = new Vector<String>(); Vector<String> result = new Vector<>();
while (ix < hands.length()) { while (ix < hands.length()) {
int end = ix; int end = ix;
while (end < hands.length()) { while (end < hands.length()) {
......
...@@ -85,8 +85,7 @@ public class LogRecord implements java.io.Serializable { ...@@ -85,8 +85,7 @@ public class LogRecord implements java.io.Serializable {
private static final AtomicInteger nextThreadId private static final AtomicInteger nextThreadId
= new AtomicInteger(MIN_SEQUENTIAL_THREAD_ID); = new AtomicInteger(MIN_SEQUENTIAL_THREAD_ID);
private static final ThreadLocal<Integer> threadIds private static final ThreadLocal<Integer> threadIds = new ThreadLocal<>();
= new ThreadLocal<Integer>();
/** /**
* @serial Logging message level * @serial Logging message level
......
...@@ -170,7 +170,7 @@ public class Logger { ...@@ -170,7 +170,7 @@ public class Logger {
private LogManager manager; private LogManager manager;
private String name; private String name;
private final CopyOnWriteArrayList<Handler> handlers = private final CopyOnWriteArrayList<Handler> handlers =
new CopyOnWriteArrayList<Handler>(); new CopyOnWriteArrayList<>();
private String resourceBundleName; private String resourceBundleName;
private volatile boolean useParentHandlers = true; private volatile boolean useParentHandlers = true;
private volatile Filter filter; private volatile Filter filter;
...@@ -1420,13 +1420,13 @@ public class Logger { ...@@ -1420,13 +1420,13 @@ public class Logger {
// Set our new parent. // Set our new parent.
parent = newParent; parent = newParent;
if (parent.kids == null) { if (parent.kids == null) {
parent.kids = new ArrayList<LogManager.LoggerWeakRef>(2); parent.kids = new ArrayList<>(2);
} }
if (ref == null) { if (ref == null) {
// we didn't have a previous parent // we didn't have a previous parent
ref = manager.new LoggerWeakRef(this); ref = manager.new LoggerWeakRef(this);
} }
ref.setParentRef(new WeakReference<Logger>(parent)); ref.setParentRef(new WeakReference<>(parent));
parent.kids.add(ref); parent.kids.add(ref);
// As a result of the reparenting, the effective level // As a result of the reparenting, the effective level
......
...@@ -56,7 +56,7 @@ class Logging implements LoggingMXBean { ...@@ -56,7 +56,7 @@ class Logging implements LoggingMXBean {
public List<String> getLoggerNames() { public List<String> getLoggerNames() {
Enumeration loggers = logManager.getLoggerNames(); Enumeration loggers = logManager.getLoggerNames();
ArrayList<String> array = new ArrayList<String>(); ArrayList<String> array = new ArrayList<>();
for (; loggers.hasMoreElements();) { for (; loggers.hasMoreElements();) {
array.add((String) loggers.nextElement()); array.add((String) loggers.nextElement());
......
...@@ -155,8 +155,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -155,8 +155,7 @@ public abstract class AbstractPreferences extends Preferences {
* All known unremoved children of this node. (This "cache" is consulted * All known unremoved children of this node. (This "cache" is consulted
* prior to calling childSpi() or getChild(). * prior to calling childSpi() or getChild().
*/ */
private Map<String, AbstractPreferences> kidCache private Map<String, AbstractPreferences> kidCache = new HashMap<>();
= new HashMap<String, AbstractPreferences>();
/** /**
* This field is used to keep track of whether or not this node has * This field is used to keep track of whether or not this node has
...@@ -713,7 +712,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -713,7 +712,7 @@ public abstract class AbstractPreferences extends Preferences {
if (removed) if (removed)
throw new IllegalStateException("Node has been removed."); throw new IllegalStateException("Node has been removed.");
Set<String> s = new TreeSet<String>(kidCache.keySet()); Set<String> s = new TreeSet<>(kidCache.keySet());
for (String kid : childrenNamesSpi()) for (String kid : childrenNamesSpi())
s.add(kid); s.add(kid);
return s.toArray(EMPTY_STRING_ARRAY); return s.toArray(EMPTY_STRING_ARRAY);
...@@ -1442,8 +1441,7 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -1442,8 +1441,7 @@ public abstract class AbstractPreferences extends Preferences {
* event delivery from preference activity, greatly simplifying * event delivery from preference activity, greatly simplifying
* locking and reducing opportunity for deadlock. * locking and reducing opportunity for deadlock.
*/ */
private static final List<EventObject> eventQueue private static final List<EventObject> eventQueue = new LinkedList<>();
= new LinkedList<EventObject>();
/** /**
* These two classes are used to distinguish NodeChangeEvents on * These two classes are used to distinguish NodeChangeEvents on
......
...@@ -1068,7 +1068,7 @@ public final class Pattern ...@@ -1068,7 +1068,7 @@ public final class Pattern
public String[] split(CharSequence input, int limit) { public String[] split(CharSequence input, int limit) {
int index = 0; int index = 0;
boolean matchLimited = limit > 0; boolean matchLimited = limit > 0;
ArrayList<String> matchList = new ArrayList<String>(); ArrayList<String> matchList = new ArrayList<>();
Matcher m = matcher(input); Matcher m = matcher(input);
// Add segments before each match found // Add segments before each match found
...@@ -1566,7 +1566,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -1566,7 +1566,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
Map<String, Integer> namedGroups() { Map<String, Integer> namedGroups() {
if (namedGroups == null) if (namedGroups == null)
namedGroups = new HashMap<String, Integer>(2); namedGroups = new HashMap<>(2);
return namedGroups; return namedGroups;
} }
...@@ -5309,7 +5309,7 @@ NEXT: while (i <= last) { ...@@ -5309,7 +5309,7 @@ NEXT: while (i <= last) {
} }
private static final HashMap<String, CharPropertyFactory> map private static final HashMap<String, CharPropertyFactory> map
= new HashMap<String, CharPropertyFactory>(); = new HashMap<>();
static { static {
// Unicode character property aliases, defined in // Unicode character property aliases, defined in
......
...@@ -543,7 +543,7 @@ class ZipFile implements ZipConstants, Closeable { ...@@ -543,7 +543,7 @@ class ZipFile implements ZipConstants, Closeable {
if (streams.size() !=0) { if (streams.size() !=0) {
Set<InputStream> copy = streams; Set<InputStream> copy = streams;
streams = new HashSet<InputStream>(); streams = new HashSet<>();
for (InputStream is: copy) for (InputStream is: copy)
is.close(); is.close();
} }
......
...@@ -52,8 +52,8 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { ...@@ -52,8 +52,8 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
} }
private XEntry current; private XEntry current;
private Vector<XEntry> xentries = new Vector<XEntry>(); private Vector<XEntry> xentries = new Vector<>();
private HashSet<String> names = new HashSet<String>(); private HashSet<String> names = new HashSet<>();
private CRC32 crc = new CRC32(); private CRC32 crc = new CRC32();
private long written = 0; private long written = 0;
private long locoff = 0; private long locoff = 0;
......
...@@ -120,7 +120,7 @@ public class Converters { ...@@ -120,7 +120,7 @@ public class Converters {
private static Class<?> cache(int type, Object encoding, Class<?> c) { private static Class<?> cache(int type, Object encoding, Class<?> c) {
SoftReference<Object[]>[] srs = classCache[type]; SoftReference<Object[]>[] srs = classCache[type];
srs[CACHE_SIZE - 1] = new SoftReference<Object[]>(new Object[] { c, encoding }); srs[CACHE_SIZE - 1] = new SoftReference<>(new Object[] { c, encoding });
moveToFront(srs, CACHE_SIZE - 1); moveToFront(srs, CACHE_SIZE - 1);
return c; return c;
} }
......
...@@ -113,7 +113,7 @@ public class PlatformLogger { ...@@ -113,7 +113,7 @@ public class PlatformLogger {
// Table of known loggers. Maps names to PlatformLoggers. // Table of known loggers. Maps names to PlatformLoggers.
private static Map<String,WeakReference<PlatformLogger>> loggers = private static Map<String,WeakReference<PlatformLogger>> loggers =
new HashMap<String,WeakReference<PlatformLogger>>(); new HashMap<>();
/** /**
* Returns a PlatformLogger of a given name. * Returns a PlatformLogger of a given name.
...@@ -126,7 +126,7 @@ public class PlatformLogger { ...@@ -126,7 +126,7 @@ public class PlatformLogger {
} }
if (log == null) { if (log == null) {
log = new PlatformLogger(name); log = new PlatformLogger(name);
loggers.put(name, new WeakReference<PlatformLogger>(log)); loggers.put(name, new WeakReference<>(log));
} }
return log; return log;
} }
...@@ -488,7 +488,7 @@ public class PlatformLogger { ...@@ -488,7 +488,7 @@ public class PlatformLogger {
*/ */
static class JavaLogger extends LoggerProxy { static class JavaLogger extends LoggerProxy {
private static final Map<Integer, Object> levelObjects = private static final Map<Integer, Object> levelObjects =
new HashMap<Integer, Object>(); new HashMap<>();
static { static {
if (LoggingSupport.isAvailable()) { if (LoggingSupport.isAvailable()) {
......
...@@ -68,7 +68,7 @@ final class ProcessEnvironment ...@@ -68,7 +68,7 @@ final class ProcessEnvironment
// We cache the C environment. This means that subsequent calls // We cache the C environment. This means that subsequent calls
// to putenv/setenv from C will not be visible from Java code. // to putenv/setenv from C will not be visible from Java code.
byte[][] environ = environ(); byte[][] environ = environ();
theEnvironment = new HashMap<Variable,Value>(environ.length/2 + 3); theEnvironment = new HashMap<>(environ.length/2 + 3);
// Read environment variables back to front, // Read environment variables back to front,
// so that earlier variables override later ones. // so that earlier variables override later ones.
for (int i = environ.length-1; i > 0; i-=2) for (int i = environ.length-1; i > 0; i-=2)
......
...@@ -354,7 +354,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -354,7 +354,7 @@ class FileSystemPreferences extends AbstractPreferences {
* log against that map. The resulting map is then written back * log against that map. The resulting map is then written back
* to the disk. * to the disk.
*/ */
final List<Change> changeLog = new ArrayList<Change>(); final List<Change> changeLog = new ArrayList<>();
/** /**
* Represents a change to a preference. * Represents a change to a preference.
...@@ -507,7 +507,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -507,7 +507,7 @@ class FileSystemPreferences extends AbstractPreferences {
}); });
if (newNode) { if (newNode) {
// These 2 things guarantee node will get wrtten at next flush/sync // These 2 things guarantee node will get wrtten at next flush/sync
prefsCache = new TreeMap<String, String>(); prefsCache = new TreeMap<>();
nodeCreate = new NodeCreate(); nodeCreate = new NodeCreate();
changeLog.add(nodeCreate); changeLog.add(nodeCreate);
} }
...@@ -550,7 +550,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -550,7 +550,7 @@ class FileSystemPreferences extends AbstractPreferences {
loadCache(); loadCache();
} catch(Exception e) { } catch(Exception e) {
// assert lastSyncTime == 0; // assert lastSyncTime == 0;
prefsCache = new TreeMap<String, String>(); prefsCache = new TreeMap<>();
} }
} }
...@@ -567,7 +567,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -567,7 +567,7 @@ class FileSystemPreferences extends AbstractPreferences {
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>() { new PrivilegedExceptionAction<Void>() {
public Void run() throws BackingStoreException { public Void run() throws BackingStoreException {
Map<String, String> m = new TreeMap<String, String>(); Map<String, String> m = new TreeMap<>();
long newLastSyncTime = 0; long newLastSyncTime = 0;
try { try {
newLastSyncTime = prefsFile.lastModified(); newLastSyncTime = prefsFile.lastModified();
...@@ -581,7 +581,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -581,7 +581,7 @@ class FileSystemPreferences extends AbstractPreferences {
prefsFile.renameTo( new File( prefsFile.renameTo( new File(
prefsFile.getParentFile(), prefsFile.getParentFile(),
"IncorrectFormatPrefs.xml")); "IncorrectFormatPrefs.xml"));
m = new TreeMap<String, String>(); m = new TreeMap<>();
} else if (e instanceof FileNotFoundException) { } else if (e instanceof FileNotFoundException) {
getLogger().warning("Prefs file removed in background " getLogger().warning("Prefs file removed in background "
+ prefsFile.getPath()); + prefsFile.getPath());
...@@ -646,7 +646,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -646,7 +646,7 @@ class FileSystemPreferences extends AbstractPreferences {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<String[]>() { new PrivilegedAction<String[]>() {
public String[] run() { public String[] run() {
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<>();
File[] dirContents = dir.listFiles(); File[] dirContents = dir.listFiles();
if (dirContents != null) { if (dirContents != null) {
for (int i = 0; i < dirContents.length; i++) for (int i = 0; i < dirContents.length; i++)
...@@ -794,7 +794,7 @@ class FileSystemPreferences extends AbstractPreferences { ...@@ -794,7 +794,7 @@ class FileSystemPreferences extends AbstractPreferences {
} else if (lastSyncTime != 0 && !dir.exists()) { } else if (lastSyncTime != 0 && !dir.exists()) {
// This node was removed in the background. Playback any changes // This node was removed in the background. Playback any changes
// against a virgin (empty) Map. // against a virgin (empty) Map.
prefsCache = new TreeMap<String, String>(); prefsCache = new TreeMap<>();
replayChanges(); replayChanges();
} }
if (!changeLog.isEmpty()) { if (!changeLog.isEmpty()) {
......
...@@ -250,8 +250,7 @@ final class ProcessEnvironment extends HashMap<String,String> ...@@ -250,8 +250,7 @@ final class ProcessEnvironment extends HashMap<String,String>
envblock.substring(eql+1,end)); envblock.substring(eql+1,end));
} }
theCaseInsensitiveEnvironment theCaseInsensitiveEnvironment = new TreeMap<>(nameComparator);
= new TreeMap<String,String>(nameComparator);
theCaseInsensitiveEnvironment.putAll(theEnvironment); theCaseInsensitiveEnvironment.putAll(theEnvironment);
} }
...@@ -296,8 +295,7 @@ final class ProcessEnvironment extends HashMap<String,String> ...@@ -296,8 +295,7 @@ final class ProcessEnvironment extends HashMap<String,String>
// Only for use by ProcessImpl.start() // Only for use by ProcessImpl.start()
String toEnvironmentBlock() { String toEnvironmentBlock() {
// Sort Unicode-case-insensitively by name // Sort Unicode-case-insensitively by name
List<Map.Entry<String,String>> list List<Map.Entry<String,String>> list = new ArrayList<>(entrySet());
= new ArrayList<Map.Entry<String,String>>(entrySet());
Collections.sort(list, entryComparator); Collections.sort(list, entryComparator);
StringBuilder sb = new StringBuilder(size()*30); StringBuilder sb = new StringBuilder(size()*30);
......
...@@ -56,7 +56,7 @@ public class NPEProvoker implements java.io.Externalizable { ...@@ -56,7 +56,7 @@ public class NPEProvoker implements java.io.Externalizable {
public static void main(String[] args) { public static void main(String[] args) {
System.err.println("\n Regression test for bug 6541870\n"); System.err.println("\n Regression test for bug 6541870\n");
try { try {
ArrayList<NPEProvoker> list = new ArrayList<NPEProvoker>(); ArrayList<NPEProvoker> list = new ArrayList<>();
list.add(new NPEProvoker()); list.add(new NPEProvoker());
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
......
...@@ -107,7 +107,7 @@ public class Inject implements RuntimeConstants { ...@@ -107,7 +107,7 @@ public class Inject implements RuntimeConstants {
class IndexedInjector implements TrackerInjector { class IndexedInjector implements TrackerInjector {
int counter = 0; int counter = 0;
int tracker; int tracker;
List<Info> infoList = new ArrayList<Info>(); List<Info> infoList = new ArrayList<>();
public int stackSize(int currentSize) { public int stackSize(int currentSize) {
return currentSize + 1; return currentSize + 1;
......
...@@ -50,7 +50,7 @@ class InjectBytecodes implements RuntimeConstants { ...@@ -50,7 +50,7 @@ class InjectBytecodes implements RuntimeConstants {
private final Injector[] after = new Injector[256]; private final Injector[] after = new Injector[256];
private final String className; private final String className;
private final String methodName; private final String methodName;
private final Map<Integer,byte[]> snippets = new HashMap<Integer,byte[]>(); private final Map<Integer,byte[]> snippets = new HashMap<>();
private int pos; private int pos;
private int newPos; private int newPos;
......
...@@ -103,7 +103,7 @@ public class TestPlainArrayNotGeneric { ...@@ -103,7 +103,7 @@ public class TestPlainArrayNotGeneric {
} }
} }
private static final Set<Type> checking = new HashSet<Type>(); private static final Set<Type> checking = new HashSet<>();
private static void check(Type t, String what) { private static void check(Type t, String what) {
if (t == null || !checking.add(t)) if (t == null || !checking.add(t))
......
...@@ -59,7 +59,7 @@ public class DistinctSeeds { ...@@ -59,7 +59,7 @@ public class DistinctSeeds {
} }
} }
final int threadCount = 2; final int threadCount = 2;
List<RandomCollector> collectors = new ArrayList<RandomCollector>(); List<RandomCollector> collectors = new ArrayList<>();
List<Thread> threads = new ArrayList<Thread>(); List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < threadCount; i++) { for (int i = 0; i < threadCount; i++) {
RandomCollector r = new RandomCollector(); RandomCollector r = new RandomCollector();
......
...@@ -89,7 +89,7 @@ public class ClassLoaderLeakTest { ...@@ -89,7 +89,7 @@ public class ClassLoaderLeakTest {
MyClassLoader appClassLoader = new MyClassLoader(urls, "test0"); MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
WeakReference<MyClassLoader> ref = WeakReference<MyClassLoader> ref =
new WeakReference<MyClassLoader>(appClassLoader); new WeakReference<>(appClassLoader);
Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0"); Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册