langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java
changeset 22163 3651128c74eb
parent 21488 4a69e26aa999
child 22165 ec53c8946fc2
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Dec 18 19:22:58 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Dec 18 16:05:18 2013 -0500
@@ -62,8 +62,7 @@
  *  deletion without notice.</b>
  */
 public class Infer {
-    protected static final Context.Key<Infer> inferKey =
-        new Context.Key<Infer>();
+    protected static final Context.Key<Infer> inferKey = new Context.Key<>();
 
     Resolve rs;
     Check chk;
@@ -510,9 +509,9 @@
                     uv.listener = null;
                 }
             }
-        };
+        }
 
-        /** max number of incorporation rounds */
+    /** max number of incorporation rounds */
         static final int MAX_INCORPORATION_STEPS = 100;
 
     /**
@@ -893,8 +892,7 @@
     }
 
     /** an incorporation cache keeps track of all executed incorporation-related operations */
-    Map<IncorporationBinaryOp, Boolean> incorporationCache =
-            new HashMap<IncorporationBinaryOp, Boolean>();
+    Map<IncorporationBinaryOp, Boolean> incorporationCache = new HashMap<>();
 
     /**
      * Make sure that the upper bounds we got so far lead to a solvable inference
@@ -927,7 +925,7 @@
                 return !t.isErroneous() && !inferenceContext.free(t) &&
                         !t.hasTag(BOT);
             }
-        };
+        }
 
     /**
      * This enumeration defines all possible bound-checking related errors.
@@ -1045,7 +1043,7 @@
             if (g.nodes.isEmpty()) {
                 //should not happen
                 throw new NodeNotFoundException(g);
-            };
+            }
             return g.nodes.get(0);
         }
 
@@ -1111,16 +1109,15 @@
                 //cache miss
                 if (n.isLeaf()) {
                     //if leaf, stop
-                    cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
+                    cachedPath = new Pair<>(List.of(n), n.data.length());
                 } else {
                     //if non-leaf, proceed recursively
-                    Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
+                    Pair<List<Node>, Integer> path = new Pair<>(List.of(n), n.data.length());
                     for (Node n2 : n.getAllDependencies()) {
                         if (n2 == n) continue;
                         Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
-                        path = new Pair<List<Node>, Integer>(
-                                path.fst.prependList(subpath.fst),
-                                path.snd + subpath.snd);
+                        path = new Pair<>(path.fst.prependList(subpath.fst),
+                                          path.snd + subpath.snd);
                     }
                     cachedPath = path;
                 }
@@ -1131,12 +1128,10 @@
         }
 
         /** cache used to avoid redundant computation of tree costs */
-        final Map<Node, Pair<List<Node>, Integer>> treeCache =
-                new HashMap<Node, Pair<List<Node>, Integer>>();
+        final Map<Node, Pair<List<Node>, Integer>> treeCache = new HashMap<>();
 
         /** constant value used to mark non-existent paths */
-        final Pair<List<Node>, Integer> noPath =
-                new Pair<List<Node>, Integer>(null, Integer.MAX_VALUE);
+        final Pair<List<Node>, Integer> noPath = new Pair<>(null, Integer.MAX_VALUE);
 
         /**
          * Pick the leaf that minimize cost
@@ -1460,7 +1455,7 @@
 
                 Node(Type ivar) {
                     super(ListBuffer.of(ivar));
-                    this.deps = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class);
+                    this.deps = new EnumMap<>(DependencyKind.class);
                 }
 
                 @Override
@@ -1502,7 +1497,7 @@
                  * Retrieves all dependencies with given kind(s).
                  */
                 protected Set<Node> getDependencies(DependencyKind... depKinds) {
-                    Set<Node> buf = new LinkedHashSet<Node>();
+                    Set<Node> buf = new LinkedHashSet<>();
                     for (DependencyKind dk : depKinds) {
                         Set<Node> depsByKind = deps.get(dk);
                         if (depsByKind != null) {
@@ -1518,7 +1513,7 @@
                 protected void addDependency(DependencyKind dk, Node depToAdd) {
                     Set<Node> depsByKind = deps.get(dk);
                     if (depsByKind == null) {
-                        depsByKind = new LinkedHashSet<Node>();
+                        depsByKind = new LinkedHashSet<>();
                         deps.put(dk, depsByKind);
                     }
                     depsByKind.add(depToAdd);
@@ -1554,11 +1549,11 @@
                  */
                 protected Set<Node> closure(DependencyKind... depKinds) {
                     boolean progress = true;
-                    Set<Node> closure = new HashSet<Node>();
+                    Set<Node> closure = new HashSet<>();
                     closure.add(this);
                     while (progress) {
                         progress = false;
-                        for (Node n1 : new HashSet<Node>(closure)) {
+                        for (Node n1 : new HashSet<>(closure)) {
                             progress = closure.addAll(n1.getDependencies(depKinds));
                         }
                     }
@@ -1595,12 +1590,12 @@
                         }
                     }
                     //update deps
-                    EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class);
+                    EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<>(DependencyKind.class);
                     for (DependencyKind dk : DependencyKind.values()) {
                         for (Node d : getDependencies(dk)) {
                             Set<Node> depsByKind = deps2.get(dk);
                             if (depsByKind == null) {
-                                depsByKind = new LinkedHashSet<Node>();
+                                depsByKind = new LinkedHashSet<>();
                                 deps2.put(dk, depsByKind);
                             }
                             if (data.contains(d.data.first())) {
@@ -1674,7 +1669,7 @@
              */
             void initNodes(Map<Type, Set<Type>> stuckDeps) {
                 //add nodes
-                nodes = new ArrayList<Node>();
+                nodes = new ArrayList<>();
                 for (Type t : inferenceContext.restvars()) {
                     nodes.add(new Node(t));
                 }
@@ -1696,7 +1691,7 @@
                     }
                 }
                 //merge cyclic nodes
-                ArrayList<Node> acyclicNodes = new ArrayList<Node>();
+                ArrayList<Node> acyclicNodes = new ArrayList<>();
                 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
                     if (conSubGraph.length() > 1) {
                         Node root = conSubGraph.head;
@@ -1753,8 +1748,7 @@
         /** list of inference vars in this context */
         List<Type> inferencevars;
 
-        java.util.Map<FreeTypeListener, List<Type>> freeTypeListeners =
-                new java.util.HashMap<FreeTypeListener, List<Type>>();
+        Map<FreeTypeListener, List<Type>> freeTypeListeners = new HashMap<>();
 
         List<FreeTypeListener> freetypeListeners = List.nil();
 
@@ -1946,7 +1940,7 @@
         void notifyChange(List<Type> inferredVars) {
             InferenceException thrownEx = null;
             for (Map.Entry<FreeTypeListener, List<Type>> entry :
-                    new HashMap<FreeTypeListener, List<Type>>(freeTypeListeners).entrySet()) {
+                    new HashMap<>(freeTypeListeners).entrySet()) {
                 if (!Type.containsAny(entry.getValue(), inferencevars.diff(inferredVars))) {
                     try {
                         entry.getKey().typesInferred(this);
@@ -2019,7 +2013,7 @@
         }
 
         private void solve(GraphStrategy ss, Warner warn) {
-            solve(ss, new HashMap<Type, Set<Type>>(), warn);
+            solve(ss, new HashMap<>(), warn);
         }
 
         /**