langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 22163 3651128c74eb
parent 21712 d363f367d4c0
child 22167 e0ba35f27975
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Dec 18 19:22:58 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Dec 18 16:05:18 2013 -0500
@@ -75,8 +75,7 @@
  * deletion without notice.</b>
  */
 public class Types {
-    protected static final Context.Key<Types> typesKey =
-        new Context.Key<Types>();
+    protected static final Context.Key<Types> typesKey = new Context.Key<>();
 
     final Symtab syms;
     final JavacMessages messages;
@@ -247,8 +246,8 @@
                 Type base = asSuper(sym.type, t.tsym);
                 if (base == null)
                     return null;
-                ListBuffer<Type> from = new ListBuffer<Type>();
-                ListBuffer<Type> to = new ListBuffer<Type>();
+                ListBuffer<Type> from = new ListBuffer<>();
+                ListBuffer<Type> to = new ListBuffer<>();
                 try {
                     adapt(base, t, from, to);
                 } catch (AdaptFailure ex) {
@@ -257,7 +256,7 @@
                 Type res = subst(sym.type, from.toList(), to.toList());
                 if (!isSubtype(res, t))
                     return null;
-                ListBuffer<Type> openVars = new ListBuffer<Type>();
+                ListBuffer<Type> openVars = new ListBuffer<>();
                 for (List<Type> l = sym.type.allparams();
                      l.nonEmpty(); l = l.tail)
                     if (res.contains(l.head) && !t.contains(l.head))
@@ -269,7 +268,7 @@
                     } else {
                         // Unbound type arguments default to ?
                         List<Type> opens = openVars.toList();
-                        ListBuffer<Type> qs = new ListBuffer<Type>();
+                        ListBuffer<Type> qs = new ListBuffer<>();
                         for (List<Type> iter = opens; iter.nonEmpty(); iter = iter.tail) {
                             qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, (TypeVar) iter.head.unannotatedType()));
                         }
@@ -347,7 +346,7 @@
      */
     class DescriptorCache {
 
-        private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<TypeSymbol, Entry>();
+        private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<>();
 
         class FunctionDescriptor {
             Symbol descSym;
@@ -727,7 +726,7 @@
                    !overridesObjectMethod(origin, sym) &&
                    (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
        }
-    };
+    }
 
     // <editor-fold defaultstate="collapsed" desc="isSubtype">
     /**
@@ -864,7 +863,7 @@
                  }
             }
 
-            private Set<TypePair> cache = new HashSet<TypePair>();
+            private Set<TypePair> cache = new HashSet<>();
 
             private boolean containsTypeRecursive(Type t, Type s) {
                 TypePair pair = new TypePair(t, s);
@@ -1144,7 +1143,7 @@
                     if (!visit(supertype(t), supertype(s)))
                         return false;
 
-                    HashSet<UniqueType> set = new HashSet<UniqueType>();
+                    HashSet<UniqueType> set = new HashSet<>();
                     for (Type x : interfaces(t))
                         set.add(new UniqueType(x.unannotatedType(), Types.this));
                     for (Type x : interfaces(s)) {
@@ -1232,9 +1231,9 @@
             protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
                 return containsTypeEquivalent(ts1, ts2);
             }
-        };
-
-        /**
+        }
+
+    /**
          * Strict type-equality relation - type variables are considered
          * equals if they share the same object identity.
          */
@@ -1707,7 +1706,7 @@
     // where
         private TypeRelation disjointType = new TypeRelation() {
 
-            private Set<TypePair> cache = new HashSet<TypePair>();
+            private Set<TypePair> cache = new HashSet<>();
 
             @Override
             public Boolean visitType(Type t, Type s) {
@@ -2446,7 +2445,7 @@
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="isDerivedRaw">
-    Map<Type,Boolean> isDerivedRawCache = new HashMap<Type,Boolean>();
+    Map<Type,Boolean> isDerivedRawCache = new HashMap<>();
 
     public boolean isDerivedRaw(Type t) {
         Boolean result = isDerivedRawCache.get(t);
@@ -2608,8 +2607,7 @@
     // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
     class ImplementationCache {
 
-        private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>> _map =
-                new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>>();
+        private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>> _map = new WeakHashMap<>();
 
         class Entry {
             final MethodSymbol cachedImpl;
@@ -2638,8 +2636,8 @@
             SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
             Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
             if (cache == null) {
-                cache = new HashMap<TypeSymbol, Entry>();
-                _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
+                cache = new HashMap<>();
+                _map.put(ms, new SoftReference<>(cache));
             }
             Entry e = cache.get(origin);
             CompoundScope members = membersClosure(origin.type, true);
@@ -2681,8 +2679,7 @@
     // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
     class MembersClosureCache extends SimpleVisitor<CompoundScope, Boolean> {
 
-        private WeakHashMap<TypeSymbol, Entry> _map =
-                new WeakHashMap<TypeSymbol, Entry>();
+        private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<>();
 
         class Entry {
             final boolean skipInterfaces;
@@ -2800,7 +2797,7 @@
                             s.isInheritedIn(site.tsym, Types.this) &&
                             overrideEquivalent(memberType(site, s), memberType(site, msym));
                 }
-            };
+            }
     // </editor-fold>
 
     /**
@@ -2856,9 +2853,9 @@
             public Boolean visitErrorType(ErrorType t, Type s) {
                 return false;
             }
-        };
-
-        TypeRelation hasSameArgs_strict = new HasSameArgs(true);
+        }
+
+    TypeRelation hasSameArgs_strict = new HasSameArgs(true);
         TypeRelation hasSameArgs_nonstrict = new HasSameArgs(false);
 
     // </editor-fold>
@@ -3301,7 +3298,7 @@
      * (that is, subclasses come first, arbitrary but fixed
      * otherwise).
      */
-    private Map<Type,List<Type>> closureCache = new HashMap<Type,List<Type>>();
+    private Map<Type,List<Type>> closureCache = new HashMap<>();
 
     /**
      * Returns the closure of a class or interface type.
@@ -3404,13 +3401,13 @@
                     && isSameType(t2, typePair.t2);
             }
         }
-        Set<TypePair> mergeCache = new HashSet<TypePair>();
+        Set<TypePair> mergeCache = new HashSet<>();
         private Type merge(Type c1, Type c2) {
             ClassType class1 = (ClassType) c1;
             List<Type> act1 = class1.getTypeArguments();
             ClassType class2 = (ClassType) c2;
             List<Type> act2 = class2.getTypeArguments();
-            ListBuffer<Type> merged = new ListBuffer<Type>();
+            ListBuffer<Type> merged = new ListBuffer<>();
             List<Type> typarams = class1.tsym.type.getTypeArguments();
 
             while (act1.nonEmpty() && act2.nonEmpty() && typarams.nonEmpty()) {
@@ -4090,7 +4087,7 @@
         Adapter(ListBuffer<Type> from, ListBuffer<Type> to) {
             this.from = from;
             this.to = to;
-            mapping = new HashMap<Symbol,Type>();
+            mapping = new HashMap<>();
         }
 
         public void adapt(Type source, Type target) throws AdaptFailure {
@@ -4159,7 +4156,7 @@
             return null;
         }
 
-        private Set<TypePair> cache = new HashSet<TypePair>();
+        private Set<TypePair> cache = new HashSet<>();
 
         private void adaptRecursive(Type source, Type target) {
             TypePair pair = new TypePair(source, target);
@@ -4233,7 +4230,7 @@
 
         @Override
         public Type visitClassType(ClassType t, Void s) {
-            ListBuffer<Type> rewritten = new ListBuffer<Type>();
+            ListBuffer<Type> rewritten = new ListBuffer<>();
             boolean changed = false;
             for (Type arg : t.allparams()) {
                 Type bound = visit(arg);