changeset 3828:44bdefe64114

8181370: Convert anonymous inner classes into lambdas/method references Reviewed-by: jjg, rfield, mchung
author mcimadamore
date Fri, 16 Dec 2016 15:27:34 +0000
parents 0939cac53f1d
children d30434bde0a8
files make/tools/anttasks/SelectToolTask.java make/tools/propertiesparser/PropertiesParser.java src/jdk.compiler/share/classes/com/sun/tools/doclint/Messages.java src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/jdk.compiler/share/classes/com/sun/tools/javac/model/FilteredMemberList.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocClassFinder.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocEnter.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocMemberEnter.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTodo.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Messager.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocClassFinder.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocMemberEnter.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTodo.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java src/jdk.jdeps/share/classes/com/sun/tools/classfile/Code_attribute.java src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConstantPool.java src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java src/jdk.jshell/share/classes/jdk/jshell/DiagList.java src/jdk.jshell/share/classes/jdk/jshell/Eval.java src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java src/jdk.jshell/share/classes/jdk/jshell/Unit.java src/jdk.jshell/share/classes/jdk/jshell/Wrap.java src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
diffstat 73 files changed, 489 insertions(+), 777 deletions(-) [+]
line wrap: on
line diff
--- a/make/tools/anttasks/SelectToolTask.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/make/tools/anttasks/SelectToolTask.java	Fri Dec 16 15:27:34 2016 +0000
@@ -203,14 +203,11 @@
         if (toolName != null) {
             toolChoice.setSelectedItem(tool);
         }
-        toolChoice.addItemListener(new ItemListener() {
-            @Override
-            public void itemStateChanged(ItemEvent e) {
-                ToolChoices tool = (ToolChoices)e.getItem();
-                argsField.setText(getDefaultArgsForTool(props, tool));
-                if (toolProperty != null)
-                    okButton.setEnabled(tool != ToolChoices.NONE);
-            }
+        toolChoice.addItemListener(e -> {
+            ToolChoices tool1 = (ToolChoices)e.getItem();
+            argsField.setText(getDefaultArgsForTool(props, tool1));
+            if (toolProperty != null)
+                okButton.setEnabled(tool1 != ToolChoices.NONE);
         });
         fc.anchor = GridBagConstraints.EAST;
 
@@ -248,12 +245,9 @@
         final JOptionPane p = new JOptionPane(body);
         okButton = new JButton("OK");
         okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
-        okButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
-                d.setVisible(false);
-            }
+        okButton.addActionListener(e -> {
+            JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
+            d.setVisible(false);
         });
         p.setOptions(new Object[] { okButton });
 
--- a/make/tools/propertiesparser/PropertiesParser.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/make/tools/propertiesparser/PropertiesParser.java	Fri Dec 16 15:27:34 2016 +0000
@@ -57,7 +57,7 @@
     }
 
     public static boolean run(String[] args, PrintStream out) {
-        PropertiesParser pp = new PropertiesParser(msg -> out.println(msg));
+        PropertiesParser pp = new PropertiesParser(out::println);
         return pp.run(args);
     }
 
@@ -76,7 +76,7 @@
             return false;
         }
         try {
-            optionsMap.forEach((propfile, outfile) -> compilePropertyFile(propfile, outfile));
+            optionsMap.forEach(this::compilePropertyFile);
             return true;
         } catch (RuntimeException ex) {
             ex.printStackTrace();
--- a/src/jdk.compiler/share/classes/com/sun/tools/doclint/Messages.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/doclint/Messages.java	Fri Dec 16 15:27:34 2016 +0000
@@ -315,12 +315,7 @@
          */
         private static class Table {
 
-            private static final Comparator<Integer> DECREASING = new Comparator<Integer>() {
-
-                public int compare(Integer o1, Integer o2) {
-                    return o2.compareTo(o1);
-                }
-            };
+            private static final Comparator<Integer> DECREASING = (o1, o2) -> o2.compareTo(o1);
             private final TreeMap<Integer, Set<String>> map = new TreeMap<>(DECREASING);
 
             void put(String label, int n) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Fri Dec 16 15:27:34 2016 +0000
@@ -97,15 +97,12 @@
     /* Internal version of call exposing Main.Result. */
     public Main.Result doCall() {
         try {
-            return handleExceptions(new Callable<Main.Result>() {
-                @Override
-                public Main.Result call() throws Exception {
-                    prepareCompiler(false);
-                    if (compiler.errorCount() > 0)
-                        return Main.Result.ERROR;
-                    compiler.compile(args.getFileObjects(), args.getClassNames(), processors);
-                    return (compiler.errorCount() > 0) ? Main.Result.ERROR : Main.Result.OK; // FIXME?
-                }
+            return handleExceptions(() -> {
+                prepareCompiler(false);
+                if (compiler.errorCount() > 0)
+                    return Main.Result.ERROR;
+                compiler.compile(args.getFileObjects(), args.getClassNames(), processors);
+                return (compiler.errorCount() > 0) ? Main.Result.ERROR : Main.Result.OK; // FIXME?
             }, Main.Result.SYSERR, Main.Result.ABNORMAL);
         } finally {
             try {
@@ -228,12 +225,7 @@
 
     @Override @DefinedBy(Api.COMPILER_TREE)
     public Iterable<? extends CompilationUnitTree> parse() {
-        return handleExceptions(new Callable<Iterable<? extends CompilationUnitTree>>() {
-            @Override
-            public Iterable<? extends CompilationUnitTree> call() {
-                return parseInternal();
-            }
-        }, List.<CompilationUnitTree>nil(), List.<CompilationUnitTree>nil());
+        return handleExceptions(this::parseInternal, List.<CompilationUnitTree>nil(), List.<CompilationUnitTree>nil());
     }
 
     private Iterable<? extends CompilationUnitTree> parseInternal() {
@@ -360,12 +352,7 @@
 
     @Override @DefinedBy(Api.COMPILER_TREE)
     public Iterable<? extends Element> analyze() {
-        return handleExceptions(new Callable<Iterable<? extends Element>>() {
-            @Override
-            public Iterable<? extends Element> call() {
-                return analyze(null);
-            }
-        }, List.<Element>nil(), List.<Element>nil());
+        return handleExceptions(() -> analyze(null), List.<Element>nil(), List.<Element>nil());
     }
 
     /**
@@ -427,12 +414,7 @@
 
     @Override @DefinedBy(Api.COMPILER_TREE)
     public Iterable<? extends JavaFileObject> generate() {
-        return handleExceptions(new Callable<Iterable<? extends JavaFileObject>>() {
-            @Override
-            public Iterable<? extends JavaFileObject> call() {
-                return generate(null);
-            }
-        }, List.<JavaFileObject>nil(), List.<JavaFileObject>nil());
+        return handleExceptions(() -> generate(null), List.<JavaFileObject>nil(), List.<JavaFileObject>nil());
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Fri Dec 16 15:27:34 2016 +0000
@@ -163,12 +163,7 @@
     /**
      * Completer that delegates to the complete-method of this class.
      */
-    private final Completer thisCompleter = new Completer() {
-        @Override
-        public void complete(Symbol sym) throws CompletionFailure {
-            ClassFinder.this.complete(sym);
-        }
-    };
+    private final Completer thisCompleter = this::complete;
 
     public Completer getCompleter() {
         return thisCompleter;
@@ -516,7 +511,7 @@
 
         ModuleSymbol msym = p.modle;
 
-        Assert.checkNonNull(msym, () -> p.toString());
+        Assert.checkNonNull(msym, p::toString);
 
         msym.complete();
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Fri Dec 16 15:27:34 2016 +0000
@@ -143,12 +143,7 @@
     /** Returns true iff the given Symbol is in this scope, optionally checking outward scopes.
      */
     public boolean includes(final Symbol sym, LookupKind lookupKind) {
-        return getSymbolsByName(sym.name, new Filter<Symbol>() {
-            @Override
-            public boolean accepts(Symbol t) {
-                return t == sym;
-            }
-        }, lookupKind).iterator().hasNext();
+        return getSymbolsByName(sym.name, t -> t == sym, lookupKind).iterator().hasNext();
     }
 
     /** Returns true iff this scope does not contain any Symbol. Does not inspect outward scopes.
@@ -574,64 +569,56 @@
 
         public Iterable<Symbol> getSymbols(final Filter<Symbol> sf,
                                            final LookupKind lookupKind) {
-            return new Iterable<Symbol>() {
-                public Iterator<Symbol> iterator() {
-                    return new Iterator<Symbol>() {
-                        private ScopeImpl currScope = ScopeImpl.this;
-                        private Scope.Entry currEntry = elems;
-                        private int seenRemoveCount = currScope.removeCount;
-                        {
-                            update();
+            return () -> new Iterator<Symbol>() {
+                private ScopeImpl currScope = ScopeImpl.this;
+                private Entry currEntry = elems;
+                private int seenRemoveCount = currScope.removeCount;
+                {
+                    update();
+                }
+
+                public boolean hasNext() {
+                    if (seenRemoveCount != currScope.removeCount &&
+                        currEntry != null &&
+                        !currEntry.scope.includes(currEntry.sym)) {
+                        doNext(); //skip entry that is no longer in the Scope
+                        seenRemoveCount = currScope.removeCount;
+                    }
+                    return currEntry != null;
+                }
+
+                public Symbol next() {
+                    if (!hasNext()) {
+                        throw new NoSuchElementException();
+                    }
+
+                    return doNext();
+                }
+                private Symbol doNext() {
+                    Symbol sym = (currEntry == null ? null : currEntry.sym);
+                    if (currEntry != null) {
+                        currEntry = currEntry.sibling;
+                    }
+                    update();
+                    return sym;
+                }
+
+                private void update() {
+                    skipToNextMatchingEntry();
+                    if (lookupKind == RECURSIVE) {
+                        while (currEntry == null && currScope.next != null) {
+                            currScope = currScope.next;
+                            currEntry = currScope.elems;
+                            seenRemoveCount = currScope.removeCount;
+                            skipToNextMatchingEntry();
                         }
+                    }
+                }
 
-                        public boolean hasNext() {
-                            if (seenRemoveCount != currScope.removeCount &&
-                                currEntry != null &&
-                                !currEntry.scope.includes(currEntry.sym)) {
-                                doNext(); //skip entry that is no longer in the Scope
-                                seenRemoveCount = currScope.removeCount;
-                            }
-                            return currEntry != null;
-                        }
-
-                        public Symbol next() {
-                            if (!hasNext()) {
-                                throw new NoSuchElementException();
-                            }
-
-                            return doNext();
-                        }
-                        private Symbol doNext() {
-                            Symbol sym = (currEntry == null ? null : currEntry.sym);
-                            if (currEntry != null) {
-                                currEntry = currEntry.sibling;
-                            }
-                            update();
-                            return sym;
-                        }
-
-                        public void remove() {
-                            throw new UnsupportedOperationException();
-                        }
-
-                        private void update() {
-                            skipToNextMatchingEntry();
-                            if (lookupKind == RECURSIVE) {
-                                while (currEntry == null && currScope.next != null) {
-                                    currScope = currScope.next;
-                                    currEntry = currScope.elems;
-                                    seenRemoveCount = currScope.removeCount;
-                                    skipToNextMatchingEntry();
-                                }
-                            }
-                        }
-
-                        void skipToNextMatchingEntry() {
-                            while (currEntry != null && sf != null && !sf.accepts(currEntry.sym)) {
-                                currEntry = currEntry.sibling;
-                            }
-                        }
-                    };
+                void skipToNextMatchingEntry() {
+                    while (currEntry != null && sf != null && !sf.accepts(currEntry.sym)) {
+                        currEntry = currEntry.sibling;
+                    }
                 }
             };
         }
@@ -639,40 +626,36 @@
         public Iterable<Symbol> getSymbolsByName(final Name name,
                                                  final Filter<Symbol> sf,
                                                  final LookupKind lookupKind) {
-            return new Iterable<Symbol>() {
-                public Iterator<Symbol> iterator() {
-                     return new Iterator<Symbol>() {
-                        Scope.Entry currentEntry = lookup(name, sf);
-                        int seenRemoveCount = currentEntry.scope != null ?
-                                currentEntry.scope.removeCount : -1;
+            return () -> new Iterator<Symbol>() {
+               Entry currentEntry = lookup(name, sf);
+               int seenRemoveCount = currentEntry.scope != null ?
+                       currentEntry.scope.removeCount : -1;
 
-                        public boolean hasNext() {
-                            if (currentEntry.scope != null &&
-                                seenRemoveCount != currentEntry.scope.removeCount &&
-                                !currentEntry.scope.includes(currentEntry.sym)) {
-                                doNext(); //skip entry that is no longer in the Scope
-                            }
-                            return currentEntry.scope != null &&
-                                    (lookupKind == RECURSIVE ||
-                                     currentEntry.scope == ScopeImpl.this);
-                        }
-                        public Symbol next() {
-                            if (!hasNext()) {
-                                throw new NoSuchElementException();
-                            }
-                            return doNext();
-                        }
-                        private Symbol doNext() {
-                            Scope.Entry prevEntry = currentEntry;
-                            currentEntry = currentEntry.next(sf);
-                            return prevEntry.sym;
-                        }
-                        public void remove() {
-                            throw new UnsupportedOperationException();
-                        }
-                    };
-                }
-            };
+               public boolean hasNext() {
+                   if (currentEntry.scope != null &&
+                       seenRemoveCount != currentEntry.scope.removeCount &&
+                       !currentEntry.scope.includes(currentEntry.sym)) {
+                       doNext(); //skip entry that is no longer in the Scope
+                   }
+                   return currentEntry.scope != null &&
+                           (lookupKind == RECURSIVE ||
+                            currentEntry.scope == ScopeImpl.this);
+               }
+               public Symbol next() {
+                   if (!hasNext()) {
+                       throw new NoSuchElementException();
+                   }
+                   return doNext();
+               }
+               private Symbol doNext() {
+                   Entry prevEntry = currentEntry;
+                   currentEntry = currentEntry.next(sf);
+                   return prevEntry.sym;
+               }
+               public void remove() {
+                   throw new UnsupportedOperationException();
+               }
+           };
         }
 
         public Scope getOrigin(Symbol s) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Dec 16 15:27:34 2016 +0000
@@ -1549,11 +1549,7 @@
                                       final Attr attr,
                                       final JCVariableDecl variable)
         {
-            setData(new Callable<Object>() {
-                public Object call() {
-                    return attr.attribLazyConstantValue(env, variable, type);
-                }
-            });
+            setData((Callable<Object>)() -> attr.attribLazyConstantValue(env, variable, type));
         }
 
         /**
@@ -1856,12 +1852,8 @@
             return implementation(origin, types, checkResult, implementation_filter);
         }
         // where
-            public static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
-                public boolean accepts(Symbol s) {
-                    return s.kind == MTH &&
-                            (s.flags() & SYNTHETIC) == 0;
-                }
-            };
+            public static final Filter<Symbol> implementation_filter = s ->
+                    s.kind == MTH && (s.flags() & SYNTHETIC) == 0;
 
         public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
             MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Dec 16 15:27:34 2016 +0000
@@ -590,7 +590,7 @@
         arrayClass.members().enter(arrayCloneMethod);
 
         if (java_base != noModule)
-            java_base.completer = sym -> moduleCompleter.complete(sym); //bootstrap issues
+            java_base.completer = moduleCompleter::complete; //bootstrap issues
 
     }
 
@@ -624,7 +624,7 @@
     }
 
     public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
-        Assert.checkNonNull(msym, () -> flatName.toString());
+        Assert.checkNonNull(msym, flatName::toString);
         return classes.getOrDefault(flatName, Collections.emptyMap()).get(msym);
     }
 
@@ -757,7 +757,8 @@
                 }
             };
         unnamedPackage.modle = module;
-        unnamedPackage.completer = sym -> initialCompleter.complete(sym);
+        //we cannot use a method reference below, as initialCompleter might be null now
+        unnamedPackage.completer = s -> initialCompleter.complete(s);
         module.unnamedPackage = unnamedPackage;
     }
 
@@ -770,7 +771,7 @@
         if (msym == null) {
             msym = ModuleSymbol.create(name, names.module_info);
             addRootPackageFor(msym);
-            msym.completer = sym -> moduleCompleter.complete(sym); //bootstrap issues
+            msym.completer = s -> moduleCompleter.complete(s); //bootstrap issues
             modules.put(name, msym);
         }
         return msym;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Fri Dec 16 15:27:34 2016 +0000
@@ -2138,11 +2138,9 @@
             UndetVarListener prevListener = listener;
             try {
                 //setup new listener for keeping track of changed bounds
-                listener = new UndetVarListener() {
-                    public void varBoundChanged(UndetVar uv, InferenceBound ib, Type t, boolean _ignored) {
-                        Assert.check(uv == UndetVar.this);
-                        boundsChanged.add(new Pair<>(ib, t));
-                    }
+                listener = (uv, ib, t, _ignored) -> {
+                    Assert.check(uv == UndetVar.this);
+                    boundsChanged.add(new Pair<>(ib, t));
                 };
                 for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
                     InferenceBound ib = _entry.getKey();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Dec 16 15:27:34 2016 +0000
@@ -2651,12 +2651,8 @@
         private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
                 final InferenceContext inferenceContext, final List<Type> ts) {
             if (inferenceContext.free(ts)) {
-                inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
-                    @Override
-                    public void typesInferred(InferenceContext inferenceContext) {
-                        checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts));
-                    }
-                });
+                inferenceContext.addFreeTypeListener(ts,
+                        solvedContext -> checkAccessibleTypes(pos, env, solvedContext, solvedContext.asInstTypes(ts)));
             } else {
                 for (Type t : ts) {
                     rs.checkAccessibleType(env, t);
@@ -3094,12 +3090,9 @@
     private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
             final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
         if (checkContext.inferenceContext().free(descriptorType)) {
-            checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType), new FreeTypeListener() {
-                public void typesInferred(InferenceContext inferenceContext) {
-                    setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
-                            inferenceContext.asInstType(primaryTarget), checkContext);
-                }
-            });
+            checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType),
+                    inferenceContext -> setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
+                    inferenceContext.asInstType(primaryTarget), checkContext));
         } else {
             ListBuffer<Type> targets = new ListBuffer<>();
             if (pt.hasTag(CLASS)) {
@@ -4574,13 +4567,8 @@
             }
         }
 
-        public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = new Filter<Symbol>() {
-            @Override
-            public boolean accepts(Symbol s) {
-                return s.kind == MTH &&
-                       (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
-            }
-        };
+        public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = s ->
+                s.kind == MTH && (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
 
         /** get a diagnostic position for an attribute of Type t, or null if attribute missing */
         private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Dec 16 15:27:34 2016 +0000
@@ -565,12 +565,8 @@
     Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) {
         final InferenceContext inferenceContext = checkContext.inferenceContext();
         if (inferenceContext.free(req) || inferenceContext.free(found)) {
-            inferenceContext.addFreeTypeListener(List.of(req, found), new FreeTypeListener() {
-                @Override
-                public void typesInferred(InferenceContext inferenceContext) {
-                    checkType(pos, inferenceContext.asInstType(found), inferenceContext.asInstType(req), checkContext);
-                }
-            });
+            inferenceContext.addFreeTypeListener(List.of(req, found),
+                    solvedContext -> checkType(pos, solvedContext.asInstType(found), solvedContext.asInstType(req), checkContext));
         }
         if (req.hasTag(ERROR))
             return req;
@@ -614,13 +610,10 @@
                 && types.isSameType(tree.expr.type, tree.clazz.type)
                 && !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz))
                 && !is292targetTypeCast(tree)) {
-            deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
-                @Override
-                public void report() {
-                    if (lint.isEnabled(Lint.LintCategory.CAST))
-                        log.warning(Lint.LintCategory.CAST,
-                                tree.pos(), "redundant.cast", tree.clazz.type);
-                }
+            deferredLintHandler.report(() -> {
+                if (lint.isEnabled(LintCategory.CAST))
+                    log.warning(LintCategory.CAST,
+                            tree.pos(), "redundant.cast", tree.clazz.type);
             });
         }
     }
@@ -953,11 +946,8 @@
         // System.out.println("method : " + owntype);
         // System.out.println("actuals: " + argtypes);
         if (inferenceContext.free(mtype)) {
-            inferenceContext.addFreeTypeListener(List.of(mtype), new FreeTypeListener() {
-                public void typesInferred(InferenceContext inferenceContext) {
-                    checkMethod(inferenceContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, inferenceContext);
-                }
-            });
+            inferenceContext.addFreeTypeListener(List.of(mtype),
+                    solvedContext -> checkMethod(solvedContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, solvedContext));
             return mtype;
         }
         Type owntype = mtype;
@@ -2070,13 +2060,8 @@
         }
     }
 
-    private Filter<Symbol> equalsHasCodeFilter = new Filter<Symbol>() {
-        public boolean accepts(Symbol s) {
-            return MethodSymbol.implementation_filter.accepts(s) &&
-                    (s.flags() & BAD_OVERRIDE) == 0;
-
-        }
-    };
+    private Filter<Symbol> equalsHasCodeFilter = s -> MethodSymbol.implementation_filter.accepts(s) &&
+            (s.flags() & BAD_OVERRIDE) == 0;
 
     public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos,
             ClassSymbol someClass) {
@@ -3266,12 +3251,7 @@
         if ( (s.isDeprecatedForRemoval()
                 || s.isDeprecated() && !other.isDeprecated())
                 && (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
-            deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
-                @Override
-                public void report() {
-                    warnDeprecated(pos, s);
-                }
-            });
+            deferredLintHandler.report(() -> warnDeprecated(pos, s));
         }
     }
 
@@ -3410,12 +3390,7 @@
             int opc = ((OperatorSymbol)operator).opcode;
             if (opc == ByteCodes.idiv || opc == ByteCodes.imod
                 || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) {
-                deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
-                    @Override
-                    public void report() {
-                        warnDivZero(pos);
-                    }
-                });
+                deferredLintHandler.report(() -> warnDivZero(pos));
             }
         }
     }
@@ -3892,12 +3867,9 @@
 
     void checkModuleExists(final DiagnosticPosition pos, ModuleSymbol msym) {
         if (msym.kind != MDL) {
-            deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
-                @Override
-                public void report() {
-                    if (lint.isEnabled(Lint.LintCategory.MODULE))
-                        log.warning(LintCategory.MODULE, pos, Warnings.ModuleNotFound(msym));
-                }
+            deferredLintHandler.report(() -> {
+                if (lint.isEnabled(LintCategory.MODULE))
+                    log.warning(LintCategory.MODULE, pos, Warnings.ModuleNotFound(msym));
             });
         }
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Fri Dec 16 15:27:34 2016 +0000
@@ -507,12 +507,10 @@
             }
 
             DeferredAttrDiagHandler(Log log, JCTree newTree) {
-                super(log, new Filter<JCDiagnostic>() {
-                    public boolean accepts(JCDiagnostic d) {
-                        PosScanner posScanner = new PosScanner(d.getDiagnosticPosition());
-                        posScanner.scan(newTree);
-                        return posScanner.found;
-                    }
+                super(log, d -> {
+                    PosScanner posScanner = new PosScanner(d.getDiagnosticPosition());
+                    posScanner.scan(newTree);
+                    return posScanner.found;
                 });
             }
         }
@@ -1008,11 +1006,7 @@
         final Filter<JCTree> treeFilter;
 
         FilterScanner(final Set<JCTree.Tag> validTags) {
-            this.treeFilter = new Filter<JCTree>() {
-                public boolean accepts(JCTree t) {
-                    return validTags.contains(t.getTag());
-                }
-            };
+            this.treeFilter = t -> validTags.contains(t.getTag());
         }
 
         @Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -415,7 +415,7 @@
                 if (c.owner != owner) {
                     //anonymous class loaded from a classfile may be recreated from source (see below)
                     //if this class is a member of such an anonymous class, fix the owner:
-                    Assert.check(owner.owner.kind != TYP, () -> owner.toString());
+                    Assert.check(owner.owner.kind != TYP, owner::toString);
                     Assert.check(c.owner.kind == TYP, () -> c.owner.toString());
                     ClassSymbol cowner = (ClassSymbol) c.owner;
                     if (cowner.members_field != null) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java	Fri Dec 16 15:27:34 2016 +0000
@@ -123,11 +123,7 @@
      * inference context
      */
     List<Type> restvars() {
-        return filterVars(new Filter<UndetVar>() {
-            public boolean accepts(UndetVar uv) {
-                return uv.getInst() == null;
-            }
-        });
+        return filterVars(uv -> uv.getInst() == null);
     }
 
     /**
@@ -135,11 +131,7 @@
      * inference context
      */
     List<Type> instvars() {
-        return filterVars(new Filter<UndetVar>() {
-            public boolean accepts(UndetVar uv) {
-                return uv.getInst() != null;
-            }
-        });
+        return filterVars(uv -> uv.getInst() != null);
     }
 
     /**
@@ -147,13 +139,9 @@
      * declared bounds).
      */
     final List<Type> boundedVars() {
-        return filterVars(new Filter<UndetVar>() {
-            public boolean accepts(UndetVar uv) {
-                return uv.getBounds(InferenceBound.UPPER)
-                         .diff(uv.getDeclaredBounds())
-                         .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty();
-            }
-        });
+        return filterVars(uv -> uv.getBounds(InferenceBound.UPPER)
+                 .diff(uv.getDeclaredBounds())
+                 .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty());
     }
 
     /* Returns the corresponding inference variables.
@@ -341,11 +329,7 @@
         //set up listeners to notify original inference contexts as
         //propagated vars are inferred in new context
         for (Type t : inferencevars) {
-            that.freeTypeListeners.put(new FreeTypeListener() {
-                public void typesInferred(InferenceContext inferenceContext) {
-                    InferenceContext.this.notifyChange();
-                }
-            }, List.of(t));
+            that.freeTypeListeners.put(inferenceContext -> InferenceContext.this.notifyChange(), List.of(t));
         }
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Dec 16 15:27:34 2016 +0000
@@ -2254,25 +2254,15 @@
             final JCFieldAccess s = (JCFieldAccess)lval;
             Symbol lid = TreeInfo.symbol(s.selected);
             if (lid != null && lid.kind == TYP) return builder.build(lval);
-            return abstractRval(s.selected, new TreeBuilder() {
-                    public JCExpression build(final JCExpression selected) {
-                        return builder.build(make.Select(selected, s.sym));
-                    }
-                });
+            return abstractRval(s.selected, selected -> builder.build(make.Select(selected, s.sym)));
         }
         case INDEXED: {
             final JCArrayAccess i = (JCArrayAccess)lval;
-            return abstractRval(i.indexed, new TreeBuilder() {
-                    public JCExpression build(final JCExpression indexed) {
-                        return abstractRval(i.index, syms.intType, new TreeBuilder() {
-                                public JCExpression build(final JCExpression index) {
-                                    JCExpression newLval = make.Indexed(indexed, index);
-                                    newLval.setType(i.type);
-                                    return builder.build(newLval);
-                                }
-                            });
-                    }
-                });
+            return abstractRval(i.indexed, indexed -> abstractRval(i.index, syms.intType, index -> {
+                JCExpression newLval = make.Indexed(indexed, index);
+                newLval.setType(i.type);
+                return builder.build(newLval);
+            }));
         }
         case TYPECAST: {
             return abstractLval(((JCTypeCast)lval).expr, builder);
@@ -2283,11 +2273,7 @@
 
     // evaluate and discard the first expression, then evaluate the second.
     JCExpression makeComma(final JCExpression expr1, final JCExpression expr2) {
-        return abstractRval(expr1, new TreeBuilder() {
-                public JCExpression build(final JCExpression discarded) {
-                    return expr2;
-                }
-            });
+        return abstractRval(expr1, discarded -> expr2);
     }
 
 /**************************************************************************
@@ -3195,33 +3181,31 @@
             // boxing required; need to rewrite as x = (unbox typeof x)(x op y);
             // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
             // (but without recomputing x)
-            JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
-                    public JCExpression build(final JCExpression lhs) {
-                        JCTree.Tag newTag = tree.getTag().noAssignOp();
-                        // Erasure (TransTypes) can change the type of
-                        // tree.lhs.  However, we can still get the
-                        // unerased type of tree.lhs as it is stored
-                        // in tree.type in Attr.
-                        OperatorSymbol newOperator = operators.resolveBinary(tree,
-                                                                      newTag,
-                                                                      tree.type,
-                                                                      tree.rhs.type);
-                        //Need to use the "lhs" at two places, once on the future left hand side
-                        //and once in the future binary operator. But further processing may change
-                        //the components of the tree in place (see visitSelect for e.g. <Class>.super.<ident>),
-                        //so cloning the tree to avoid interference between the uses:
-                        JCExpression expr = (JCExpression) lhs.clone();
-                        if (expr.type != tree.type)
-                            expr = make.TypeCast(tree.type, expr);
-                        JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
-                        opResult.operator = newOperator;
-                        opResult.type = newOperator.type.getReturnType();
-                        JCExpression newRhs = boxingReq ?
-                            make.TypeCast(types.unboxedType(tree.type), opResult) :
-                            opResult;
-                        return make.Assign(lhs, newRhs).setType(tree.type);
-                    }
-                });
+            JCTree newTree = abstractLval(tree.lhs, lhs -> {
+                Tag newTag = tree.getTag().noAssignOp();
+                // Erasure (TransTypes) can change the type of
+                // tree.lhs.  However, we can still get the
+                // unerased type of tree.lhs as it is stored
+                // in tree.type in Attr.
+                OperatorSymbol newOperator = operators.resolveBinary(tree,
+                                                              newTag,
+                                                              tree.type,
+                                                              tree.rhs.type);
+                //Need to use the "lhs" at two places, once on the future left hand side
+                //and once in the future binary operator. But further processing may change
+                //the components of the tree in place (see visitSelect for e.g. <Class>.super.<ident>),
+                //so cloning the tree to avoid interference between the uses:
+                JCExpression expr = (JCExpression) lhs.clone();
+                if (expr.type != tree.type)
+                    expr = make.TypeCast(tree.type, expr);
+                JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
+                opResult.operator = newOperator;
+                opResult.type = newOperator.type.getReturnType();
+                JCExpression newRhs = boxingReq ?
+                    make.TypeCast(types.unboxedType(tree.type), opResult) :
+                    opResult;
+                return make.Assign(lhs, newRhs).setType(tree.type);
+            });
             result = translate(newTree);
             return;
         }
@@ -3287,28 +3271,22 @@
         // translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2
         // where OP is += or -=
         final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST);
-        return abstractLval(tree.arg, new TreeBuilder() {
-                public JCExpression build(final JCExpression tmp1) {
-                    return abstractRval(tmp1, tree.arg.type, new TreeBuilder() {
-                            public JCExpression build(final JCExpression tmp2) {
-                                JCTree.Tag opcode = (tree.hasTag(POSTINC))
-                                    ? PLUS_ASG : MINUS_ASG;
-                                //"tmp1" and "tmp2" may refer to the same instance
-                                //(for e.g. <Class>.super.<ident>). But further processing may
-                                //change the components of the tree in place (see visitSelect),
-                                //so cloning the tree to avoid interference between the two uses:
-                                JCExpression lhs = (JCExpression)tmp1.clone();
-                                lhs = cast
-                                    ? make.TypeCast(tree.arg.type, lhs)
-                                    : lhs;
-                                JCExpression update = makeAssignop(opcode,
-                                                             lhs,
-                                                             make.Literal(1));
-                                return makeComma(update, tmp2);
-                            }
-                        });
-                }
-            });
+        return abstractLval(tree.arg, tmp1 -> abstractRval(tmp1, tree.arg.type, tmp2 -> {
+            Tag opcode = (tree.hasTag(POSTINC))
+                ? PLUS_ASG : MINUS_ASG;
+            //"tmp1" and "tmp2" may refer to the same instance
+            //(for e.g. <Class>.super.<ident>). But further processing may
+            //change the components of the tree in place (see visitSelect),
+            //so cloning the tree to avoid interference between the two uses:
+            JCExpression lhs = (JCExpression)tmp1.clone();
+            lhs = cast
+                ? make.TypeCast(tree.arg.type, lhs)
+                : lhs;
+            JCExpression update = makeAssignop(opcode,
+                                         lhs,
+                                         make.Literal(1));
+            return makeComma(update, tmp2);
+        }));
     }
 
     public void visitUnary(JCUnary tree) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Dec 16 15:27:34 2016 +0000
@@ -424,12 +424,7 @@
                             checkNoAllModulePath();
                             defaultModule.complete();
                             // Question: why not do completeModule here?
-                            defaultModule.completer = new Completer() {
-                                @Override
-                                public void complete(Symbol sym) throws CompletionFailure {
-                                    completeModule((ModuleSymbol) sym);
-                                }
-                            };
+                            defaultModule.completer = sym -> completeModule((ModuleSymbol) sym);
                         }
                         rootModules.add(defaultModule);
                         break;
@@ -1522,7 +1517,7 @@
                 current.complete();
                 if ((current.flags() & Flags.ACYCLIC) != 0)
                     continue;
-                Assert.checkNonNull(current.requires, () -> current.toString());
+                Assert.checkNonNull(current.requires, current::toString);
                 for (RequiresDirective dep : current.requires) {
                     if (!dep.flags.contains(RequiresFlag.EXTRA))
                         queue = queue.prepend(dep.module);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java	Fri Dec 16 15:27:34 2016 +0000
@@ -296,7 +296,7 @@
          */
         private OperatorSymbol[] initOperators() {
             OperatorSymbol[] operators = operatorSuppliers.stream()
-                    .map(op -> op.get())
+                    .map(Supplier::get)
                     .toArray(OperatorSymbol[]::new);
             alternatives = Optional.of(operators);
             operatorSuppliers = null; //let GC do its work
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Dec 16 15:27:34 2016 +0000
@@ -881,12 +881,8 @@
          */
         private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
             if (inferenceContext.free(t)) {
-                inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
-                    @Override
-                    public void typesInferred(InferenceContext inferenceContext) {
-                        varargsAccessible(env, inferenceContext.asInstType(t), inferenceContext);
-                    }
-                });
+                inferenceContext.addFreeTypeListener(List.of(t),
+                        solvedContext -> varargsAccessible(env, solvedContext.asInstType(t), solvedContext));
             } else {
                 if (!isAccessible(env, types.erasure(t))) {
                     Symbol location = env.enclClass.sym;
@@ -1851,47 +1847,43 @@
      * errors if some of the not-needed supertypes are missing/ill-formed).
      */
     Iterable<TypeSymbol> superclasses(final Type intype) {
-        return new Iterable<TypeSymbol>() {
-            public Iterator<TypeSymbol> iterator() {
-                return new Iterator<TypeSymbol>() {
-
-                    List<TypeSymbol> seen = List.nil();
-                    TypeSymbol currentSym = symbolFor(intype);
-                    TypeSymbol prevSym = null;
-
-                    public boolean hasNext() {
-                        if (currentSym == syms.noSymbol) {
-                            currentSym = symbolFor(types.supertype(prevSym.type));
-                        }
-                        return currentSym != null;
-                    }
-
-                    public TypeSymbol next() {
-                        prevSym = currentSym;
-                        currentSym = syms.noSymbol;
-                        Assert.check(prevSym != null || prevSym != syms.noSymbol);
-                        return prevSym;
-                    }
-
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
-
-                    TypeSymbol symbolFor(Type t) {
-                        if (!t.hasTag(CLASS) &&
-                                !t.hasTag(TYPEVAR)) {
-                            return null;
-                        }
-                        t = types.skipTypeVars(t, false);
-                        if (seen.contains(t.tsym)) {
-                            //degenerate case in which we have a circular
-                            //class hierarchy - because of ill-formed classfiles
-                            return null;
-                        }
-                        seen = seen.prepend(t.tsym);
-                        return t.tsym;
-                    }
-                };
+        return () -> new Iterator<TypeSymbol>() {
+
+            List<TypeSymbol> seen = List.nil();
+            TypeSymbol currentSym = symbolFor(intype);
+            TypeSymbol prevSym = null;
+
+            public boolean hasNext() {
+                if (currentSym == syms.noSymbol) {
+                    currentSym = symbolFor(types.supertype(prevSym.type));
+                }
+                return currentSym != null;
+            }
+
+            public TypeSymbol next() {
+                prevSym = currentSym;
+                currentSym = syms.noSymbol;
+                Assert.check(prevSym != null || prevSym != syms.noSymbol);
+                return prevSym;
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+            TypeSymbol symbolFor(Type t) {
+                if (!t.hasTag(CLASS) &&
+                        !t.hasTag(TYPEVAR)) {
+                    return null;
+                }
+                t = types.skipTypeVars(t, false);
+                if (seen.contains(t.tsym)) {
+                    //degenerate case in which we have a circular
+                    //class hierarchy - because of ill-formed classfiles
+                    return null;
+                }
+                seen = seen.prepend(t.tsym);
+                return t.tsym;
             }
         };
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Fri Dec 16 15:27:34 2016 +0000
@@ -32,6 +32,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Context.Factory;
 
 /**
  * Caching implementation of FSInfo.
@@ -47,13 +48,11 @@
      * Register a Context.Factory to create a CacheFSInfo.
      */
     public static void preRegister(Context context) {
-        context.put(FSInfo.class, new Context.Factory<FSInfo>() {
-            public FSInfo make(Context c) {
+        context.put(FSInfo.class, (Factory<FSInfo>)c -> {
                 FSInfo instance = new CacheFSInfo();
                 c.put(FSInfo.class, instance);
                 return instance;
-            }
-        });
+            });
     }
 
     public void clearCache() {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Dec 16 15:27:34 2016 +0000
@@ -71,6 +71,7 @@
 import com.sun.tools.javac.file.RelativePath.RelativeFile;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Context.Factory;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.List;
@@ -134,12 +135,8 @@
      * Register a Context.Factory to create a JavacFileManager.
      */
     public static void preRegister(Context context) {
-        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
-            @Override
-            public JavaFileManager make(Context c) {
-                return new JavacFileManager(c, true, null);
-            }
-        });
+        context.put(JavaFileManager.class,
+                (Factory<JavaFileManager>)c -> new JavacFileManager(c, true, null));
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Dec 16 15:27:34 2016 +0000
@@ -272,7 +272,7 @@
             }
 
             try (Stream<Path> s = Files.list(dir)) {
-                s.filter(dirEntry -> isArchive(dirEntry))
+                s.filter(Locations.this::isArchive)
                         .forEach(dirEntry -> addFile(dirEntry, warn));
             } catch (IOException ignore) {
             }
@@ -946,7 +946,7 @@
             if (searchPath == null)
                 return Collections.emptyList();
 
-            return () -> new ModulePathIterator();
+            return ModulePathIterator::new;
         }
 
         @Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Dec 16 15:27:34 2016 +0000
@@ -365,16 +365,8 @@
             Assert.check(!refSym.owner.isInterface() || interfaceOwner);
         }
         //where
-                Filter<Name> nonInitFilter = new Filter<Name>() {
-                    public boolean accepts(Name n) {
-                        return n != n.table.names.init && n != n.table.names.clinit;
-                    }
-                };
+                Filter<Name> nonInitFilter = n -> (n != n.table.names.init && n != n.table.names.clinit);
 
-                Filter<Name> initFilter = new Filter<Name>() {
-                    public boolean accepts(Name n) {
-                        return n == n.table.names.init;
-                    }
-                };
+                Filter<Name> initFilter = n -> n == n.table.names.init;
     }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Dec 16 15:27:34 2016 +0000
@@ -337,12 +337,7 @@
      * SourceCompleter that delegates to the readSourceFile method of this class.
      */
     protected final Symbol.Completer sourceCompleter =
-            new Symbol.Completer() {
-                @Override
-                public void complete(Symbol sym) throws CompletionFailure {
-                    readSourceFile((ClassSymbol) sym);
-                }
-            };
+            sym -> readSourceFile((ClassSymbol) sym);
 
     protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
             fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/FilteredMemberList.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/FilteredMemberList.java	Fri Dec 16 15:27:34 2016 +0000
@@ -71,11 +71,7 @@
 
     // A more efficient implementation than AbstractList's.
     public Iterator<Symbol> iterator() {
-        return scope.getSymbols(new Filter<Symbol>() {
-            public boolean accepts(Symbol t) {
-                return !unwanted(t);
-            }
-        }, NON_RECURSIVE).iterator();
+        return scope.getSymbols(t -> !unwanted(t), NON_RECURSIVE).iterator();
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Dec 16 15:27:34 2016 +0000
@@ -1718,11 +1718,7 @@
     }
 
     /** Accepts all identifier-like tokens */
-    protected Filter<TokenKind> LAX_IDENTIFIER = new Filter<TokenKind>() {
-        public boolean accepts(TokenKind t) {
-            return t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
-        }
-    };
+    protected Filter<TokenKind> LAX_IDENTIFIER = t -> t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
 
     enum ParensResult {
         CAST,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Dec 16 15:27:34 2016 +0000
@@ -324,7 +324,7 @@
         if (platformProvider != null) {
             platformProcessors = platformProvider.getAnnotationProcessors()
                                                  .stream()
-                                                 .map(ap -> ap.getPlugin())
+                                                 .map(PluginInfo::getPlugin)
                                                  .collect(Collectors.toList());
         }
         List<Iterator<? extends Processor>> iterators = List.of(processorIterator,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri Dec 16 15:27:34 2016 +0000
@@ -73,11 +73,7 @@
 
             final Options options = Options.instance(context);
             initOptions(options);
-            options.addListener(new Runnable() {
-               public void run() {
-                   initOptions(options);
-               }
-            });
+            options.addListener(() -> initOptions(options));
         }
 
         private void initOptions(Options options) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java	Fri Dec 16 15:27:34 2016 +0000
@@ -557,8 +557,8 @@
      */
     public static <Z> Collector<Z, ListBuffer<Z>, List<Z>> collector() {
         return Collector.of(ListBuffer::new,
-                (buf, el)->buf.add(el),
+                ListBuffer::add,
                 (buf1, buf2)-> { buf1.addAll(buf2); return buf1; },
-                buf->buf.toList());
+                ListBuffer::toList);
     }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Fri Dec 16 15:27:34 2016 +0000
@@ -364,12 +364,7 @@
 
         final Options options = Options.instance(context);
         initOptions(options);
-        options.addListener(new Runnable() {
-            @Override
-            public void run() {
-                initOptions(options);
-            }
-        });
+        options.addListener(() -> initOptions(options));
     }
     // where
         private void initOptions(Options options) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java	Fri Dec 16 15:27:34 2016 +0000
@@ -310,15 +310,12 @@
 
     private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
         final PrintWriter pw = getPrintWriterForWriter(w);
-        return new DiagnosticListener<JavaFileObject> () {
-            @DefinedBy(Api.COMPILER)
-            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-                if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
-                    pw.print(getMessage("err.prefix"));
-                    pw.print(" ");
-                }
-                pw.println(diagnostic.getMessage(null));
+        return diagnostic -> {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                pw.print(getMessage("err.prefix"));
+                pw.print(" ");
             }
+            pw.println(diagnostic.getMessage(null));
         };
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Fri Dec 16 15:27:34 2016 +0000
@@ -487,7 +487,7 @@
             Set<String> deps = pkg.typeDependencies()
                                   .values()
                                   .stream()
-                                  .flatMap(s -> s.stream())
+                                  .flatMap(Collection::stream)
                                   .collect(Collectors.toSet());
             for (String dep : deps) {
                 String depPkg = ":" + dep.substring(0, dep.lastIndexOf('.'));
--- a/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java	Fri Dec 16 15:27:34 2016 +0000
@@ -53,6 +53,7 @@
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.ElementFilter;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileManager;
@@ -240,7 +241,7 @@
                             List<String> throwsList =
                                     executableElement.getThrownTypes()
                                                      .stream()
-                                                     .map(exc -> exc.toString())
+                                                     .map(TypeMirror::toString)
                                                      .collect(Collectors.toList());
                             Set<String> missingParams = new HashSet<>(parameters);
                             Set<String> missingThrows = new HashSet<>(throwsList);
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocClassFinder.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocClassFinder.java	Fri Dec 16 15:27:34 2016 +0000
@@ -31,6 +31,7 @@
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.ClassFinder;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Context.Factory;
 
 /** Javadoc uses an extended class finder that records package.html entries
  *
@@ -52,11 +53,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(classFinderKey, new Context.Factory<ClassFinder>() {
-            public ClassFinder make(Context c) {
-                return new JavadocClassFinder(c);
-            }
-        });
+        context.put(classFinderKey, (Factory<ClassFinder>)JavadocClassFinder::new);
     }
 
     private DocEnv docenv;
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocEnter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocEnter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -58,11 +58,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(enterKey, new Context.Factory<Enter>() {
-               public Enter make(Context c) {
-                   return new JavadocEnter(c);
-               }
-        });
+        context.put(enterKey, (Context.Factory<Enter>)JavadocEnter::new);
     }
 
     protected JavadocEnter(Context context) {
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocMemberEnter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocMemberEnter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -57,11 +57,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
-               public MemberEnter make(Context c) {
-                   return new JavadocMemberEnter(c);
-               }
-        });
+        context.put(memberEnterKey, (Context.Factory<MemberEnter>)JavadocMemberEnter::new);
     }
 
     final DocEnv docenv;
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTodo.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTodo.java	Fri Dec 16 15:27:34 2016 +0000
@@ -27,6 +27,7 @@
 
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Context.Factory;
 
 /**
  *  Javadoc's own todo queue doesn't queue its inputs, as javadoc
@@ -42,11 +43,7 @@
 @Deprecated
 public class JavadocTodo extends Todo {
     public static void preRegister(Context context) {
-        context.put(todoKey, new Context.Factory<Todo>() {
-               public Todo make(Context c) {
-                   return new JavadocTodo(c);
-               }
-        });
+        context.put(todoKey, (Factory<Todo>)JavadocTodo::new);
     }
 
     protected JavadocTodo(Context context) {
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Messager.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Messager.java	Fri Dec 16 15:27:34 2016 +0000
@@ -31,6 +31,7 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Context.Factory;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 import com.sun.tools.javac.util.JavacMessages;
@@ -66,27 +67,18 @@
 
     public static void preRegister(Context context,
                                    final String programName) {
-        context.put(logKey, new Context.Factory<Log>() {
-            public Log make(Context c) {
-                return new Messager(c,
-                                    programName);
-            }
-        });
+        context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
     }
     public static void preRegister(Context context,
                                    final String programName,
                                    final PrintWriter errWriter,
                                    final PrintWriter warnWriter,
                                    final PrintWriter noticeWriter) {
-        context.put(logKey, new Context.Factory<Log>() {
-            public Log make(Context c) {
-                return new Messager(c,
-                                    programName,
-                                    errWriter,
-                                    warnWriter,
-                                    noticeWriter);
-            }
-        });
+        context.put(logKey, (Factory<Log>)c -> new Messager(c,
+                            programName,
+                            errWriter,
+                            warnWriter,
+                            noticeWriter));
     }
 
     public class ExitJavadoc extends Error {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -258,7 +258,7 @@
             }
         }
         if (!set.isEmpty()) {
-            String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
+            String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
             htmltree.addContent(mods);
             htmltree.addContent(Contents.SPACE);
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Dec 16 15:27:34 2016 +0000
@@ -263,9 +263,7 @@
         generateClassFiles(classtree);
         SortedSet<PackageElement> packages = new TreeSet<>(utils.makePackageComparator());
         packages.addAll(configuration.getSpecifiedPackageElements());
-        configuration.modulePackages.values().stream().forEach(pset -> {
-            packages.addAll(pset);
-        });
+        configuration.modulePackages.values().stream().forEach(packages::addAll);
         for (PackageElement pkg : packages) {
             generateClassFiles(utils.getAllClasses(pkg), classtree);
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Fri Dec 16 15:27:34 2016 +0000
@@ -529,9 +529,7 @@
             buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);
         if (!summaryTreeList.isEmpty()) {
             Content memberTree = writer.getMemberSummaryHeader(typeElement, memberSummaryTree);
-            summaryTreeList.stream().forEach((aSummaryTreeList) -> {
-                memberTree.addContent(aSummaryTreeList);
-            });
+            summaryTreeList.stream().forEach(memberTree::addContent);
             writer.addMemberTree(memberSummaryTree, memberTree);
         }
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Dec 16 15:27:34 2016 +0000
@@ -533,7 +533,7 @@
             }
 
             void addModifers(Set<Modifier> modifiers) {
-                String s = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
+                String s = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
                 sb.append(s);
                 if (!s.isEmpty())
                     sb.append(" ");
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java	Fri Dec 16 15:27:34 2016 +0000
@@ -255,13 +255,9 @@
                 vars.add(t.asType());
             });
         } else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
-            ((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach((t) -> {
-                vars.add(t);
-            });
+            ((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach(vars::add);
         } else if (ctype != null && utils.isDeclaredType(ctype)) {
-            ((DeclaredType)ctype).getTypeArguments().stream().forEach((t) -> {
-                vars.add(t);
-            });
+            ((DeclaredType)ctype).getTypeArguments().stream().forEach(vars::add);
         } else if (linkInfo.typeElement != null) {
             linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
                 vars.add(t.asType());
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java	Fri Dec 16 15:27:34 2016 +0000
@@ -373,7 +373,7 @@
         // scan for modules with qualified subpackages
         ((List<String>)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST))
             .stream()
-            .map((packageName) -> new ModulePackage(packageName))
+            .map(ModulePackage::new)
             .forEachOrdered((mpkg) -> {
                 subPackages.add(mpkg);
                 if (mpkg.hasModule()) {
@@ -420,7 +420,7 @@
      */
     ElementsTable packages(Collection<String> packageNames) {
         packageNames.stream()
-            .map((packageName) -> new ModulePackage(packageName))
+            .map(ModulePackage::new)
             .forEachOrdered((mpkg) -> cmdLinePackages.add(mpkg));
         return this;
     }
@@ -443,7 +443,7 @@
     private void computeSubpackages() throws ToolException {
         ((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
                 .stream()
-                .map((packageName) -> new ModulePackage(packageName))
+                .map(ModulePackage::new)
                 .forEachOrdered((mpkg) -> excludePackages.add(mpkg));
 
         excludePackages.forEach((p) -> {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocClassFinder.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocClassFinder.java	Fri Dec 16 15:27:34 2016 +0000
@@ -33,6 +33,7 @@
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.ClassFinder;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Context.Factory;
 
 /** Javadoc uses an extended class finder that records package.html entries
  *
@@ -53,11 +54,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(classFinderKey, new Context.Factory<ClassFinder>() {
-            public ClassFinder make(Context c) {
-                return new JavadocClassFinder(c);
-            }
-        });
+        context.put(classFinderKey, (Factory<ClassFinder>)JavadocClassFinder::new);
     }
 
     private ToolEnvironment toolEnv;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocEnter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -57,11 +57,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(enterKey, new Context.Factory<Enter>() {
-               public Enter make(Context c) {
-                   return new JavadocEnter(c);
-               }
-        });
+        context.put(enterKey, (Context.Factory<Enter>)JavadocEnter::new);
     }
 
     protected JavadocEnter(Context context) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocMemberEnter.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocMemberEnter.java	Fri Dec 16 15:27:34 2016 +0000
@@ -56,11 +56,7 @@
     }
 
     public static void preRegister(Context context) {
-        context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
-               public MemberEnter make(Context c) {
-                   return new JavadocMemberEnter(c);
-               }
-        });
+        context.put(memberEnterKey, (Context.Factory<MemberEnter>)JavadocMemberEnter::new);
     }
 
     final ToolEnvironment toolEnv;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTodo.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTodo.java	Fri Dec 16 15:27:34 2016 +0000
@@ -27,6 +27,7 @@
 
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Context.Factory;
 
 /**
  *  Javadoc's own todo queue doesn't queue its inputs, as javadoc
@@ -41,11 +42,7 @@
  */
 public class JavadocTodo extends Todo {
     public static void preRegister(Context context) {
-        context.put(todoKey, new Context.Factory<Todo>() {
-               public Todo make(Context c) {
-                   return new JavadocTodo(c);
-               }
-        });
+        context.put(todoKey, (Factory<Todo>)JavadocTodo::new);
     }
 
     protected JavadocTodo(Context context) {
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Fri Dec 16 15:27:34 2016 +0000
@@ -33,6 +33,7 @@
 import javax.lang.model.element.Element;
 import javax.tools.Diagnostic.Kind;
 
+import com.sun.tools.javac.util.Context.Factory;
 import jdk.javadoc.doclet.Reporter;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.util.DocSourcePositions;
@@ -73,20 +74,12 @@
 
     public static void preRegister(Context context,
                                    final String programName) {
-        context.put(logKey, new Context.Factory<Log>() {
-            public Log make(Context c) {
-                return new Messager(c, programName);
-            }
-        });
+        context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
     }
 
     public static void preRegister(Context context, final String programName,
             final PrintWriter outWriter, final PrintWriter errWriter) {
-        context.put(logKey, new Context.Factory<Log>() {
-            public Log make(Context c) {
-                return new Messager(c, programName, outWriter, errWriter);
-            }
-        });
+        context.put(logKey, (Factory<Log>)c -> new Messager(c, programName, outWriter, errWriter));
     }
 
     @Override
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Fri Dec 16 15:27:34 2016 +0000
@@ -211,7 +211,7 @@
         Stream.of(ToolOption.values())
                     .filter(opt -> opt.kind == kind)
                     .sorted(comp)
-                    .forEach(opt -> showToolOption(opt));
+                    .forEach(this::showToolOption);
     }
 
     void showToolOption(ToolOption option) {
@@ -241,7 +241,7 @@
         doclet.getSupportedOptions().stream()
                 .filter(opt -> opt.getKind() == kind)
                 .sorted(comp)
-                .forEach(opt -> showDocletOption(opt));
+                .forEach(this::showDocletOption);
     }
 
     void showDocletOption(Doclet.Option option) {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Code_attribute.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Code_attribute.java	Fri Dec 16 15:27:34 2016 +0000
@@ -103,34 +103,29 @@
     }
 
     public Iterable<Instruction> getInstructions() {
-        return new Iterable<Instruction>() {
-            public Iterator<Instruction> iterator() {
-                return new Iterator<Instruction>() {
+        return () -> new Iterator<Instruction>() {
 
-                    public boolean hasNext() {
-                        return (next != null);
-                    }
+            public boolean hasNext() {
+                return (next != null);
+            }
 
-                    public Instruction next() {
-                        if (next == null)
-                            throw new NoSuchElementException();
+            public Instruction next() {
+                if (next == null)
+                    throw new NoSuchElementException();
 
-                        current = next;
-                        pc += current.length();
-                        next = (pc < code.length ? new Instruction(code, pc) : null);
-                        return current;
-                    }
+                current = next;
+                pc += current.length();
+                next = (pc < code.length ? new Instruction(code, pc) : null);
+                return current;
+            }
 
-                    public void remove() {
-                        throw new UnsupportedOperationException("Not supported.");
-                    }
+            public void remove() {
+                throw new UnsupportedOperationException("Not supported.");
+            }
 
-                    Instruction current = null;
-                    int pc = 0;
-                    Instruction next = new Instruction(code, pc);
-
-                };
-            }
+            Instruction current = null;
+            int pc = 0;
+            Instruction next = new Instruction(code, pc);
 
         };
     }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConstantPool.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ConstantPool.java	Fri Dec 16 15:27:34 2016 +0000
@@ -313,36 +313,32 @@
     }
 
     public Iterable<CPInfo> entries() {
-        return new Iterable<CPInfo>() {
-            public Iterator<CPInfo> iterator() {
-                return new Iterator<CPInfo>() {
+        return () -> new Iterator<CPInfo>() {
 
-                    public boolean hasNext() {
-                        return next < pool.length;
-                    }
+            public boolean hasNext() {
+                return next < pool.length;
+            }
 
-                    public CPInfo next() {
-                        current = pool[next];
-                        switch (current.getTag()) {
-                            case CONSTANT_Double:
-                            case CONSTANT_Long:
-                                next += 2;
-                                break;
-                            default:
-                                next += 1;
-                        }
-                        return current;
-                    }
+            public CPInfo next() {
+                current = pool[next];
+                switch (current.getTag()) {
+                    case CONSTANT_Double:
+                    case CONSTANT_Long:
+                        next += 2;
+                        break;
+                    default:
+                        next += 1;
+                }
+                return current;
+            }
 
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
 
-                    private CPInfo current;
-                    private int next = 1;
+            private CPInfo current;
+            private int next = 1;
 
-                };
-            }
         };
     }
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependencies.java	Fri Dec 16 15:27:34 2016 +0000
@@ -248,11 +248,7 @@
             boolean transitiveClosure)
             throws ClassFileNotFoundException {
         final Set<Dependency> results = new HashSet<>();
-        Recorder r = new Recorder() {
-            public void addDependency(Dependency d) {
-                results.add(d);
-            }
-        };
+        Recorder r = results::add;
         findAllDependencies(classFinder, rootClassNames, transitiveClosure, r);
         return results;
     }
@@ -565,7 +561,7 @@
         private Map<String,Location> locations = new ConcurrentHashMap<>();
 
         Location getLocation(String className) {
-            return locations.computeIfAbsent(className, cn -> new SimpleLocation(cn));
+            return locations.computeIfAbsent(className, SimpleLocation::new);
         }
 
         class Visitor implements ConstantPool.Visitor<Void,Void>, Type.Visitor<Void, Void> {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Fri Dec 16 15:27:34 2016 +0000
@@ -408,22 +408,20 @@
 
     private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
         final PrintWriter pw = getPrintWriterForWriter(w);
-        return new DiagnosticListener<JavaFileObject> () {
-            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-                switch (diagnostic.getKind()) {
-                    case ERROR:
-                        pw.print(getMessage("err.prefix"));
-                        break;
-                    case WARNING:
-                        pw.print(getMessage("warn.prefix"));
-                        break;
-                    case NOTE:
-                        pw.print(getMessage("note.prefix"));
-                        break;
-                }
-                pw.print(" ");
-                pw.println(diagnostic.getMessage(null));
+        return diagnostic -> {
+            switch (diagnostic.getKind()) {
+                case ERROR:
+                    pw.print(getMessage("err.prefix"));
+                    break;
+                case WARNING:
+                    pw.print(getMessage("warn.prefix"));
+                    break;
+                case NOTE:
+                    pw.print(getMessage("note.prefix"));
+                    break;
             }
+            pw.print(" ");
+            pw.println(diagnostic.getMessage(null));
         };
     }
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Fri Dec 16 15:27:34 2016 +0000
@@ -147,11 +147,7 @@
     }
 
     public Iterable<ClassFile> getClassFiles() throws IOException {
-        return new Iterable<ClassFile>() {
-            public Iterator<ClassFile> iterator() {
-                return new FileIterator();
-            }
-        };
+        return FileIterator::new;
     }
 
     protected ClassFile readClassFile(Path p) throws IOException {
@@ -232,7 +228,7 @@
         protected Set<String> scan() {
             try (Stream<Path> stream = Files.walk(path, Integer.MAX_VALUE)) {
                 return stream.filter(ClassFileReader::isClass)
-                             .map(f -> path.relativize(f))
+                             .map(path::relativize)
                              .map(Path::toString)
                              .map(p -> p.replace(File.separatorChar, '/'))
                              .collect(Collectors.toSet());
@@ -264,11 +260,7 @@
 
         public Iterable<ClassFile> getClassFiles() throws IOException {
             final Iterator<ClassFile> iter = new DirectoryIterator();
-            return new Iterable<ClassFile>() {
-                public Iterator<ClassFile> iterator() {
-                    return iter;
-                }
-            };
+            return () -> iter;
         }
 
         class DirectoryIterator implements Iterator<ClassFile> {
@@ -387,11 +379,7 @@
 
         public Iterable<ClassFile> getClassFiles() throws IOException {
             final Iterator<ClassFile> iter = new JarFileIterator(this, jarfile);
-            return new Iterable<ClassFile>() {
-                public Iterator<ClassFile> iterator() {
-                    return iter;
-                }
-            };
+            return () -> iter;
         }
     }
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java	Fri Dec 16 15:27:34 2016 +0000
@@ -32,6 +32,7 @@
 import com.sun.tools.classfile.ClassFile;
 import com.sun.tools.classfile.ConstantPoolException;
 import com.sun.tools.classfile.Dependencies;
+import com.sun.tools.classfile.Dependencies.ClassFileError;
 import com.sun.tools.classfile.Dependency;
 import com.sun.tools.classfile.Dependency.Location;
 
@@ -172,43 +173,41 @@
         parsedArchives.get(finder).add(archive);
 
         trace("parsing %s %s%n", archive.getName(), archive.path());
-        FutureTask<Set<Location>> task = new FutureTask<>(new Callable<>() {
-            public Set<Location> call() throws Exception {
-                Set<Location> targets = new HashSet<>();
-                for (ClassFile cf : archive.reader().getClassFiles()) {
-                    if (cf.access_flags.is(AccessFlags.ACC_MODULE))
-                        continue;
+        FutureTask<Set<Location>> task = new FutureTask<>(() -> {
+            Set<Location> targets = new HashSet<>();
+            for (ClassFile cf : archive.reader().getClassFiles()) {
+                if (cf.access_flags.is(AccessFlags.ACC_MODULE))
+                    continue;
 
-                    String classFileName;
-                    try {
-                        classFileName = cf.getName();
-                    } catch (ConstantPoolException e) {
-                        throw new Dependencies.ClassFileError(e);
-                    }
-
-                    // filter source class/archive
-                    String cn = classFileName.replace('/', '.');
-                    if (!finder.accept(archive, cn, cf.access_flags))
-                        continue;
-
-                    // tests if this class matches the -include
-                    if (!filter.matches(cn))
-                        continue;
-
-                    for (Dependency d : finder.findDependencies(cf)) {
-                        if (filter.accepts(d)) {
-                            archive.addClass(d.getOrigin(), d.getTarget());
-                            targets.add(d.getTarget());
-                        } else {
-                            // ensure that the parsed class is added the archive
-                            archive.addClass(d.getOrigin());
-                        }
-                        parsedClasses.putIfAbsent(d.getOrigin(), archive);
-                    }
+                String classFileName;
+                try {
+                    classFileName = cf.getName();
+                } catch (ConstantPoolException e) {
+                    throw new ClassFileError(e);
                 }
 
-                return targets;
+                // filter source class/archive
+                String cn = classFileName.replace('/', '.');
+                if (!finder.accept(archive, cn, cf.access_flags))
+                    continue;
+
+                // tests if this class matches the -include
+                if (!filter.matches(cn))
+                    continue;
+
+                for (Dependency d : finder.findDependencies(cf)) {
+                    if (filter.accepts(d)) {
+                        archive.addClass(d.getOrigin(), d.getTarget());
+                        targets.add(d.getTarget());
+                    } else {
+                        // ensure that the parsed class is added the archive
+                        archive.addClass(d.getOrigin());
+                    }
+                    parsedClasses.putIfAbsent(d.getOrigin(), archive);
+                }
             }
+
+            return targets;
         });
         tasks.add(task);
         pool.submit(task);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Fri Dec 16 15:27:34 2016 +0000
@@ -209,7 +209,7 @@
                 visited.add(node);
                 edges.get(node).stream()
                      .filter(e -> includeAdjacent || !node.equals(u) || !e.equals(v))
-                     .forEach(e -> stack.push(e));
+                     .forEach(stack::push);
             }
         }
         assert !visited.contains(v);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java	Fri Dec 16 15:27:34 2016 +0000
@@ -394,25 +394,20 @@
                 ModuleDescriptor descriptor = dropHashes(ModuleDescriptor.read(bin));
                 String mn = descriptor.name();
                 URI uri = URI.create("jrt:/" + path.getFileName().toString());
-                Supplier<ModuleReader> readerSupplier = new Supplier<>() {
+                Supplier<ModuleReader> readerSupplier = () -> new ModuleReader() {
                     @Override
-                    public ModuleReader get() {
-                        return new ModuleReader() {
-                            @Override
-                            public Optional<URI> find(String name) throws IOException {
-                                return name.equals(mn)
-                                    ? Optional.of(uri) : Optional.empty();
-                            }
+                    public Optional<URI> find(String name) throws IOException {
+                        return name.equals(mn)
+                            ? Optional.of(uri) : Optional.empty();
+                    }
 
-                            @Override
-                            public Stream<String> list() {
-                                return Stream.empty();
-                            }
+                    @Override
+                    public Stream<String> list() {
+                        return Stream.empty();
+                    }
 
-                            @Override
-                            public void close() {
-                            }
-                        };
+                    @Override
+                    public void close() {
                     }
                 };
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Fri Dec 16 15:27:34 2016 +0000
@@ -889,15 +889,11 @@
             if (!ok && !options.nowarning) {
                 reportError("err.missing.dependences");
                 builder.visitMissingDeps(
-                    new Analyzer.Visitor() {
-                        @Override
-                        public void visitDependence(String origin, Archive originArchive,
-                                                    String target, Archive targetArchive) {
+                        (origin, originArchive, target, targetArchive) -> {
                             if (builder.notFound(targetArchive))
                                 log.format("   %-50s -> %-50s %s%n",
                                     origin, target, targetArchive.getName());
-                        }
-                    });
+                        });
             }
             return ok;
         }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java	Fri Dec 16 15:27:34 2016 +0000
@@ -69,21 +69,16 @@
 
         // A visitor to record the module-level dependences as well as
         // use of JDK internal APIs
-        Analyzer.Visitor visitor = new Analyzer.Visitor() {
-            @Override
-            public void visitDependence(String origin, Archive originArchive,
-                                        String target, Archive targetArchive)
-            {
-                Set<String> jdkInternals =
-                    deps.computeIfAbsent(originArchive, _k -> new HashMap<>())
-                        .computeIfAbsent(targetArchive, _k -> new HashSet<>());
+        Analyzer.Visitor visitor = (origin, originArchive, target, targetArchive) -> {
+            Set<String> jdkInternals =
+                deps.computeIfAbsent(originArchive, _k -> new HashMap<>())
+                    .computeIfAbsent(targetArchive, _k -> new HashSet<>());
 
-                Module module = targetArchive.getModule();
-                if (originArchive.getModule() != module &&
-                        module.isJDK() && !module.isExported(target)) {
-                    // use of JDK internal APIs
-                    jdkInternals.add(target);
-                }
+            Module module = targetArchive.getModule();
+            if (originArchive.getModule() != module &&
+                    module.isJDK() && !module.isExported(target)) {
+                // use of JDK internal APIs
+                jdkInternals.add(target);
             }
         };
 
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java	Fri Dec 16 15:27:34 2016 +0000
@@ -150,6 +150,6 @@
         }
         System.out.println("All JDK modules:-");
         JDK.stream().sorted(Comparator.comparing(Module::name))
-           .forEach(m -> System.out.println(m));
+           .forEach(System.out::println);
     }
 }
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Fri Dec 16 15:27:34 2016 +0000
@@ -30,6 +30,8 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+
 import static java.util.stream.Collectors.toList;
 
 /**
@@ -139,7 +141,7 @@
      */
     int optionCount() {
         return (int) options.entrySet().stream()
-                .filter(e -> e.getValue())
+                .filter(Entry::getValue)
                 .count();
     }
 
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Fri Dec 16 15:27:34 2016 +0000
@@ -125,7 +125,7 @@
 
                 boolean smart = allowSmart &&
                                 suggestions.stream()
-                                           .anyMatch(s -> s.matchesType());
+                                           .anyMatch(Suggestion::matchesType);
 
                 lastTest = test;
                 lastCursor = cursor;
@@ -133,16 +133,16 @@
 
                 suggestions.stream()
                            .filter(s -> !smart || s.matchesType())
-                           .map(s -> s.continuation())
+                           .map(Suggestion::continuation)
                            .forEach(result::add);
 
                 boolean onlySmart = suggestions.stream()
-                                               .allMatch(s -> s.matchesType());
+                                               .allMatch(Suggestion::matchesType);
 
                 if (smart && !onlySmart) {
                     Optional<String> prefix =
                             suggestions.stream()
-                                       .map(s -> s.continuation())
+                                       .map(Suggestion::continuation)
                                        .reduce(ConsoleIOContext::commonPrefix);
 
                     String prefixStr = prefix.orElse("").substring(cursor - anchor[0]);
@@ -281,7 +281,7 @@
                                                               term.isAnsiSupported());
             Function<Documentation, String> convertor;
             if (firstInvocation) {
-                convertor = d -> d.signature();
+                convertor = Documentation::signature;
             } else {
                 convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) +
                                  (d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc")
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java	Fri Dec 16 15:27:34 2016 +0000
@@ -38,10 +38,8 @@
 
 class ContinuousCompletionProvider implements CompletionProvider {
 
-    static final BiPredicate<String, String> STARTSWITH_MATCHER =
-            (word, input) -> word.startsWith(input);
-    static final BiPredicate<String, String> PERFECT_MATCHER =
-            (word, input) -> word.equals(input);
+    static final BiPredicate<String, String> STARTSWITH_MATCHER = String::startsWith;
+    static final BiPredicate<String, String> PERFECT_MATCHER = String::equals;
 
     private final Supplier<Map<String, CompletionProvider>> wordCompletionProviderSupplier;
     private final BiPredicate<String, String> matcher;
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java	Fri Dec 16 15:27:34 2016 +0000
@@ -882,7 +882,7 @@
 
         void showTruncationSettings(Mode sm) {
             if (sm == null) {
-                modeMap.values().forEach(m -> showTruncationSettings(m));
+                modeMap.values().forEach(this::showTruncationSettings);
             } else {
                 List<Mode.Setting> trunc = sm.cases.get(TRUNCATION_FIELD);
                 if (trunc != null) {
@@ -897,7 +897,7 @@
 
         void showPromptSettings(Mode sm) {
             if (sm == null) {
-                modeMap.values().forEach(m -> showPromptSettings(m));
+                modeMap.values().forEach(this::showPromptSettings);
             } else {
                 hard("/set prompt %s %s %s",
                         sm.name,
@@ -908,7 +908,7 @@
 
         void showModeSettings(String umode, String msg) {
             if (umode == null) {
-                modeMap.values().forEach(n -> showModeSettings(n));
+                modeMap.values().forEach(this::showModeSettings);
             } else {
                 Mode m;
                 String retained = retainedMap.get(umode);
@@ -1272,7 +1272,7 @@
                 return null;
             }
             if (at.isQuoted() ||
-                    !id.codePoints().allMatch(cp -> Character.isJavaIdentifierPart(cp))) {
+                    !id.codePoints().allMatch(Character::isJavaIdentifierPart)) {
                 errorat(err, id);
                 return null;
             }
@@ -1307,8 +1307,8 @@
             // Failing an exact match, go searching
             Mode[] matches = modeMap.entrySet().stream()
                     .filter(e -> e.getKey().startsWith(umode))
-                    .map(e -> e.getValue())
-                    .toArray(size -> new Mode[size]);
+                    .map(Entry::getValue)
+                    .toArray(Mode[]::new);
             if (matches.length == 1) {
                 return matches[0];
             } else {
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Dec 16 15:27:34 2016 +0000
@@ -452,7 +452,7 @@
     <T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
         Map<String, String> a2b = stream.collect(toMap(a, b,
                 (m1, m2) -> m1,
-                () -> new LinkedHashMap<>()));
+                LinkedHashMap::new));
         for (Entry<String, String> e : a2b.entrySet()) {
             hard("%s", e.getKey());
             rawout(prefix(e.getValue(), feedback.getPre() + "\t", feedback.getPost()));
@@ -953,7 +953,7 @@
                        .stream()
                        .filter(filter)
                        .filter(command -> command.command.startsWith(cmd))
-                       .toArray(size -> new Command[size]);
+                       .toArray(Command[]::new);
     }
 
     private static Path toPathResolvingUserHome(String pathString) {
@@ -1125,7 +1125,7 @@
                                 ? Stream.of(String.valueOf(k.id()) + " ", ((DeclarationSnippet) k).name() + " ")
                                 : Stream.of(String.valueOf(k.id()) + " "))
                         .filter(k -> k.startsWith(argPrefix))
-                        .map(k -> new ArgSuggestion(k))
+                        .map(ArgSuggestion::new)
                         .collect(Collectors.toList());
         };
     }
@@ -1154,7 +1154,7 @@
                 result = new FixedCompletionProvider(commands.values().stream()
                         .filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
                         .map(c -> c.command + " ")
-                        .toArray(size -> new String[size]))
+                        .toArray(String[]::new))
                         .completionSuggestions(code, cursor, anchor);
             } else if (code.startsWith("/se")) {
                 result = new FixedCompletionProvider(SET_SUBCOMMANDS)
@@ -1264,33 +1264,33 @@
 
     {
         registerCommand(new Command("/list",
-                arg -> cmdList(arg),
+                this::cmdList,
                 snippetWithOptionCompletion(SNIPPET_HISTORY_OPTION_COMPLETION_PROVIDER,
                         this::allSnippets)));
         registerCommand(new Command("/edit",
-                arg -> cmdEdit(arg),
+                this::cmdEdit,
                 snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
                         this::allSnippets)));
         registerCommand(new Command("/drop",
-                arg -> cmdDrop(arg),
+                this::cmdDrop,
                 snippetCompletion(this::dropableSnippets),
                 CommandKind.REPLAY));
         registerCommand(new Command("/save",
-                arg -> cmdSave(arg),
+                this::cmdSave,
                 saveCompletion()));
         registerCommand(new Command("/open",
-                arg -> cmdOpen(arg),
+                this::cmdOpen,
                 FILE_COMPLETION_PROVIDER));
         registerCommand(new Command("/vars",
-                arg -> cmdVars(arg),
+                this::cmdVars,
                 snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
                         this::allVarSnippets)));
         registerCommand(new Command("/methods",
-                arg -> cmdMethods(arg),
+                this::cmdMethods,
                 snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
                         this::allMethodSnippets)));
         registerCommand(new Command("/types",
-                arg -> cmdTypes(arg),
+                this::cmdTypes,
                 snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
                         this::allTypeSnippets)));
         registerCommand(new Command("/imports",
@@ -1303,24 +1303,24 @@
                 arg -> cmdReset(),
                 EMPTY_COMPLETION_PROVIDER));
         registerCommand(new Command("/reload",
-                arg -> cmdReload(arg),
+                this::cmdReload,
                 reloadCompletion()));
         registerCommand(new Command("/classpath",
-                arg -> cmdClasspath(arg),
+                this::cmdClasspath,
                 classPathCompletion(),
                 CommandKind.REPLAY));
         registerCommand(new Command("/history",
                 arg -> cmdHistory(),
                 EMPTY_COMPLETION_PROVIDER));
         registerCommand(new Command("/debug",
-                arg -> cmdDebug(arg),
+                this::cmdDebug,
                 EMPTY_COMPLETION_PROVIDER,
                 CommandKind.HIDDEN));
         registerCommand(new Command("/help",
-                arg -> cmdHelp(arg),
+                this::cmdHelp,
                 helpCompletion()));
         registerCommand(new Command("/set",
-                arg -> cmdSet(arg),
+                this::cmdSet,
                 new ContinuousCompletionProvider(Map.of(
                         // need more completion for format for usability
                         "format", feedback.modeCompletions(),
@@ -1335,7 +1335,7 @@
                         STARTSWITH_MATCHER)));
         registerCommand(new Command("/?",
                 "help.quest",
-                arg -> cmdHelp(arg),
+                this::cmdHelp,
                 helpCompletion(),
                 CommandKind.NORMAL));
         registerCommand(new Command("/!",
@@ -1450,7 +1450,7 @@
         }
         String[] matches = Arrays.stream(subs)
                 .filter(s -> s.startsWith(sub))
-                .toArray(size -> new String[size]);
+                .toArray(String[]::new);
         if (matches.length == 0) {
             // There are no matching sub-commands
             errormsg("jshell.err.arg", cmd, sub);
@@ -1784,7 +1784,7 @@
         if (subject != null) {
             Command[] matches = commands.values().stream()
                     .filter(c -> c.command.startsWith(subject))
-                    .toArray(size -> new Command[size]);
+                    .toArray(Command[]::new);
             if (matches.length == 1) {
                 String cmd = matches[0].command;
                 if (cmd.equals("/set")) {
@@ -2414,7 +2414,7 @@
      */
     List<Diag> errorsOnly(List<Diag> diagnostics) {
         return diagnostics.stream()
-                .filter(d -> d.isError())
+                .filter(Diag::isError)
                 .collect(toList());
     }
 
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Fri Dec 16 15:27:34 2016 +0000
@@ -51,36 +51,33 @@
             throw new IllegalStateException("Already initialized.");
         initialized = true;
 
-        Thread reader = new Thread() {
-            @Override
-            public void run() {
-                try {
-                    int read;
-                    while (true) {
-                        //to support external terminal editors, the "cmdin.read" must not run when
-                        //an external editor is running. At the same time, it needs to run while the
-                        //user's code is running (so Ctrl-C is detected). Hence waiting here until
-                        //there is a confirmed need for input.
-                        StopDetectingInputStream.State currentState = waitInputNeeded();
-                        if (currentState == StopDetectingInputStream.State.CLOSED) {
-                            break;
-                        }
-                        if ((read = input.read()) == (-1)) {
-                            break;
-                        }
-                        if (read == 3 && currentState == StopDetectingInputStream.State.BUFFER) {
-                            stop.run();
-                        } else {
-                            write(read);
-                        }
+        Thread reader = new Thread(() -> {
+            try {
+                int read;
+                while (true) {
+                    //to support external terminal editors, the "cmdin.read" must not run when
+                    //an external editor is running. At the same time, it needs to run while the
+                    //user's code is running (so Ctrl-C is detected). Hence waiting here until
+                    //there is a confirmed need for input.
+                    State currentState = waitInputNeeded();
+                    if (currentState == State.CLOSED) {
+                        break;
                     }
-                } catch (IOException ex) {
-                    errorHandler.accept(ex);
-                } finally {
-                    shutdown();
+                    if ((read = input.read()) == (-1)) {
+                        break;
+                    }
+                    if (read == 3 && currentState == State.BUFFER) {
+                        stop.run();
+                    } else {
+                        write(read);
+                    }
                 }
+            } catch (IOException ex) {
+                errorHandler.accept(ex);
+            } finally {
+                shutdown();
             }
-        };
+        });
         reader.setDaemon(true);
         reader.start();
 
--- a/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java	Fri Dec 16 15:27:34 2016 +0000
@@ -126,6 +126,6 @@
 
     // Lookup the ClassInfo by class name, create if it does not exist.
     ClassInfo get(String className) {
-        return map.computeIfAbsent(className, k -> new ClassInfo(k));
+        return map.computeIfAbsent(className, ClassInfo::new);
     }
 }
--- a/src/jdk.jshell/share/classes/jdk/jshell/DiagList.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/DiagList.java	Fri Dec 16 15:27:34 2016 +0000
@@ -72,7 +72,7 @@
 
     @Override
     public boolean addAll(Collection<? extends Diag> c) {
-        return c.stream().filter(d -> add(d)).count() > 0;
+        return c.stream().filter(this::add).count() > 0;
     }
 
     @Override
@@ -110,7 +110,7 @@
                     Snippet snn = d.snippetOrNull();
                     return snn == u.snippet();
                 })
-                .collect(Collectors.toCollection(() -> new DiagList()));
+                .collect(Collectors.toCollection(DiagList::new));
     }
 
     boolean hasErrors() {
--- a/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Fri Dec 16 15:27:34 2016 +0000
@@ -635,7 +635,7 @@
         while (true) {
             state.debug(DBG_GEN, "compileAndLoad  %s\n", ins);
 
-            ins.stream().forEach(u -> u.initialize());
+            ins.stream().forEach(Unit::initialize);
             ins.stream().forEach(u -> u.setWrap(ins, ins));
             AnalyzeTask at = state.taskFactory.new AnalyzeTask(outerWrapSet(ins));
             ins.stream().forEach(u -> u.setDiagnostics(at));
@@ -654,7 +654,7 @@
             boolean success;
             while (true) {
                 List<Unit> legit = ins.stream()
-                        .filter(u -> u.isDefined())
+                        .filter(Unit::isDefined)
                         .collect(toList());
                 state.debug(DBG_GEN, "compileAndLoad ins = %s -- legit = %s\n",
                         ins, legit);
@@ -693,7 +693,7 @@
                     // loop by replacing all that have been replaced
                     if (!toReplace.isEmpty()) {
                         replaced.addAll(toReplace);
-                        replaced.stream().forEach(u -> u.markForReplacement());
+                        replaced.stream().forEach(Unit::markForReplacement);
                     }
 
                     success = toReplace.isEmpty();
@@ -703,7 +703,7 @@
 
             // add any new dependencies to the working set
             List<Unit> newDependencies = ins.stream()
-                    .flatMap(u -> u.effectedDependents())
+                    .flatMap(Unit::effectedDependents)
                     .collect(toList());
             state.debug(DBG_GEN, "compileAndLoad %s -- deps: %s  success: %s\n",
                     ins, newDependencies, success);
@@ -711,7 +711,7 @@
                 // all classes that could not be directly loaded (because they
                 // are new) have been redefined, and no new dependnencies were
                 // identified
-                ins.stream().forEach(u -> u.finish());
+                ins.stream().forEach(Unit::finish);
                 return ins;
             }
         }
--- a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Fri Dec 16 15:27:34 2016 +0000
@@ -64,6 +64,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
 import java.util.function.Predicate;
 
 import javax.lang.model.element.Element;
@@ -280,7 +281,7 @@
         String requiredPrefix = identifier;
         return computeSuggestions(codeWrap, cursor, anchor).stream()
                 .filter(s -> s.continuation().startsWith(requiredPrefix) && !s.continuation().equals(REPL_DOESNOTMATTER_CLASS_NAME))
-                .sorted(Comparator.comparing(s -> s.continuation()))
+                .sorted(Comparator.comparing(Suggestion::continuation))
                 .collect(collectingAndThen(toList(), Collections::unmodifiableList));
     }
 
@@ -509,7 +510,7 @@
     @Override
     public List<SnippetWrapper> wrappers(String input) {
         return proc.eval.sourceToSnippetsWithWrappers(input).stream()
-                .map(sn -> wrapper(sn))
+                .map(this::wrapper)
                 .collect(toList());
     }
 
@@ -637,7 +638,7 @@
         return IS_STATIC.or(IS_CLASS).or(IS_INTERFACE).negate().test(el) ||
                 IS_PACKAGE.test(encl);
     };
-    private final Function<Element, Iterable<? extends Element>> IDENTITY = el -> Collections.singletonList(el);
+    private final Function<Element, Iterable<? extends Element>> IDENTITY = Collections::singletonList;
     private final Function<Boolean, String> DEFAULT_PAREN = hasParams -> hasParams ? "(" : "()";
     private final Function<Boolean, String> NO_PAREN = hasParams -> "";
 
@@ -831,7 +832,7 @@
         };
         @SuppressWarnings("unchecked")
         List<Element> result = Util.stream(scopeIterable)
-                             .flatMap(s -> localElements(s))
+                             .flatMap(this::localElements)
                              .flatMap(el -> Util.stream((Iterable<Element>)elementConvertor.apply(el)))
                              .collect(toCollection(ArrayList :: new));
         result.addAll(listPackages(at, ""));
@@ -1186,7 +1187,7 @@
 
         try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) {
             result = elements.map(el -> constructDocumentation(at, helper, el, computeJavadoc))
-                             .filter(r -> r != null)
+                             .filter(Objects::nonNull)
                              .collect(Collectors.toList());
         } catch (IOException ex) {
             proc.debug(ex, "JavadocHelper.close()");
--- a/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Fri Dec 16 15:27:34 2016 +0000
@@ -168,11 +168,11 @@
             // Snippets to add to imports
             Collection<Snippet> plus = plusUnfiltered.stream()
                     .filter(u -> !units.contains(u))
-                    .map(u -> u.snippet())
+                    .map(Unit::snippet)
                     .collect(toList());
             // Snippets to wrap in an outer
             List<Snippet> snippets = units.stream()
-                    .map(u -> u.snippet())
+                    .map(Unit::snippet)
                     .collect(toList());
             // Snippet wraps to wrap in an outer
             List<Wrap> wraps = units.stream()
@@ -305,8 +305,8 @@
             return true;
         }
         ClassBytecodes[] cbcs = toRedefine.stream()
-                .map(ci -> ci.toClassBytecodes())
-                .toArray(size -> new ClassBytecodes[size]);
+                .map(ClassInfo::toClassBytecodes)
+                .toArray(ClassBytecodes[]::new);
         try {
             state.executionControl().redefine(cbcs);
             state.classTracker.markLoaded(cbcs);
--- a/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/Wrap.java	Fri Dec 16 15:27:34 2016 +0000
@@ -359,7 +359,7 @@
 
         @Override
         public String toString() {
-            return "CompoundWrap(" + Arrays.stream(os).map(u -> u.toString()).collect(joining(",")) + ")";
+            return "CompoundWrap(" + Arrays.stream(os).map(Object::toString).collect(joining(",")) + ")";
         }
     }
 
--- a/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java	Fri Dec 16 12:08:46 2016 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java	Fri Dec 16 15:27:34 2016 +0000
@@ -65,7 +65,7 @@
         outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
         outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
         Map<String, Consumer<InputStream>> input = new HashMap<>();
-        input.put("in", st -> System.setIn(st));
+        input.put("in", System::setIn);
         forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);
     }