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