Merge
authorduke
Wed, 05 Jul 2017 18:30:46 +0200
changeset 14558 baa1be763c4c
parent 14557 4f273518dc3b (diff)
parent 14535 f8f49b361b60 (current diff)
child 14559 17820b958ae8
Merge
--- a/langtools/.hgtags	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/.hgtags	Wed Jul 05 18:30:46 2017 +0200
@@ -186,3 +186,4 @@
 b47bb81ba962ef80bb6f0b863c33a0afcfb0b49e jdk8-b62
 92e6f2190ca0567c857f85c3fb7a2be5adf079d0 jdk8-b63
 e6ee43b3e2473798b17a556e9f11eebe25ab81d4 jdk8-b64
+5f2faba89cac665e365c05074064ffc934a495eb jdk8-b65
--- a/langtools/make/build.xml	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/make/build.xml	Wed Jul 05 18:30:46 2017 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -277,7 +277,7 @@
         <!-- transform the output to a simple html -->
         <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
                out="${dist.checkstyle.dir}/checkstyle_report.html"
-               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>            
+               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
         <!-- transform the output to a very simple emacs friendly text file -->
         <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
                out="${dist.checkstyle.dir}/checkstyle_report.tmp"
@@ -297,9 +297,9 @@
     <target name="checkstyle-ide" depends="checkstyle">
         <concat>
             <fileset file="${dist.checkstyle.dir}/checkstyle_report.emacs.txt"/>
-        </concat>  
+        </concat>
     </target>
-    
+
     <target name="findbugs" depends="-def-findbugs,build-all-tools">
         <property name="findbugs.reportLevel" value="medium"/>
         <mkdir dir="${dist.findbugs.dir}"/>
@@ -368,7 +368,7 @@
             executable="${dist.bin.dir}/javac"
             srcdir="test/tools/javac/diags"
             destdir="${build.dir}/diag-examples/classes"
-            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
+            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
             sourcepath=""
             classpath="${dist.lib.dir}/javac.jar"
             includeAntRuntime="no"
@@ -381,6 +381,7 @@
             dir="test/tools/javac/diags"
             classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar"
             classname="RunExamples">
+            <jvmarg value="-Dtest.classes=${build.dir}/diag-examples/classes"/>
             <arg value="-examples"/>
             <arg value="examples"/>
             <arg value="-o"/>
@@ -695,7 +696,7 @@
     <target name="-check-checkstyle.home" depends="-def-check">
         <check name="checkstyle" property="checkstyle.home" marker="${checkstyle.name.version}.jar"/>
     </target>
-    
+
     <target name="-check-jtreg.home" depends="-def-check">
         <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
     </target>
@@ -1005,7 +1006,7 @@
         </taskdef>
         <property name="checkstyle.defined" value="true"/>
     </target>
-    
+
     <target name="-def-findbugs" unless="findbugs.defined"
         depends="-check-findbugs.home,-check-target.java.home">
         <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
--- a/langtools/makefiles/BuildLangtools.gmk	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/makefiles/BuildLangtools.gmk	Wed Jul 05 18:30:46 2017 +0200
@@ -38,6 +38,9 @@
         SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\
         FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
 
+# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
+RESOURCE_SUFFIXES:=.gif .xml .css .js javax.tools.JavaCompilerTool
+
 # Now setup the compilation of the properties compilation tool. You can depend
 # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
 # add src/share/classes to the sourcepath. This is necessary since the GenStubs
@@ -99,6 +102,7 @@
 		DISABLE_SJAVAC:=true,\
 		SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
 		EXCLUDES:=com/sun/tools/javac/nio,\
+		COPY:=$(RESOURCE_SUFFIXES),\
 		BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
 
         $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\
@@ -119,6 +123,7 @@
         $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\
 		SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
 		JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\
+		SUFFIXES:=.class $(RESOURCE_SUFFIXES),\
 		JARMAIN:=com.sun.tools.javadoc.Main))
 
         # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not 
@@ -172,9 +177,6 @@
                   SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
                   SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
 
-                # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
-		RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool
-
                 $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\
 			SETUP:=GENERATE_NEWBYTECODE,\
 			SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for an attribute in an HTML element.
+ *
+ * @since 1.8
+ */
+public interface AttributeTree extends DocTree {
+    enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE };
+
+    Name getName();
+    ValueKind getValueKind();
+    List<? extends DocTree> getValue();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @author block tag.
+ *
+ * <p>
+ * &#064;author name-text.
+ *
+ * @since 1.8
+ */
+public interface AuthorTree extends BlockTagTree {
+    List<? extends DocTree> getName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * block tags.
+ *
+ * @since 1.8
+ */
+public interface BlockTagTree extends DocTree {
+    String getTagName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * An embedded HTML comment.
+ *
+ * <p>
+ * {@literal <!-- text --> }
+ *
+ * @since 1.8
+ */
+public interface CommentTree extends DocTree {
+    String getBody();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @deprecated block tag.
+ *
+ * <p>
+ * &#064;deprecated deprecated text.
+ *
+ * @since 1.8
+ */
+public interface DeprecatedTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * The top level representation of a documentation comment.
+ *
+ * <p>
+ * first-sentence body block-tags
+ *
+ * @since 1.8
+ */
+public interface DocCommentTree extends DocTree {
+    List<? extends DocTree> getFirstSentence();
+    List<? extends DocTree> getBody();
+    List<? extends DocTree> getBlockTags();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for an @docroot inline tag.
+ *
+ * <p>
+ * {&#064;docroot}
+ *
+ * @since 1.8
+ */
+public interface DocRootTree extends InlineTagTree { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * Common interface for all nodes in a documentation syntax tree.
+ *
+ * @since 1.8
+ */
+public interface DocTree {
+    enum Kind {
+        /**
+         * Used for instances of {@link AttributeTree}
+         * representing an HTML attribute.
+         */
+        ATTRIBUTE,
+
+        /**
+         * Used for instances of {@link AuthorTree}
+         * representing an @author tag.
+         */
+        AUTHOR("author"),
+
+        /**
+         * Used for instances of {@link LiteralTree}
+         * representing an @code tag.
+         */
+        CODE("code"),
+
+        /**
+         * Used for instances of {@link CommentTree}
+         * representing an HTML comment.
+         */
+        COMMENT,
+
+        /**
+         * Used for instances of {@link DeprecatedTree}
+         * representing an @deprecated tag.
+         */
+        DEPRECATED("deprecated"),
+
+        /**
+         * Used for instances of {@link DocCommentTree}
+         * representing a complete doc comment.
+         */
+        DOC_COMMENT,
+
+        /**
+         * Used for instances of {@link DocRootTree}
+         * representing an @docRoot tag.
+         */
+        DOC_ROOT("docRoot"),
+
+        /**
+         * Used for instances of {@link EndElementTree}
+         * representing the end of an HTML element.
+         */
+        END_ELEMENT,
+
+        /**
+         * Used for instances of {@link EntityTree}
+         * representing an HTML entity.
+         */
+        ENTITY,
+
+        /**
+         * Used for instances of {@link ErroneousTree}
+         * representing some invalid text.
+         */
+        ERRONEOUS,
+
+        /**
+         * Used for instances of {@link ThrowsTree}
+         * representing an @exception tag.
+         */
+        EXCEPTION("exception"),
+
+        /**
+         * Used for instances of {@link IdentifierTree}
+         * representing an identifier.
+         */
+        IDENTIFIER,
+
+        /**
+         * Used for instances of {@link InheritDocTree}
+         * representing an @inheritDoc tag.
+         */
+        INHERIT_DOC("inheritDoc"),
+
+        /**
+         * Used for instances of {@link LinkTree}
+         * representing an @link tag.
+         */
+        LINK("link"),
+
+        /**
+         * Used for instances of {@link LinkTree}
+         * representing an @linkplain tag.
+         */
+        LINK_PLAIN("linkplain"),
+
+        /**
+         * Used for instances of {@link LiteralTree}
+         * representing an @literal tag.
+         */
+        LITERAL("literal"),
+
+        /**
+         * Used for instances of {@link ParamTree}
+         * representing an @param tag.
+         */
+        PARAM("param"),
+
+        /**
+         * Used for instances of {@link ReferenceTree}
+         * representing a reference to a element in the
+         * Java programming language.
+         */
+        REFERENCE,
+
+        /**
+         * Used for instances of {@link ReturnTree}
+         * representing an @return tag.
+         */
+        RETURN("return"),
+
+        /**
+         * Used for instances of {@link SeeTree}
+         * representing an @see tag.
+         */
+        SEE("see"),
+
+        /**
+         * Used for instances of {@link SerialTree}
+         * representing an @serial tag.
+         */
+        SERIAL("serial"),
+
+        /**
+         * Used for instances of {@link SerialDataTree}
+         * representing an @serialData tag.
+         */
+        SERIAL_DATA("serialData"),
+
+        /**
+         * Used for instances of {@link SerialFieldTree}
+         * representing an @serialField tag.
+         */
+        SERIAL_FIELD("serialField"),
+
+        /**
+         * Used for instances of {@link SinceTree}
+         * representing an @since tag.
+         */
+        SINCE("since"),
+
+        /**
+         * Used for instances of {@link EndElementTree}
+         * representing the start of an HTML element.
+         */
+        START_ELEMENT,
+
+        /**
+         * Used for instances of {@link TextTree}
+         * representing some documentation text.
+         */
+        TEXT,
+
+        /**
+         * Used for instances of {@link ThrowsTree}
+         * representing an @throws tag.
+         */
+        THROWS("throws"),
+
+        /**
+         * Used for instances of {@link UnknownBlockTagTree}
+         * representing an unknown block tag.
+         */
+        UNKNOWN_BLOCK_TAG,
+
+        /**
+         * Used for instances of {@link UnknownInlineTagTree}
+         * representing an unknown inline tag.
+         */
+        UNKNOWN_INLINE_TAG,
+
+        /**
+         * Used for instances of {@link ValueTree}
+         * representing an @value tag.
+         */
+        VALUE("value"),
+
+        /**
+         * Used for instances of {@link VersionTree}
+         * representing an @version tag.
+         */
+        VERSION("version"),
+
+        /**
+         * An implementation-reserved node. This is the not the node
+         * you are looking for.
+         */
+        OTHER;
+
+        public final String tagName;
+
+        Kind() {
+            tagName = null;
+        }
+
+        Kind(String tagName) {
+            this.tagName = tagName;
+        }
+    };
+
+    /**
+     * Gets the kind of this tree.
+     *
+     * @return the kind of this tree.
+     */
+    Kind getKind();
+
+    /**
+     * Accept method used to implement the visitor pattern.  The
+     * visitor pattern is used to implement operations on trees.
+     *
+     * @param <R> result type of this operation.
+     * @param <D> type of additional data.
+     */
+    <R, D> R accept(DocTreeVisitor<R,D> visitor, D data);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+
+/**
+ * A visitor of trees, in the style of the visitor design pattern.
+ * Classes implementing this interface are used to operate
+ * on a tree when the kind of tree is unknown at compile time.
+ * When a visitor is passed to an tree's {@link DocTree#accept
+ * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
+ * to that tree is invoked.
+ *
+ * <p> Classes implementing this interface may or may not throw a
+ * {@code NullPointerException} if the additional parameter {@code p}
+ * is {@code null}; see documentation of the implementing class for
+ * details.
+ *
+ * <p> <b>WARNING:</b> It is possible that methods will be added to
+ * this interface to accommodate new, currently unknown, doc comment
+ * structures added to future versions of the Java&trade; programming
+ * language.  Therefore, visitor classes directly implementing this
+ * interface may be source incompatible with future versions of the
+ * platform.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @since 1.8
+ */
+public interface DocTreeVisitor<R,P> {
+    R visitAttribute(AttributeTree node, P p);
+    R visitAuthor(AuthorTree node, P p);
+    R visitComment(CommentTree node, P p);
+    R visitDeprecated(DeprecatedTree node, P p);
+    R visitDocComment(DocCommentTree node, P p);
+    R visitDocRoot(DocRootTree node, P p);
+    R visitEndElement(EndElementTree node, P p);
+    R visitEntity(EntityTree node, P p);
+    R visitErroneous(ErroneousTree node, P p);
+    R visitIdentifier(IdentifierTree node, P p);
+    R visitInheritDoc(InheritDocTree node, P p);
+    R visitLink(LinkTree node, P p);
+    R visitLiteral(LiteralTree node, P p);
+    R visitParam(ParamTree node, P p);
+    R visitReference(ReferenceTree node, P p);
+    R visitReturn(ReturnTree node, P p);
+    R visitSee(SeeTree node, P p);
+    R visitSerial(SerialTree node, P p);
+    R visitSerialData(SerialDataTree node, P p);
+    R visitSerialField(SerialFieldTree node, P p);
+    R visitSince(SinceTree node, P p);
+    R visitStartElement(StartElementTree node, P p);
+    R visitText(TextTree node, P p);
+    R visitThrows(ThrowsTree node, P p);
+    R visitUnknownBlockTag(UnknownBlockTagTree node, P p);
+    R visitUnknownInlineTag(UnknownInlineTagTree node, P p);
+    R visitValue(ValueTree node, P p);
+    R visitVersion(VersionTree node, P p);
+    R visitOther(DocTree node, P p);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the end of an HTML element.
+ *
+ * <p>
+ * &lt;/ name &gt;
+ *
+ * @since 1.8
+ */
+public interface EndElementTree extends DocTree {
+    Name getName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+
+/**
+ * A tree node for an HTML entity.
+ *
+ * <p>
+ * &amp; name ;
+ *
+ * @since 1.8
+ */
+public interface EntityTree extends DocTree {
+    Name getName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+
+/**
+ * A tree node to stand in for a malformed text
+ *
+ * @since 1.8
+ */
+public interface ErroneousTree extends TextTree {
+    /**
+     * Gets a diagnostic object giving details about
+     * the reason the body text is in error.
+     *
+     * @return a diagnostic
+     */
+    Diagnostic<JavaFileObject> getDiagnostic();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * An identifier in a documentation comment.
+ *
+ * <p>
+ * name
+ *
+ * @since 1.8
+ */
+public interface IdentifierTree extends DocTree {
+    Name getName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @inheritDoc inline tag.
+ *
+ * <p>
+ * {&#064;inheritDoc}
+ *
+ * @since 1.8
+ */
+public interface InheritDocTree extends InlineTagTree { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * inline tags.
+ *
+ * @since 1.8
+ */
+public interface InlineTagTree extends DocTree {
+    String getTagName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @link or &#064;linkplain inline tag.
+ *
+ * <p>
+ * {&#064;link reference label} <br>
+ * {&#064;linkplain reference label }
+ *
+ * @since 1.8
+ */
+public interface LinkTree extends InlineTagTree {
+    ReferenceTree getReference();
+    List<? extends DocTree> getLabel();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @literal or @code inline tag.
+ *
+ * <p>
+ * {&#064;literal text}
+ *
+ * @since 1.8
+ */
+public interface LiteralTree extends InlineTagTree {
+    TextTree getBody();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @param block tag.
+ *
+ * <p>
+ * &#064;param parameter-name description
+ *
+ * @since 1.8
+ */
+public interface ParamTree extends BlockTagTree {
+    boolean isTypeParameter();
+    IdentifierTree getName();
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node to a reference to a Java language element.
+ *
+ * <p>
+ * package.class#field
+ *
+ * @since 1.8
+ */
+public interface ReferenceTree extends DocTree {
+    String getSignature();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @return block tag.
+ *
+ * <p>
+ * &#064;return description
+ *
+ * @since 1.8
+ */
+public interface ReturnTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @see block tag.
+ *
+ * <p>
+ * &#064;see "string" <br>
+ * &#064;see &lt;a href="URL#value"&gt; label &lt;/a&gt; <br>
+ * &#064;see reference
+ *
+ * @since 1.8
+ */
+public interface SeeTree extends BlockTagTree {
+    List<? extends DocTree> getReference();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ * <p>
+ * &#064;serialData data-description
+ *
+ * @since 1.8
+ */
+public interface SerialDataTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ * <p>
+ * &#064;serialField field-name field-type field-description
+ *
+ * @since 1.8
+ */
+public interface SerialFieldTree extends BlockTagTree {
+    IdentifierTree getName();
+    ReferenceTree getType();
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serial block tag.
+ *
+ * <p>
+ * &#064;serial field-description | include | exclude
+ *
+ * @since 1.8
+ */
+public interface SerialTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @since block tag.
+ *
+ * <p>
+ * &#064;since since-text
+ *
+ * @since 1.8
+ */
+public interface SinceTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the start of an HTML element.
+ *
+ * <p>
+ * &lt; name [attributes] [/]&gt;
+ *
+ * @since 1.8
+ */
+public interface StartElementTree extends DocTree {
+    Name getName();
+    List<? extends DocTree> getAttributes();
+    boolean isSelfClosing();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for plain text.
+ *
+ * @since 1.8
+ */
+public interface TextTree extends DocTree {
+    String getBody();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @exception or &#064;throws block tag.
+ * &#064;exception is a synonym for &#064;throws.
+ *
+ * <p>
+ * &#064;exception class-name description <br>
+ * &#064;throws class-name description
+ *
+ * @since 1.8
+ */
+public interface ThrowsTree extends BlockTagTree {
+    ReferenceTree getExceptionName();
+    List<? extends DocTree> getDescription();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ * <p>
+ * &#064;name content
+ *
+ * @since 1.8
+ *
+ */
+public interface UnknownBlockTagTree extends BlockTagTree {
+    List<? extends DocTree> getContent();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ * <p>
+ * {&#064;name content}
+ *
+ * @since 1.8
+ *
+ */
+public interface UnknownInlineTagTree extends InlineTagTree {
+    List<? extends DocTree> getContent();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for an @value inline tag.
+ *
+ * <p>
+ * { &#064;value reference }
+ *
+ * @since 1.8
+ */
+public interface ValueTree extends InlineTagTree {
+    ReferenceTree getReference();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @version block tag.
+ *
+ * <p>
+ * &#064;version version-text
+ *
+ * @since 1.8
+ */
+public interface VersionTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/doctree/package-info.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Provides interfaces to represent documentation comments as abstract syntax
+ * trees (AST).
+ *
+ * @author Jonathan Gibbons
+ * @since 1.8
+ * @see <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a>
+ */
+package com.sun.source.doctree;
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -610,7 +610,7 @@
      * visitor pattern is used to implement operations on trees.
      *
      * @param <R> result type of this operation.
-     * @param <D> type of additonal data.
+     * @param <D> type of additional data.
      */
     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import com.sun.source.doctree.*;
+
+
+/**
+ * A TreeVisitor that visits all the child tree nodes.
+ * To visit nodes of a particular type, just override the
+ * corresponding visitXYZ method.
+ * Inside your method, call super.visitXYZ to visit descendant
+ * nodes.
+ *
+ * <p>The default implementation of the visitXYZ methods will determine
+ * a result as follows:
+ * <ul>
+ * <li>If the node being visited has no children, the result will be null.
+ * <li>If the node being visited has one child, the result will be the
+ * result of calling {@code scan} on that child. The child may be a simple node
+ * or itself a list of nodes.
+ * <li> If the node being visited has more than one child, the result will
+ * be determined by calling {@code scan} each child in turn, and then combining the
+ * result of each scan after the first with the cumulative result
+ * so far, as determined by the {@link #reduce} method. Each child may be either
+ * a simple node of a list of nodes. The default behavior of the {@code reduce}
+ * method is such that the result of the visitXYZ method will be the result of
+ * the last child scanned.
+ * </ul>
+ *
+ * <p>Here is an example to count the number of erroneous nodes in a tree:
+ * <pre>
+ *   class CountErrors extends DocTreeScanner<Integer,Void> {
+ *      {@literal @}Override
+ *      public Integer visitErroneous(ErroneousTree node, Void p) {
+ *          return 1;
+ *      }
+ *      {@literal @}Override
+ *      public Integer reduce(Integer r1, Integer r2) {
+ *          return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
+ *      }
+ *   }
+ * </pre>
+ *
+ * @since 1.8
+ */
+public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> {
+
+    /**
+     * Scan a single node.
+     */
+    public R scan(DocTree node, P p) {
+        return (node == null) ? null : node.accept(this, p);
+    }
+
+    private R scanAndReduce(DocTree node, P p, R r) {
+        return reduce(scan(node, p), r);
+    }
+
+    /**
+     * Scan a list of nodes.
+     */
+    public R scan(Iterable<? extends DocTree> nodes, P p) {
+        R r = null;
+        if (nodes != null) {
+            boolean first = true;
+            for (DocTree node : nodes) {
+                r = (first ? scan(node, p) : scanAndReduce(node, p, r));
+                first = false;
+            }
+        }
+        return r;
+    }
+
+    private R scanAndReduce(Iterable<? extends DocTree> nodes, P p, R r) {
+        return reduce(scan(nodes, p), r);
+    }
+
+    /**
+     * Reduces two results into a combined result.
+     * The default implementation is to return the first parameter.
+     * The general contract of the method is that it may take any action whatsoever.
+     */
+    public R reduce(R r1, R r2) {
+        return r1;
+    }
+
+
+/* ***************************************************************************
+ * Visitor methods
+ ****************************************************************************/
+
+    @Override
+    public R visitAttribute(AttributeTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitAuthor(AuthorTree node, P p) {
+        return scan(node.getName(), p);
+    }
+
+    @Override
+    public R visitComment(CommentTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitDeprecated(DeprecatedTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitDocComment(DocCommentTree node, P p) {
+        R r = scan(node.getFirstSentence(), p);
+        r = scanAndReduce(node.getBody(), p, r);
+        r = scanAndReduce(node.getBlockTags(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitDocRoot(DocRootTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitEndElement(EndElementTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitEntity(EntityTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitErroneous(ErroneousTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitIdentifier(IdentifierTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitInheritDoc(InheritDocTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitLink(LinkTree node, P p) {
+        R r = scan(node.getReference(), p);
+        r = scanAndReduce(node.getLabel(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitLiteral(LiteralTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitParam(ParamTree node, P p) {
+        R r = scan(node.getName(), p);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitReference(ReferenceTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitReturn(ReturnTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSee(SeeTree node, P p) {
+        return scan(node.getReference(), p);
+    }
+
+    @Override
+    public R visitSerial(SerialTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSerialData(SerialDataTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSerialField(SerialFieldTree node, P p) {
+        R r = scan(node.getName(), p);
+        r = scanAndReduce(node.getType(), p, r);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitSince(SinceTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitStartElement(StartElementTree node, P p) {
+        return scan(node.getAttributes(), p);
+    }
+
+    @Override
+    public R visitText(TextTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitThrows(ThrowsTree node, P p) {
+        R r = scan(node.getExceptionName(), p);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+        return scan(node.getContent(), p);
+    }
+
+    @Override
+    public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+        return scan(node.getContent(), p);
+    }
+
+    @Override
+    public R visitValue(ValueTree node, P p) {
+        return scan(node.getReference(), p);
+    }
+
+    @Override
+    public R visitVersion(VersionTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitOther(DocTree node, P p) {
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ReferenceTree;
+import javax.tools.Diagnostic;
+
+/**
+ * Provides access to syntax trees for doc comments.
+ *
+ * @since 1.8
+ */
+public abstract class DocTrees extends Trees {
+    /**
+     * Gets a DocTrees object for a given CompilationTask.
+     * @param task the compilation task for which to get the Trees object
+     * @throws IllegalArgumentException if the task does not support the Trees API.
+     */
+    public static DocTrees instance(CompilationTask task) {
+        if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
+            throw new IllegalArgumentException();
+        return (DocTrees) getJavacTrees(CompilationTask.class, task);
+    }
+
+    /**
+     * Gets a DocTrees object for a given ProcessingEnvironment.
+     * @param env the processing environment for which to get the Trees object
+     * @throws IllegalArgumentException if the env does not support the Trees API.
+     */
+    public static DocTrees instance(ProcessingEnvironment env) {
+        if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
+            throw new IllegalArgumentException();
+        return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env);
+    }
+
+    /**
+     * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.
+     * Returns null if no doc comment was found.
+     */
+    public abstract DocCommentTree getDocCommentTree(TreePath path);
+
+    /**
+     * Gets the language model element referred to by a ReferenceTree that
+     * appears on the declaration identified by the given path.
+     */
+    public abstract Element getElement(TreePath path, ReferenceTree reference);
+
+    /**
+     * Prints a message of the specified kind at the location of the
+     * tree within the provided compilation unit
+     *
+     * @param kind the kind of message
+     * @param msg  the message, or an empty string if none
+     * @param t    the tree to use as a position hint
+     * @param root the compilation unit that contains tree
+     */
+    public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.doctree.DocTree t,
+            com.sun.source.doctree.DocCommentTree c,
+            com.sun.source.tree.CompilationUnitTree root);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.util;
+
+import java.util.ServiceLoader;
+import javax.tools.StandardLocation;
+
+/**
+ * The interface for a javac plug-in.
+ *
+ * <p>The javac plug-in mechanism allows a user to specify one or more plug-ins
+ * on the javac command line, to be started soon after the compilation
+ * has begun. Plug-ins are identified by a user-friendly name. Each plug-in that
+ * is started will be passed an array of strings, which may be used to
+ * provide the plug-in with values for any desired options or other arguments.
+ *
+ * <p>Plug-ins are located via a {@link ServiceLoader},
+ * using the same class path as annotation processors (i.e.
+ * {@link StandardLocation#PROCESSOR_PATH PROCESSOR_PATH} or
+ * {@code -processorpath}).
+ *
+ * <p>It is expected that a typical plug-in will simply register a
+ * {@link TaskListener} to be informed of events during the execution
+ * of the compilation, and that the rest of the work will be done
+ * by the task listener.
+ *
+ * @since 1.8
+ */
+public interface Plugin {
+    /**
+     * Get the user-friendly name of this plug-in.
+     * @return the user-friendly name of the plug-in
+     */
+    String getName();
+
+    /**
+     * Invoke the plug-in for a given compilation task.
+     * @param task The compilation task that has just been started
+     * @param args Arguments, if any, for the plug-in
+     */
+    void call(JavacTask task, String... args);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import com.sun.source.doctree.*;
+
+/**
+ * A simple visitor for tree nodes.
+ *
+ * @since 1.8
+ */
+public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> {
+    protected final R DEFAULT_VALUE;
+
+    protected SimpleDocTreeVisitor() {
+        DEFAULT_VALUE = null;
+    }
+
+    protected SimpleDocTreeVisitor(R defaultValue) {
+        DEFAULT_VALUE = defaultValue;
+    }
+
+    protected R defaultAction(DocTree node, P p) {
+        return DEFAULT_VALUE;
+    }
+
+    public final R visit(DocTree node, P p) {
+        return (node == null) ? null : node.accept(this, p);
+    }
+
+    public final R visit(Iterable<? extends DocTree> nodes, P p) {
+        R r = null;
+        if (nodes != null) {
+            for (DocTree node : nodes)
+                r = visit(node, p);
+        }
+        return r;
+    }
+
+    public R visitAttribute(AttributeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitAuthor(AuthorTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitComment(CommentTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDeprecated(DeprecatedTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDocComment(DocCommentTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDocRoot(DocRootTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitEndElement(EndElementTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitEntity(EntityTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitErroneous(ErroneousTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitIdentifier(IdentifierTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitInheritDoc(InheritDocTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitLink(LinkTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitLiteral(LiteralTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitParam(ParamTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitReference(ReferenceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitReturn(ReturnTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSee(SeeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerial(SerialTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerialData(SerialDataTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerialField(SerialFieldTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSince(SinceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitStartElement(StartElementTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitText(TextTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitThrows(ThrowsTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitValue(ValueTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitVersion(VersionTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitOther(DocTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+}
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.source.util;
 
 import java.lang.reflect.Method;
+
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
@@ -57,7 +58,9 @@
      * @throws IllegalArgumentException if the task does not support the Trees API.
      */
     public static Trees instance(CompilationTask task) {
-        if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
+        String taskClassName = task.getClass().getName();
+        if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
+                && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
             throw new IllegalArgumentException();
         return getJavacTrees(CompilationTask.class, task);
     }
@@ -73,7 +76,7 @@
         return getJavacTrees(ProcessingEnvironment.class, env);
     }
 
-    private static Trees getJavacTrees(Class<?> argType, Object arg) {
+    static Trees getJavacTrees(Class<?> argType, Object arg) {
         try {
             ClassLoader cl = arg.getClass().getClassLoader();
             Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
@@ -168,6 +171,7 @@
     /**
      * Gets the doc comment, if any, for the Tree node identified by a given TreePath.
      * Returns null if no doc comment was found.
+     * @see DocTrees#getDocCommentTree(TreePath)
      */
     public abstract String getDocComment(TreePath path);
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -45,7 +45,7 @@
 public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
 
     public AbstractExecutableMemberWriter(SubWriterHolderWriter writer,
-                                     ClassDoc classdoc) {
+            ClassDoc classdoc) {
         super(writer, classdoc);
     }
 
@@ -61,7 +61,7 @@
      * @return the display length required to write this information.
      */
     protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
             LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
         String typeParameters = writer.getTypeParameterLinks(linkInfo);
         if (linkInfo.displayLength > 0) {
@@ -129,8 +129,8 @@
         boolean isVarArg, Content tree) {
         if (param.type() != null) {
             Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
-                    isVarArg)));
+                    configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM,
+                    param.type(), isVarArg)));
             tree.addContent(link);
         }
         if(param.name().length() > 0) {
@@ -161,7 +161,7 @@
         htmltree.addContent("(");
         Parameter[] params = member.parameters();
         String indent = makeSpace(writer.displayLength);
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             //add spaces to offset indentation changes caused by link.
             indent+= makeSpace(member.name().length());
         }
@@ -212,7 +212,7 @@
     protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
         Type[] exceptions = member.thrownExceptionTypes();
         if(exceptions.length > 0) {
-            LinkInfoImpl memberTypeParam = new LinkInfoImpl(
+            LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_MEMBER, member, false);
             int retlen = getReturnTypeLength(member);
             writer.getTypeParameterLinks(memberTypeParam);
@@ -224,7 +224,7 @@
             htmltree.addContent(indent);
             htmltree.addContent("throws ");
             indent += "       ";
-            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
+            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
             htmltree.addContent(link);
             for(int i = 1; i < exceptions.length; i++) {
@@ -232,7 +232,7 @@
                 htmltree.addContent(DocletConstants.NL);
                 htmltree.addContent(indent);
                 Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                        LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
+                        configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
                 htmltree.addContent(exceptionLink);
             }
         }
@@ -246,7 +246,7 @@
                 return rettype.typeName().length() +
                        rettype.dimension().length();
             } else {
-                LinkInfoImpl linkInfo = new LinkInfoImpl(
+                LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_MEMBER, rettype);
                 writer.getLink(linkInfo);
                 return linkInfo.displayLength;
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -140,7 +140,8 @@
      */
     protected void addDescription(ClassDoc cd, Content dlTree) {
         Content link = new RawHtml(
-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
+                getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.CONTEXT_INDEX, cd, true)));
         Content dt = HtmlTree.DT(link);
         dt.addContent(" - ");
         addClassInfo(cd, dt);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -49,15 +49,20 @@
  */
 public abstract class AbstractMemberWriter {
 
-    protected boolean printedSummaryHeader = false;
+    protected final ConfigurationImpl configuration;
     protected final SubWriterHolderWriter writer;
     protected final ClassDoc classdoc;
+    protected Map<String,Integer> typeMap = new LinkedHashMap<String,Integer>();
+    protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class);
+    private int methodTypesOr = 0;
     public final boolean nodepr;
 
-    public AbstractMemberWriter(SubWriterHolderWriter writer,
-                             ClassDoc classdoc) {
+    protected boolean printedSummaryHeader = false;
+
+    public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) {
+        this.configuration = writer.configuration;
         this.writer = writer;
-        this.nodepr = configuration().nodeprecated;
+        this.nodepr = configuration.nodeprecated;
         this.classdoc = classdoc;
     }
 
@@ -281,11 +286,11 @@
                     code.addContent(new HtmlTree(HtmlTag.BR));
                 }
                 code.addContent(new RawHtml(
-                        writer.getLink(new LinkInfoImpl(
+                        writer.getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
             } else {
                 code.addContent(new RawHtml(
-                        writer.getLink(new LinkInfoImpl(
+                        writer.getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
             }
 
@@ -305,7 +310,7 @@
         } else if (member.isPrivate()) {
             code.addContent("private ");
         } else if (!member.isPublic()) { // Package private
-            code.addContent(configuration().getText("doclet.Package_private"));
+            code.addContent(configuration.getText("doclet.Package_private"));
             code.addContent(" ");
         }
         if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
@@ -389,7 +394,7 @@
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprmembers.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                writer.getTableCaption(configuration().getText(headingKey)));
+                writer.getTableCaption(configuration.getText(headingKey)));
             table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprmembers.size(); i++) {
@@ -507,8 +512,8 @@
     }
 
     protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
-        if (configuration().serialwarn) {
-            ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2);
+        if (configuration.serialwarn) {
+            configuration.getDocletSpecificMsg().warning(pos, key, a1, a2);
         }
     }
 
@@ -516,21 +521,17 @@
         return nodepr? Util.excludeDeprecatedMembers(members): members;
     }
 
-    public ConfigurationImpl configuration() {
-        return writer.configuration;
-    }
-
     /**
      * Add the member summary for the given class.
      *
      * @param classDoc the class that is being documented
      * @param member the member being documented
      * @param firstSentenceTags the first sentence tags to be added to the summary
-     * @param tableTree the content tree to which the documentation will be added
-     * @param counter the counter for determing style for the table row
+     * @param tableContents the list of contents to which the documentation will be added
+     * @param counter the counter for determining id and style for the table row
      */
     public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
-            Tag[] firstSentenceTags, Content tableTree, int counter) {
+            Tag[] firstSentenceTags, List<Content> tableContents, int counter) {
         HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
         tdSummaryType.addStyle(HtmlStyle.colFirst);
         writer.addSummaryType(this, member, tdSummaryType);
@@ -540,11 +541,46 @@
         writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
         HtmlTree tr = HtmlTree.TR(tdSummaryType);
         tr.addContent(tdSummary);
+        if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
+            int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
+                    MethodTypes.INSTANCE.value();
+            methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
+                    methodType | MethodTypes.ABSTRACT.value() :
+                    methodType | MethodTypes.CONCRETE.value();
+            if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
+                methodType = methodType | MethodTypes.DEPRECATED.value();
+            }
+            methodTypesOr = methodTypesOr | methodType;
+            String tableId = "i" + counter;
+            typeMap.put(tableId, methodType);
+            tr.addAttr(HtmlAttr.ID, tableId);
+        }
         if (counter%2 == 0)
             tr.addStyle(HtmlStyle.altColor);
         else
             tr.addStyle(HtmlStyle.rowColor);
-        tableTree.addContent(tr);
+        tableContents.add(tr);
+    }
+
+    /**
+     * Generate the method types set and return true if the method summary table
+     * needs to show tabs.
+     *
+     * @return true if the table should show tabs
+     */
+    public boolean showTabs() {
+        int value;
+        for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
+            value = type.value();
+            if ((value & methodTypesOr) == value) {
+                methodTypes.add(type);
+            }
+        }
+        boolean showTabs = methodTypes.size() > 1;
+        if (showTabs) {
+            methodTypes.add(MethodTypes.ALL);
+        }
+        return showTabs;
     }
 
     /**
@@ -597,10 +633,11 @@
      * Get the summary table tree for the given class.
      *
      * @param classDoc the class for which the summary table is generated
+     * @param tableContents list of contents to be displayed in the summary table
      * @return a content tree for the summary table
      */
-    public Content getSummaryTableTree(ClassDoc classDoc) {
-        return writer.getSummaryTableTree(this, classDoc);
+    public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) {
+        return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -138,7 +138,7 @@
             for (int i = 0; i < interfaces.length; i++) {
                 if (parent != interfaces[i]) {
                     if (! (interfaces[i].isPublic() ||
-                            Util.isLinkable(interfaces[i], configuration()))) {
+                            Util.isLinkable(interfaces[i], configuration))) {
                         continue;
                     }
                     if (counter == 0) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -159,10 +159,11 @@
             String label = italicsClassName(cd, false);
             Content linkContent;
             if(wantFrames){
-                linkContent = new RawHtml(getLink(new LinkInfoImpl(
+                linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
             } else {
-                linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
+                linkContent = new RawHtml(getLink(new LinkInfoImpl(
+                        configuration, cd, label)));
             }
             Content li = HtmlTree.LI(linkContent);
             content.addContent(li);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -103,16 +103,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
-                configuration().getText("doclet.annotation_type_optional_members"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
+                configuration.getText("doclet.annotation_type_optional_members"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Annotation_Type_Optional_Members");
+        return configuration.getText("doclet.Annotation_Type_Optional_Members");
     }
 
     /**
@@ -121,9 +121,9 @@
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Annotation_Type_Optional_Member"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Annotation_Type_Optional_Member"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -52,7 +52,7 @@
      * @param annotationType the AnnotationType that holds this member.
      */
     public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
-        AnnotationTypeDoc annotationType) {
+            AnnotationTypeDoc annotationType) {
         super(writer, annotationType);
     }
 
@@ -106,11 +106,11 @@
         writer.addAnnotationInfo(member, pre);
         addModifiers(member, pre);
         Content link = new RawHtml(
-                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                getType(member))));
+                writer.getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.CONTEXT_MEMBER, getType(member))));
         pre.addContent(link);
         pre.addContent(writer.getSpace());
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content memberName = new StringContent(member.name());
             writer.addSrcLink(member, memberName, pre);
         } else {
@@ -175,16 +175,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
-                configuration().getText("doclet.annotation_type_required_members"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
+                configuration.getText("doclet.annotation_type_required_members"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Annotation_Type_Required_Members");
+        return configuration.getText("doclet.Annotation_Type_Required_Members");
     }
 
     /**
@@ -193,9 +193,9 @@
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Annotation_Type_Required_Member"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Annotation_Type_Required_Member"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -65,10 +65,10 @@
      * @param prevType the previous class that was documented.
      * @param nextType the next class being documented.
      */
-    public AnnotationTypeWriterImpl(AnnotationTypeDoc annotationType,
-            Type prevType, Type nextType)
+    public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
+            AnnotationTypeDoc annotationType, Type prevType, Type nextType)
             throws Exception {
-        super(ConfigurationImpl.getInstance(), DocPath.forClass(annotationType));
+        super(configuration, DocPath.forClass(annotationType));
         this.annotationType = annotationType;
         configuration.currentcd = annotationType.asClassDoc();
         this.prev = prevType;
@@ -116,7 +116,7 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
                     configuration.getText("doclet.Prev_Class"), true)));
             li = HtmlTree.LI(prevLink);
@@ -134,7 +134,7 @@
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
                     configuration.getText("doclet.Next_Class"), true)));
             li = HtmlTree.LI(nextLink);
@@ -162,7 +162,7 @@
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
             div.addContent(pkgNameDiv);
         }
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                 LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
         Content headerContent = new StringContent(header);
         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
@@ -219,11 +219,11 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         addAnnotationInfo(annotationType, pre);
         pre.addContent(modifiers);
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
         Content annotationName = new StringContent(annotationType.name());
         Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             addSrcLink(annotationType, annotationName, pre);
             pre.addContent(parameterLinks);
         } else {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -256,9 +256,9 @@
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.getText(
                 "doclet.ClassUse_Packages.that.use.0",
-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
                 false)))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
@@ -287,14 +287,14 @@
     protected void addPackageAnnotationList(Content contentTree) throws IOException {
         if ((!classdoc.isAnnotationType()) ||
                 pkgToPackageAnnotations == null ||
-                pkgToPackageAnnotations.size() == 0) {
+                pkgToPackageAnnotations.isEmpty()) {
             return;
         }
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.getText(
                 "doclet.ClassUse_PackageAnnotation",
-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
-                false)))));
+                getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false)))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
         Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
@@ -333,7 +333,7 @@
             Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
             Content link = new RawHtml(
                     configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
-                    getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
+                    getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
                     classdoc, false)),
                     getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
             Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
@@ -368,7 +368,7 @@
      * @param contentTree the content tree to which the class use information will be added
      */
     protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
-        String classLink = getLink(new LinkInfoImpl(
+        String classLink = getLink(new LinkInfoImpl(configuration,
             LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
         String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
         classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
@@ -477,8 +477,8 @@
      */
     protected Content getNavLinkClass() {
         Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
-                configuration.getText("doclet.Class"), false)));
+                configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                "", configuration.getText("doclet.Class"), false)));
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -34,6 +34,7 @@
 import com.sun.tools.doclets.internal.toolkit.builders.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
+import java.io.IOException;
 
 /**
  * Generate the Class Information Page.
@@ -56,24 +57,25 @@
 public class ClassWriterImpl extends SubWriterHolderWriter
         implements ClassWriter {
 
-    protected ClassDoc classDoc;
+    protected final ClassDoc classDoc;
 
-    protected ClassTree classtree;
+    protected final ClassTree classtree;
 
-    protected ClassDoc prev;
+    protected final ClassDoc prev;
 
-    protected ClassDoc next;
+    protected final ClassDoc next;
 
     /**
+     * @param configuration the configuration data for the doclet
      * @param classDoc the class being documented.
      * @param prevClass the previous class that was documented.
      * @param nextClass the next class being documented.
      * @param classTree the class tree for the given class.
      */
-    public ClassWriterImpl (ClassDoc classDoc,
+    public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc,
             ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
-            throws Exception {
-        super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc));
+            throws IOException {
+        super(configuration, DocPath.forClass(classDoc));
         this.classDoc = classDoc;
         configuration.currentcd = classDoc;
         this.classtree = classTree;
@@ -122,7 +124,7 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_CLASS, prev, "",
                     configuration.getText("doclet.Prev_Class"), true)));
             li = HtmlTree.LI(prevLink);
@@ -140,7 +142,7 @@
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_CLASS, next, "",
                     configuration.getText("doclet.Next_Class"), true)));
             li = HtmlTree.LI(nextLink);
@@ -168,8 +170,8 @@
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
             div.addContent(pkgNameDiv);
         }
-        LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER,
-                classDoc, false);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false);
         //Let's not link to ourselves in the header.
         linkInfo.linkToSelf = false;
         Content headerContent = new StringContent(header);
@@ -228,13 +230,13 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         addAnnotationInfo(classDoc, pre);
         pre.addContent(modifiers);
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
         //Let's not link to ourselves in the signature.
         linkInfo.linkToSelf = false;
         Content className = new StringContent(classDoc.name());
         Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             addSrcLink(classDoc, className, pre);
             pre.addContent(parameterLinks);
         } else {
@@ -244,11 +246,11 @@
         }
         if (!isInterface) {
             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
-                    configuration());
+                    configuration);
             if (superclass != null) {
                 pre.addContent(DocletConstants.NL);
                 pre.addContent("extends ");
-                Content link = new RawHtml(getLink(new LinkInfoImpl(
+                Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
                         superclass)));
                 pre.addContent(link);
@@ -260,7 +262,7 @@
             for (int i = 0; i < implIntfacs.length; i++) {
                 ClassDoc classDoc = implIntfacs[i].asClassDoc();
                 if (! (classDoc.isPublic() ||
-                        Util.isLinkable(classDoc, configuration()))) {
+                        Util.isLinkable(classDoc, configuration))) {
                     continue;
                 }
                 if (counter == 0) {
@@ -269,7 +271,7 @@
                 } else {
                     pre.addContent(", ");
                 }
-                Content link = new RawHtml(getLink(new LinkInfoImpl(
+                Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
                         implIntfacs[i])));
                 pre.addContent(link);
@@ -315,7 +317,7 @@
         do {
             sup = Util.getFirstVisibleSuperClass(
                     type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
-                    configuration());
+                    configuration);
             if (sup != null) {
                 HtmlTree ul = new HtmlTree(HtmlTag.UL);
                 ul.addStyle(HtmlStyle.inheritance);
@@ -345,7 +347,7 @@
         Content li = new HtmlTree(HtmlTag.LI);
         if (type.equals(classDoc)) {
             String typeParameters = getTypeParameterLinks(
-                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE,
+                    new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE,
                     classDoc, false));
             if (configuration.shouldExcludeQualifier(
                     classDoc.containingPackage().name())) {
@@ -356,7 +358,7 @@
                 li.addContent(new RawHtml(typeParameters));
             }
         } else {
-            Content link = new RawHtml(getLink(new LinkInfoImpl(
+            Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
                     type instanceof ClassDoc ? (ClassDoc) type : type,
                     configuration.getClassName(type.asClassDoc()), false)));
@@ -504,8 +506,8 @@
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             Content dd = new HtmlTree(HtmlTag.DD);
-            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
-                    false))));
+            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.CONTEXT_CLASS, outerClass, false))));
             dl.addContent(dd);
             classInfoTree.addContent(dl);
         }
@@ -549,11 +551,11 @@
             }
             if (typeList[i] instanceof ClassDoc) {
                 Content link = new RawHtml(getLink(
-                        new LinkInfoImpl(context, (ClassDoc)(typeList[i]))));
+                        new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
                 dd.addContent(link);
             } else {
                 Content link = new RawHtml(getLink(
-                        new LinkInfoImpl(context, (Type)(typeList[i]))));
+                        new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
                 dd.addContent(link);
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -28,9 +28,13 @@
 import java.net.*;
 import java.util.*;
 
+import javax.tools.JavaFileManager;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
 
 /**
  * Configure the output based on the command line options.
@@ -57,8 +61,6 @@
  */
 public class ConfigurationImpl extends Configuration {
 
-    private static ConfigurationImpl instance = new ConfigurationImpl();
-
     /**
      * The build date.  Note: For now, we will use
      * a version number instead of a date.
@@ -183,34 +185,21 @@
     /**
      * The classdoc for the class file getting generated.
      */
-    public ClassDoc currentcd = null;  // Set this classdoc in the
-    // ClassWriter.
+    public ClassDoc currentcd = null;  // Set this classdoc in the ClassWriter.
 
     /**
      * Constructor. Initializes resource for the
      * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
      */
-    private ConfigurationImpl() {
+    public ConfigurationImpl() {
         standardmessage = new MessageRetriever(this,
             "com.sun.tools.doclets.formats.html.resources.standard");
     }
 
     /**
-     * Reset to a fresh new ConfigurationImpl, to allow multiple invocations
-     * of javadoc within a single VM. It would be better not to be using
-     * static fields at all, but .... (sigh).
-     */
-    public static void reset() {
-        instance = new ConfigurationImpl();
-    }
-
-    public static ConfigurationImpl getInstance() {
-        return instance;
-    }
-
-    /**
      * Return the build date for the doclet.
      */
+    @Override
     public String getDocletSpecificBuildDate() {
         return BUILD_DATE;
     }
@@ -221,6 +210,7 @@
      *
      * @param options The array of option names and values.
      */
+    @Override
     public void setSpecificDocletOptions(String[][] options) {
         for (int oi = 0; oi < options.length; ++oi) {
             String[] os = options[oi];
@@ -339,6 +329,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public boolean validOptions(String options[][],
             DocErrorReporter reporter) {
         boolean helpfile = false;
@@ -427,6 +418,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public MessageRetriever getDocletSpecificMsg() {
         return standardmessage;
     }
@@ -496,6 +488,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public WriterFactory getWriterFactory() {
         return new WriterFactoryImpl(this);
     }
@@ -503,6 +496,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public Comparator<ProgramElementDoc> getMemberComparator() {
         return null;
     }
@@ -510,10 +504,27 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public Locale getLocale() {
         if (root instanceof com.sun.tools.javadoc.RootDocImpl)
             return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale();
         else
             return Locale.getDefault();
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JavaFileManager getFileManager() {
+        if (fileManager == null) {
+            if (root instanceof com.sun.tools.javadoc.RootDocImpl)
+                fileManager = ((com.sun.tools.javadoc.RootDocImpl)root).getFileManager();
+            else
+                fileManager = new JavacFileManager(new Context(), false, null);
+        }
+        return fileManager;
+    }
+
+    private JavaFileManager fileManager;
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -184,9 +184,9 @@
      */
     public Content getConstantMembersHeader(ClassDoc cd) {
         //generate links backward only to public classes.
-        String classlink = (cd.isPublic() || cd.isProtected())?
-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
-                false)) :
+        String classlink = (cd.isPublic() || cd.isProtected()) ?
+            getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd, false)) :
             cd.qualifiedName();
         String name = cd.containingPackage().name();
         if (name.length() > 0) {
@@ -260,7 +260,7 @@
             code.addContent(modifier);
             code.addContent(getSpace());
         }
-        Content type = new RawHtml(getLink(new LinkInfoImpl(
+        Content type = new RawHtml(getLink(new LinkInfoImpl(configuration,
                 LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
         code.addContent(type);
         tdType.addContent(code);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -60,7 +60,7 @@
             ClassDoc classDoc) {
         super(writer, classDoc);
         VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
+            VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated);
         List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
         for (int i = 0; i < constructors.size(); i++) {
             if ((constructors.get(i)).isProtected() ||
@@ -130,7 +130,7 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(constructor, pre);
         addModifiers(constructor, pre);
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content constructorName = new StringContent(constructor.name());
             writer.addSrcLink(constructor, constructorName, pre);
         } else {
@@ -217,16 +217,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Constructor_Summary"),
-                configuration().getText("doclet.constructors"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Constructor_Summary"),
+                configuration.getText("doclet.constructors"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Constructors");
+        return configuration.getText("doclet.Constructors");
     }
 
     /**
@@ -236,17 +236,17 @@
         String[] header;
         if (foundNonPubConstructor) {
             header = new String[] {
-                configuration().getText("doclet.Modifier"),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Constructor"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.Modifier"),
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Constructor"),
+                        configuration.getText("doclet.Description"))
             };
         }
         else {
             header = new String[] {
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Constructor"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Constructor"),
+                        configuration.getText("doclet.Description"))
             };
         }
         return header;
@@ -313,7 +313,7 @@
                 code.addContent(writer.getSpace());
             } else {
                 code.addContent(
-                        configuration().getText("doclet.Package_private"));
+                        configuration.getText("doclet.Package_private"));
             }
             tdSummaryType.addContent(code);
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -101,11 +101,11 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(enumConstant, pre);
         addModifiers(enumConstant, pre);
-        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                enumConstant.type())));
+        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.CONTEXT_MEMBER, enumConstant.type())));
         pre.addContent(enumConstantLink);
         pre.addContent(" ");
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content enumConstantName = new StringContent(enumConstant.name());
             writer.addSrcLink(enumConstant, enumConstantName, pre);
         } else {
@@ -174,16 +174,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Enum_Constant_Summary"),
-                configuration().getText("doclet.enum_constants"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Enum_Constant_Summary"),
+                configuration.getText("doclet.enum_constants"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Enum_Constants");
+        return configuration.getText("doclet.Enum_Constants");
     }
 
     /**
@@ -191,9 +191,9 @@
      */
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Enum_Constant"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Enum_Constant"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -266,7 +266,7 @@
             return writer.getHyperLink((cd == null)?
                 "enum_constant_summary":
                 "enum_constants_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navEnum"));
         } else {
             return writer.getResource("doclet.navEnum");
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -102,11 +102,11 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(field, pre);
         addModifiers(field, pre);
-        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                field.type())));
+        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.CONTEXT_MEMBER, field.type())));
         pre.addContent(fieldlink);
         pre.addContent(" ");
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content fieldName = new StringContent(field.name());
             writer.addSrcLink(field, fieldName, pre);
         } else {
@@ -129,7 +129,7 @@
         ClassDoc holder = field.containingClass();
         if (field.inlineTags().length > 0) {
             if (holder.equals(classdoc) ||
-                    (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+                    (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
                 writer.addInlineComment(field, fieldDocTree);
             } else {
                 Content link = new RawHtml(
@@ -195,16 +195,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Field_Summary"),
-                configuration().getText("doclet.fields"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Field_Summary"),
+                configuration.getText("doclet.fields"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Fields");
+        return configuration.getText("doclet.Fields");
     }
 
     /**
@@ -213,9 +213,9 @@
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Field"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Field"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -232,7 +232,7 @@
      */
     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
         inheritedTree.addContent(writer.getMarkerAnchor(
-                "fields_inherited_from_class_" + configuration().getClassName(cd)));
+                "fields_inherited_from_class_" + configuration.getClassName(cd)));
     }
 
     /**
@@ -242,8 +242,8 @@
         Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
                 LinkInfoImpl.CONTEXT_MEMBER, cd, false));
         Content label = new StringContent(cd.isClass() ?
-            configuration().getText("doclet.Fields_Inherited_From_Class") :
-            configuration().getText("doclet.Fields_Inherited_From_Interface"));
+            configuration.getText("doclet.Fields_Inherited_From_Class") :
+            configuration.getText("doclet.Fields_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -296,7 +296,7 @@
             return writer.getHyperLink((cd == null)?
                 "field_summary":
                 "fields_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navField"));
         } else {
             return writer.getResource("doclet.navField");
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 18:30:46 2017 +0200
@@ -46,14 +46,17 @@
  *
  */
 public class HtmlDoclet extends AbstractDoclet {
+    // An instance will be created by validOptions, and used by start.
+    private static HtmlDoclet docletToStart = null;
+
     public HtmlDoclet() {
-        configuration = (ConfigurationImpl) configuration();
+        configuration = new ConfigurationImpl();
     }
 
     /**
      * The global configuration information for this run.
      */
-    public ConfigurationImpl configuration;
+    public final ConfigurationImpl configuration;
 
     /**
      * The "start" method as required by Javadoc.
@@ -63,12 +66,16 @@
      * @return true if the doclet ran without encountering any errors.
      */
     public static boolean start(RootDoc root) {
-        try {
-            HtmlDoclet doclet = new HtmlDoclet();
-            return doclet.start(doclet, root);
-        } finally {
-            ConfigurationImpl.reset();
+        // In typical use, options will have been set up by calling validOptions,
+        // which will create an HtmlDoclet for use here.
+        HtmlDoclet doclet;
+        if (docletToStart != null) {
+            doclet = docletToStart;
+            docletToStart = null;
+        } else {
+            doclet = new HtmlDoclet();
         }
+        return doclet.start(doclet, root);
     }
 
     /**
@@ -77,7 +84,7 @@
      * configuration.
      */
     public Configuration configuration() {
-        return ConfigurationImpl.getInstance();
+        return configuration;
     }
 
     /**
@@ -110,6 +117,8 @@
         copyResourceFile("tab.gif");
         copyResourceFile("titlebar.gif");
         copyResourceFile("titlebar_end.gif");
+        copyResourceFile("activetitlebar.gif");
+        copyResourceFile("activetitlebar_end.gif");
         // do early to reduce memory footprint
         if (configuration.classuse) {
             ClassUseWriter.generate(configuration, classtree);
@@ -145,10 +154,13 @@
         }
         // If a stylesheet file is not specified, copy the default stylesheet
         // and replace newline with platform-specific newline.
+        DocFile f;
         if (configuration.stylesheetfile.length() == 0) {
-            DocFile f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
+            f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
             f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
         }
+        f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
+        f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
     }
 
     /**
@@ -220,6 +232,9 @@
         }
     }
 
+    public static final ConfigurationImpl sharedInstanceForOptions =
+            new ConfigurationImpl();
+
     /**
      * Check for doclet added options here.
      *
@@ -228,7 +243,7 @@
      */
     public static int optionLength(String option) {
         // Construct temporary configuration for check
-        return (ConfigurationImpl.getInstance()).optionLength(option);
+        return sharedInstanceForOptions.optionLength(option);
     }
 
     /**
@@ -244,8 +259,8 @@
      */
     public static boolean validOptions(String options[][],
             DocErrorReporter reporter) {
-        // Construct temporary configuration for check
-        return (ConfigurationImpl.getInstance()).validOptions(options, reporter);
+        docletToStart = new HtmlDoclet();
+        return docletToStart.configuration.validOptions(options, reporter);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -82,7 +82,7 @@
     /**
      * The global configuration information for this run.
      */
-    public ConfigurationImpl configuration;
+    public final ConfigurationImpl configuration;
 
     /**
      * To check whether annotation heading is printed or not.
@@ -302,7 +302,7 @@
      */
     public void printHtmlDocument(String[] metakeywords, boolean includeScript,
             Content body) throws IOException {
-        Content htmlDocType = DocType.Transitional();
+        Content htmlDocType = DocType.TRANSITIONAL;
         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
         Content head = new HtmlTree(HtmlTag.HEAD);
         if (!configuration.notimestamp) {
@@ -327,6 +327,7 @@
             }
         }
         head.addContent(getStyleSheetProperties());
+        head.addContent(getScriptProperties());
         Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
                 head, body);
         Content htmlDocument = new HtmlDocument(htmlDocType,
@@ -835,7 +836,7 @@
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprPkgs.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration().getText(headingKey)));
+                    getTableCaption(configuration.getText(headingKey)));
             table.addContent(getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprPkgs.size(); i++) {
@@ -1079,7 +1080,7 @@
      * @return a content tree for the link
      */
     public Content getQualifiedClassLink(int context, ClassDoc cd) {
-        return new RawHtml(getLink(new LinkInfoImpl(context, cd,
+        return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd,
                 configuration.getClassName(cd), "")));
     }
 
@@ -1110,7 +1111,8 @@
         if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
             classlink = getPkgName(cd);
         }
-        classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong));
+        classlink += getLink(new LinkInfoImpl(configuration,
+                context, cd, cd.name(), isStrong));
         return classlink;
     }
 
@@ -1130,7 +1132,7 @@
         if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
             contentTree.addContent(getPkgName(cd));
         }
-        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
+        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
                 context, cd, cd.name(), isStrong))));
     }
 
@@ -1187,14 +1189,14 @@
     public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
         String label, boolean strong) {
         if (! (doc.isIncluded() ||
-            Util.isLinkable(classDoc, configuration()))) {
+            Util.isLinkable(classDoc, configuration))) {
             return label;
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return getLink(new LinkInfoImpl(context, classDoc,
+            return getLink(new LinkInfoImpl(configuration, context, classDoc,
                 getAnchor(emd), label, strong));
         } else if (doc instanceof MemberDoc) {
-            return getLink(new LinkInfoImpl(context, classDoc,
+            return getLink(new LinkInfoImpl(configuration, context, classDoc,
                 doc.name(), label, strong));
         } else {
             return label;
@@ -1215,14 +1217,14 @@
     public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
         String label) {
         if (! (doc.isIncluded() ||
-            Util.isLinkable(classDoc, configuration()))) {
+            Util.isLinkable(classDoc, configuration))) {
             return new StringContent(label);
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+            return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
                 getAnchor(emd), label, false)));
         } else if (doc instanceof MemberDoc) {
-            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+            return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
                 doc.name(), label, false)));
         } else {
             return new StringContent(label);
@@ -1302,7 +1304,7 @@
             if (label.isEmpty()) {
                 label = plainOrCodeText(plain, refClass.name());
             }
-            return getLink(new LinkInfoImpl(refClass, label));
+            return getLink(new LinkInfoImpl(configuration, refClass, label));
         } else if (refMem == null) {
             // Must be a member reference since refClass is not null and refMemName is not null.
             // However, refMem is null, so this referenced member does not exist.
@@ -1313,7 +1315,7 @@
             ClassDoc containing = refMem.containingClass();
             if (see.text().trim().startsWith("#") &&
                 ! (containing.isPublic() ||
-                Util.isLinkable(containing, configuration()))) {
+                Util.isLinkable(containing, configuration))) {
                 // Since the link is relative and the holder is not even being
                 // documented, this must be an inherited link.  Redirect it.
                 // The current class either overrides the referenced member or
@@ -1502,7 +1504,7 @@
                 StringBuilder textBuff = new StringBuilder();
                 while (lines.hasMoreTokens()) {
                     StringBuilder line = new StringBuilder(lines.nextToken());
-                    Util.replaceTabs(configuration.sourcetab, line);
+                    Util.replaceTabs(configuration, line);
                     textBuff.append(line.toString());
                 }
                 result.append(textBuff);
@@ -1687,6 +1689,17 @@
     }
 
     /**
+     * Returns a link to the JavaScript file.
+     *
+     * @return an HtmlTree for the Script tag which provides the JavaScript location
+     */
+    public HtmlTree getScriptProperties() {
+        HtmlTree script = HtmlTree.SCRIPT("text/javascript",
+                pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
+        return script;
+    }
+
+    /**
      * According to
      * <cite>The Java&trade; Language Specification</cite>,
      * all the outer classes and static nested classes are core classes.
@@ -1784,7 +1797,7 @@
                 continue;
             }
             annotation = new StringBuilder();
-            LinkInfoImpl linkInfo = new LinkInfoImpl(
+            LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
             linkInfo.label = "@" + annotationDoc.name();
             annotation.append(getLink(linkInfo));
@@ -1835,7 +1848,7 @@
         if (annotationValue.value() instanceof Type) {
             Type type = (Type) annotationValue.value();
             if (type.asClassDoc() != null) {
-                LinkInfoImpl linkInfo = new LinkInfoImpl(
+                LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                     LinkInfoImpl.CONTEXT_ANNOTATION, type);
                     linkInfo.label = (type.asClassDoc().isIncluded() ?
                         type.typeName() :
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -130,7 +130,7 @@
             pre.addContent(fieldTypeStr);
         } else {
             Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
+                    configuration, LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
             pre.addContent(fieldContent);
         }
         pre.addContent(fieldDimensions + " ");
@@ -187,8 +187,8 @@
      */
     public void addMemberTags(FieldDoc field, Content contentTree) {
         TagletOutputImpl output = new TagletOutputImpl("");
-        TagletWriter.genTagOuput(configuration().tagletManager, field,
-                configuration().tagletManager.getCustomTags(field),
+        TagletWriter.genTagOuput(configuration.tagletManager, field,
+                configuration.tagletManager.getCustomTags(field),
                 writer.getTagletWriterInstance(false), output);
         String outputString = output.toString().trim();
         Content dlTags = new HtmlTree(HtmlTag.DL);
@@ -208,7 +208,7 @@
      * @return true if overview details need to be printed
      */
     public boolean shouldPrintOverview(FieldDoc field) {
-        if (!configuration().nocomment) {
+        if (!configuration.nocomment) {
             if(!field.commentText().isEmpty() ||
                     writer.hasSerializationOverviewTags(field))
                 return true;
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -148,7 +148,7 @@
     public void addMemberTags(MethodDoc member, Content methodsContentTree) {
         TagletOutputImpl output = new TagletOutputImpl("");
         TagletManager tagletManager =
-            ConfigurationImpl.getInstance().tagletManager;
+            configuration.tagletManager;
         TagletWriter.genTagOuput(tagletManager, member,
             tagletManager.getSerializedFormTags(),
             writer.getTagletWriterInstance(false), output);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -74,7 +74,7 @@
         StringBuilder label = new StringBuilder(
             classLinkInfo.getClassLinkLabel(m_writer.configuration));
         classLinkInfo.displayLength += label.length();
-        Configuration configuration = ConfigurationImpl.getInstance();
+        Configuration configuration = m_writer.configuration;
         LinkOutputImpl linkOutput = new LinkOutputImpl();
         if (classDoc.isIncluded()) {
             if (configuration.isGeneratedDoc(classDoc)) {
@@ -118,8 +118,8 @@
      */
     protected LinkOutput getTypeParameterLink(LinkInfo linkInfo,
         Type typeParam) {
-        LinkInfoImpl typeLinkInfo = new LinkInfoImpl(linkInfo.getContext(),
-            typeParam);
+        LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
+                linkInfo.getContext(), typeParam);
         typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
         typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
         typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
@@ -135,10 +135,10 @@
      * @return the tool tip for the appropriate class.
      */
     private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
-        Configuration configuration = ConfigurationImpl.getInstance();
+        Configuration configuration = m_writer.configuration;
         if (isTypeLink) {
             return configuration.getText("doclet.Href_Type_Param_Title",
-            classDoc.name());
+                classDoc.name());
         } else if (classDoc.isInterface()){
             return configuration.getText("doclet.Href_Interface_Title",
                 Util.getPackageName(classDoc.containingPackage()));
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -198,6 +198,8 @@
      */
     public static final int CONTEXT_CLASS_USE_HEADER = 33;
 
+    public final ConfigurationImpl configuration;
+
     /**
      * The integer indicating the location of the link.
      */
@@ -214,20 +216,22 @@
     public String styleName ="";
 
     /**
-     * The valueof the target.
+     * The value of the target.
      */
     public String target = "";
 
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param label      the label for the link.
      * @param target     the value of the target attribute.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String label,
-            String target){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ClassDoc classDoc, String label, String target) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.label = label;
         this.target = target;
@@ -237,6 +241,7 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param where      the value of the marker #.
@@ -244,8 +249,10 @@
      * @param isStrong       true if the link should be strong.
      * @param styleName  String style of text defined in style sheet.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong, String styleName){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ClassDoc classDoc, String where, String label,
+            boolean isStrong, String styleName) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.where = where;
         this.label = label;
@@ -257,14 +264,17 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param where      the value of the marker #.
      * @param label      the label for the link.
      * @param isStrong       true if the link should be strong.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ClassDoc classDoc, String where, String label,
+            boolean isStrong) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.where = where;
         this.label = label;
@@ -275,10 +285,13 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param classDoc   the class to link to.
      * @param label      the label for the link.
      */
-    public LinkInfoImpl (ClassDoc classDoc, String label){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            ClassDoc classDoc, String label) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.label = label;
         setContext(context);
@@ -287,12 +300,15 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context               the context of the link.
      * @param executableMemberDoc   the member to link to.
      * @param isStrong                true if the link should be strong.
      */
-    public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
-            boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ExecutableMemberDoc executableMemberDoc,
+            boolean isStrong) {
+        this.configuration = configuration;
         this.executableMemberDoc = executableMemberDoc;
         this.isStrong = isStrong;
         setContext(context);
@@ -301,11 +317,14 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param isStrong       true if the link should be strong.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ClassDoc classDoc,  boolean isStrong) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.isStrong = isStrong;
         setContext(context);
@@ -314,10 +333,13 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param type       the class to link to.
      */
-    public LinkInfoImpl (int context, Type type){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, Type type) {
+        this.configuration = configuration;
         this.type = type;
         setContext(context);
     }
@@ -325,11 +347,14 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param type       the class to link to.
      * @param isVarArg   true if this is a link to a var arg.
      */
-    public LinkInfoImpl (int context, Type type, boolean isVarArg){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, Type type, boolean isVarArg) {
+        this.configuration = configuration;
         this.type = type;
         this.isVarArg = isVarArg;
         setContext(context);
@@ -338,13 +363,16 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param type       the class to link to.
      * @param label      the label for the link.
      * @param isStrong     true if the link should be strong.
      */
-    public LinkInfoImpl (int context, Type type, String label,
-            boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, Type type, String label,
+            boolean isStrong) {
+        this.configuration = configuration;
         this.type = type;
         this.label = label;
         this.isStrong = isStrong;
@@ -354,13 +382,16 @@
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param label      the label for the link.
      * @param isStrong       true if the link should be strong.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String label,
-            boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            int context, ClassDoc classDoc, String label,
+            boolean isStrong) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
         this.label = label;
         this.isStrong = isStrong;
@@ -448,6 +479,6 @@
      * desired place.
      */
     public boolean isLinkable() {
-        return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
+        return Util.isLinkable(classDoc, configuration);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -123,7 +123,7 @@
         addModifiers(method, pre);
         addTypeParameters(method, pre);
         addReturnType(method, pre);
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content methodName = new StringContent(method.name());
             writer.addSrcLink(method, methodName, pre);
         } else {
@@ -149,7 +149,7 @@
         if (method.inlineTags().length > 0) {
             if (holder.asClassDoc().equals(classdoc) ||
                     (! (holderClassDoc.isPublic() ||
-                    Util.isLinkable(holderClassDoc, configuration())))) {
+                    Util.isLinkable(holderClassDoc, configuration)))) {
                 writer.addInlineComment(method, methodDocTree);
             } else {
                 Content link = new RawHtml(
@@ -215,16 +215,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Method_Summary"),
-                configuration().getText("doclet.methods"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Method_Summary"),
+                configuration.getText("doclet.methods"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Methods");
+        return configuration.getText("doclet.Methods");
     }
 
     /**
@@ -233,9 +233,9 @@
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Method"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Method"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -253,7 +253,7 @@
     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
         inheritedTree.addContent(writer.getMarkerAnchor(
                 "methods_inherited_from_class_" +
-                configuration().getClassName(cd)));
+                configuration.getClassName(cd)));
     }
 
     /**
@@ -263,8 +263,8 @@
         Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
                 LinkInfoImpl.CONTEXT_MEMBER, cd, false));
         Content label = new StringContent(cd.isClass() ?
-            configuration().getText("doclet.Methods_Inherited_From_Class") :
-            configuration().getText("doclet.Methods_Inherited_From_Interface"));
+            configuration.getText("doclet.Methods_Inherited_From_Class") :
+            configuration.getText("doclet.Methods_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -285,12 +285,12 @@
      */
     protected static void addOverridden(HtmlDocletWriter writer,
             Type overriddenType, MethodDoc method, Content dl) {
-        if(writer.configuration.nocomment){
+        if (writer.configuration.nocomment) {
             return;
         }
         ClassDoc holderClassDoc = overriddenType.asClassDoc();
         if (! (holderClassDoc.isPublic() ||
-            Util.isLinkable(holderClassDoc, writer.configuration()))) {
+            Util.isLinkable(holderClassDoc, writer.configuration))) {
             //This is an implementation detail that should not be documented.
             return;
         }
@@ -303,7 +303,7 @@
         int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES;
 
         if (method != null) {
-            if(overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
+            if (overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
                 //Abstract method is implemented from abstract class,
                 //not overridden
                 label = writer.specifiedByLabel;
@@ -312,11 +312,11 @@
             Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
             dl.addContent(dt);
             Content overriddenTypeLink = new RawHtml(
-                    writer.getLink(new LinkInfoImpl(context, overriddenType)));
+                    writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType)));
             Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
             String name = method.name();
             Content methlink = new RawHtml(writer.getLink(
-                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                    new LinkInfoImpl(writer.configuration, LinkInfoImpl.CONTEXT_MEMBER,
                     overriddenType.asClassDoc(),
                     writer.getAnchor(method), name, false)));
             Content codeMethLink = HtmlTree.CODE(methlink);
@@ -362,7 +362,7 @@
             MethodDoc implementedMeth = implementedMethods[i];
             Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
             Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+                    writer.configuration, LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
             Content codeIntfacLink = HtmlTree.CODE(intfaclink);
             Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
             dl.addContent(dt);
@@ -389,7 +389,7 @@
         Type type = method.returnType();
         if (type != null) {
             Content linkContent = new RawHtml(writer.getLink(
-                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
+                    new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
             htmltree.addContent(linkContent);
             htmltree.addContent(writer.getSpace());
         }
@@ -403,7 +403,7 @@
             return writer.getHyperLink((cd == null)?
                 "method_summary":
                 "methods_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navMethod"));
         } else {
             return writer.getResource("doclet.navMethod");
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -93,16 +93,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Nested_Class_Summary"),
-                configuration().getText("doclet.nested_classes"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Nested_Class_Summary"),
+                configuration.getText("doclet.nested_classes"));
     }
 
     /**
      * {@inheritDoc}
      */
     public String getCaption() {
-        return configuration().getText("doclet.Nested_Classes");
+        return configuration.getText("doclet.Nested_Classes");
     }
 
     /**
@@ -113,17 +113,17 @@
         if (member.isInterface()) {
             header = new String[] {
                 writer.getModifierTypeHeader(),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Interface"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Interface"),
+                        configuration.getText("doclet.Description"))
             };
         }
         else {
             header = new String[] {
                 writer.getModifierTypeHeader(),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Class"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Class"),
+                        configuration.getText("doclet.Description"))
             };
         }
         return header;
@@ -151,8 +151,8 @@
         Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
                 LinkInfoImpl.CONTEXT_MEMBER, cd, false));
         Content label = new StringContent(cd.isInterface() ?
-            configuration().getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
-            configuration().getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
+            configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
+            configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -166,7 +166,7 @@
     protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
         Content strong = HtmlTree.STRONG(new RawHtml(
-                writer.getLink(new LinkInfoImpl(context, (ClassDoc)member, false))));
+                writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false))));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -177,7 +177,7 @@
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
         linksTree.addContent(new RawHtml(
-                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
                 (ClassDoc)member, false))));
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -121,7 +121,7 @@
      * @param contentTree the content tree to which the listing will be added
      */
     protected void addClassListing(Content contentTree) {
-        Configuration config = configuration();
+        Configuration config = configuration;
         if (packageDoc.isIncluded()) {
             addClassKindListing(packageDoc.interfaces(),
                 getResource("doclet.Interfaces"), contentTree);
@@ -181,7 +181,7 @@
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
-                Content link = new RawHtml (getLink(new LinkInfoImpl(
+                Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.PACKAGE_FRAME, arr[i],
                         (arr[i].isInterface() ? italicsText(arr[i].name()) :
                             arr[i].name()),"classFrame")));
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -152,7 +152,7 @@
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.getText(
                 "doclet.ClassUse_Packages.that.use.0",
                 getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
@@ -197,7 +197,7 @@
             String tableSummary = configuration.getText("doclet.Use_Table_Summary",
                     configuration.getText("doclet.classes"));
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration().getText(
+                    getTableCaption(configuration.getText(
                     "doclet.ClassUse_Classes.in.0.used.by.1",
                     getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false),
                     getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -179,7 +179,8 @@
                     continue;
                 }
                 Content classContent = new RawHtml(getLink(new LinkInfoImpl(
-                        LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false)));
+                        configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i],
+                        false)));
                 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
                 HtmlTree tr = HtmlTree.TR(tdClass);
                 if (i%2 == 0)
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -46,11 +46,13 @@
     implements SerializedFormWriter {
 
     /**
+     * @param configuration the configuration data for the doclet
      * @throws IOException
      * @throws DocletAbortException
      */
-    public SerializedFormWriterImpl() throws IOException {
-        super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM);
+    public SerializedFormWriterImpl(ConfigurationImpl configuration)
+            throws IOException {
+        super(configuration, DocPaths.SERIALIZED_FORM);
     }
 
     /**
@@ -126,15 +128,16 @@
      */
     public Content getClassHeader(ClassDoc classDoc) {
         String classLink = (classDoc.isPublic() || classDoc.isProtected())?
-            getLink(new LinkInfoImpl(classDoc,
+            getLink(new LinkInfoImpl(configuration, classDoc,
             configuration.getClassName(classDoc))):
             classDoc.qualifiedName();
         Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
                 classDoc.qualifiedName()));
         String superClassLink =
             classDoc.superclassType() != null ?
-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
-                classDoc.superclassType())) :
+                getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
+                        classDoc.superclassType())) :
                 null;
 
         //Print the heading.
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -60,16 +60,24 @@
      */
     private static final Content NEW_LINE = new RawHtml(DocletConstants.NL);
 
+    private final ConfigurationImpl configuration;
+
+    private final RootDoc rootDoc;
+
+    private DocPath outputdir;
+
     /**
      * Relative path from the documentation root to the file that is being
      * generated.
      */
-    private static DocPath relativePath = DocPath.empty;
+    private DocPath relativePath = DocPath.empty;
 
-    /**
-     * Source is converted to HTML using static methods below.
-     */
-    private SourceToHTMLConverter() {}
+    private SourceToHTMLConverter(ConfigurationImpl configuration, RootDoc rd,
+            DocPath outputdir) {
+        this.configuration  = configuration;
+        this.rootDoc = rd;
+        this.outputdir = outputdir;
+    }
 
     /**
      * Convert the Classes in the given RootDoc to an HTML.
@@ -80,36 +88,38 @@
      */
     public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
             DocPath outputdir) {
-        if (rd == null || outputdir == null) {
+        new SourceToHTMLConverter(configuration, rd, outputdir).generate();
+    }
+
+    void generate() {
+        if (rootDoc == null || outputdir == null) {
             return;
         }
-        PackageDoc[] pds = rd.specifiedPackages();
+        PackageDoc[] pds = rootDoc.specifiedPackages();
         for (int i = 0; i < pds.length; i++) {
             // If -nodeprecated option is set and the package is marked as deprecated,
             // do not convert the package files to HTML.
             if (!(configuration.nodeprecated && Util.isDeprecated(pds[i])))
-                convertPackage(configuration, pds[i], outputdir);
+                convertPackage(pds[i], outputdir);
         }
-        ClassDoc[] cds = rd.specifiedClasses();
+        ClassDoc[] cds = rootDoc.specifiedClasses();
         for (int i = 0; i < cds.length; i++) {
             // If -nodeprecated option is set and the class is marked as deprecated
             // or the containing package is deprecated, do not convert the
             // package files to HTML.
             if (!(configuration.nodeprecated &&
                     (Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage()))))
-                convertClass(configuration, cds[i], outputdir);
+                convertClass(cds[i], outputdir);
         }
     }
 
     /**
      * Convert the Classes in the given Package to an HTML.
      *
-     * @param configuration the configuration.
      * @param pd the Package to convert.
      * @param outputdir the name of the directory to output to.
      */
-    public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
-            DocPath outputdir) {
+    public void convertPackage(PackageDoc pd, DocPath outputdir) {
         if (pd == null) {
             return;
         }
@@ -120,19 +130,17 @@
             // containing package deprecation since it is already check in
             // the calling method above.
             if (!(configuration.nodeprecated && Util.isDeprecated(cds[i])))
-                convertClass(configuration, cds[i], outputdir);
+                convertClass(cds[i], outputdir);
         }
     }
 
     /**
      * Convert the given Class to an HTML.
      *
-     * @param configuration the configuration.
      * @param cd the class to convert.
      * @param outputdir the name of the directory to output to.
      */
-    public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
-            DocPath outputdir) {
+    public void convertClass(ClassDoc cd, DocPath outputdir) {
         if (cd == null) {
             return;
         }
@@ -164,7 +172,7 @@
             try {
                 while ((line = reader.readLine()) != null) {
                     addLineNo(pre, lineno);
-                    addLine(pre, line, configuration.sourcetab, lineno);
+                    addLine(pre, line, lineno);
                     lineno++;
                 }
             } finally {
@@ -173,7 +181,7 @@
             addBlankLines(pre);
             Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
             body.addContent(div);
-            writeToFile(body, outputdir.resolve(DocPath.forClass(cd)), configuration);
+            writeToFile(body, outputdir.resolve(DocPath.forClass(cd)));
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -184,15 +192,13 @@
      *
      * @param body the documentation content to be written to the file.
      * @param path the path for the file.
-     * @param configuration the Doclet configuration to pass notices to.
      */
-    private static void writeToFile(Content body, DocPath path,
-            ConfigurationImpl configuration) throws IOException {
-        Content htmlDocType = DocType.Transitional();
+    private void writeToFile(Content body, DocPath path) throws IOException {
+        Content htmlDocType = DocType.TRANSITIONAL;
         Content head = new HtmlTree(HtmlTag.HEAD);
         head.addContent(HtmlTree.TITLE(new StringContent(
                 configuration.getText("doclet.Window_Source_title"))));
-        head.addContent(getStyleSheetProperties(configuration));
+        head.addContent(getStyleSheetProperties());
         Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
                 head, body);
         Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
@@ -210,10 +216,9 @@
     /**
      * Returns a link to the stylesheet file.
      *
-     * @param configuration the doclet configuration for the current run of javadoc
      * @return an HtmlTree for the lINK tag which provides the stylesheet location
      */
-    public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
+    public HtmlTree getStyleSheetProperties() {
         String filename = configuration.stylesheetfile;
         DocPath stylesheet;
         if (filename.length() > 0) {
@@ -260,14 +265,13 @@
      *
      * @param pre the content tree to which the line will be added.
      * @param line the string to format.
-     * @param tabLength the number of spaces for each tab.
      * @param currentLineNo the current number.
      */
-    private static void addLine(Content pre, String line, int tabLength,
-            int currentLineNo) {
+    private void addLine(Content pre, String line, int currentLineNo) {
         if (line != null) {
-            StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
-            Util.replaceTabs(tabLength, lineBuffer);
+            StringBuilder lineBuffer = new StringBuilder(line);
+            Util.replaceTabs(configuration, lineBuffer);
+            Util.escapeHtmlChars(lineBuffer);
             pre.addContent(new RawHtml(lineBuffer.toString()));
             Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
             pre.addContent(anchor);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
+import java.util.*;
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.*;
@@ -77,16 +78,71 @@
      *
      * @param mw the writer for the member being documented
      * @param cd the classdoc to be documented
+     * @param tableContents list of summary table contents
+     * @param showTabs true if the table needs to show tabs
      * @return the content tree for the summary table
      */
-    public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
+    public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd,
+            List<Content> tableContents, boolean showTabs) {
+        Content caption;
+        if (showTabs) {
+            caption = getTableCaption(mw.methodTypes);
+            generateMethodTypesScript(mw.typeMap, mw.methodTypes);
+        }
+        else {
+            caption = getTableCaption(mw.getCaption());
+        }
         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
-                mw.getTableSummary(), getTableCaption(mw.getCaption()));
+                mw.getTableSummary(), caption);
         table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
+        for (int i = 0; i < tableContents.size(); i++) {
+            table.addContent(tableContents.get(i));
+        }
         return table;
     }
 
     /**
+     * Get the summary table caption.
+     *
+     * @param methodTypes set comprising of method types to show as table caption
+     * @return the caption for the summary table
+     */
+    public Content getTableCaption(Set<MethodTypes> methodTypes) {
+        Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
+        for (MethodTypes type : methodTypes) {
+            Content captionSpan;
+            Content span;
+            if (type.isDefaultTab()) {
+                captionSpan = HtmlTree.SPAN(new StringContent(type.text()));
+                span = HtmlTree.SPAN(type.tabId(),
+                        HtmlStyle.activeTableTab, captionSpan);
+            } else {
+                captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type));
+                span = HtmlTree.SPAN(type.tabId(),
+                        HtmlStyle.tableTab, captionSpan);
+            }
+            Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
+            span.addContent(tabSpan);
+            tabbedCaption.addContent(span);
+        }
+        return tabbedCaption;
+    }
+
+    /**
+     * Get the method type links for the table caption.
+     *
+     * @param methodType the method type to be displayed as link
+     * @return the content tree for the method type link
+     */
+    public Content getMethodTypeLinks(MethodTypes methodType) {
+        StringBuilder jsShow = new StringBuilder("javascript:show(");
+        jsShow.append(methodType.value()).append(");");
+        HtmlTree link = HtmlTree.A(jsShow.toString(),
+                new StringContent(methodType.text()));
+        return link;
+    }
+
+    /**
      * Add the inherited summary header.
      *
      * @param mw the writer for the member being documented
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -46,11 +46,13 @@
 
 public class TagletWriterImpl extends TagletWriter {
 
-    private HtmlDocletWriter htmlWriter;
+    private final HtmlDocletWriter htmlWriter;
+    private final ConfigurationImpl configuration;
 
     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
+        super(isFirstSentence);
         this.htmlWriter = htmlWriter;
-        this.isFirstSentence = isFirstSentence;
+        configuration = htmlWriter.configuration;
     }
 
     /**
@@ -64,8 +66,8 @@
      * {@inheritDoc}
      */
     public TagletOutput getDocRootOutput() {
-        if (htmlWriter.configuration.docrootparent.length() > 0)
-            return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
+        if (configuration.docrootparent.length() > 0)
+            return new TagletOutputImpl(configuration.docrootparent);
         else if (htmlWriter.pathToRoot.isEmpty())
             return new TagletOutputImpl(".");
         else
@@ -81,7 +83,7 @@
         if (doc instanceof ClassDoc) {
             if (Util.isDeprecated((ProgramElementDoc) doc)) {
                 output.append("<span class=\"strong\">" +
-                    ConfigurationImpl.getInstance().
+                    configuration.
                         getText("doclet.Deprecated") + "</span>&nbsp;");
                 if (deprs.length > 0) {
                     Tag[] commentTags = deprs[0].inlineTags();
@@ -97,7 +99,7 @@
             MemberDoc member = (MemberDoc) doc;
             if (Util.isDeprecated((ProgramElementDoc) doc)) {
                 output.append("<span class=\"strong\">" +
-                    ConfigurationImpl.getInstance().
+                    configuration.
                             getText("doclet.Deprecated") + "</span>&nbsp;");
                 if (deprs.length > 0) {
                     output.append("<i>");
@@ -108,7 +110,7 @@
             } else {
                 if (Util.isDeprecated(member.containingClass())) {
                     output.append("<span class=\"strong\">" +
-                    ConfigurationImpl.getInstance().
+                    configuration.
                             getText("doclet.Deprecated") + "</span>&nbsp;");
                 }
             }
@@ -120,7 +122,7 @@
      * {@inheritDoc}
      */
     public MessageRetriever getMsgRetriever() {
-        return htmlWriter.configuration.message;
+        return configuration.message;
     }
 
     /**
@@ -147,7 +149,7 @@
      */
     public TagletOutput returnTagOutput(Tag returnTag) {
         TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<dt>" +
-            "<span class=\"strong\">" + htmlWriter.configuration.getText("doclet.Returns") +
+            "<span class=\"strong\">" + configuration.getText("doclet.Returns") +
             "</span>" + "</dt>" + "<dd>" +
             htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
             false) + "</dd>");
@@ -178,7 +180,7 @@
                     ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name();
             DocLink link = constantsPath.fragment(whichConstant);
             result += htmlWriter.getHyperLinkString(link,
-                    htmlWriter.configuration.getText("doclet.Constants_Summary"),
+                    configuration.getText("doclet.Constants_Summary"),
                     false);
         }
         if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
@@ -189,7 +191,7 @@
                 DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
                 DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName());
                 result += htmlWriter.getHyperLinkString(link,
-                        htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+                        configuration.getText("doclet.Serialized_Form"), false);
             }
         }
         return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
@@ -200,7 +202,7 @@
             return result + ", " + DocletConstants.NL;
         } else {
             return "<dt><span class=\"strong\">" +
-                    htmlWriter.configuration().getText("doclet.See_Also") + "</span></dt><dd>";
+                    configuration.getText("doclet.See_Also") + "</span></dt><dd>";
         }
      }
 
@@ -234,7 +236,7 @@
      */
     public TagletOutput getThrowsHeader() {
         return new TagletOutputImpl(DocletConstants.NL + "<dt>" + "<span class=\"strong\">" +
-            htmlWriter.configuration().getText("doclet.Throws") + "</span></dt>");
+            configuration.getText("doclet.Throws") + "</span></dt>");
     }
 
     /**
@@ -245,7 +247,7 @@
         result += throwsTag.exceptionType() == null ?
             htmlWriter.codeText(throwsTag.exceptionName()) :
             htmlWriter.codeText(
-                htmlWriter.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
                 throwsTag.exceptionType())));
         TagletOutput text = new TagletOutputImpl(
             htmlWriter.commentTagsToString(throwsTag, null,
@@ -263,7 +265,7 @@
     public TagletOutput throwsTagOutput(Type throwsType) {
         return new TagletOutputImpl(DocletConstants.NL + "<dd>" +
             htmlWriter.codeText(htmlWriter.getLink(
-                new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</dd>");
+                new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</dd>");
     }
 
     /**
@@ -303,7 +305,7 @@
      * {@inheritDoc}
      */
     public Configuration configuration() {
-        return htmlWriter.configuration();
+        return configuration;
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,6 +25,8 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.IOException;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -42,7 +44,7 @@
  */
 public class WriterFactoryImpl implements WriterFactory {
 
-    private ConfigurationImpl configuration;
+    private final ConfigurationImpl configuration;
 
     public WriterFactoryImpl(ConfigurationImpl configuration) {
         this.configuration = configuration;
@@ -60,7 +62,7 @@
      */
     public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
         PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
-        return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
+        return new PackageWriterImpl(configuration, packageDoc,
             prevPkg, nextPkg);
     }
 
@@ -68,9 +70,9 @@
      * {@inheritDoc}
      */
     public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
-            ClassDoc nextClass, ClassTree classTree)
-            throws Exception {
-        return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
+            ClassDoc nextClass, ClassTree classTree) throws IOException {
+        return new ClassWriterImpl(configuration, classDoc,
+                prevClass, nextClass, classTree);
     }
 
     /**
@@ -79,7 +81,8 @@
     public AnnotationTypeWriter getAnnotationTypeWriter(
         AnnotationTypeDoc annotationType, Type prevType, Type nextType)
     throws Exception {
-        return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
+        return new AnnotationTypeWriterImpl(configuration,
+                annotationType, prevType, nextType);
     }
 
     /**
@@ -106,7 +109,7 @@
     /**
      * {@inheritDoc}
      */
-    public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
+    public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
             throws Exception {
         return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -115,7 +118,7 @@
     /**
      * {@inheritDoc}
      */
-    public FieldWriter getFieldWriter(ClassWriter classWriter)
+    public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
             throws Exception {
         return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -124,7 +127,7 @@
     /**
      * {@inheritDoc}
      */
-    public  MethodWriter getMethodWriter(ClassWriter classWriter)
+    public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
             throws Exception {
         return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -133,7 +136,7 @@
     /**
      * {@inheritDoc}
      */
-    public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
+    public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
             throws Exception {
         return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -143,20 +146,20 @@
      * {@inheritDoc}
      */
     public MemberSummaryWriter getMemberSummaryWriter(
-        ClassWriter classWriter, int memberType)
-    throws Exception {
+            ClassWriter classWriter, int memberType)
+            throws Exception {
         switch (memberType) {
             case VisibleMemberMap.CONSTRUCTORS:
-                return (ConstructorWriterImpl) getConstructorWriter(classWriter);
+                return getConstructorWriter(classWriter);
             case VisibleMemberMap.ENUM_CONSTANTS:
-                return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
+                return getEnumConstantWriter(classWriter);
             case VisibleMemberMap.FIELDS:
-                return (FieldWriterImpl) getFieldWriter(classWriter);
+                return getFieldWriter(classWriter);
             case VisibleMemberMap.INNERCLASSES:
                 return new NestedClassWriterImpl((SubWriterHolderWriter)
                     classWriter, classWriter.getClassDoc());
             case VisibleMemberMap.METHODS:
-                return (MethodWriterImpl) getMethodWriter(classWriter);
+                return getMethodWriter(classWriter);
             default:
                 return null;
         }
@@ -184,6 +187,6 @@
      * {@inheritDoc}
      */
     public SerializedFormWriter getSerializedFormWriter() throws Exception {
-        return new SerializedFormWriterImpl();
+        return new SerializedFormWriterImpl(configuration);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java	Wed Jul 05 18:30:46 2017 +0200
@@ -41,13 +41,15 @@
  *
  * @author Bhavesh Patel
  */
-public class DocType extends Content{
+public class DocType extends Content {
 
     private String docType;
 
-    private static DocType transitional;
+    public static final DocType TRANSITIONAL =
+            new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
 
-    private static DocType frameset;
+    public static final DocType FRAMESET =
+            new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
 
     /**
      * Constructor to construct a DocType object.
@@ -59,28 +61,6 @@
                 "//EN\" \"" + dtd + "\">" + DocletConstants.NL;
     }
 
-     /**
-     * Construct and return a HTML 4.01 transitional DocType content
-     *
-     * @return a content tree for transitional DocType
-     */
-    public static DocType Transitional() {
-        if (transitional == null)
-            transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
-        return transitional;
-    }
-
-    /**
-     * Construct and return a HTML 4.01 frameset DocType content
-     *
-     * @return a content tree for frameset DocType
-     */
-    public static DocType Frameset() {
-        if (frameset == null)
-            frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
-        return frameset;
-    }
-
     /**
      * This method is not supported by the class.
      *
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -31,6 +31,7 @@
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.ConfigurationImpl;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocFile;
 import com.sun.tools.doclets.internal.toolkit.util.DocLink;
 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
 import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
@@ -63,7 +64,7 @@
             throws IOException {
         super(configuration, filename);
         configuration.message.notice("doclet.Generating_0",
-            filename.resolveAgainst(configuration.destDirName));
+            DocFile.createFileForOutput(configuration, filename).getPath());
     }
 
     /**
@@ -254,7 +255,7 @@
      */
     public void printFramesetDocument(String title, boolean noTimeStamp,
             Content frameset) throws IOException {
-        Content htmlDocType = DocType.Frameset();
+        Content htmlDocType = DocType.FRAMESET;
         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
         Content head = new HtmlTree(HtmlTag.HEAD);
         if (! noTimeStamp) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java	Wed Jul 05 18:30:46 2017 +0200
@@ -37,6 +37,7 @@
  */
 public enum HtmlStyle {
     aboutLanguage,
+    activeTableTab,
     altColor,
     bar,
     block,
@@ -75,6 +76,7 @@
     summary,
     deprecatedContent,
     tabEnd,
+    tableTab,
     title,
     topNav;
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -494,6 +494,20 @@
     }
 
     /**
+     * Generates a SCRIPT tag with the type and src attributes.
+     *
+     * @param type type of link
+     * @param src the path for the script
+     * @return an HtmlTree object for the SCRIPT tag
+     */
+    public static HtmlTree SCRIPT(String type, String src) {
+        HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
+        htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
+        htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
+        return htmltree;
+    }
+
+    /**
      * Generates a SMALL tag with some content.
      *
      * @param body content for the tag
@@ -540,6 +554,23 @@
     }
 
     /**
+     * Generates a SPAN tag with id and style class attributes. It also encloses
+     * a content.
+     *
+     * @param id the id for the tag
+     * @param styleClass stylesheet class for the tag
+     * @param body content for the tag
+     * @return an HtmlTree object for the SPAN tag
+     */
+    public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) {
+        HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
+        htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+        if (styleClass != null)
+            htmltree.addStyle(styleClass);
+        return htmltree;
+    }
+
+    /**
      * Generates a Table tag with border, width and summary attributes and
      * some content.
      *
@@ -742,6 +773,9 @@
                 return (hasAttr(HtmlAttr.HREF) && !hasContent());
             case META :
                 return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
+            case SCRIPT :
+                return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) ||
+                        (hasAttr(HtmlAttr.TYPE) && hasContent()));
             default :
                 return hasContent();
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.formats.html.markup;
 
 import java.io.*;
+import java.util.*;
 
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -144,6 +145,8 @@
 
     private final Writer writer;
 
+    private Content script;
+
     /**
      * Constructor.
      *
@@ -301,7 +304,8 @@
         // Don't print windowtitle script for overview-frame, allclasses-frame
         // and package-frame
         if (includeScript) {
-            body.addContent(getWinTitleScript());
+            this.script = getWinTitleScript();
+            body.addContent(script);
             Content noScript = HtmlTree.NOSCRIPT(
                     HtmlTree.DIV(getResource("doclet.No_Script_Message")));
             body.addContent(noScript);
@@ -310,6 +314,53 @@
     }
 
     /**
+     * Generated javascript variables for the document.
+     *
+     * @param typeMap map comprising of method and type relationship
+     * @param methodTypes set comprising of all methods types for this class
+     */
+    public void generateMethodTypesScript(Map<String,Integer> typeMap,
+            Set<MethodTypes> methodTypes) {
+        String sep = "";
+        StringBuilder vars = new StringBuilder("var methods = {");
+        for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
+            vars.append(sep);
+            sep = ",";
+            vars.append("\"");
+            vars.append(entry.getKey());
+            vars.append("\":");
+            vars.append(entry.getValue());
+        }
+        vars.append("};").append(DocletConstants.NL);
+        sep = "";
+        vars.append("var tabs = {");
+        for (MethodTypes entry : methodTypes) {
+            vars.append(sep);
+            sep = ",";
+            vars.append(entry.value()).append(":");
+            vars.append("[").append("\"").append(entry.tabId());
+            vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]");
+        }
+        vars.append("};").append(DocletConstants.NL);
+        addStyles(HtmlStyle.altColor, vars);
+        addStyles(HtmlStyle.rowColor, vars);
+        addStyles(HtmlStyle.tableTab, vars);
+        addStyles(HtmlStyle.activeTableTab, vars);
+        script.addContent(new RawHtml(vars.toString()));
+    }
+
+    /**
+     * Adds javascript style variables to the document.
+     *
+     * @param style style to be added as a javascript variable
+     * @param vars variable string to which the style variable will be added
+     */
+    public void addStyles(HtmlStyle style, StringBuilder vars) {
+        vars.append("var ").append(style).append(" = \"").append(style)
+                .append("\";").append(DocletConstants.NL);
+    }
+
+    /**
      * Returns an HtmlTree for the TITLE tag.
      *
      * @return an HtmlTree for the TITLE tag
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java	Wed Jul 05 18:30:46 2017 +0200
@@ -51,8 +51,8 @@
     /**
      * The only doclet that may use this toolkit is {@value}
      */
-    private static final String TOOLKIT_DOCLET_NAME = new
-        com.sun.tools.doclets.formats.html.HtmlDoclet().getClass().getName();
+    private static final String TOOLKIT_DOCLET_NAME =
+        com.sun.tools.doclets.formats.html.HtmlDoclet.class.getName();
 
     /**
      * Verify that the only doclet that is using this toolkit is
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Wed Jul 05 18:30:46 2017 +0200
@@ -32,6 +32,7 @@
 import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
+import javax.tools.JavaFileManager;
 
 /**
  * Configure the output based on the options. Doclets should sub-class
@@ -77,14 +78,16 @@
 
     /**
      * This is true if option "-serialwarn" is used. Defualt value is false to
-     * supress excessive warnings about serial tag.
+     * suppress excessive warnings about serial tag.
      */
     public boolean serialwarn = false;
 
     /**
      * The specified amount of space between tab stops.
      */
-    public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+    public int sourcetab;
+
+    public String tabSpaces;
 
     /**
      * True if we should generate browsable sources.
@@ -259,6 +262,7 @@
             "com.sun.tools.doclets.internal.toolkit.resources.doclets");
         excludedDocFileDirs = new HashSet<String>();
         excludedQualifiers = new HashSet<String>();
+        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
     }
 
     /**
@@ -382,7 +386,7 @@
             } else if (opt.equals("-sourcetab")) {
                 linksource = true;
                 try {
-                    sourcetab = Integer.parseInt(os[1]);
+                    setTabWidth(Integer.parseInt(os[1]));
                 } catch (NumberFormatException e) {
                     //Set to -1 so that warning will be printed
                     //to indicate what is valid argument.
@@ -390,7 +394,7 @@
                 }
                 if (sourcetab <= 0) {
                     message.warning("doclet.sourcetab_warning");
-                    sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+                    setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
                 }
             } else if (opt.equals("-notimestamp")) {
                 notimestamp = true;
@@ -442,7 +446,7 @@
     /**
      * Initialize the taglet manager.  The strings to initialize the simple custom tags should
      * be in the following format:  "[tag name]:[location str]:[heading]".
-     * @param customTagStrs the set two dimentional arrays of strings.  These arrays contain
+     * @param customTagStrs the set two dimensional arrays of strings.  These arrays contain
      * either -tag or -taglet arguments.
      */
     private void initTagletManager(Set<String[]> customTagStrs) {
@@ -453,11 +457,11 @@
         for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) {
             args = it.next();
             if (args[0].equals("-taglet")) {
-                tagletManager.addCustomTag(args[1], tagletpath);
+                tagletManager.addCustomTag(args[1], getFileManager(), tagletpath);
                 continue;
             }
             String[] tokens = tokenize(args[1],
-                TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3);
+                TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
             if (tokens.length == 1) {
                 String tagName = args[1];
                 if (tagletManager.isKnownCustomTag(tagName)) {
@@ -749,7 +753,7 @@
      * @return the input steam to the builder XML.
      * @throws FileNotFoundException when the given XML file cannot be found.
      */
-    public InputStream getBuilderXML() throws FileNotFoundException {
+    public InputStream getBuilderXML() throws IOException {
         return builderXMLPath == null ?
             Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
             DocFile.createFileForInput(this, builderXMLPath).openInputStream();
@@ -761,10 +765,20 @@
     public abstract Locale getLocale();
 
     /**
+     * Return the current file manager.
+     */
+    public abstract JavaFileManager getFileManager();
+
+    /**
      * Return the comparator that will be used to sort member documentation.
      * To no do any sorting, return null.
      *
      * @return the {@link java.util.Comparator} used to sort members.
      */
     public abstract Comparator<ProgramElementDoc> getMemberComparator();
+
+    private void setTabWidth(int n) {
+        sourcetab = n;
+        tabSpaces = String.format("%" + n + "s", "");
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -58,9 +58,11 @@
      * Get the summary table for the given class.
      *
      * @param classDoc the class the summary table belongs to
+     * @param tableContents list of contents that will be added to the summary table
      * @return a content tree for the member summary table
      */
-    public Content getSummaryTableTree(ClassDoc classDoc);
+    public Content getSummaryTableTree(ClassDoc classDoc,
+            List<Content> tableContents);
 
     /**
      * Add the member summary for the given class and member.
@@ -68,11 +70,11 @@
      * @param classDoc the class the summary belongs to
      * @param member the member that is documented
      * @param firstSentenceTags the tags for the sentence being documented
-     * @param tableTree the content treeto which the information will be added
-     * @param counter the counter for determing style for the table row
+     * @param tableContents list of contents to which the summary will be added
+     * @param counter the counter for determining id and style for the table row
      */
     public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
-        Tag[] firstSentenceTags, Content tableTree, int counter);
+            Tag[] firstSentenceTags, List<Content> tableContents, int counter);
 
     /**
      * Get the inherited member summary header for the given class.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -52,18 +52,46 @@
  */
 
 public abstract class AbstractBuilder {
+    public static class Context {
+        /**
+         * The configuration used in this run of the doclet.
+         */
+        final Configuration configuration;
+
+        /**
+         * Keep track of which packages we have seen for
+         * efficiency purposes.  We don't want to copy the
+         * doc files multiple times for a single package.
+         */
+        final Set<String> containingPackagesSeen;
+
+        /**
+         * Shared parser for the builder XML file
+         */
+        final LayoutParser layoutParser;
+
+        Context(Configuration configuration,
+                Set<String> containingPackagesSeen,
+                LayoutParser layoutParser) {
+            this.configuration = configuration;
+            this.containingPackagesSeen = containingPackagesSeen;
+            this.layoutParser = layoutParser;
+        }
+    }
 
     /**
      * The configuration used in this run of the doclet.
      */
-    protected Configuration configuration;
+    protected final Configuration configuration;
 
     /**
      * Keep track of which packages we have seen for
      * efficiency purposes.  We don't want to copy the
      * doc files multiple times for a single package.
      */
-    protected static Set<String> containingPackagesSeen;
+    protected final Set<String> containingPackagesSeen;
+
+    protected final LayoutParser layoutParser;
 
     /**
      * True if we want to print debug output.
@@ -75,8 +103,10 @@
      * @param configuration the configuration used in this run
      *        of the doclet.
      */
-    public AbstractBuilder(Configuration configuration) {
-        this.configuration = configuration;
+    public AbstractBuilder(Context c) {
+        this.configuration = c.configuration;
+        this.containingPackagesSeen = c.containingPackagesSeen;
+        this.layoutParser = c.layoutParser;
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,6 +25,8 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
+import java.util.Set;
+
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
@@ -48,8 +50,8 @@
      * @param configuration the configuration used in this run
      *        of the doclet.
      */
-    public AbstractMemberBuilder(Configuration configuration) {
-        super(configuration);
+    public AbstractMemberBuilder(Context context) {
+        super(context);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -54,12 +54,12 @@
     /**
      * The annotation type being documented.
      */
-    private AnnotationTypeDoc annotationTypeDoc;
+    private final AnnotationTypeDoc annotationTypeDoc;
 
     /**
      * The doclet specific writer.
      */
-    private AnnotationTypeWriter writer;
+    private final AnnotationTypeWriter writer;
 
     /**
      * The content tree for the annotation documentation.
@@ -69,38 +69,37 @@
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context           the build context.
+     * @param annotationTypeDoc the class being documented.
+     * @param writer            the doclet specific writer.
      */
-    private AnnotationTypeBuilder(Configuration configuration) {
-        super(configuration);
+    private AnnotationTypeBuilder(Context context,
+            AnnotationTypeDoc annotationTypeDoc,
+            AnnotationTypeWriter writer) {
+        super(context);
+        this.annotationTypeDoc = annotationTypeDoc;
+        this.writer = writer;
     }
 
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration     the current configuration of the doclet.
+     * @param context           the build context.
      * @param annotationTypeDoc the class being documented.
      * @param writer            the doclet specific writer.
      */
-    public static AnnotationTypeBuilder getInstance(Configuration configuration,
-        AnnotationTypeDoc annotationTypeDoc, AnnotationTypeWriter writer)
-    throws Exception {
-        AnnotationTypeBuilder builder = new AnnotationTypeBuilder(configuration);
-        builder.configuration = configuration;
-        builder.annotationTypeDoc = annotationTypeDoc;
-        builder.writer = writer;
-        if(containingPackagesSeen == null) {
-            containingPackagesSeen = new HashSet<String>();
-        }
-        return builder;
+    public static AnnotationTypeBuilder getInstance(Context context,
+            AnnotationTypeDoc annotationTypeDoc,
+            AnnotationTypeWriter writer)
+            throws Exception {
+        return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
     }
 
     /**
      * {@inheritDoc}
      */
     public void build() throws IOException {
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,8 +25,6 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
-import java.util.*;
-
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -44,43 +42,36 @@
  * @since 1.5
  */
 public class AnnotationTypeOptionalMemberBuilder extends
-    AnnotationTypeRequiredMemberBuilder {
+        AnnotationTypeRequiredMemberBuilder {
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
-        super(configuration);
+    private AnnotationTypeOptionalMemberBuilder(Context context,
+            ClassDoc classDoc,
+            AnnotationTypeOptionalMemberWriter writer) {
+        super(context, classDoc, writer,
+                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
     }
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the doclet.
-     * @param classDoc the class whoses members are being documented.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
      * @param writer the doclet specific writer.
      */
     public static AnnotationTypeOptionalMemberBuilder getInstance(
-            Configuration configuration, ClassDoc classDoc,
+            Context context, ClassDoc classDoc,
             AnnotationTypeOptionalMemberWriter writer) {
-        AnnotationTypeOptionalMemberBuilder builder =
-            new AnnotationTypeOptionalMemberBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
-        builder.members = new ArrayList<ProgramElementDoc>(
-            builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(builder.members,
-                configuration.getMemberComparator());
-        }
-        return builder;
+        return new AnnotationTypeOptionalMemberBuilder(context,
+                classDoc, writer);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -74,37 +74,40 @@
     /**
      * Construct a new AnnotationTypeRequiredMemberBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
+     * @param writer the doclet specific writer.
      */
-    protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) {
-        super(configuration);
+    protected AnnotationTypeRequiredMemberBuilder(Context context,
+            ClassDoc classDoc,
+            AnnotationTypeRequiredMemberWriter writer,
+            int memberType) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
+            configuration.nodeprecated);
+        this.members = new ArrayList<ProgramElementDoc>(
+            this.visibleMemberMap.getMembersFor(classDoc));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(this.members, configuration.getMemberComparator());
+        }
     }
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the doclet.
-     * @param classDoc the class whoses members are being documented.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
      * @param writer the doclet specific writer.
      */
     public static AnnotationTypeRequiredMemberBuilder getInstance(
-            Configuration configuration, ClassDoc classDoc,
+            Context context, ClassDoc classDoc,
             AnnotationTypeRequiredMemberWriter writer) {
-        AnnotationTypeRequiredMemberBuilder builder =
-            new AnnotationTypeRequiredMemberBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated);
-        builder.members = new ArrayList<ProgramElementDoc>(
-            builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(builder.members,
-                configuration.getMemberComparator());
-        }
-        return builder;
+        return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
+                    writer,
+                    VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,6 +25,9 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -46,12 +49,14 @@
     /**
      * The current configuration of the doclet.
      */
-    private Configuration configuration;
+    private final Configuration configuration;
 
     /**
      * The factory to retrieve the required writers from.
      */
-    private WriterFactory writerFactory;
+    private final WriterFactory writerFactory;
+
+    private final AbstractBuilder.Context context;
 
     /**
      * Construct a builder factory using the given configuration.
@@ -61,6 +66,10 @@
     public BuilderFactory (Configuration configuration) {
         this.configuration = configuration;
         this.writerFactory = configuration.getWriterFactory();
+
+        Set<String> containingPackagesSeen = new HashSet<String>();
+        context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
+                LayoutParser.getInstance(configuration));
     }
 
     /**
@@ -68,7 +77,7 @@
      * @return the builder that builds the constant summary.
      */
     public AbstractBuilder getConstantsSummaryBuider() throws Exception {
-        return ConstantsSummaryBuilder.getInstance(configuration,
+        return ConstantsSummaryBuilder.getInstance(context,
             writerFactory.getConstantsSummaryWriter());
     }
 
@@ -82,7 +91,7 @@
      */
     public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
             PackageDoc nextPkg) throws Exception {
-        return PackageSummaryBuilder.getInstance(configuration, pkg,
+        return PackageSummaryBuilder.getInstance(context, pkg,
             writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
     }
 
@@ -97,9 +106,9 @@
      * writer is not supported by the doclet.
      */
     public AbstractBuilder getClassBuilder(ClassDoc classDoc,
-        ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
+            ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
             throws Exception {
-        return ClassBuilder.getInstance(configuration, classDoc,
+        return ClassBuilder.getInstance(context, classDoc,
             writerFactory.getClassWriter(classDoc, prevClass, nextClass,
                 classTree));
     }
@@ -117,9 +126,8 @@
         AnnotationTypeDoc annotationType,
         Type prevType, Type nextType)
             throws Exception {
-        return AnnotationTypeBuilder.getInstance(configuration, annotationType,
-            writerFactory.getAnnotationTypeWriter(annotationType, prevType,
-            nextType));
+        return AnnotationTypeBuilder.getInstance(context, annotationType,
+            writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
     }
 
     /**
@@ -129,7 +137,7 @@
      */
     public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
            throws Exception {
-        return MethodBuilder.getInstance(configuration,
+        return MethodBuilder.getInstance(context,
             classWriter.getClassDoc(),
             writerFactory.getMethodWriter(classWriter));
     }
@@ -144,7 +152,7 @@
     public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return AnnotationTypeOptionalMemberBuilder.getInstance(configuration,
+        return AnnotationTypeOptionalMemberBuilder.getInstance(context,
             annotationTypeWriter.getAnnotationTypeDoc(),
             writerFactory.getAnnotationTypeOptionalMemberWriter(
                 annotationTypeWriter));
@@ -160,7 +168,7 @@
     public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return AnnotationTypeRequiredMemberBuilder.getInstance(configuration,
+        return AnnotationTypeRequiredMemberBuilder.getInstance(context,
             annotationTypeWriter.getAnnotationTypeDoc(),
             writerFactory.getAnnotationTypeRequiredMemberWriter(
                 annotationTypeWriter));
@@ -173,7 +181,7 @@
      */
     public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
             throws Exception {
-        return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(),
+        return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
             writerFactory.getEnumConstantWriter(classWriter));
     }
 
@@ -184,7 +192,7 @@
      */
     public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
             throws Exception {
-        return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(),
+        return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
             writerFactory.getFieldWriter(classWriter));
     }
 
@@ -195,9 +203,9 @@
      */
     public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
             throws Exception {
-        return ConstructorBuilder.getInstance(configuration,
-            classWriter.getClassDoc(), writerFactory.getConstructorWriter(
-            classWriter));
+        return ConstructorBuilder.getInstance(context,
+            classWriter.getClassDoc(),
+            writerFactory.getConstructorWriter(classWriter));
     }
 
     /**
@@ -207,7 +215,7 @@
      */
     public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
             throws Exception {
-        return MemberSummaryBuilder.getInstance(classWriter, configuration);
+        return MemberSummaryBuilder.getInstance(classWriter, context);
     }
 
     /**
@@ -220,8 +228,7 @@
     public AbstractBuilder getMemberSummaryBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return MemberSummaryBuilder.getInstance(annotationTypeWriter,
-            configuration);
+        return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
     }
 
     /**
@@ -231,6 +238,6 @@
      */
     public AbstractBuilder getSerializedFormBuilder()
             throws Exception {
-        return SerializedFormBuilder.getInstance(configuration);
+        return SerializedFormBuilder.getInstance(context);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -54,22 +54,22 @@
     /**
      * The class being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The doclet specific writer.
      */
-    private ClassWriter writer;
+    private final ClassWriter writer;
 
     /**
      * Keep track of whether or not this classdoc is an interface.
      */
-    private boolean isInterface = false;
+    private final boolean isInterface;
 
     /**
      * Keep track of whether or not this classdoc is an enum.
      */
-    private boolean isEnum = false;
+    private final boolean isEnum;
 
     /**
      * The content tree for the class documentation.
@@ -79,44 +79,45 @@
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context
+     * @param classDoc the class being documented.
+     * @param writer the doclet specific writer.
      */
-    private ClassBuilder(Configuration configuration) {
-        super(configuration);
+    private ClassBuilder(Context context,
+            ClassDoc classDoc, ClassWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        if (classDoc.isInterface()) {
+            isInterface = true;
+            isEnum = false;
+        } else if (classDoc.isEnum()) {
+            isInterface = false;
+            isEnum = true;
+            Util.setEnumDocumentation(configuration, classDoc);
+        } else {
+            isInterface = false;
+            isEnum = false;
+        }
     }
 
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context
      * @param classDoc the class being documented.
      * @param writer the doclet specific writer.
      */
-    public static ClassBuilder getInstance(Configuration configuration,
-        ClassDoc classDoc, ClassWriter writer)
-    throws Exception {
-        ClassBuilder builder = new ClassBuilder(configuration);
-        builder.configuration = configuration;
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        if (classDoc.isInterface()) {
-            builder.isInterface = true;
-        } else if (classDoc.isEnum()) {
-            builder.isEnum = true;
-            Util.setEnumDocumentation(configuration, classDoc);
-        }
-        if(containingPackagesSeen == null) {
-            containingPackagesSeen = new HashSet<String>();
-        }
-        return builder;
+    public static ClassBuilder getInstance(Context context,
+            ClassDoc classDoc, ClassWriter writer) {
+        return new ClassBuilder(context, classDoc, writer);
     }
 
     /**
      * {@inheritDoc}
      */
     public void build() throws IOException {
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -60,12 +60,12 @@
     /**
      * The writer used to write the results.
      */
-    protected ConstantsSummaryWriter writer;
+    protected final ConstantsSummaryWriter writer;
 
     /**
      * The set of ClassDocs that have constant fields.
      */
-    protected Set<ClassDoc> classDocsWithConstFields;
+    protected final Set<ClassDoc> classDocsWithConstFields;
 
     /**
      * The set of printed package headers.
@@ -90,27 +90,25 @@
     /**
      * Construct a new ConstantsSummaryBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context       the build context.
+     * @param writer        the writer for the summary.
      */
-    private ConstantsSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    private ConstantsSummaryBuilder(Context context,
+            ConstantsSummaryWriter writer) {
+        super(context);
+        this.writer = writer;
+        this.classDocsWithConstFields = new HashSet<ClassDoc>();
     }
 
     /**
      * Construct a ConstantsSummaryBuilder.
      *
-     * @param configuration the configuration used in this run
-     *                      of the doclet.
+     * @param context       the build context.
      * @param writer        the writer for the summary.
      */
-    public static ConstantsSummaryBuilder getInstance(
-        Configuration configuration, ConstantsSummaryWriter writer) {
-        ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder(
-            configuration);
-        builder.writer = writer;
-        builder.classDocsWithConstFields = new HashSet<ClassDoc>();
-        return builder;
+    public static ConstantsSummaryBuilder getInstance(Context context,
+            ConstantsSummaryWriter writer) {
+        return new ConstantsSummaryBuilder(context, writer);
     }
 
     /**
@@ -121,7 +119,7 @@
             //Doclet does not support this output.
             return;
         }
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -59,66 +59,64 @@
     /**
      * The class whose constructors are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible constructors for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the constructor documentation.
      */
-    private ConstructorWriter writer;
+    private final ConstructorWriter writer;
 
     /**
      * The constructors being documented.
      */
-    private List<ProgramElementDoc> constructors;
+    private final List<ProgramElementDoc> constructors;
 
     /**
      * Construct a new ConstructorBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private ConstructorBuilder(Configuration configuration) {
-        super(configuration);
+    private ConstructorBuilder(Context context,
+            ClassDoc classDoc,
+            ConstructorWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
+                new VisibleMemberMap(
+                classDoc,
+                VisibleMemberMap.CONSTRUCTORS,
+                configuration.nodeprecated);
+        constructors =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
+        for (int i = 0; i < constructors.size(); i++) {
+            if (constructors.get(i).isProtected()
+                    || constructors.get(i).isPrivate()) {
+                writer.setFoundNonPubConstructor(true);
+            }
+        }
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(constructors,configuration.getMemberComparator());
+        }
     }
 
     /**
      * Construct a new ConstructorBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static ConstructorBuilder getInstance(
-            Configuration configuration,
-            ClassDoc classDoc,
-            ConstructorWriter writer) {
-        ConstructorBuilder builder = new ConstructorBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
-                classDoc,
-                VisibleMemberMap.CONSTRUCTORS,
-                configuration.nodeprecated);
-        builder.constructors =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
-        for (int i = 0; i < builder.constructors.size(); i++) {
-            if (builder.constructors.get(i).isProtected()
-                    || builder.constructors.get(i).isPrivate()) {
-                writer.setFoundNonPubConstructor(true);
-            }
-        }
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.constructors,
-                    configuration.getMemberComparator());
-        }
-        return builder;
+    public static ConstructorBuilder getInstance(Context context,
+            ClassDoc classDoc, ConstructorWriter writer) {
+        return new ConstructorBuilder(context, classDoc, writer);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -48,22 +48,22 @@
     /**
      * The class whose enum constants are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible enum constantss for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the enum constants documentation.
      */
-    private EnumConstantWriter writer;
+    private final EnumConstantWriter writer;
 
     /**
      * The list of enum constants being documented.
      */
-    private List<ProgramElementDoc> enumConstants;
+    private final List<ProgramElementDoc> enumConstants;
 
     /**
      * The index of the current enum constant that is being documented at this point
@@ -74,40 +74,37 @@
     /**
      * Construct a new EnumConstantsBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private EnumConstantBuilder(Configuration configuration) {
-        super(configuration);
+    private EnumConstantBuilder(Context context,
+            ClassDoc classDoc, EnumConstantWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
+                new VisibleMemberMap(
+                classDoc,
+                VisibleMemberMap.ENUM_CONSTANTS,
+                configuration.nodeprecated);
+        enumConstants =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(enumConstants, configuration.getMemberComparator());
+        }
     }
 
     /**
      * Construct a new EnumConstantsBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static EnumConstantBuilder getInstance(
-            Configuration configuration,
-            ClassDoc classDoc,
-            EnumConstantWriter writer) {
-        EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
-                classDoc,
-                VisibleMemberMap.ENUM_CONSTANTS,
-                configuration.nodeprecated);
-        builder.enumConstants =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.enumConstants,
-                    configuration.getMemberComparator());
-        }
-        return builder;
+    public static EnumConstantBuilder getInstance(Context context,
+            ClassDoc classDoc, EnumConstantWriter writer) {
+        return new EnumConstantBuilder(context, classDoc, writer);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -48,22 +48,22 @@
     /**
      * The class whose fields are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible fields for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the field documentation.
      */
-    private FieldWriter writer;
+    private final FieldWriter writer;
 
     /**
      * The list of fields being documented.
      */
-    private List<ProgramElementDoc> fields;
+    private final List<ProgramElementDoc> fields;
 
     /**
      * The index of the current field that is being documented at this point
@@ -74,41 +74,40 @@
     /**
      * Construct a new FieldBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private FieldBuilder(Configuration configuration) {
-        super(configuration);
+    private FieldBuilder(Context context,
+            ClassDoc classDoc,
+            FieldWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
+                new VisibleMemberMap(
+                classDoc,
+                VisibleMemberMap.FIELDS,
+                configuration.nodeprecated);
+        fields =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
+                configuration));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(fields, configuration.getMemberComparator());
+        }
     }
 
     /**
      * Construct a new FieldBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static FieldBuilder getInstance(
-            Configuration configuration,
+    public static FieldBuilder getInstance(Context context,
             ClassDoc classDoc,
             FieldWriter writer) {
-        FieldBuilder builder = new FieldBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
-                classDoc,
-                VisibleMemberMap.FIELDS,
-                configuration.nodeprecated);
-        builder.fields =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
-                configuration));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.fields,
-                    configuration.getMemberComparator());
-        }
-        return builder;
+        return new FieldBuilder(context, classDoc, writer);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java	Wed Jul 05 18:30:46 2017 +0200
@@ -55,14 +55,10 @@
      */
     private Map<String,XMLNode> xmlElementsMap;
     private XMLNode currentNode;
-    private Configuration configuration;
-    private static LayoutParser instance;
+    private final Configuration configuration;
     private String currentRoot;
     private boolean isParsing;
 
-    /**
-     * This class is a singleton.
-     */
     private LayoutParser(Configuration configuration) {
         xmlElementsMap = new HashMap<String,XMLNode>();
         this.configuration = configuration;
@@ -75,10 +71,7 @@
      * @return an instance of the BuilderXML.
      */
     public static LayoutParser getInstance(Configuration configuration) {
-        if (instance == null) {
-            instance = new LayoutParser(configuration);
-        }
-        return instance;
+        return new LayoutParser(configuration);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -53,7 +53,7 @@
     /**
      * The visible members for the given class.
      */
-    private VisibleMemberMap[] visibleMemberMaps;
+    private final VisibleMemberMap[] visibleMemberMaps;
 
     /**
      * The member summary writers for the given class.
@@ -63,10 +63,27 @@
     /**
      * The type being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
-    private MemberSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    /**
+     * Construct a new MemberSummaryBuilder.
+     *
+     * @param classWriter   the writer for the class whose members are being
+     *                      summarized.
+     * @param context       the build context.
+     */
+    private MemberSummaryBuilder(Context context, ClassDoc classDoc) {
+        super(context);
+        this.classDoc = classDoc;
+        visibleMemberMaps =
+                new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
+        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+            visibleMemberMaps[i] =
+                    new VisibleMemberMap(
+                    classDoc,
+                    i,
+                    configuration.nodeprecated);
+        }
     }
 
     /**
@@ -74,14 +91,22 @@
      *
      * @param classWriter   the writer for the class whose members are being
      *                      summarized.
-     * @param configuration the current configuration of the doclet.
+     * @param context       the build context.
      */
     public static MemberSummaryBuilder getInstance(
-            ClassWriter classWriter, Configuration configuration)
+            ClassWriter classWriter, Context context)
             throws Exception {
-        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
-        builder.classDoc = classWriter.getClassDoc();
-        builder.init(classWriter);
+        MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+                classWriter.getClassDoc());
+        builder.memberSummaryWriters =
+                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+        WriterFactory wf = context.configuration.getWriterFactory();
+        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+                builder.memberSummaryWriters[i] =
+                    builder.visibleMemberMaps[i].noVisibleMembers() ?
+                        null :
+                        wf.getMemberSummaryWriter(classWriter, i);
+        }
         return builder;
     }
 
@@ -93,42 +118,21 @@
      * @param configuration the current configuration of the doclet.
      */
     public static MemberSummaryBuilder getInstance(
-            AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
+            AnnotationTypeWriter annotationTypeWriter, Context context)
             throws Exception {
-        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
-        builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
-        builder.init(annotationTypeWriter);
-        return builder;
-    }
-
-    private void init(Object writer) throws Exception {
-        visibleMemberMaps =
-                new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
+        MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+                annotationTypeWriter.getAnnotationTypeDoc());
+        builder.memberSummaryWriters =
+                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+        WriterFactory wf = context.configuration.getWriterFactory();
         for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
-            visibleMemberMaps[i] =
-                    new VisibleMemberMap(
-                    classDoc,
-                    i,
-                    configuration.nodeprecated);
+                builder.memberSummaryWriters[i] =
+                    builder.visibleMemberMaps[i].noVisibleMembers()?
+                        null :
+                        wf.getMemberSummaryWriter(
+                        annotationTypeWriter, i);
         }
-        memberSummaryWriters =
-                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
-        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
-            if (classDoc.isAnnotationType()) {
-                memberSummaryWriters[i] =
-                    visibleMemberMaps[i].noVisibleMembers()?
-                        null :
-                        configuration.getWriterFactory().getMemberSummaryWriter(
-                        (AnnotationTypeWriter) writer, i);
-            } else {
-                memberSummaryWriters[i] =
-                    visibleMemberMaps[i].noVisibleMembers()?
-                        null :
-                        configuration.getWriterFactory().getMemberSummaryWriter(
-                        (ClassWriter) writer, i);
-            }
-        }
-
+        return builder;
     }
 
     /**
@@ -304,7 +308,7 @@
                 configuration));
         if (members.size() > 0) {
             Collections.sort(members);
-            Content tableTree = writer.getSummaryTableTree(classDoc);
+            List<Content> tableContents = new LinkedList<Content>();
             for (int i = 0; i < members.size(); i++) {
                 ProgramElementDoc member = members.get(i);
                 Tag[] firstSentenceTags = member.firstSentenceTags();
@@ -313,14 +317,15 @@
                     //necessary.
                     DocFinder.Output inheritedDoc =
                             DocFinder.search(new DocFinder.Input((MethodDoc) member));
-                    if (inheritedDoc.holder != null &&
-                            inheritedDoc.holder.firstSentenceTags().length > 0) {
+                    if (inheritedDoc.holder != null
+                            && inheritedDoc.holder.firstSentenceTags().length > 0) {
                         firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
                     }
                 }
-                writer.addMemberSummary(classDoc, member, firstSentenceTags, tableTree, i);
+                writer.addMemberSummary(classDoc, member, firstSentenceTags,
+                        tableContents, i);
             }
-            summaryTreeList.add(tableTree);
+            summaryTreeList.add(writer.getSummaryTableTree(classDoc, tableContents));
         }
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -54,57 +54,61 @@
     /**
      * The class whose methods are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible methods for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the method documentation.
      */
-    private MethodWriter writer;
+    private final MethodWriter writer;
 
     /**
      * The methods being documented.
      */
     private List<ProgramElementDoc> methods;
 
-    private MethodBuilder(Configuration configuration) {
-        super(configuration);
+
+    /**
+     * Construct a new MethodBuilder.
+     *
+     * @param context       the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
+     */
+    private MethodBuilder(Context context,
+            ClassDoc classDoc,
+            MethodWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap = new VisibleMemberMap(
+                classDoc,
+                VisibleMemberMap.METHODS,
+                configuration.nodeprecated);
+        methods =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
+                configuration));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(methods, configuration.getMemberComparator());
+        }
     }
 
     /**
      * Construct a new MethodBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context       the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      *
      * @return an instance of a MethodBuilder.
      */
-    public static MethodBuilder getInstance(
-            Configuration configuration,
-            ClassDoc classDoc,
-            MethodWriter writer) {
-        MethodBuilder builder = new MethodBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
-                classDoc,
-                VisibleMemberMap.METHODS,
-                configuration.nodeprecated);
-        builder.methods =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
-                configuration));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.methods,
-                    configuration.getMemberComparator());
-        }
-        return builder;
+    public static MethodBuilder getInstance(Context context,
+            ClassDoc classDoc, MethodWriter writer) {
+        return new MethodBuilder(context, classDoc, writer);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -52,40 +52,47 @@
     /**
      * The package being documented.
      */
-    private PackageDoc packageDoc;
+    private final PackageDoc packageDoc;
 
     /**
      * The doclet specific writer that will output the result.
      */
-    private PackageSummaryWriter packageWriter;
+    private final PackageSummaryWriter packageWriter;
 
     /**
      * The content that will be added to the package summary documentation tree.
      */
     private Content contentTree;
 
-    private PackageSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    /**
+     * Construct a new PackageSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param pkg the package being documented.
+     * @param packageWriter the doclet specific writer that will output the
+     *        result.
+     */
+    private PackageSummaryBuilder(Context context,
+            PackageDoc pkg,
+            PackageSummaryWriter packageWriter) {
+        super(context);
+        this.packageDoc = pkg;
+        this.packageWriter = packageWriter;
     }
 
     /**
      * Construct a new PackageSummaryBuilder.
-     * @param configuration the current configuration of the doclet.
+     *
+     * @param context  the build context.
      * @param pkg the package being documented.
      * @param packageWriter the doclet specific writer that will output the
      *        result.
      *
      * @return an instance of a PackageSummaryBuilder.
      */
-    public static PackageSummaryBuilder getInstance(
-        Configuration configuration,
-        PackageDoc pkg,
-        PackageSummaryWriter packageWriter) {
-        PackageSummaryBuilder builder =
-                new PackageSummaryBuilder(configuration);
-        builder.packageDoc = pkg;
-        builder.packageWriter = packageWriter;
-        return builder;
+    public static PackageSummaryBuilder getInstance(Context context,
+            PackageDoc pkg, PackageSummaryWriter packageWriter) {
+        return new PackageSummaryBuilder(context, pkg, packageWriter);
     }
 
     /**
@@ -96,7 +103,7 @@
             //Doclet does not support this output.
             return;
         }
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -93,17 +93,21 @@
      */
     private Content contentTree;
 
-    private SerializedFormBuilder(Configuration configuration) {
-        super(configuration);
+
+    /**
+     * Construct a new SerializedFormBuilder.
+     * @param context  the build context.
+     */
+    private SerializedFormBuilder(Context context) {
+        super(context);
     }
 
     /**
      * Construct a new SerializedFormBuilder.
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      */
-    public static SerializedFormBuilder getInstance(Configuration configuration) {
-        SerializedFormBuilder builder = new SerializedFormBuilder(configuration);
-        return builder;
+    public static SerializedFormBuilder getInstance(Context context) {
+        return new SerializedFormBuilder(context);
     }
 
     /**
@@ -123,7 +127,7 @@
         } catch (Exception e) {
             throw new DocletAbortException();
         }
-        build(LayoutParser.getInstance(configuration).parseXML(NAME), contentTree);
+        build(layoutParser.parseXML(NAME), contentTree);
         writer.close();
     }
 
Binary file langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif has changed
Binary file langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,30 @@
+function show(type)
+{
+    count = 0;
+    for (var key in methods) {
+        var row = document.getElementById(key);
+        if ((methods[key] &  type) != 0) {
+            row.style.display = '';
+            row.className = (count++ % 2) ? rowColor : altColor;
+        }
+        else
+            row.style.display = 'none';
+    }
+    updateTabs(type);
+}
+
+function updateTabs(type)
+{
+    for (var value in tabs) {
+        var sNode = document.getElementById(tabs[value][0]);
+        var spanNode = sNode.firstChild;
+        if (value == type) {
+            sNode.className = activeTableTab;
+            spanNode.innerHTML = tabs[value][1];
+        }
+        else {
+            sNode.className = tableTab;
+            spanNode.innerHTML = "<a href=\"javascript:show("+ value + ");\">" + tabs[value][1] + "</a>";
+        }
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css	Wed Jul 05 18:30:46 2017 +0200
@@ -381,6 +381,31 @@
     background-image:url(resources/titlebar.gif);
     height:18px;
 }
+.contentContainer ul.blockList li.blockList caption span.activeTableTab span {
+    white-space:nowrap;
+    padding-top:8px;
+    padding-left:8px;
+    display:block;
+    float:left;
+    background-image:url(resources/activetitlebar.gif);
+    height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab span {
+    white-space:nowrap;
+    padding-top:8px;
+    padding-left:8px;
+    display:block;
+    float:left;
+    background-image:url(resources/titlebar.gif);
+    height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab {
+    padding-top:0px;
+    padding-left:0px;
+    background-image:none;
+    float:none;
+    display:inline;
+}
 .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
     width:10px;
     background-image:url(resources/titlebar_end.gif);
@@ -389,6 +414,24 @@
     position:relative;
     float:left;
 }
+.contentContainer ul.blockList li.blockList .activeTableTab .tabEnd {
+    width:10px;
+    margin-right:5px;
+    background-image:url(resources/activetitlebar_end.gif);
+    background-repeat:no-repeat;
+    background-position:top right;
+    position:relative;
+    float:left;
+}
+.contentContainer ul.blockList li.blockList .tableTab .tabEnd {
+    width:10px;
+    margin-right:5px;
+    background-image:url(resources/titlebar_end.gif);
+    background-repeat:no-repeat;
+    background-position:top right;
+    position:relative;
+    float:left;
+}
 ul.blockList ul.blockList li.blockList table {
     margin:0 0 12px 0px;
     width:100%;
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Configuration;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -104,7 +105,7 @@
 
     /**
      * Given a <code>MethodDoc</code> item, a <code>Tag</code> in the
-     * <code>MethodDoc</code> item and a String, replace all occurances
+     * <code>MethodDoc</code> item and a String, replace all occurrences
      * of @inheritDoc with documentation from it's superclass or superinterface.
      *
      * @param writer the writer that is writing the output.
@@ -116,12 +117,13 @@
             MethodDoc md, Tag holderTag, boolean isFirstSentence) {
         TagletOutput replacement = writer.getTagletOutputInstance();
 
+        Configuration configuration = writer.configuration();
         Taglet inheritableTaglet = holderTag == null ?
-            null : writer.configuration().tagletManager.getTaglet(holderTag.name());
+            null : configuration.tagletManager.getTaglet(holderTag.name());
         if (inheritableTaglet != null &&
             !(inheritableTaglet instanceof InheritableTaglet)) {
                 //This tag does not support inheritence.
-                writer.configuration().message.warning(md.position(),
+                configuration.message.warning(md.position(),
                 "doclet.noInheritedDoc", md.name() + md.flatSignature());
          }
         DocFinder.Output inheritedDoc =
@@ -129,7 +131,7 @@
                 (InheritableTaglet) inheritableTaglet, holderTag,
                 isFirstSentence, true));
         if (inheritedDoc.isValidInheritDocTag == false) {
-            writer.configuration().message.warning(md.position(),
+            configuration.message.warning(md.position(),
                 "doclet.noInheritedDoc", md.name() + md.flatSignature());
         } else if (inheritedDoc.inlineTags.length > 0) {
             replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Wed Jul 05 18:30:46 2017 +0200
@@ -30,6 +30,9 @@
 import java.net.*;
 import java.util.*;
 
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
@@ -48,16 +51,16 @@
 public class TagletManager {
 
     /**
-     * The default seperator for the simple tag option.
+     * The default separator for the simple tag option.
      */
-    public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':';
+    public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
 
     /**
-     * The alternate seperator for simple tag options.  Use this
-     * with you want the default seperator to be in the name of the
+     * The alternate separator for simple tag options.  Use this
+     * when you want the default separator to be in the name of the
      * custom tag.
      */
-    public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-";
+    public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
 
     /**
      * The map of custom tags.
@@ -200,18 +203,24 @@
      * @param classname  the name of the class representing the custom tag.
      * @param tagletPath  the path to the class representing the custom tag.
      */
-    public void addCustomTag(String classname, String tagletPath) {
+    public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
         try {
             Class<?> customTagClass = null;
             // construct class loader
             String cpString = null;   // make sure env.class.path defaults to dot
 
-            // do prepends to get correct ordering
-            cpString = appendPath(System.getProperty("env.class.path"), cpString);
-            cpString = appendPath(System.getProperty("java.class.path"), cpString);
-            cpString = appendPath(tagletPath, cpString);
-            URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString));
-            customTagClass = appClassLoader.loadClass(classname);
+            ClassLoader tagClassLoader;
+            if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) {
+                tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH);
+            } else {
+                // do prepends to get correct ordering
+                cpString = appendPath(System.getProperty("env.class.path"), cpString);
+                cpString = appendPath(System.getProperty("java.class.path"), cpString);
+                cpString = appendPath(tagletPath, cpString);
+                tagClassLoader = new URLClassLoader(pathToURLs(cpString));
+            }
+
+            customTagClass = tagClassLoader.loadClass(classname);
             Method meth = customTagClass.getMethod("register",
                                                    new Class<?>[] {java.util.Map.class});
             Object[] list = customTags.values().toArray();
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -46,7 +46,11 @@
     /**
      * True if we only want to write the first sentence.
      */
-    protected boolean isFirstSentence = false;
+    protected final boolean isFirstSentence;
+
+    protected TagletWriter(boolean isFirstSentence) {
+        this.isFirstSentence = isFirstSentence;
+    }
 
     /**
      * @return an instance of the output object.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,14 +25,9 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -40,10 +35,6 @@
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
 
 import javax.tools.JavaFileManager.Location;
 import javax.tools.StandardLocation;
@@ -61,46 +52,36 @@
  *
  * @since 8
  */
-public class DocFile {
+public abstract class DocFile {
+
+    /** Create a DocFile for a directory. */
+    public static DocFile createFileForDirectory(Configuration configuration, String file) {
+        return DocFileFactory.getFactory(configuration).createFileForDirectory(file);
+    }
 
-    /**
-     * The doclet configuration.
-     * Provides access to options such as docencoding, output directory, etc.
-     */
+    /** Create a DocFile for a file that will be opened for reading. */
+    public static DocFile createFileForInput(Configuration configuration, String file) {
+        return DocFileFactory.getFactory(configuration).createFileForInput(file);
+    }
+
+    /** Create a DocFile for a file that will be opened for writing. */
+    public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
+        return DocFileFactory.getFactory(configuration).createFileForOutput(path);
+    }
+
     private final Configuration configuration;
 
     /**
      * The location for this file. Maybe null if the file was created without
      * a location or path.
      */
-    private final Location location;
+    protected final Location location;
 
     /**
      * The path relative to the (output) location. Maybe null if the file was
      * created without a location or path.
      */
-    private final DocPath path;
-
-    /**
-     * The file object itself.
-     * This is temporary, until we create different subtypes of DocFile.
-     */
-    private final File file;
-
-    /** Create a DocFile for a directory. */
-    public static DocFile createFileForDirectory(Configuration configuration, String file) {
-        return new DocFile(configuration, new File(file));
-    }
-
-    /** Create a DocFile for a file that will be opened for reading. */
-    public static DocFile createFileForInput(Configuration configuration, String file) {
-        return new DocFile(configuration, new File(file));
-    }
-
-    /** Create a DocFile for a file that will be opened for writing. */
-    public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
-        return new DocFile(configuration, StandardLocation.CLASS_OUTPUT, path);
-    }
+    protected final DocPath path;
 
     /**
      * List the directories and files found in subdirectories along the
@@ -111,85 +92,46 @@
      *  list files
      */
     public static Iterable<DocFile> list(Configuration configuration, Location location, DocPath path) {
-        if (location != StandardLocation.SOURCE_PATH)
-            throw new IllegalArgumentException();
-
-        Set<DocFile> files = new LinkedHashSet<DocFile>();
-        for (String s : configuration.sourcepath.split(File.pathSeparator)) {
-            if (s.isEmpty())
-                continue;
-            File f = new File(s);
-            if (f.isDirectory()) {
-                f = new File(f, path.getPath());
-                if (f.exists())
-                    files.add(new DocFile(configuration, f));
-            }
-        }
-        return files;
+        return DocFileFactory.getFactory(configuration).list(location, path);
     }
 
-    /** Create a DocFile for a given file. */
-    private DocFile(Configuration configuration, File file) {
+    /** Create a DocFile without a location or path */
+    protected DocFile(Configuration configuration) {
         this.configuration = configuration;
         this.location = null;
         this.path = null;
-        this.file = file;
     }
 
     /** Create a DocFile for a given location and relative path. */
-    private DocFile(Configuration configuration, Location location, DocPath path) {
+    protected DocFile(Configuration configuration, Location location, DocPath path) {
         this.configuration = configuration;
         this.location = location;
         this.path = path;
-        this.file = path.resolveAgainst(configuration.destDirName);
     }
 
     /** Open an input stream for the file. */
-    public InputStream openInputStream() throws FileNotFoundException {
-        return new BufferedInputStream(new FileInputStream(file));
-    }
+    public abstract InputStream openInputStream() throws IOException;
 
     /**
      * Open an output stream for the file.
      * The file must have been created with a location of
-     * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path.
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT}
+     * and a corresponding relative path.
      */
-    public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
-        if (location != StandardLocation.CLASS_OUTPUT)
-            throw new IllegalStateException();
-
-        createDirectoryForFile(file);
-        return new BufferedOutputStream(new FileOutputStream(file));
-    }
+    public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException;
 
     /**
      * Open an writer for the file, using the encoding (if any) given in the
      * doclet configuration.
      * The file must have been created with a location of
-     * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path.
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
      */
-    public Writer openWriter() throws IOException, UnsupportedEncodingException {
-        if (location != StandardLocation.CLASS_OUTPUT)
-            throw new IllegalStateException();
-
-        createDirectoryForFile(file);
-        FileOutputStream fos = new FileOutputStream(file);
-        if (configuration.docencoding == null) {
-            return new BufferedWriter(new OutputStreamWriter(fos));
-        } else {
-            return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
-        }
-    }
+    public abstract Writer openWriter() throws IOException, UnsupportedEncodingException;
 
     /**
      * Copy the contents of another file directly to this file.
      */
     public void copyFile(DocFile fromFile) throws IOException {
-        if (location != StandardLocation.CLASS_OUTPUT)
-            throw new IllegalStateException();
-
-        createDirectoryForFile(file);
-
         InputStream input = fromFile.openInputStream();
         OutputStream output = openOutputStream();
         try {
@@ -215,20 +157,15 @@
      *     separator
      */
     public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) {
-        if (location != StandardLocation.CLASS_OUTPUT)
-            throw new IllegalStateException();
-
-        if (file.exists() && !overwrite)
+        if (exists() && !overwrite)
             return;
 
-        createDirectoryForFile(file);
-
         try {
             InputStream in = Configuration.class.getResourceAsStream(resource.getPath());
             if (in == null)
                 return;
 
-            OutputStream out = new FileOutputStream(file);
+            OutputStream out = openOutputStream();
             try {
                 if (!replaceNewLine) {
                     byte[] buf = new byte[2048];
@@ -265,68 +202,37 @@
     }
 
     /** Return true if the file can be read. */
-    public boolean canRead() {
-        return file.canRead();
-    }
+    public abstract boolean canRead();
 
     /** Return true if the file can be written. */
-    public boolean canWrite() {
-        return file.canRead();
-    }
+    public abstract boolean canWrite();
 
     /** Return true if the file exists. */
-    public boolean exists() {
-        return file.exists();
-    }
+    public abstract boolean exists();
 
     /** Return the base name (last component) of the file name. */
-    public String getName() {
-        return file.getName();
-    }
+    public abstract String getName();
 
     /** Return the file system path for this file. */
-    public String getPath() {
-        return file.getPath();
-    }
+    public abstract String getPath();
 
-    /** Return true is file has an absolute path name. */
-    boolean isAbsolute() {
-        return file.isAbsolute();
-    }
+    /** Return true if file has an absolute path name. */
+    public abstract boolean isAbsolute();
 
-    /** Return true is file identifies a directory. */
-    public boolean isDirectory() {
-        return file.isDirectory();
-    }
+    /** Return true if file identifies a directory. */
+    public abstract boolean isDirectory();
 
-    /** Return true is file identifies a file. */
-    public boolean isFile() {
-        return file.isFile();
-    }
+    /** Return true if file identifies a file. */
+    public abstract boolean isFile();
 
     /** Return true if this file is the same as another. */
-    public boolean isSameFile(DocFile other) {
-        try {
-            return file.exists()
-                    && file.getCanonicalFile().equals(other.file.getCanonicalFile());
-        } catch (IOException e) {
-            return false;
-        }
-    }
+    public abstract boolean isSameFile(DocFile other);
 
     /** If the file is a directory, list its contents. */
-    public Iterable<DocFile> list() {
-        List<DocFile> files = new ArrayList<DocFile>();
-        for (File f: file.listFiles()) {
-            files.add(new DocFile(configuration, f));
-        }
-        return files;
-    }
+    public abstract Iterable<DocFile> list() throws IOException;
 
     /** Create the file as a directory, including any parent directories. */
-    public boolean mkdirs() {
-        return file.mkdirs();
-    }
+    public abstract boolean mkdirs();
 
     /**
      * Derive a new file by resolving a relative path against this file.
@@ -334,9 +240,7 @@
      * If this file has a path set, the new file will have a corresponding
      * new path.
      */
-    public DocFile resolve(DocPath p) {
-        return resolve(p.getPath());
-    }
+    public abstract DocFile resolve(DocPath p);
 
     /**
      * Derive a new file by resolving a relative path against this file.
@@ -344,56 +248,12 @@
      * If this file has a path set, the new file will have a corresponding
      * new path.
      */
-    public DocFile resolve(String p) {
-        if (location == null && path == null) {
-            return new DocFile(configuration, new File(file, p));
-        } else {
-            return new DocFile(configuration, location, path.resolve(p));
-        }
-    }
+    public abstract DocFile resolve(String p);
 
     /**
      * Resolve a relative file against the given output location.
-     * @param locn Currently, only SOURCE_OUTPUT is supported.
-     */
-    public DocFile resolveAgainst(StandardLocation locn) {
-        if (locn != StandardLocation.CLASS_OUTPUT)
-            throw new IllegalArgumentException();
-        return new DocFile(configuration,
-                new File(configuration.destDirName, file.getPath()));
-    }
-
-    /**
-     * Given a path string create all the directories in the path. For example,
-     * if the path string is "java/applet", the method will create directory
-     * "java" and then "java/applet" if they don't exist. The file separator
-     * string "/" is platform dependent system property.
-     *
-     * @param path Directory path string.
+     * @param locn Currently, only
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
      */
-    private void createDirectoryForFile(File file) {
-        File dir = file.getParentFile();
-        if (dir == null || dir.exists() || dir.mkdirs())
-            return;
-
-        configuration.message.error(
-               "doclet.Unable_to_create_directory_0", dir.getPath());
-        throw new DocletAbortException();
-    }
-
-    /** Return a string to identify the contents of this object,
-     * for debugging purposes.
-     */
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("DocFile[");
-        if (location != null)
-            sb.append("locn:").append(location).append(",");
-        if (path != null)
-            sb.append("path:").append(path.getPath()).append(",");
-        sb.append("file:").append(file);
-        sb.append("]");
-        return sb.toString();
-    }
+    public abstract DocFile resolveAgainst(Location locn);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Factory for DocFile objects.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @since 1.8
+ */
+abstract class DocFileFactory {
+    private static Map<Configuration, DocFileFactory> factories =
+            new WeakHashMap<Configuration, DocFileFactory>();
+
+    /**
+     * Get the appropriate factory, based on the file manager given in the
+     * configuration.
+     */
+    static synchronized DocFileFactory getFactory(Configuration configuration) {
+        DocFileFactory f = factories.get(configuration);
+        if (f == null) {
+            JavaFileManager fm = configuration.getFileManager();
+            if (fm instanceof StandardJavaFileManager)
+                f = new StandardDocFileFactory(configuration);
+            else {
+                try {
+                    Class<?> pathFileManagerClass =
+                            Class.forName("com.sun.tools.javac.nio.PathFileManager");
+                    if (pathFileManagerClass.isAssignableFrom(fm.getClass()))
+                        f = new PathDocFileFactory(configuration);
+                } catch (Throwable t) {
+                    throw new IllegalStateException(t);
+                }
+            }
+            factories.put(configuration, f);
+        }
+        return f;
+    }
+
+    protected Configuration configuration;
+
+    protected DocFileFactory(Configuration configuration) {
+        this.configuration = configuration;
+    }
+
+    /** Create a DocFile for a directory. */
+    abstract DocFile createFileForDirectory(String file);
+
+    /** Create a DocFile for a file that will be opened for reading. */
+    abstract DocFile createFileForInput(String file);
+
+    /** Create a DocFile for a file that will be opened for writing. */
+    abstract DocFile createFileForOutput(DocPath path);
+
+    /**
+     * List the directories and files found in subdirectories along the
+     * elements of the given location.
+     * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported.
+     * @param path the subdirectory of the directories of the location for which to
+     *  list files
+     */
+    abstract Iterable<DocFile> list(Location location, DocPath path);
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java	Wed Jul 05 18:30:46 2017 +0200
@@ -27,7 +27,6 @@
 
 import com.sun.javadoc.ClassDoc;
 import com.sun.javadoc.PackageDoc;
-import java.io.File;
 
 /**
  * Abstraction for immutable relative paths.
@@ -159,15 +158,6 @@
     }
 
     /**
-     * Get the file created by evaluating the path against a specified directory.
-     */
-    // Temporary: this signature should not use String for dir.
-    // Eventually, this should involve javax.tools.Location.
-    public File resolveAgainst(String dir) {
-        return dir.isEmpty() ? new File(path) : new File(dir, path);
-    }
-
-    /**
      * Return the inverse path for this path.
      * For example, if the path is a/b/c, the inverse path is ../../..
      */
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java	Wed Jul 05 18:30:46 2017 +0200
@@ -72,6 +72,9 @@
         return DocPath.create("index-" + n + ".html");
     }
 
+    /** The name of the default javascript file. */
+    public static final DocPath JAVASCRIPT = DocPath.create("script.js");
+
     /** The name of the file for the overview frame. */
     public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java	Wed Jul 05 18:30:46 2017 +0200
@@ -30,7 +30,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.tools.StandardLocation;
+import javax.tools.DocumentationTool;
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
@@ -253,7 +253,7 @@
             throws Fault {
         DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
         if (! (file.isAbsolute() || linkoffline)){
-            file = file.resolveAgainst(StandardLocation.CLASS_OUTPUT);
+            file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
         }
         try {
             if (file.exists() && file.canRead()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Enum representing method types.
+ *
+ * @author Bhavesh Patel
+ */
+public enum MethodTypes {
+    ALL(0xffff, "All Methods", "t0", true),
+    STATIC(0x1, "Static Methods", "t1", false),
+    INSTANCE(0x2, "Instance Methods", "t2", false),
+    ABSTRACT(0x4, "Abstract Methods", "t3", false),
+    CONCRETE(0x8, "Concrete Methods", "t4", false),
+    DEPRECATED(0x10, "Deprecated Methods", "t5", false);
+
+    private final int value;
+    private final String text;
+    private final String tabId;
+    private final boolean isDefaultTab;
+
+    MethodTypes(int v, String t, String id, boolean dt) {
+        this.value = v;
+        this.text = t;
+        this.tabId = id;
+        this.isDefaultTab = dt;
+    }
+
+    public int value() {
+        return value;
+    }
+
+    public String text() {
+        return text;
+    }
+
+    public String tabId() {
+        return tabId;
+    }
+
+    public boolean isDefaultTab() {
+        return isDefaultTab;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.doclets.internal.toolkit.util;
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.nio.PathFileManager;
+
+
+/**
+ * Implementation of DocFileFactory using a {@link PathFileManager}.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @since 1.8
+ */
+class PathDocFileFactory extends DocFileFactory {
+    private final PathFileManager fileManager;
+    private final Path destDir;
+
+    public PathDocFileFactory(Configuration configuration) {
+        super(configuration);
+        fileManager = (PathFileManager) configuration.getFileManager();
+
+        if (!configuration.destDirName.isEmpty()
+                || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+            try {
+                String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+                Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
+                fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+            } catch (IOException e) {
+                throw new DocletAbortException();
+            }
+        }
+
+        destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        if (fileManager.hasLocation(location)) {
+            for (Path f: fileManager.getLocation(location)) {
+                if (Files.isDirectory(f)) {
+                    f = f.resolve(path.getPath());
+                    if (Files.exists(f))
+                        files.add(new StandardDocFile(f));
+                }
+            }
+        }
+        return files;
+    }
+
+    class StandardDocFile extends DocFile {
+        private Path file;
+
+        /** Create a StandardDocFile for a given file. */
+        private StandardDocFile(Path file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a StandardDocFile for a given location and relative path. */
+        private StandardDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            this.file = destDir.resolve(path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws IOException {
+            JavaFileObject fo = getJavaFileObjectForInput(file);
+            return new BufferedInputStream(fo.openInputStream());
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            return new BufferedOutputStream(out);
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(out));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return Files.isReadable(file);
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return Files.isWritable(file);
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return Files.exists(file);
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getFileName().toString();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.toString();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return Files.isDirectory(file);
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return Files.isRegularFile(file);
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof StandardDocFile))
+                return false;
+
+            try {
+                return Files.isSameFile(file, ((StandardDocFile) other).file);
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() throws IOException {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (Path f: Files.newDirectoryStream(file)) {
+                files.add(new StandardDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            try {
+                Files.createDirectories(file);
+                return true;
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new StandardDocFile(file.resolve(p));
+            } else {
+                return new StandardDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new StandardDocFile(destDir.resolve(file));
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("PathDocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+        private JavaFileObject getJavaFileObjectForInput(Path file) {
+            return fileManager.getJavaFileObjects(file).iterator().next();
+        }
+
+        private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+            // break the path into a package-part and the rest, by finding
+            // the position of the last '/' before an invalid character for a
+            // package name, such as the "." before an extension or the "-"
+            // in filenames like package-summary.html, doc-files or src-html.
+            String p = path.getPath();
+            int lastSep = -1;
+            for (int i = 0; i < p.length(); i++) {
+                char ch = p.charAt(i);
+                if (ch == '/') {
+                    lastSep = i;
+                } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+                        || !Character.isJavaIdentifierPart(ch)) {
+                    break;
+                }
+            }
+            String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+            String rest = p.substring(lastSep + 1);
+            return fileManager.getFileForOutput(location, pkg, rest, null);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Implementation of DocFileFactory that just uses java.io.File API,
+ * and does not use a JavaFileManager..
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @since 1.8
+ */
+class SimpleDocFileFactory extends DocFileFactory {
+
+    public SimpleDocFileFactory(Configuration configuration) {
+        super(configuration);
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new SimpleDocFile(new File(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new SimpleDocFile(new File(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new SimpleDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        for (String s : configuration.sourcepath.split(File.pathSeparator)) {
+            if (s.isEmpty())
+                continue;
+            File f = new File(s);
+            if (f.isDirectory()) {
+                f = new File(f, path.getPath());
+                if (f.exists())
+                    files.add(new SimpleDocFile(f));
+            }
+        }
+        return files;
+    }
+
+    class SimpleDocFile extends DocFile {
+        private File file;
+
+        /** Create a DocFile for a given file. */
+        private SimpleDocFile(File file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a DocFile for a given location and relative path. */
+        private SimpleDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            String destDirName = configuration.destDirName;
+            this.file = destDirName.isEmpty() ? new File(path.getPath())
+                    : new File(destDirName, path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws FileNotFoundException {
+            return new BufferedInputStream(new FileInputStream(file));
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            createDirectoryForFile(file);
+            return new BufferedOutputStream(new FileOutputStream(file));
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            createDirectoryForFile(file);
+            FileOutputStream fos = new FileOutputStream(file);
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(fos));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return file.canRead();
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return file.canRead();
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return file.exists();
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getName();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.getPath();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return file.isDirectory();
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return file.isFile();
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof SimpleDocFile))
+                return false;
+
+            try {
+                return file.exists()
+                        && file.getCanonicalFile().equals(((SimpleDocFile)other).file.getCanonicalFile());
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (File f: file.listFiles()) {
+                files.add(new SimpleDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            return file.mkdirs();
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new SimpleDocFile(new File(file, p));
+            } else {
+                return new SimpleDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new SimpleDocFile(
+                    new File(configuration.destDirName, file.getPath()));
+        }
+
+        /**
+         * Given a path string create all the directories in the path. For example,
+         * if the path string is "java/applet", the method will create directory
+         * "java" and then "java/applet" if they don't exist. The file separator
+         * string "/" is platform dependent system property.
+         *
+         * @param path Directory path string.
+         */
+        private void createDirectoryForFile(File file) {
+            File dir = file.getParentFile();
+            if (dir == null || dir.exists() || dir.mkdirs())
+                return;
+
+            configuration.message.error(
+                   "doclet.Unable_to_create_directory_0", dir.getPath());
+            throw new DocletAbortException();
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("DocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.util.Assert;
+
+/**
+ * Implementation of DocFileFactory using a {@link StandardJavaFileManager}.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @since 1.8
+ */
+class StandardDocFileFactory extends DocFileFactory {
+    private final StandardJavaFileManager fileManager;
+    private File destDir;
+
+    public StandardDocFileFactory(Configuration configuration) {
+        super(configuration);
+        fileManager = (StandardJavaFileManager) configuration.getFileManager();
+    }
+
+    private File getDestDir() {
+        if (destDir == null) {
+            if (!configuration.destDirName.isEmpty()
+                    || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+                try {
+                    String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+                    File dir = new File(dirName);
+                    fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+                } catch (IOException e) {
+                    throw new DocletAbortException();
+                }
+            }
+
+            destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+        }
+        return destDir;
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new StandardDocFile(new File(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new StandardDocFile(new File(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        Location l = fileManager.hasLocation(StandardLocation.SOURCE_PATH)
+                ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
+        for (File f: fileManager.getLocation(l)) {
+            if (f.isDirectory()) {
+                f = new File(f, path.getPath());
+                if (f.exists())
+                    files.add(new StandardDocFile(f));
+            }
+        }
+        return files;
+    }
+
+    private static File newFile(File dir, String path) {
+        return (dir == null) ? new File(path) : new File(dir, path);
+    }
+
+    class StandardDocFile extends DocFile {
+        private File file;
+
+
+        /** Create a StandardDocFile for a given file. */
+        private StandardDocFile(File file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a StandardDocFile for a given location and relative path. */
+        private StandardDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            Assert.check(location == DocumentationTool.Location.DOCUMENTATION_OUTPUT);
+            this.file = newFile(getDestDir(), path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws IOException {
+            JavaFileObject fo = getJavaFileObjectForInput(file);
+            return new BufferedInputStream(fo.openInputStream());
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            return new BufferedOutputStream(out);
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(out));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return file.canRead();
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return file.canWrite();
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return file.exists();
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getName();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.getPath();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return file.isDirectory();
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return file.isFile();
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof StandardDocFile))
+                return false;
+
+            try {
+                return file.exists()
+                        && file.getCanonicalFile().equals(((StandardDocFile) other).file.getCanonicalFile());
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (File f: file.listFiles()) {
+                files.add(new StandardDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            return file.mkdirs();
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new StandardDocFile(new File(file, p));
+            } else {
+                return new StandardDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new StandardDocFile(newFile(getDestDir(), file.getPath()));
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("StandardDocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+        private JavaFileObject getJavaFileObjectForInput(File file) {
+            return fileManager.getJavaFileObjects(file).iterator().next();
+        }
+
+        private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+            // break the path into a package-part and the rest, by finding
+            // the position of the last '/' before an invalid character for a
+            // package name, such as the "." before an extension or the "-"
+            // in filenames like package-summary.html, doc-files or src-html.
+            String p = path.getPath();
+            int lastSep = -1;
+            for (int i = 0; i < p.length(); i++) {
+                char ch = p.charAt(i);
+                if (ch == '/') {
+                    lastSep = i;
+                } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+                        || !Character.isJavaIdentifierPart(ch)) {
+                    break;
+                }
+            }
+            String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+            String rest = p.substring(lastSep + 1);
+            return fileManager.getFileForOutput(location, pkg, rest, null);
+        }
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Jul 05 18:30:46 2017 +0200
@@ -46,13 +46,6 @@
 public class Util {
 
     /**
-     * A mapping between characters and their
-     * corresponding HTML escape character.
-     */
-    public static final String[][] HTML_ESCAPE_CHARS =
-    {{"&", "&amp;"}, {"<", "&lt;"}, {">", "&gt;"}};
-
-    /**
      * Return array of class members whose documentation is to be generated.
      * If the member is deprecated do not include such a member in the
      * returned array.
@@ -424,18 +417,44 @@
      * return the result.
      *
      * @param s The string to check.
-     * @return the original string with all of the HTML characters
-     * escaped.
-     *
-     * @see #HTML_ESCAPE_CHARS
+     * @return the original string with all of the HTML characters escaped.
      */
     public static String escapeHtmlChars(String s) {
-        String result = s;
-        for (int i = 0; i < HTML_ESCAPE_CHARS.length; i++) {
-            result = Util.replaceText(result,
-                    HTML_ESCAPE_CHARS[i][0], HTML_ESCAPE_CHARS[i][1]);
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+                // only start building a new string if we need to
+                case '<': case '>': case '&':
+                    StringBuilder sb = new StringBuilder(s.substring(0, i));
+                    for ( ; i < s.length(); i++) {
+                        ch = s.charAt(i);
+                        switch (ch) {
+                            case '<': sb.append("&lt;");  break;
+                            case '>': sb.append("&gt;");  break;
+                            case '&': sb.append("&amp;"); break;
+                            default:  sb.append(ch);      break;
+                        }
+                    }
+                    return sb.toString();
+            }
         }
-        return result;
+        return s;
+    }
+
+    /**
+     * Escape all special html characters in a string buffer.
+     *
+     * @param sb The string buffer to update
+     */
+    public static void escapeHtmlChars(StringBuilder sb) {
+        // scan backwards, replacing characters as needed.
+        for (int i = sb.length() - 1; i >= 0; i--) {
+            switch (sb.charAt(i)) {
+                case '<': sb.replace(i, i+1, "&lt;"); break;
+                case '>': sb.replace(i, i+1, "&gt;"); break;
+                case '&': sb.replace(i, i+1, "&amp;"); break;
+            }
+        }
     }
 
     /**
@@ -579,22 +598,21 @@
     }
 
     /**
-     * Given a string, replace all tabs with the appropriate
-     * number of spaces.
-     * @param tabLength the length of each tab.
-     * @param s the String to scan.
+     * Replace all tabs with the appropriate number of spaces.
+     * @param configuration the doclet configuration defining the setting for the
+     *                      tab length.
+     * @param sb the StringBuilder in which to replace the tabs
      */
-    public static void replaceTabs(int tabLength, StringBuilder s) {
-        if (whitespace == null || whitespace.length() < tabLength)
-            whitespace = String.format("%" + tabLength + "s", " ");
+    public static void replaceTabs(Configuration configuration, StringBuilder sb) {
+        int tabLength = configuration.sourcetab;
+        String whitespace = configuration.tabSpaces;
         int index = 0;
-        while ((index = s.indexOf("\t", index)) != -1) {
+        while ((index = sb.indexOf("\t", index)) != -1) {
             int spaceCount = tabLength - index % tabLength;
-            s.replace(index, index+1, whitespace.substring(0, spaceCount));
+            sb.replace(index, index+1, whitespace.substring(0, spaceCount));
             index += spaceCount;
         }
     }
-    private static String whitespace;
 
     /**
      * The documentation for values() and valueOf() in Enums are set by the
--- a/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Wed Jul 05 18:30:46 2017 +0200
@@ -140,6 +140,14 @@
      * For internal use only.  This method will be
      * removed without warning.
      */
+    public Context getContext() {
+        return context;
+    }
+
+    /**
+     * For internal use only.  This method will be
+     * removed without warning.
+     */
     public void updateContext(Context newContext) {
         context = newContext;
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java	Wed Jul 05 18:30:46 2017 +0200
@@ -149,7 +149,7 @@
             return fo;
     }
 
-    <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
+    public <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
         if (isTrusted(dl))
             return dl;
         return new WrappedDiagnosticListener<T>(dl);
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -74,7 +74,7 @@
     private List<JavaFileObject> fileObjects;
     private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
     private ListBuffer<Env<AttrContext>> genList;
-    private AtomicBoolean used = new AtomicBoolean();
+    private final AtomicBoolean used = new AtomicBoolean();
     private Iterable<? extends Processor> processors;
 
     private Main.Result result = null;
@@ -99,11 +99,11 @@
     }
 
     JavacTaskImpl(Main compilerMain,
-                Iterable<String> flags,
+                Iterable<String> args,
                 Context context,
                 Iterable<String> classes,
                 Iterable<? extends JavaFileObject> fileObjects) {
-        this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects));
+        this(compilerMain, toArray(args), toArray(classes), context, toList(fileObjects));
     }
 
     static private String[] toArray(Iterable<String> iter) {
@@ -489,22 +489,6 @@
      * For internal use only.  This method will be
      * removed without warning.
      */
-    public Context getContext() {
-        return context;
-    }
-
-    /**
-     * For internal use only.  This method will be
-     * removed without warning.
-     */
-    public void updateContext(Context newContext) {
-        context = newContext;
-    }
-
-    /**
-     * For internal use only.  This method will be
-     * removed without warning.
-     */
     public Type parseType(String expr, TypeElement scope) {
         if (expr == null || expr.equals(""))
             throw new IllegalArgumentException();
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,6 +26,8 @@
 package com.sun.tools.javac.api;
 
 import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.AnnotationMirror;
@@ -40,19 +42,31 @@
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ReferenceTree;
 import com.sun.source.tree.CatchTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
+import com.sun.source.util.DocTrees;
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.Type.ErrorType;
 import com.sun.tools.javac.code.Type.UnionClassType;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.Types.TypeRelation;
 import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
@@ -61,6 +75,9 @@
 import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCReference;
 import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -71,8 +88,12 @@
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Pair;
+import static com.sun.tools.javac.code.TypeTag.*;
 
 /**
  * Provides an implementation of Trees.
@@ -84,7 +105,7 @@
  *
  * @author Peter von der Ah&eacute;
  */
-public class JavacTrees extends Trees {
+public class JavacTrees extends DocTrees {
 
     // in a world of a single context per compilation, these would all be final
     private Resolve resolve;
@@ -95,12 +116,14 @@
     private TreeMaker treeMaker;
     private JavacElements elements;
     private JavacTaskImpl javacTaskImpl;
+    private Names names;
+    private Types types;
 
     // called reflectively from Trees.instance(CompilationTask task)
     public static JavacTrees instance(JavaCompiler.CompilationTask task) {
-        if (!(task instanceof JavacTaskImpl))
+        if (!(task instanceof BasicJavacTask))
             throw new IllegalArgumentException();
-        return instance(((JavacTaskImpl)task).getContext());
+        return instance(((BasicJavacTask)task).getContext());
     }
 
     // called reflectively from Trees.instance(ProcessingEnvironment env)
@@ -134,6 +157,8 @@
         resolve = Resolve.instance(context);
         treeMaker = TreeMaker.instance(context);
         memberEnter = MemberEnter.instance(context);
+        names = Names.instance(context);
+        types = Types.instance(context);
 
         JavacTask t = context.get(JavacTask.class);
         if (t instanceof JavacTaskImpl)
@@ -229,6 +254,324 @@
         return sym;
     }
 
+    @Override
+    public Element getElement(TreePath path, ReferenceTree reference) {
+        if (!(reference instanceof DCReference))
+            return null;
+        DCReference ref = (DCReference) reference;
+
+        Env<AttrContext> env = getAttrContext(path);
+
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
+                new Log.DeferredDiagnosticHandler(log);
+        try {
+            final ClassSymbol tsym;
+            final Name memberName;
+            if (ref.qualifierExpression == null) {
+                tsym = env.enclClass.sym;
+                memberName = ref.memberName;
+            } else {
+                // See if the qualifierExpression is a type or package name.
+                // javac does not provide the exact method required, so
+                // we first check if qualifierExpression identifies a type,
+                // and if not, then we check to see if it identifies a package.
+                Type t = attr.attribType(ref.qualifierExpression, env);
+                if (t.isErroneous()) {
+                    if (ref.memberName == null) {
+                        // Attr/Resolve assume packages exist and create symbols as needed
+                        // so use getPackageElement to restrict search to existing packages
+                        PackageSymbol pck = elements.getPackageElement(ref.qualifierExpression.toString());
+                        if (pck != null) {
+                            return pck;
+                        } else if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) {
+                            // fixup:  allow "identifier" instead of "#identifier"
+                            // for compatibility with javadoc
+                            tsym = env.enclClass.sym;
+                            memberName = ((JCIdent) ref.qualifierExpression).name;
+                        } else
+                            return null;
+                    } else {
+                        return null;
+                    }
+                } else {
+                    tsym = (ClassSymbol) t.tsym;
+                    memberName = ref.memberName;
+                }
+            }
+
+            if (memberName == null)
+                return tsym;
+
+            final List<Type> paramTypes;
+            if (ref.paramTypes == null)
+                paramTypes = null;
+            else {
+                ListBuffer<Type> lb = new ListBuffer<Type>();
+                for (List<JCTree> l = ref.paramTypes; l.nonEmpty(); l = l.tail) {
+                    JCTree tree = l.head;
+                    Type t = attr.attribType(tree, env);
+                    lb.add(t);
+                }
+                paramTypes = lb.toList();
+            }
+
+            Symbol msym = (memberName == tsym.name)
+                    ? findConstructor(tsym, paramTypes)
+                    : findMethod(tsym, memberName, paramTypes);
+            if (paramTypes != null) {
+                // explicit (possibly empty) arg list given, so cannot be a field
+                return msym;
+            }
+
+            VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName);
+            // prefer a field over a method with no parameters
+            if (vsym != null &&
+                    (msym == null ||
+                        types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) {
+                return vsym;
+            } else {
+                return msym;
+            }
+        } finally {
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
+        }
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#findField */
+    private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
+        return searchField(tsym, fieldName, new HashSet<ClassSymbol>());
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#searchField */
+    private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set<ClassSymbol> searched) {
+        if (searched.contains(tsym)) {
+            return null;
+        }
+        searched.add(tsym);
+
+        for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(fieldName);
+                e.scope != null; e = e.next()) {
+            if (e.sym.kind == Kinds.VAR) {
+                return (VarSymbol)e.sym;
+            }
+        }
+
+        //### If we found a VarSymbol above, but which did not pass
+        //### the modifier filter, we should return failure here!
+
+        ClassSymbol encl = tsym.owner.enclClass();
+        if (encl != null) {
+            VarSymbol vsym = searchField(encl, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        // search superclass
+        Type superclass = tsym.getSuperclass();
+        if (superclass.tsym != null) {
+            VarSymbol vsym = searchField((ClassSymbol) superclass.tsym, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        // search interfaces
+        List<Type> intfs = tsym.getInterfaces();
+        for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
+            Type intf = l.head;
+            if (intf.isErroneous()) continue;
+            VarSymbol vsym = searchField((ClassSymbol) intf.tsym, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */
+    MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes) {
+        for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init);
+                e.scope != null; e = e.next()) {
+            if (e.sym.kind == Kinds.MTH) {
+                if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+                    return (MethodSymbol) e.sym;
+                }
+            }
+        }
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */
+    private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List<Type> paramTypes) {
+        return searchMethod(tsym, methodName, paramTypes, new HashSet<ClassSymbol>());
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */
+    private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
+                                       List<Type> paramTypes, Set<ClassSymbol> searched) {
+        //### Note that this search is not necessarily what the compiler would do!
+
+        // do not match constructors
+        if (methodName == names.init)
+            return null;
+
+        if (searched.contains(tsym))
+            return null;
+        searched.add(tsym);
+
+        // search current class
+        com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName);
+
+        //### Using modifier filter here isn't really correct,
+        //### but emulates the old behavior.  Instead, we should
+        //### apply the normal rules of visibility and inheritance.
+
+        if (paramTypes == null) {
+            // If no parameters specified, we are allowed to return
+            // any method with a matching name.  In practice, the old
+            // code returned the first method, which is now the last!
+            // In order to provide textually identical results, we
+            // attempt to emulate the old behavior.
+            MethodSymbol lastFound = null;
+            for (; e.scope != null; e = e.next()) {
+                if (e.sym.kind == Kinds.MTH) {
+                    if (e.sym.name == methodName) {
+                        lastFound = (MethodSymbol)e.sym;
+                    }
+                }
+            }
+            if (lastFound != null) {
+                return lastFound;
+            }
+        } else {
+            for (; e.scope != null; e = e.next()) {
+                if (e.sym != null &&
+                    e.sym.kind == Kinds.MTH) {
+                    if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+                        return (MethodSymbol) e.sym;
+                    }
+                }
+            }
+        }
+
+        //### If we found a MethodSymbol above, but which did not pass
+        //### the modifier filter, we should return failure here!
+
+        // search superclass
+        Type superclass = tsym.getSuperclass();
+        if (superclass.tsym != null) {
+            MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        // search interfaces
+        List<Type> intfs = tsym.getInterfaces();
+        for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
+            Type intf = l.head;
+            if (intf.isErroneous()) continue;
+            MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        // search enclosing class
+        ClassSymbol encl = tsym.owner.enclClass();
+        if (encl != null) {
+            MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl */
+    private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
+        if (paramTypes == null)
+            return true;
+
+        if (method.params().size() != paramTypes.size())
+            return false;
+
+        List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
+
+        return (Type.isErroneous(paramTypes))
+            ? fuzzyMatch(paramTypes, methodParamTypes)
+            : types.isSameTypes(paramTypes, methodParamTypes);
+    }
+
+    boolean fuzzyMatch(List<Type> paramTypes, List<Type> methodParamTypes) {
+        List<Type> l1 = paramTypes;
+        List<Type> l2 = methodParamTypes;
+        while (l1.nonEmpty()) {
+            if (!fuzzyMatch(l1.head, l2.head))
+                return false;
+            l1 = l1.tail;
+            l2 = l2.tail;
+        }
+        return true;
+    }
+
+    boolean fuzzyMatch(Type paramType, Type methodParamType) {
+        Boolean b = fuzzyMatcher.visit(paramType, methodParamType);
+        return (b == Boolean.TRUE);
+    }
+
+    TypeRelation fuzzyMatcher = new TypeRelation() {
+        @Override
+        public Boolean visitType(Type t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            switch (t.getTag()) {
+            case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
+            case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE:
+                return t.getTag() == s.getTag();
+
+            default:
+                throw new AssertionError("fuzzyMatcher " + t.getTag());
+            }
+        }
+
+        @Override
+        public Boolean visitArrayType(ArrayType t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            return s.getTag() == ARRAY
+                && visit(t.elemtype, types.elemtype(s));
+        }
+
+        @Override
+        public Boolean visitClassType(ClassType t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            return t.tsym == s.tsym;
+        }
+
+        @Override
+        public Boolean visitErrorType(ErrorType t, Type s) {
+            return s.getTag() == CLASS
+                    && t.tsym.name == ((ClassType) s).tsym.name;
+        }
+    };
+
     public TypeMirror getTypeMirror(TreePath path) {
         Tree t = path.getLeaf();
         return ((JCTree)t).type;
@@ -250,6 +593,18 @@
         return null;
     }
 
+    public DocCommentTree getDocCommentTree(TreePath path) {
+        CompilationUnitTree t = path.getCompilationUnit();
+        Tree leaf = path.getLeaf();
+        if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
+            JCCompilationUnit cu = (JCCompilationUnit) t;
+            if (cu.docComments != null) {
+                return cu.docComments.getCommentTree((JCTree) leaf);
+            }
+        }
+        return null;
+    }
+
     public boolean isAccessible(Scope scope, TypeElement type) {
         if (scope instanceof JavacScope && type instanceof ClassSymbol) {
             Env<AttrContext> env = ((JavacScope) scope).env;
@@ -418,14 +773,27 @@
     public void printMessage(Diagnostic.Kind kind, CharSequence msg,
             com.sun.source.tree.Tree t,
             com.sun.source.tree.CompilationUnitTree root) {
+        printMessage(kind, msg, ((JCTree) t).pos(), root);
+    }
+
+    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.doctree.DocTree t,
+            com.sun.source.doctree.DocCommentTree c,
+            com.sun.source.tree.CompilationUnitTree root) {
+        printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root);
+    }
+
+    private void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            JCDiagnostic.DiagnosticPosition pos,
+            com.sun.source.tree.CompilationUnitTree root) {
         JavaFileObject oldSource = null;
         JavaFileObject newSource = null;
-        JCDiagnostic.DiagnosticPosition pos = null;
 
         newSource = root.getSourceFile();
-        if (newSource != null) {
+        if (newSource == null) {
+            pos = null;
+        } else {
             oldSource = log.useSource(newSource);
-            pos = ((JCTree) t).pos();
         }
 
         try {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Wed Jul 05 18:30:46 2017 +0200
@@ -67,6 +67,7 @@
         if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
         if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
         if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
+        if ((mask&DEFAULT) != 0) flags.add(Flag.DEFAULT);
         if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
         if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
         if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
@@ -261,7 +262,7 @@
      * Flag that marks class as auxiliary, ie a non-public class following
      * the public class in a source file, that could block implicit compilation.
      */
-    public static final long AUXILIARY = 1L<<43;
+    public static final long AUXILIARY = 1L<<44;
 
     /** Modifier masks.
      */
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 05 18:30:46 2017 +0200
@@ -438,7 +438,8 @@
     }
 
     public Set<Modifier> getModifiers() {
-        return Flags.asModifierSet(flags());
+        long flags = flags();
+        return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags);
     }
 
     public Name getSimpleName() {
@@ -475,6 +476,7 @@
         public String toString() { return other.toString(); }
         public Symbol location() { return other.location(); }
         public Symbol location(Type site, Types types) { return other.location(site, types); }
+        public Symbol baseSymbol() { return other; }
         public Type erasure(Types types) { return other.erasure(types); }
         public Type externalType(Types types) { return other.externalType(types); }
         public boolean isLocal() { return other.isLocal(); }
@@ -1192,7 +1194,7 @@
 
             // check for an inherited implementation
             if ((flags() & ABSTRACT) != 0 ||
-                    (other.flags() & ABSTRACT) == 0 ||
+                    ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
                     !other.isOverridableIn(origin) ||
                     !this.isMemberOf(origin, types))
                 return false;
@@ -1202,7 +1204,7 @@
             Type ot = types.memberType(origin.type, other);
             return
                 types.isSubSignature(mt, ot) &&
-                (!checkResult || types.resultSubtype(mt, ot, Warner.noWarnings));
+                (!checkResult || types.resultSubtype(mt, ot, types.noWarnings));
         }
 
         private boolean isOverridableIn(TypeSymbol origin) {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Jul 05 18:30:46 2017 +0200
@@ -130,6 +130,7 @@
     public final Type methodHandleLookupType;
     public final Type methodTypeType;
     public final Type nativeHeaderType;
+    public final Type nativeHeaderType_old;
     public final Type throwableType;
     public final Type errorType;
     public final Type interruptedExceptionType;
@@ -505,7 +506,8 @@
                                             List.of(exceptionType), methodClass),
                              autoCloseableType.tsym);
         trustMeType = enterClass("java.lang.SafeVarargs");
-        nativeHeaderType = enterClass("javax.tools.annotation.GenerateNativeHeader");
+        nativeHeaderType = enterClass("java.lang.annotation.Native");
+        nativeHeaderType_old = enterClass("javax.tools.annotation.GenerateNativeHeader");
         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
 
         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Jul 05 18:30:46 2017 +0200
@@ -83,6 +83,8 @@
     final Name capturedName;
     private final FunctionDescriptorLookupError functionDescriptorLookupError;
 
+    public final Warner noWarnings;
+
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
         Types instance = context.get(typesKey);
@@ -106,6 +108,7 @@
         messages = JavacMessages.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         functionDescriptorLookupError = new FunctionDescriptorLookupError();
+        noWarnings = new Warner(null);
     }
     // </editor-fold>
 
@@ -296,7 +299,7 @@
      * convertions to s?
      */
     public boolean isConvertible(Type t, Type s) {
-        return isConvertible(t, s, Warner.noWarnings);
+        return isConvertible(t, s, noWarnings);
     }
     // </editor-fold>
 
@@ -394,15 +397,10 @@
 
             @Override
             public boolean accepts(Symbol sym) {
-                    return sym.kind == Kinds.MTH &&
-                            (sym.flags() & ABSTRACT) != 0 &&
-                            !overridesObjectMethod(origin, sym) &&
-                            notOverridden(sym);
-            }
-
-            private boolean notOverridden(Symbol msym) {
-                Symbol impl = ((MethodSymbol)msym).implementation(origin, Types.this, false);
-                return impl == null || (impl.flags() & ABSTRACT) != 0;
+                return sym.kind == Kinds.MTH &&
+                        (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT &&
+                        !overridesObjectMethod(origin, sym) &&
+                        (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
             }
         };
 
@@ -593,7 +591,7 @@
      * Is t an unchecked subtype of s?
      */
     public boolean isSubtypeUnchecked(Type t, Type s) {
-        return isSubtypeUnchecked(t, s, Warner.noWarnings);
+        return isSubtypeUnchecked(t, s, noWarnings);
     }
     /**
      * Is t an unchecked subtype of s?
@@ -1196,7 +1194,7 @@
 
     // <editor-fold defaultstate="collapsed" desc="isCastable">
     public boolean isCastable(Type t, Type s) {
-        return isCastable(t, s, Warner.noWarnings);
+        return isCastable(t, s, noWarnings);
     }
 
     /**
@@ -1259,7 +1257,7 @@
                     return true;
 
                 if (s.tag == TYPEVAR) {
-                    if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
+                    if (isCastable(t, s.getUpperBound(), noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1269,7 +1267,7 @@
 
                 if (t.isCompound()) {
                     Warner oldWarner = warnStack.head;
-                    warnStack.head = Warner.noWarnings;
+                    warnStack.head = noWarnings;
                     if (!visit(supertype(t), s))
                         return false;
                     for (Type intf : interfaces(t)) {
@@ -1368,7 +1366,7 @@
                 case BOT:
                     return true;
                 case TYPEVAR:
-                    if (isCastable(s, t, Warner.noWarnings)) {
+                    if (isCastable(s, t, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1396,7 +1394,7 @@
                 case TYPEVAR:
                     if (isSubtype(t, s)) {
                         return true;
-                    } else if (isCastable(t.bound, s, Warner.noWarnings)) {
+                    } else if (isCastable(t.bound, s, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1535,7 +1533,7 @@
             TypeVar tv = (TypeVar) t;
             return !isCastable(tv.bound,
                                relaxBound(s),
-                               Warner.noWarnings);
+                               noWarnings);
         }
         if (s.tag != WILDCARD)
             s = upperBound(s);
@@ -1838,7 +1836,7 @@
 
     // <editor-fold defaultstate="collapsed" desc="isAssignable">
     public boolean isAssignable(Type t, Type s) {
-        return isAssignable(t, s, Warner.noWarnings);
+        return isAssignable(t, s, noWarnings);
     }
 
     /**
@@ -2149,9 +2147,9 @@
             }
         };
 
-    public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) {
-        for (Type t2 : interfaces(tsym.type)) {
-            if (isSameType(t, t2)) return true;
+    public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
+        for (Type i2 : interfaces(origin.type)) {
+            if (isym == i2.tsym) return true;
         }
         return false;
     }
@@ -2224,7 +2222,9 @@
      * Return list of bounds of the given type variable.
      */
     public List<Type> getBounds(TypeVar t) {
-        if (t.bound.isErroneous() || !t.bound.isCompound())
+                if (t.bound.hasTag(NONE))
+            return List.nil();
+        else if (t.bound.isErroneous() || !t.bound.isCompound())
             return List.of(t.bound);
         else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
             return interfaces(t).prepend(supertype(t));
@@ -2319,10 +2319,6 @@
         return false;
     }
 
-    public boolean overridesObjectMethod(Symbol msym) {
-        return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null;
-    }
-
     // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
     class ImplementationCache {
 
@@ -2471,11 +2467,7 @@
 
     //where
     public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
-        return interfaceCandidates(site, ms, false);
-    }
-
-    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) {
-        Filter<Symbol> filter = new MethodFilter(ms, site, intfOnly);
+        Filter<Symbol> filter = new MethodFilter(ms, site);
         List<MethodSymbol> candidates = List.nil();
         for (Symbol s : membersClosure(site, false).getElements(filter)) {
             if (!site.tsym.isInterface() && !s.owner.isInterface()) {
@@ -2514,17 +2506,14 @@
 
                 Symbol msym;
                 Type site;
-                boolean intfOnly;
-
-                MethodFilter(Symbol msym, Type site, boolean intfOnly) {
+
+                MethodFilter(Symbol msym, Type site) {
                     this.msym = msym;
                     this.site = site;
-                    this.intfOnly = intfOnly;
                 }
 
                 public boolean accepts(Symbol s) {
                     return s.kind == Kinds.MTH &&
-                            (!intfOnly || s.owner.isInterface()) &&
                             s.name == msym.name &&
                             s.isInheritedIn(site.tsym, Types.this) &&
                             overrideEquivalent(memberType(site, s), memberType(site, msym));
@@ -3462,11 +3451,11 @@
      */
     public boolean returnTypeSubstitutable(Type r1, Type r2) {
         if (hasSameArgs(r1, r2))
-            return resultSubtype(r1, r2, Warner.noWarnings);
+            return resultSubtype(r1, r2, noWarnings);
         else
             return covariantReturnType(r1.getReturnType(),
                                        erasure(r2.getReturnType()),
-                                       Warner.noWarnings);
+                                       noWarnings);
     }
 
     public boolean returnTypeSubstitutable(Type r1,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 05 18:30:46 2017 +0200
@@ -133,7 +133,7 @@
         allowCovariantReturns = source.allowCovariantReturns();
         allowAnonOuterThis = source.allowAnonOuterThis();
         allowStringsInSwitch = source.allowStringsInSwitch();
-        allowPoly = source.allowPoly() && options.isSet("allowPoly");
+        allowPoly = source.allowPoly();
         allowLambda = source.allowLambda();
         allowDefaultMethods = source.allowDefaultMethods();
         sourceName = source.name;
@@ -179,14 +179,14 @@
      */
     boolean allowCovariantReturns;
 
+    /** Switch: support lambda expressions ?
+     */
+    boolean allowLambda;
+
     /** Switch: support default methods ?
      */
     boolean allowDefaultMethods;
 
-    /** Switch: support lambda expressions ?
-     */
-    boolean allowLambda;
-
     /** Switch: allow references to surrounding object from anonymous
      * objects during constructor call?
      */
@@ -524,6 +524,10 @@
         protected ResultInfo dup(Type newPt) {
             return new ResultInfo(pkind, newPt, checkContext);
         }
+
+        protected ResultInfo dup(CheckContext newContext) {
+            return new ResultInfo(pkind, pt, newContext);
+        }
     }
 
     class RecoveryInfo extends ResultInfo {
@@ -540,7 +544,7 @@
                 }
                 @Override
                 public void report(DiagnosticPosition pos, JCDiagnostic details) {
-                    //do nothing
+                    chk.basicHandler.report(pos, details);
                 }
             });
         }
@@ -595,8 +599,10 @@
             this.env = env;
             this.resultInfo = resultInfo;
             tree.accept(this);
-            if (tree == breakTree)
+            if (tree == breakTree &&
+                    resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
                 throw new BreakAttr(env);
+            }
             return result;
         } catch (CompletionFailure ex) {
             tree.type = syms.errType;
@@ -616,13 +622,13 @@
     /** Derived visitor method: attribute an expression tree with
      *  no constraints on the computed type.
      */
-    Type attribExpr(JCTree tree, Env<AttrContext> env) {
+    public Type attribExpr(JCTree tree, Env<AttrContext> env) {
         return attribTree(tree, env, unknownExprInfo);
     }
 
     /** Derived visitor method: attribute a type tree.
      */
-    Type attribType(JCTree tree, Env<AttrContext> env) {
+    public Type attribType(JCTree tree, Env<AttrContext> env) {
         Type result = attribType(tree, env, Type.noType);
         return result;
     }
@@ -903,7 +909,7 @@
 
             localEnv.info.lint = lint;
 
-            if (isDefaultMethod && types.overridesObjectMethod(m)) {
+            if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
                 log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
             }
 
@@ -1360,11 +1366,8 @@
             types.asSuper(resource, syms.autoCloseableType.tsym) != null &&
             !types.isSameType(resource, syms.autoCloseableType)) { // Don't emit warning for AutoCloseable itself
             Symbol close = syms.noSymbol;
-            Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
-            Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
+            Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
             try {
-                log.deferAll();
-                log.deferredDiagnostics = ListBuffer.lb();
                 close = rs.resolveQualifiedMethod(pos,
                         env,
                         resource,
@@ -1373,8 +1376,7 @@
                         List.<Type>nil());
             }
             finally {
-                log.deferredDiagFilter = prevDeferDiagsFilter;
-                log.deferredDiagnostics = prevDeferredDiags;
+                log.popDiagnosticHandler(discardHandler);
             }
             if (close.kind == MTH &&
                     close.overrides(syms.autoCloseableClose, resource.tsym, types, true) &&
@@ -1394,13 +1396,14 @@
 
         if (!standaloneConditional && resultInfo.pt.hasTag(VOID)) {
             //cannot get here (i.e. it means we are returning from void method - which is already an error)
+            resultInfo.checkContext.report(tree, diags.fragment("conditional.target.cant.be.void"));
             result = tree.type = types.createErrorType(resultInfo.pt);
             return;
         }
 
         ResultInfo condInfo = standaloneConditional ?
                 unknownExprInfo :
-                new ResultInfo(VAL, pt(), new Check.NestedCheckContext(resultInfo.checkContext) {
+                resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) {
                     //this will use enclosing check context to check compatibility of
                     //subexpression against target type; if we are in a method check context,
                     //depending on whether boxing is allowed, we could have incompatibilities
@@ -1423,11 +1426,11 @@
         result = check(tree, owntype, VAL, resultInfo);
     }
     //where
-        @SuppressWarnings("fallthrough")
         private boolean isBooleanOrNumeric(Env<AttrContext> env, JCExpression tree) {
             switch (tree.getTag()) {
                 case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) ||
-                              ((JCLiteral)tree).typetag == BOOLEAN;
+                              ((JCLiteral)tree).typetag == BOOLEAN ||
+                              ((JCLiteral)tree).typetag == BOT;
                 case LAMBDA: case REFERENCE: return false;
                 case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr);
                 case CONDEXPR:
@@ -1616,19 +1619,23 @@
             // it conforms to result type of enclosing method.
             if (tree.expr != null) {
                 if (env.info.returnResult.pt.hasTag(VOID)) {
-                    log.error(tree.expr.pos(),
-                              "cant.ret.val.from.meth.decl.void");
+                    env.info.returnResult.checkContext.report(tree.expr.pos(),
+                              diags.fragment("unexpected.ret.val"));
                 }
                 attribTree(tree.expr, env, env.info.returnResult);
             } else if (!env.info.returnResult.pt.hasTag(VOID)) {
-                log.error(tree.pos(), "missing.ret.val");
+                env.info.returnResult.checkContext.report(tree.pos(),
+                              diags.fragment("missing.ret.val"));
             }
         }
         result = null;
     }
 
     public void visitThrow(JCThrow tree) {
-        attribExpr(tree.expr, env, syms.throwableType);
+        Type owntype = attribExpr(tree.expr, env, allowPoly ? Type.noType : syms.throwableType);
+        if (allowPoly) {
+            chk.checkType(tree, owntype, syms.throwableType);
+        }
         result = null;
     }
 
@@ -2072,7 +2079,7 @@
                             resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
                     Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
                     if (!inferred.isErroneous() &&
-                        types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), Warner.noWarnings)) {
+                        types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), types.noWarnings)) {
                         String key = types.isSameType(clazztype, inferred) ?
                             "diamond.redundant.args" :
                             "diamond.redundant.args.1";
@@ -2176,7 +2183,7 @@
         }
         //create an environment for attribution of the lambda expression
         final Env<AttrContext> localEnv = lambdaEnv(that, env);
-        boolean needsRecovery = resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
+        boolean needsRecovery =
                 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK;
         try {
             List<Type> explicitParamTypes = null;
@@ -2186,10 +2193,16 @@
                 explicitParamTypes = TreeInfo.types(that.params);
             }
 
-            Type target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
-            Type lambdaType = (target == Type.recoveryType) ?
-                    fallbackDescriptorType(that) :
-                    types.findDescriptorType(target);
+            Type target;
+            Type lambdaType;
+            if (pt() != Type.recoveryType) {
+                target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
+                lambdaType = types.findDescriptorType(target);
+                chk.checkFunctionalInterface(that, target);
+            } else {
+                target = Type.recoveryType;
+                lambdaType = fallbackDescriptorType(that);
+            }
 
             if (!TreeInfo.isExplicitLambda(that)) {
                 //add param type info in the AST
@@ -2254,7 +2267,7 @@
             checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound);
 
             if (!isSpeculativeRound) {
-                checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType);
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target);
             }
             result = check(that, target, VAL, resultInfo);
         } catch (Types.FunctionDescriptorLookupError ex) {
@@ -2289,17 +2302,22 @@
             return null;
         }
 
-        private void checkAccessibleFunctionalDescriptor(final DiagnosticPosition pos,
-                final Env<AttrContext> env, final InferenceContext inferenceContext, final Type desc) {
-            if (inferenceContext.free(desc)) {
-                inferenceContext.addFreeTypeListener(List.of(desc), new FreeTypeListener() {
+        private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env, final InferenceContext inferenceContext, final Type... ts) {
+            checkAccessibleTypes(pos, env, inferenceContext, List.from(ts));
+        }
+
+        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) {
-                        checkAccessibleFunctionalDescriptor(pos, env, inferenceContext, inferenceContext.asInstType(desc, types));
+                        checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts, types));
                     }
                 });
             } else {
-                chk.checkAccessibleFunctionalDescriptor(pos, env, desc);
+                for (Type t : ts) {
+                    rs.checkAccessibleType(env, t);
+                }
             }
         }
 
@@ -2415,15 +2433,20 @@
                 typeargtypes = attribTypes(that.typeargs, localEnv);
             }
 
-            Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
-            Type desc = (target == Type.recoveryType) ?
-                    fallbackDescriptorType(that) :
-                    types.findDescriptorType(target);
+            Type target;
+            Type desc;
+            if (pt() != Type.recoveryType) {
+                target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
+                desc = types.findDescriptorType(target);
+                chk.checkFunctionalInterface(that, target);
+            } else {
+                target = Type.recoveryType;
+                desc = fallbackDescriptorType(that);
+            }
 
             List<Type> argtypes = desc.getParameterTypes();
 
             boolean allowBoxing =
-                    resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
                     resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
             Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
                     that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
@@ -2459,18 +2482,25 @@
                 JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that,
                         "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag);
 
-                if (targetError) {
-                    resultInfo.checkContext.report(that, diag);
+                if (targetError && target == Type.recoveryType) {
+                    //a target error doesn't make sense during recovery stage
+                    //as we don't know what actual parameter types are
+                    result = that.type = target;
+                    return;
                 } else {
-                    log.report(diag);
+                    if (targetError) {
+                        resultInfo.checkContext.report(that, diag);
+                    } else {
+                        log.report(diag);
+                    }
+                    result = that.type = types.createErrorType(target);
+                    return;
                 }
-                result = that.type = types.createErrorType(target);
-                return;
             }
 
             if (desc.getReturnType() == Type.recoveryType) {
                 // stop here
-                result = that.type = types.createErrorType(target);
+                result = that.type = target;
                 return;
             }
 
@@ -2496,7 +2526,7 @@
                     resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
             checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
             if (!isSpeculativeRound) {
-                checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), desc);
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target);
             }
             result = check(that, target, VAL, resultInfo);
         } catch (Types.FunctionDescriptorLookupError ex) {
@@ -2530,7 +2560,7 @@
 
         if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
             if (resType.isErroneous() ||
-                    new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) {
+                    new LambdaReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
                 incompatibleReturnType = null;
             }
         }
@@ -3043,15 +3073,52 @@
                      Symbol sym,
                      Env<AttrContext> env,
                      ResultInfo resultInfo) {
-            Type pt = resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD) ?
-                    resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) :
-                    resultInfo.pt;
-
-            DeferredAttr.DeferredTypeMap recoveryMap =
-                    deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
-
+            return (resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD)) ?
+                    checkMethodId(tree, site, sym, env, resultInfo) :
+                    checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo);
+        }
+
+        Type checkMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            boolean isPolymorhicSignature =
+                sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types);
+            return isPolymorhicSignature ?
+                    checkSigPolyMethodId(tree, site, sym, env, resultInfo) :
+                    checkMethodIdInternal(tree, site, sym, env, resultInfo);
+        }
+
+        Type checkSigPolyMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            //recover original symbol for signature polymorphic methods
+            checkMethodIdInternal(tree, site, sym.baseSymbol(), env, resultInfo);
+            env.info.pendingResolutionPhase = Resolve.MethodResolutionPhase.BASIC;
+            return sym.type;
+        }
+
+        Type checkMethodIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase));
+            Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo);
+            resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase));
+            return owntype;
+        }
+
+        Type checkIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Type pt,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
             if (pt.isErroneous()) {
-                Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 return types.createErrorType(site);
             }
             Type owntype; // The computed type of this identifier occurrence.
@@ -3136,7 +3203,6 @@
                 break;
             }
             case PCK: case ERR:
-                Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 owntype = sym.type;
                 break;
             default:
@@ -3292,21 +3358,21 @@
             }
         }
 
-        if (env.info.defaultSuperCallSite != null &&
-                !types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true).contains(sym)) {
-            Symbol ovSym = null;
-            for (MethodSymbol msym : types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true)) {
-                if (msym.overrides(sym, msym.enclClass(), types, true)) {
-                    for (Type i : types.interfaces(env.enclClass.type)) {
-                        if (i.tsym.isSubClass(msym.owner, types)) {
-                            ovSym = i.tsym;
-                            break;
-                        }
-                    }
+        if (env.info.defaultSuperCallSite != null) {
+            for (Type sup : types.interfaces(env.enclClass.type).prepend(types.supertype((env.enclClass.type)))) {
+                if (!sup.tsym.isSubClass(sym.enclClass(), types) ||
+                        types.isSameType(sup, env.info.defaultSuperCallSite)) continue;
+                List<MethodSymbol> icand_sup =
+                        types.interfaceCandidates(sup, (MethodSymbol)sym);
+                if (icand_sup.nonEmpty() &&
+                        icand_sup.head != sym &&
+                        icand_sup.head.overrides(sym, icand_sup.head.enclClass(), types, true)) {
+                    log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
+                        diags.fragment("overridden.default", sym, sup));
+                    break;
                 }
             }
-            log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
-                    diags.fragment("overridden.default", sym, ovSym));
+            env.info.defaultSuperCallSite = null;
         }
 
         // Compute the identifier's instantiated type.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Wed Jul 05 18:30:46 2017 +0200
@@ -109,6 +109,7 @@
                 pendingResolutionPhase.isVarargsRequired();
     }
 
+    @Override
     public String toString() {
         return "AttrContext[" + scope.toString() + "]";
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 05 18:30:46 2017 +0200
@@ -120,8 +120,7 @@
         allowCovariantReturns = source.allowCovariantReturns();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
         allowDefaultMethods = source.allowDefaultMethods();
-        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() &&
-                options.isSet("strictMethodClashCheck"); //pre-lambda guard
+        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
         complexInference = options.isSet("complexinference");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -451,8 +450,6 @@
         public Infer.InferenceContext inferenceContext();
 
         public DeferredAttr.DeferredAttrContext deferredAttrContext();
-
-        public boolean allowBoxing();
     }
 
     /**
@@ -487,10 +484,6 @@
         public DeferredAttrContext deferredAttrContext() {
             return enclosingContext.deferredAttrContext();
         }
-
-        public boolean allowBoxing() {
-            return enclosingContext.allowBoxing();
-        }
     }
 
     /**
@@ -515,10 +508,6 @@
         public DeferredAttrContext deferredAttrContext() {
             return deferredAttr.emptyDeferredAttrContext;
         }
-
-        public boolean allowBoxing() {
-            return true;
-        }
     };
 
     /** Check that a given type is assignable to a given proto-type.
@@ -625,7 +614,7 @@
              a = types.upperBound(a);
              return types.isSubtype(a, bound);
          } else if (a.isExtendsBound()) {
-             return types.isCastable(bound, types.upperBound(a), Warner.noWarnings);
+             return types.isCastable(bound, types.upperBound(a), types.noWarnings);
          } else if (a.isSuperBound()) {
              return !types.notSoftSubtype(types.lowerBound(a), bound);
          }
@@ -909,19 +898,21 @@
                                   "unchecked.generic.array.creation",
                                   argtype);
             }
-            Type elemtype = types.elemtype(argtype);
-            switch (tree.getTag()) {
-                case APPLY:
-                    ((JCMethodInvocation) tree).varargsElement = elemtype;
-                    break;
-                case NEWCLASS:
-                    ((JCNewClass) tree).varargsElement = elemtype;
-                    break;
-                case REFERENCE:
-                    ((JCMemberReference) tree).varargsElement = elemtype;
-                    break;
-                default:
-                    throw new AssertionError(""+tree);
+            if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
+                Type elemtype = types.elemtype(argtype);
+                switch (tree.getTag()) {
+                    case APPLY:
+                        ((JCMethodInvocation) tree).varargsElement = elemtype;
+                        break;
+                    case NEWCLASS:
+                        ((JCNewClass) tree).varargsElement = elemtype;
+                        break;
+                    case REFERENCE:
+                        ((JCMemberReference) tree).varargsElement = elemtype;
+                        break;
+                    default:
+                        throw new AssertionError(""+tree);
+                }
             }
          }
          return owntype;
@@ -937,65 +928,6 @@
                 return;
         }
 
-        void checkAccessibleFunctionalDescriptor(DiagnosticPosition pos, Env<AttrContext> env, Type desc) {
-            AccessChecker accessChecker = new AccessChecker(env);
-            //check args accessibility (only if implicit parameter types)
-            for (Type arg : desc.getParameterTypes()) {
-                if (!accessChecker.visit(arg)) {
-                    log.error(pos, "cant.access.arg.type.in.functional.desc", arg);
-                    return;
-                }
-            }
-            //check return type accessibility
-            if (!accessChecker.visit(desc.getReturnType())) {
-                log.error(pos, "cant.access.return.in.functional.desc", desc.getReturnType());
-                return;
-            }
-            //check thrown types accessibility
-            for (Type thrown : desc.getThrownTypes()) {
-                if (!accessChecker.visit(thrown)) {
-                    log.error(pos, "cant.access.thrown.in.functional.desc", thrown);
-                    return;
-                }
-            }
-        }
-
-        class AccessChecker extends Types.UnaryVisitor<Boolean> {
-
-            Env<AttrContext> env;
-
-            AccessChecker(Env<AttrContext> env) {
-                this.env = env;
-            }
-
-            Boolean visit(List<Type> ts) {
-                for (Type t : ts) {
-                    if (!visit(t))
-                        return false;
-                }
-                return true;
-            }
-
-            public Boolean visitType(Type t, Void s) {
-                return true;
-            }
-
-            @Override
-            public Boolean visitArrayType(ArrayType t, Void s) {
-                return visit(t.elemtype);
-            }
-
-            @Override
-            public Boolean visitClassType(ClassType t, Void s) {
-                return rs.isAccessible(env, t, true) &&
-                        visit(t.getTypeArguments());
-            }
-
-            @Override
-            public Boolean visitWildcardType(WildcardType t, Void s) {
-                return visit(t.type);
-            }
-        };
     /**
      * Check that type 't' is a valid instantiation of a generic class
      * (see JLS 4.5)
@@ -1919,8 +1851,8 @@
                         types.isSameType(rt1, rt2) ||
                         !rt1.isPrimitiveOrVoid() &&
                         !rt2.isPrimitiveOrVoid() &&
-                        (types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
-                         types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
+                        (types.covariantReturnType(rt1, rt2, types.noWarnings) ||
+                         types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
                          checkCommonOverriderIn(s1,s2,site);
                     if (!compat) {
                         log.error(pos, "types.incompatible.diff.ret",
@@ -1965,8 +1897,8 @@
                     boolean compat =
                         !rt13.isPrimitiveOrVoid() &&
                         !rt23.isPrimitiveOrVoid() &&
-                        (types.covariantReturnType(rt13, rt1, Warner.noWarnings) &&
-                         types.covariantReturnType(rt23, rt2, Warner.noWarnings));
+                        (types.covariantReturnType(rt13, rt1, types.noWarnings) &&
+                         types.covariantReturnType(rt23, rt2, types.noWarnings));
                     if (compat)
                         return true;
                 }
@@ -2280,19 +2212,33 @@
         c.flags_field |= ACYCLIC;
     }
 
+    /**
+     * Check that functional interface methods would make sense when seen
+     * from the perspective of the implementing class
+     */
+    void checkFunctionalInterface(JCTree tree, Type funcInterface) {
+        ClassType c = new ClassType(Type.noType, List.<Type>nil(), null);
+        ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol);
+        c.interfaces_field = List.of(funcInterface);
+        c.supertype_field = syms.objectType;
+        c.tsym = csym;
+        csym.members_field = new Scope(csym);
+        csym.completer = null;
+        checkImplementations(tree, csym, csym);
+    }
+
     /** Check that all methods which implement some
      *  method conform to the method they implement.
      *  @param tree         The class definition whose members are checked.
      */
     void checkImplementations(JCClassDecl tree) {
-        checkImplementations(tree, tree.sym);
+        checkImplementations(tree, tree.sym, tree.sym);
     }
 //where
         /** Check that all methods which implement some
          *  method in `ic' conform to the method they implement.
          */
-        void checkImplementations(JCClassDecl tree, ClassSymbol ic) {
-            ClassSymbol origin = tree.sym;
+        void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) {
             for (List<Type> l = types.closure(ic.type); l.nonEmpty(); l = l.tail) {
                 ClassSymbol lc = (ClassSymbol)l.head.tsym;
                 if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Jul 05 18:30:46 2017 +0200
@@ -38,14 +38,13 @@
 import javax.tools.JavaFileObject;
 
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import java.util.WeakHashMap;
 
-import static com.sun.tools.javac.code.TypeTag.DEFERRED;
-import static com.sun.tools.javac.code.TypeTag.NONE;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
@@ -137,19 +136,6 @@
             }
 
             /**
-             * Clone a speculative cache entry as a fresh entry associated
-             * with a new method (this maybe required to fixup speculative cache
-             * misses after Resolve.access())
-             */
-            void dupAllTo(Symbol from, Symbol to) {
-                Assert.check(cache.get(to) == null);
-                List<Entry> entries = cache.get(from);
-                if (entries != null) {
-                    cache.put(to, entries);
-                }
-            }
-
-            /**
              * Retrieve a speculative cache entry corresponding to given symbol
              * and resolution phase
              */
@@ -194,7 +180,7 @@
             DeferredAttrContext deferredAttrContext =
                     resultInfo.checkContext.deferredAttrContext();
             Assert.check(deferredAttrContext != emptyDeferredAttrContext);
-            List<Type> stuckVars = stuckVars(tree, resultInfo);
+            List<Type> stuckVars = stuckVars(tree, env, resultInfo);
             if (stuckVars.nonEmpty()) {
                 deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
                 return Type.noType;
@@ -249,28 +235,25 @@
         JCTree newTree = new TreeCopier<Object>(make).copy(tree);
         Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
         speculativeEnv.info.scope.owner = env.info.scope.owner;
-        Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
-        Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
         final JavaFileObject currentSource = log.currentSourceFile();
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
+                new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
+            public boolean accepts(JCDiagnostic t) {
+                return t.getDiagnosticSource().getFile().equals(currentSource);
+            }
+        });
         try {
-            log.deferredDiagnostics = new ListBuffer<JCDiagnostic>();
-            log.deferredDiagFilter = new Filter<JCDiagnostic>() {
-                public boolean accepts(JCDiagnostic t) {
-                    return t.getDiagnosticSource().getFile().equals(currentSource);
-                }
-            };
             attr.attribTree(newTree, speculativeEnv, resultInfo);
             unenterScanner.scan(newTree);
             return newTree;
         } catch (Abort ex) {
             //if some very bad condition occurred during deferred attribution
             //we should dump all errors before killing javac
-            log.reportDeferredDiagnostics();
+            deferredDiagnosticHandler.reportDeferredDiagnostics();
             throw ex;
         } finally {
             unenterScanner.scan(newTree);
-            log.deferredDiagFilter = prevDeferDiagsFilter;
-            log.deferredDiagnostics = prevDeferredDiags;
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
         }
     }
     //where
@@ -278,6 +261,10 @@
             @Override
             public void visitClassDef(JCClassDecl tree) {
                 ClassSymbol csym = tree.sym;
+                //if something went wrong during method applicability check
+                //it is possible that nested expressions inside argument expression
+                //are left unchecked - in such cases there's nothing to clean up.
+                if (csym == null) return;
                 enter.typeEnvs.remove(csym);
                 chk.compiled.remove(csym.flatname);
                 syms.classes.remove(csym.flatname);
@@ -336,7 +323,7 @@
          */
         void complete() {
             while (!deferredAttrNodes.isEmpty()) {
-                Set<Type> stuckVars = new HashSet<Type>();
+                Set<Type> stuckVars = new LinkedHashSet<Type>();
                 boolean progress = false;
                 //scan a defensive copy of the node list - this is because a deferred
                 //attribution round can add new nodes to the list
@@ -410,7 +397,7 @@
 
     /** an empty deferred attribution context - all methods throw exceptions */
     final DeferredAttrContext emptyDeferredAttrContext =
-            new DeferredAttrContext(null, null, null, null) {
+            new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, null) {
                 @Override
                 void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List<Type> stuckVars) {
                     Assert.error("Empty deferred context!");
@@ -474,13 +461,13 @@
     public class RecoveryDeferredTypeMap extends DeferredTypeMap {
 
         public RecoveryDeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
-            super(mode, msym, phase);
+            super(mode, msym, phase != null ? phase : MethodResolutionPhase.BOX);
         }
 
         @Override
         protected Type typeOf(DeferredType dt) {
             Type owntype = super.typeOf(dt);
-            return owntype.hasTag(NONE) ?
+            return owntype == Type.noType ?
                         recover(dt) : owntype;
         }
 
@@ -498,16 +485,7 @@
          */
         private Type recover(DeferredType dt) {
             dt.check(attr.new RecoveryInfo(deferredAttrContext));
-            switch (TreeInfo.skipParens(dt.tree).getTag()) {
-                case LAMBDA:
-                case REFERENCE:
-                case CONDEXPR:
-                    //propagate those deferred types to the
-                    //diagnostic formatter
-                    return dt;
-                default:
-                    return super.apply(dt);
-            }
+            return super.apply(dt);
         }
     }
 
@@ -516,11 +494,11 @@
      * an AST node can be type-checked
      */
     @SuppressWarnings("fallthrough")
-    List<Type> stuckVars(JCTree tree, ResultInfo resultInfo) {
-        if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
+    List<Type> stuckVars(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
+                if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
             return List.nil();
         } else {
-            StuckChecker sc = new StuckChecker(resultInfo);
+            StuckChecker sc = new StuckChecker(resultInfo, env);
             sc.scan(tree);
             return List.from(sc.stuckVars);
         }
@@ -537,7 +515,8 @@
         Type pt;
         Filter<JCTree> treeFilter;
         Infer.InferenceContext inferenceContext;
-        Set<Type> stuckVars = new HashSet<Type>();
+        Set<Type> stuckVars = new LinkedHashSet<Type>();
+        Env<AttrContext> env;
 
         final Filter<JCTree> argsFilter = new Filter<JCTree>() {
             public boolean accepts(JCTree t) {
@@ -566,10 +545,11 @@
             }
         };
 
-        StuckChecker(ResultInfo resultInfo) {
+        StuckChecker(ResultInfo resultInfo, Env<AttrContext> env) {
             this.pt = resultInfo.pt;
             this.inferenceContext = resultInfo.checkContext.inferenceContext();
             this.treeFilter = argsFilter;
+            this.env = env;
         }
 
         @Override
@@ -619,6 +599,7 @@
             if (!types.isFunctionalInterface(pt.tsym)) {
                 return;
             }
+
             Type descType = types.findDescriptorType(pt);
             List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
             stuckVars.addAll(freeArgVars);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,6 +122,7 @@
         return env1;
     }
 
+    @Override
     public String toString() {
         return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Jul 05 18:30:46 2017 +0200
@@ -213,24 +213,21 @@
     }
 
     public void analyzeLambda(Env<AttrContext> env, JCLambda that, TreeMaker make, boolean speculative) {
-        java.util.Queue<JCDiagnostic> prevDeferredDiagnostics = log.deferredDiagnostics;
-        Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
+        Log.DiagnosticHandler diagHandler = null;
         //we need to disable diagnostics temporarily; the problem is that if
         //a lambda expression contains e.g. an unreachable statement, an error
         //message will be reported and will cause compilation to skip the flow analyis
         //step - if we suppress diagnostics, we won't stop at Attr for flow-analysis
         //related errors, which will allow for more errors to be detected
         if (!speculative) {
-            log.deferAll();
-            log.deferredDiagnostics = ListBuffer.lb();
+            diagHandler = new Log.DiscardDiagnosticHandler(log);
         }
         try {
             new AliveAnalyzer().analyzeTree(env, that, make);
             new FlowAnalyzer().analyzeTree(env, that, make);
         } finally {
             if (!speculative) {
-                log.deferredDiagFilter = prevDeferDiagsFilter;
-                log.deferredDiagnostics = prevDeferredDiagnostics;
+                log.popDiagnosticHandler(diagHandler);
             }
         }
     }
@@ -275,9 +272,7 @@
         Source source = Source.instance(context);
         allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
         allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
-        Options options = Options.instance(context);
-        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses() &&
-                options.isSet("allowEffectivelyFinalInInnerClasses"); //pre-lambda guard
+        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses();
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 18:30:46 2017 +0200
@@ -501,10 +501,10 @@
                 }
                 for (Type t : funcInterfaceContext.undetvars) {
                     UndetVar uv = (UndetVar)t;
-                    minimizeInst(uv, Warner.noWarnings);
+                    minimizeInst(uv, types.noWarnings);
                     if (uv.inst == null &&
                             Type.filter(uv.getBounds(InferenceBound.UPPER), boundFilter).nonEmpty()) {
-                        maximizeInst(uv, Warner.noWarnings);
+                        maximizeInst(uv, types.noWarnings);
                     }
                 }
 
@@ -801,7 +801,7 @@
             for (Type t : varsToSolve) {
                 UndetVar uv = (UndetVar)asFree(t, types);
                 if (uv.inst == null) {
-                    infer.minimizeInst(uv, Warner.noWarnings);
+                    infer.minimizeInst(uv, types.noWarnings);
                     if (uv.inst != null) {
                         progress = true;
                     }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1120,10 +1120,10 @@
             if (context != null
                     && tree.encl == null
                     && tree.def == null
-                    && tree.type.getEnclosingType().hasTag(NONE)) {
+                    && !tree.type.getEnclosingType().hasTag(NONE)) {
                 Type encl = tree.type.getEnclosingType();
                 Type current = context.owner.enclClass().type;
-                while (current.hasTag(NONE)) {
+                while (!current.hasTag(NONE)) {
                     if (current.tsym.isSubClass(encl.tsym, types)) {
                         return true;
                     }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 05 18:30:46 2017 +0200
@@ -682,7 +682,7 @@
     /** Look up a method in a given scope.
      */
     private MethodSymbol lookupMethod(DiagnosticPosition pos, Name name, Type qual, List<Type> args) {
-        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, null);
+        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, List.<Type>nil());
     }
 
     /** Look up a constructor.
@@ -3636,13 +3636,13 @@
         boolean qualifiedSuperAccess =
             tree.selected.hasTag(SELECT) &&
             TreeInfo.name(tree.selected) == names._super &&
-            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type, currentClass);
+            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass);
         tree.selected = translate(tree.selected);
         if (tree.name == names._class) {
             result = classOf(tree.selected);
         }
         else if (tree.name == names._super &&
-                types.isDirectSuperInterface(tree.selected.type, currentClass)) {
+                types.isDirectSuperInterface(tree.selected.type.tsym, currentClass)) {
             //default super call!! Not a classic qualified super call
             TypeSymbol supSym = tree.selected.type.tsym;
             Assert.checkNonNull(types.asSuper(currentClass.type, supSym));
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 18:30:46 2017 +0200
@@ -427,6 +427,60 @@
             return c != null;
         }
 
+    /**
+     * Performs a recursive scan of a type looking for accessibility problems
+     * from current attribution environment
+     */
+    void checkAccessibleType(Env<AttrContext> env, Type t) {
+        accessibilityChecker.visit(t, env);
+    }
+
+    /**
+     * Accessibility type-visitor
+     */
+    Types.SimpleVisitor<Void, Env<AttrContext>> accessibilityChecker =
+            new Types.SimpleVisitor<Void, Env<AttrContext>>() {
+
+        void visit(List<Type> ts, Env<AttrContext> env) {
+            for (Type t : ts) {
+                visit(t, env);
+            }
+        }
+
+        public Void visitType(Type t, Env<AttrContext> env) {
+            return null;
+        }
+
+        @Override
+        public Void visitArrayType(ArrayType t, Env<AttrContext> env) {
+            visit(t.elemtype, env);
+            return null;
+        }
+
+        @Override
+        public Void visitClassType(ClassType t, Env<AttrContext> env) {
+            visit(t.getTypeArguments(), env);
+            if (!isAccessible(env, t, true)) {
+                accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitWildcardType(WildcardType t, Env<AttrContext> env) {
+            visit(t.type, env);
+            return null;
+        }
+
+        @Override
+        public Void visitMethodType(MethodType t, Env<AttrContext> env) {
+            visit(t.getParameterTypes(), env);
+            visit(t.getReturnType(), env);
+            visit(t.getThrownTypes(), env);
+            return null;
+        }
+    };
+
     /** Try to instantiate the type of a method so that it fits
      *  given type arguments and argument types. If succesful, return
      *  the method's instantiated type, else return null.
@@ -750,10 +804,6 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isSubtypeUnchecked(found, inferenceContext.asFree(req, types), warn);
         }
-
-        public boolean allowBoxing() {
-            return false;
-        }
     }
 
     /**
@@ -770,10 +820,6 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isConvertible(found, inferenceContext.asFree(req, types), warn);
         }
-
-        public boolean allowBoxing() {
-            return true;
-        }
     }
 
     /**
@@ -792,7 +838,7 @@
 
         DeferredAttr.DeferredAttrContext deferredAttrContext;
 
-        public MethodResultInfo(Type pt, MethodCheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
+        public MethodResultInfo(Type pt, CheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
             attr.super(VAL, pt, checkContext);
             this.deferredAttrContext = deferredAttrContext;
         }
@@ -809,7 +855,12 @@
 
         @Override
         protected MethodResultInfo dup(Type newPt) {
-            return new MethodResultInfo(newPt, (MethodCheckContext)checkContext, deferredAttrContext);
+            return new MethodResultInfo(newPt, checkContext, deferredAttrContext);
+        }
+
+        @Override
+        protected ResultInfo dup(CheckContext newContext) {
+            return new MethodResultInfo(pt, newContext, deferredAttrContext);
         }
     }
 
@@ -1020,7 +1071,7 @@
         Assert.check(sym.kind < AMBIGUOUS);
         try {
             Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
-                               allowBoxing, useVarargs, Warner.noWarnings);
+                               allowBoxing, useVarargs, types.noWarnings);
             if (!operator)
                 currentResolutionContext.addApplicableCandidate(sym, mt);
         } catch (InapplicableMethodException ex) {
@@ -1731,7 +1782,7 @@
 
     /** Find an unqualified identifier which matches a specified kind set.
      *  @param env       The current environment.
-     *  @param name      The indentifier's name.
+     *  @param name      The identifier's name.
      *  @param kind      Indicates the possible symbol kinds
      *                   (a subset of VAL, TYP, PCK).
      */
@@ -1921,28 +1972,31 @@
                         (typeargtypes == null || !Type.isErroneous(typeargtypes));
         }
         public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) {
-            if (syms.operatorNames.contains(name)) {
-                return argtypes;
-            } else {
-                Symbol msym = errSym.kind == WRONG_MTH ?
-                        ((InapplicableSymbolError)errSym).errCandidate().sym : accessedSym;
-
-                List<Type> argtypes2 = Type.map(argtypes,
-                        deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.step));
-
-                if (msym != accessedSym) {
-                    //fixup deferred type caches - this 'hack' is required because the symbol
-                    //returned by InapplicableSymbolError.access() will hide the candidate
-                    //method symbol that can be used for lookups in the speculative cache,
-                    //causing problems in Attr.checkId()
-                    for (Type t : argtypes) {
-                        if (t.hasTag(DEFERRED)) {
-                            DeferredType dt = (DeferredType)t;
-                            dt.speculativeCache.dupAllTo(msym, accessedSym);
-                        }
+            return (syms.operatorNames.contains(name)) ?
+                    argtypes :
+                    Type.map(argtypes, new ResolveDeferredRecoveryMap(accessedSym));
+        }
+
+        class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap {
+
+            public ResolveDeferredRecoveryMap(Symbol msym) {
+                deferredAttr.super(AttrMode.SPECULATIVE, msym, currentResolutionContext.step);
+            }
+
+            @Override
+            protected Type typeOf(DeferredType dt) {
+                Type res = super.typeOf(dt);
+                if (!res.isErroneous()) {
+                    switch (TreeInfo.skipParens(dt.tree).getTag()) {
+                        case LAMBDA:
+                        case REFERENCE:
+                            return dt;
+                        case CONDEXPR:
+                            return res == Type.recoveryType ?
+                                    dt : res;
                     }
                 }
-                return argtypes2;
+                return res;
             }
         }
     };
@@ -2069,7 +2123,6 @@
                 } else if (allowMethodHandles) {
                     MethodSymbol msym = (MethodSymbol)sym;
                     if (msym.isSignaturePolymorphic(types)) {
-                        env.info.pendingResolutionPhase = BASIC;
                         return findPolymorphicSignatureInstance(env, sym, argtypes);
                     }
                 }
@@ -2086,7 +2139,7 @@
      *  @param argtypes  The required argument types
      */
     Symbol findPolymorphicSignatureInstance(Env<AttrContext> env,
-                                            Symbol spMethod,
+                                            final Symbol spMethod,
                                             List<Type> argtypes) {
         Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
                 (MethodSymbol)spMethod, currentResolutionContext, argtypes);
@@ -2098,7 +2151,12 @@
 
         // create the desired method
         long flags = ABSTRACT | HYPOTHETICAL | spMethod.flags() & Flags.AccessFlags;
-        Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner);
+        Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner) {
+            @Override
+            public Symbol baseSymbol() {
+                return spMethod;
+            }
+        };
         polymorphicSignatureScope.enter(msym);
         return msym;
     }
@@ -2707,7 +2765,7 @@
         }
         if (allowDefaultMethods && c.isInterface() &&
                 name == names._super && !isStatic(env) &&
-                types.isDirectSuperInterface(c.type, env.enclClass.sym)) {
+                types.isDirectSuperInterface(c, env.enclClass.sym)) {
             //this might be a default super call if one of the superinterfaces is 'c'
             for (Type t : pruneInterfaces(env.enclClass.type)) {
                 if (t.tsym == c) {
@@ -3150,7 +3208,7 @@
                         "cant.apply.symbols",
                         name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
                         name == names.init ? site.tsym.name : name,
-                        argtypes);
+                        methodArguments(argtypes));
                 return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
             } else {
                 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 18:30:46 2017 +0200
@@ -133,7 +133,7 @@
     JCExpression coerce(JCExpression tree, Type target) {
         Type btarget = target.baseType();
         if (tree.type.isPrimitive() == target.isPrimitive()) {
-            return types.isAssignable(tree.type, btarget, Warner.noWarnings)
+            return types.isAssignable(tree.type, btarget, types.noWarnings)
                 ? tree
                 : cast(tree, btarget);
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Wed Jul 05 18:30:46 2017 +0200
@@ -104,7 +104,8 @@
         V45_3(45, 3), // base level for all attributes
         V49(49, 0),   // JDK 1.5: enum, generics, annotations
         V50(50, 0),   // JDK 1.6: stackmaps
-        V51(51, 0);   // JDK 1.7
+        V51(51, 0),   // JDK 1.7
+        V52(52, 0);   // JDK 1.8: lambda, type annos, param names
         Version(int major, int minor) {
             this.major = major;
             this.minor = minor;
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jul 05 18:30:46 2017 +0200
@@ -941,18 +941,6 @@
 
             new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
                 protected void read(Symbol sym, int attrLen) {
-                    if (currentOwner.isInterface() &&
-                            (sym.flags_field & ABSTRACT) == 0 && !name.equals(names.clinit)) {
-                        if (majorVersion > Target.JDK1_8.majorVersion ||
-                                //todo replace with Target.Version when available
-                                (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
-                            currentOwner.flags_field |= DEFAULT;
-                            sym.flags_field |= DEFAULT | ABSTRACT;
-                        } else {
-                            //protect against ill-formed classfiles
-                            throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
-                        }
-                    }
                     if (readAllOfClassFile || saveParameterNames)
                         ((MethodSymbol)sym).code = readCode(sym);
                     else
@@ -1753,6 +1741,17 @@
         long flags = adjustMethodFlags(nextChar());
         Name name = readName(nextChar());
         Type type = readType(nextChar());
+        if (currentOwner.isInterface() &&
+                (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
+            if (majorVersion > Target.JDK1_8.majorVersion ||
+                    (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
+                currentOwner.flags_field |= DEFAULT;
+                flags |= DEFAULT | ABSTRACT;
+            } else {
+                //protect against ill-formed classfiles
+                throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
+            }
+        }
         if (name == names.init && currentOwner.hasOuterInstance()) {
             // Sometimes anonymous classes don't have an outer
             // instance, however, there is no reliable way to tell so
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -157,13 +157,20 @@
         if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
             return false;
 
+        /* temporary code for backwards compatibility */
         for (Attribute.Compound a: c.annotations.getAttributes()) {
-            if (a.type.tsym == syms.nativeHeaderType.tsym)
+            if (a.type.tsym == syms.nativeHeaderType_old.tsym)
                 return true;
         }
+        /* end of temporary code for backwards compatibility */
+
         for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
             if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0)
                 return true;
+            for (Attribute.Compound a: i.sym.annotations.getAttributes()) {
+                if (a.type.tsym == syms.nativeHeaderType.tsym)
+                    return true;
+            }
         }
         if (checkNestedClasses) {
             for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Wed Jul 05 18:30:46 2017 +0200
@@ -95,10 +95,7 @@
      *  package.  Return the object's index in the pool.
      */
     public int put(Object value) {
-        if (value instanceof MethodSymbol)
-            value = new Method((MethodSymbol)value);
-        else if (value instanceof VarSymbol)
-            value = new Variable((VarSymbol)value);
+        value = makePoolValue(value);
 //      assert !(value instanceof Type.TypeVar);
         Integer index = indices.get(value);
         if (index == null) {
@@ -115,6 +112,18 @@
         return index.intValue();
     }
 
+    Object makePoolValue(Object o) {
+        if (o instanceof DynamicMethodSymbol) {
+            return new DynamicMethod((DynamicMethodSymbol)o);
+        } else if (o instanceof MethodSymbol) {
+            return new Method((MethodSymbol)o);
+        } else if (o instanceof VarSymbol) {
+            return new Variable((VarSymbol)o);
+        } else {
+            return o;
+        }
+    }
+
     /** Return the given object's index in the pool,
      *  or -1 if object is not in there.
      */
@@ -145,6 +154,36 @@
         }
     }
 
+    static class DynamicMethod extends Method {
+
+        DynamicMethod(DynamicMethodSymbol m) {
+            super(m);
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!super.equals(other)) return false;
+            if (!(other instanceof DynamicMethod)) return false;
+            DynamicMethodSymbol dm1 = (DynamicMethodSymbol)m;
+            DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)other).m;
+            return dm1.bsm == dm2.bsm &&
+                        dm1.bsmKind == dm2.bsmKind &&
+                        Arrays.equals(dm1.staticArgs, dm2.staticArgs);
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = super.hashCode();
+            DynamicMethodSymbol dm = (DynamicMethodSymbol)m;
+            hash += dm.bsmKind * 7 +
+                    dm.bsm.hashCode() * 11;
+            for (int i = 0; i < dm.staticArgs.length; i++) {
+                hash += (dm.staticArgs[i].hashCode() * 23);
+            }
+            return hash;
+        }
+    }
+
     static class Variable extends DelegatedSymbol {
         VarSymbol v;
         Variable(VarSymbol v) {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1018,6 +1018,8 @@
      */
     boolean processAnnotations = false;
 
+    Log.DeferredDiagnosticHandler deferredDiagnosticHandler;
+
     /**
      * Object to handle annotation processing.
      */
@@ -1038,7 +1040,8 @@
         if (options.isSet(PROC, "none")) {
             processAnnotations = false;
         } else if (procEnvImpl == null) {
-            procEnvImpl = new JavacProcessingEnvironment(context, processors);
+            procEnvImpl = JavacProcessingEnvironment.instance(context);
+            procEnvImpl.setProcessors(processors);
             processAnnotations = procEnvImpl.atLeastOneProcessor();
 
             if (processAnnotations) {
@@ -1048,7 +1051,7 @@
                 genEndPos = true;
                 if (!taskListener.isEmpty())
                     taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
-                log.deferAll();
+                deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
             } else { // free resources
                 procEnvImpl.close();
             }
@@ -1079,7 +1082,8 @@
             // or other errors during enter which cannot be fixed by running
             // any annotation processors.
             if (unrecoverableError()) {
-                log.reportDeferredDiagnostics();
+                deferredDiagnosticHandler.reportDeferredDiagnostics();
+                log.popDiagnosticHandler(deferredDiagnosticHandler);
                 return this;
             }
         }
@@ -1102,10 +1106,12 @@
                 log.error("proc.no.explicit.annotation.processing.requested",
                           classnames);
             }
-            log.reportDeferredDiagnostics();
+            Assert.checkNull(deferredDiagnosticHandler);
             return this; // continue regular compilation
         }
 
+        Assert.checkNonNull(deferredDiagnosticHandler);
+
         try {
             List<ClassSymbol> classSymbols = List.nil();
             List<PackageSymbol> pckSymbols = List.nil();
@@ -1115,7 +1121,8 @@
                 if (!explicitAnnotationProcessingRequested()) {
                     log.error("proc.no.explicit.annotation.processing.requested",
                               classnames);
-                    log.reportDeferredDiagnostics();
+                    deferredDiagnosticHandler.reportDeferredDiagnostics();
+                    log.popDiagnosticHandler(deferredDiagnosticHandler);
                     return this; // TODO: Will this halt compilation?
                 } else {
                     boolean errors = false;
@@ -1148,33 +1155,36 @@
                         }
                     }
                     if (errors) {
-                        log.reportDeferredDiagnostics();
+                        deferredDiagnosticHandler.reportDeferredDiagnostics();
+                        log.popDiagnosticHandler(deferredDiagnosticHandler);
                         return this;
                     }
                 }
             }
             try {
-                JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
+                JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols,
+                        deferredDiagnosticHandler);
                 if (c != this)
                     annotationProcessingOccurred = c.annotationProcessingOccurred = true;
                 // doProcessing will have handled deferred diagnostics
-                Assert.check(c.log.deferredDiagFilter == null
-                        && c.log.deferredDiagnostics.size() == 0);
                 return c;
             } finally {
                 procEnvImpl.close();
             }
         } catch (CompletionFailure ex) {
             log.error("cant.access", ex.sym, ex.getDetailValue());
-            log.reportDeferredDiagnostics();
+            deferredDiagnosticHandler.reportDeferredDiagnostics();
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
             return this;
         }
     }
 
     private boolean unrecoverableError() {
-        for (JCDiagnostic d: log.deferredDiagnostics) {
-            if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
-                return true;
+        if (deferredDiagnosticHandler != null) {
+            for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
+                if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
+                    return true;
+            }
         }
         return false;
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Wed Jul 05 18:30:46 2017 +0200
@@ -33,24 +33,29 @@
 import java.security.MessageDigest;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
+import java.util.ServiceLoader;
 import java.util.Set;
+
+import javax.annotation.processing.Processor;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
-import javax.annotation.processing.Processor;
 
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Plugin;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.file.CacheFSInfo;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.processing.AnnotationProcessingError;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.Log.WriterKind;
 import com.sun.tools.javac.util.Log.PrefixKind;
-import com.sun.tools.javac.processing.AnnotationProcessingError;
-
+import com.sun.tools.javac.util.Log.WriterKind;
 import static com.sun.tools.javac.main.Option.*;
 
-/** This class provides a commandline interface to the GJC compiler.
+/** This class provides a command line interface to the javac compiler.
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
@@ -423,6 +428,42 @@
             if (batchMode)
                 CacheFSInfo.preRegister(context);
 
+            // invoke any available plugins
+            String plugins = options.get(PLUGIN);
+            if (plugins != null) {
+                JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context);
+                ClassLoader cl = pEnv.getProcessorClassLoader();
+                ServiceLoader<Plugin> sl = ServiceLoader.load(Plugin.class, cl);
+                Set<List<String>> pluginsToCall = new LinkedHashSet<List<String>>();
+                for (String plugin: plugins.split("\\x00")) {
+                    pluginsToCall.add(List.from(plugin.split("\\s+")));
+                }
+                JavacTask task = null;
+                Iterator<Plugin> iter = sl.iterator();
+                while (iter.hasNext()) {
+                    Plugin plugin = iter.next();
+                    for (List<String> p: pluginsToCall) {
+                        if (plugin.getName().equals(p.head)) {
+                            pluginsToCall.remove(p);
+                            try {
+                                if (task == null)
+                                    task = JavacTask.instance(pEnv);
+                                plugin.call(task, p.tail.toArray(new String[p.tail.size()]));
+                            } catch (Throwable ex) {
+                                if (apiMode)
+                                    throw new RuntimeException(ex);
+                                pluginMessage(ex);
+                                return Result.SYSERR;
+                            }
+
+                        }
+                    }
+                }
+                for (List<String> p: pluginsToCall) {
+                    log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head);
+                }
+            }
+
             fileManager = context.get(JavaFileManager.class);
 
             comp = JavaCompiler.instance(context);
@@ -537,6 +578,14 @@
         ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
     }
 
+    /** Print a message reporting an uncaught exception from an
+     * annotation processor.
+     */
+    void pluginMessage(Throwable ex) {
+        log.printLines(PrefixKind.JAVAC, "msg.plugin.uncaught.exception");
+        ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
+    }
+
     /** Display the location and checksum of a class. */
     void showClass(String className) {
         PrintWriter pw = log.getWriter(WriterKind.NOTICE);
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 18:30:46 2017 +0200
@@ -393,6 +393,16 @@
     /* -Xjcov produces tables to support the code coverage tool jcov. */
     XJCOV("-Xjcov", null, HIDDEN, BASIC),
 
+    PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            String p = option.substring(option.indexOf(':') + 1);
+            String prev = helper.get(PLUGIN);
+            helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
+            return false;
+        }
+    },
+
     /* This is a back door to the compiler's option table.
      * -XDx=y sets the option x to the value y.
      * -XDx sets the option x to the value x.
--- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -253,7 +253,8 @@
             for (File f: files)
                 pl.add(f.toPath());
         }
-        pathsForLocation.put(locn, pl);
+        if (!pl.isEmpty())
+            pathsForLocation.put(locn, pl);
     }
 
     private void lazyInitSearchPaths() {
@@ -513,7 +514,8 @@
     }
 
     private static String getRelativePath(String packageName, String relativeName) {
-        return packageName.replace(".", "/") + relativeName;
+        return packageName.isEmpty()
+                ? relativeName : packageName.replace(".", "/") + "/" + relativeName;
     }
 
     private static String getBaseName(String relativePath) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,1288 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.parser;
+
+import com.sun.tools.javac.util.Filter;
+import java.text.BreakIterator;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.tools.javac.parser.DocCommentParser.TagParser.Kind;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.parser.Tokens.TokenKind;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCAttribute;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCEndElement;
+import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DCTree.DCIdentifier;
+import com.sun.tools.javac.tree.DCTree.DCReference;
+import com.sun.tools.javac.tree.DCTree.DCStartElement;
+import com.sun.tools.javac.tree.DCTree.DCText;
+import com.sun.tools.javac.tree.DocTreeMaker;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.Position;
+import static com.sun.tools.javac.util.LayoutCharacters.*;
+
+/**
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class DocCommentParser {
+    static class ParseException extends Exception {
+        private static final long serialVersionUID = 0;
+        ParseException(String key) {
+            super(key);
+        }
+    }
+
+    final ParserFactory fac;
+    final DiagnosticSource diagSource;
+    final Comment comment;
+    final DocTreeMaker m;
+    final Names names;
+
+    BreakIterator sentenceBreaker;
+
+    /** The input buffer, index of most recent character read,
+     *  index of one past last character in buffer.
+     */
+    protected char[] buf;
+    protected int bp;
+    protected int buflen;
+
+    /** The current character.
+     */
+    protected char ch;
+
+    int textStart = -1;
+    int lastNonWhite = -1;
+    boolean newline = true;
+
+    Map<Name, TagParser> tagParsers;
+
+    DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) {
+        this.fac = fac;
+        this.diagSource = diagSource;
+        this.comment = comment;
+        names = fac.names;
+        m = fac.docTreeMaker;
+
+        Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale;
+
+        Options options = fac.options;
+        boolean useBreakIterator = options.isSet("breakIterator");
+        if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage()))
+            sentenceBreaker = BreakIterator.getSentenceInstance(locale);
+
+        initTagParsers();
+    }
+
+    DCDocComment parse() {
+        String c = comment.getText();
+        buf = new char[c.length() + 1];
+        c.getChars(0, c.length(), buf, 0);
+        buf[buf.length - 1] = EOI;
+        buflen = buf.length - 1;
+        bp = -1;
+        nextChar();
+
+        List<DCTree> body = blockContent();
+        List<DCTree> tags = blockTags();
+
+        // split body into first sentence and body
+        ListBuffer<DCTree> fs = new ListBuffer<DCTree>();
+        loop:
+        for (; body.nonEmpty(); body = body.tail) {
+            DCTree t = body.head;
+            switch (t.getKind()) {
+                case TEXT:
+                    String s = ((DCText) t).getBody();
+                    int i = getSentenceBreak(s);
+                    if (i > 0) {
+                        int i0 = i;
+                        while (i0 > 0 && isWhitespace(s.charAt(i0 - 1)))
+                            i0--;
+                        fs.add(m.at(t.pos).Text(s.substring(0, i0)));
+                        int i1 = i;
+                        while (i1 < s.length() && isWhitespace(s.charAt(i1)))
+                            i1++;
+                        body = body.tail;
+                        if (i1 < s.length())
+                            body = body.prepend(m.at(t.pos + i1).Text(s.substring(i1)));
+                        break loop;
+                    } else if (body.tail.nonEmpty()) {
+                        if (isSentenceBreak(body.tail.head)) {
+                            int i0 = s.length() - 1;
+                            while (i0 > 0 && isWhitespace(s.charAt(i0)))
+                                i0--;
+                            fs.add(m.at(t.pos).Text(s.substring(0, i0 + 1)));
+                            body = body.tail;
+                            break loop;
+                        }
+                    }
+                    break;
+
+                case START_ELEMENT:
+                case END_ELEMENT:
+                    if (isSentenceBreak(t))
+                        break loop;
+                    break;
+            }
+            fs.add(t);
+        }
+
+        @SuppressWarnings("unchecked")
+        DCTree first = getFirst(fs.toList(), body, tags);
+        int pos = (first == null) ? Position.NOPOS : first.pos;
+
+        DCDocComment dc = m.at(pos).DocComment(comment, fs.toList(), body, tags);
+        return dc;
+    }
+
+    void nextChar() {
+        ch = buf[bp < buflen ? ++bp : buflen];
+        switch (ch) {
+            case '\f': case '\n': case '\r':
+                newline = true;
+        }
+    }
+
+    /**
+     * Read block content, consisting of text, html and inline tags.
+     * Terminated by the end of input, or the beginning of the next block tag:
+     * i.e. @ as the first non-whitespace character on a line.
+     */
+    @SuppressWarnings("fallthrough")
+    protected List<DCTree> blockContent() {
+        ListBuffer<DCTree> trees = new ListBuffer<DCTree>();
+        textStart = -1;
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fallthrough
+
+                case ' ': case '\t':
+                    nextChar();
+                    break;
+
+                case '&':
+                    entity(trees);
+                    break;
+
+                case '<':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(html());
+                    if (textStart == -1) {
+                        textStart = bp;
+                        lastNonWhite = -1;
+                    }
+                    break;
+
+                case '>':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(m.at(bp).Erroneous(newString(bp, bp+1), diagSource, "dc.bad.gt"));
+                    nextChar();
+                    if (textStart == -1) {
+                        textStart = bp;
+                        lastNonWhite = -1;
+                    }
+                    break;
+
+                case '{':
+                    inlineTag(trees);
+                    break;
+
+                case '@':
+                    if (newline) {
+                        addPendingText(trees, lastNonWhite);
+                        break loop;
+                    }
+                    // fallthrough
+
+                default:
+                    newline = false;
+                    if (textStart == -1)
+                        textStart = bp;
+                    lastNonWhite = bp;
+                    nextChar();
+            }
+        }
+
+        if (lastNonWhite != -1)
+            addPendingText(trees, lastNonWhite);
+
+        return trees.toList();
+    }
+
+    /**
+     * Read a series of block tags, including their content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     */
+    protected List<DCTree> blockTags() {
+        ListBuffer<DCTree> tags = new ListBuffer<DCTree>();
+        while (ch == '@')
+            tags.add(blockTag());
+        return tags.toList();
+    }
+
+    /**
+     * Read a single block tag, including its content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     */
+    protected DCTree blockTag() {
+        int p = bp;
+        try {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                int namePos = bp;
+                nextChar();
+                while (isIdentifierPart(ch))
+                    nextChar();
+                int nameLen = bp - namePos;
+
+                Name name = names.fromChars(buf, namePos, nameLen);
+                TagParser tp = tagParsers.get(name);
+                if (tp == null) {
+                    List<DCTree> content = blockContent();
+                    return m.at(p).UnknownBlockTag(name, content);
+                } else {
+                    switch (tp.getKind()) {
+                        case BLOCK:
+                            return tp.parse(p);
+                        case INLINE:
+                            return erroneous("dc.bad.inline.tag", p);
+                    }
+                }
+            }
+            blockContent();
+
+            return erroneous("dc.no.tag.name", p);
+        } catch (ParseException e) {
+            blockContent();
+            return erroneous(e.getMessage(), p);
+        }
+    }
+
+    protected void inlineTag(ListBuffer<DCTree> list) {
+        newline = false;
+        nextChar();
+        if (ch == '@') {
+            addPendingText(list, bp - 2);
+            list.add(inlineTag());
+            textStart = bp;
+            lastNonWhite = -1;
+        } else {
+            if (textStart == -1)
+                textStart = bp - 1;
+            lastNonWhite = bp;
+        }
+    }
+
+    /**
+     * Read a single inline tag, including its content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     * Malformed tags may be returned as {@link Erroneous}.
+     */
+    protected DCTree inlineTag() {
+        int p = bp - 1;
+        try {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                int namePos = bp;
+                nextChar();
+                while (isIdentifierPart(ch))
+                    nextChar();
+                int nameLen = bp - namePos;
+                skipWhitespace();
+
+                Name name = names.fromChars(buf, namePos, nameLen);
+                TagParser tp = tagParsers.get(name);
+                if (tp == null) {
+                    DCTree text = inlineText();
+                    if (text != null) {
+                        nextChar();
+                        return m.at(p).UnknownInlineTag(name, List.of(text));
+                    }
+                } else if (tp.getKind() == TagParser.Kind.INLINE) {
+                    DCTree tree =  tp.parse(p);
+                    if (tree != null) {
+                        return tree;
+                    }
+                } else {
+                    inlineText(); // skip content
+                    nextChar();
+                }
+            }
+            return erroneous("dc.no.tag.name", p);
+        } catch (ParseException e) {
+            return erroneous(e.getMessage(), p);
+        }
+    }
+
+    /**
+     * Read plain text content of an inline tag.
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    protected DCTree inlineText() throws ParseException {
+        skipWhitespace();
+        int pos = bp;
+        int depth = 1;
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    break;
+
+                case ' ': case '\t':
+                    break;
+
+                case '{':
+                    newline = false;
+                    lastNonWhite = bp;
+                    depth++;
+                    break;
+
+                case '}':
+                    if (--depth == 0) {
+                        return m.at(pos).Text(newString(pos, bp));
+                    }
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+
+                default:
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+            }
+            nextChar();
+        }
+        throw new ParseException("dc.unterminated.inline.tag");
+    }
+
+    /**
+     * Read Java class name, possibly followed by member
+     * Matching pairs of < > are skipped. The text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    // TODO: boolean allowMember should be enum FORBID, ALLOW, REQUIRE
+    // TODO: improve quality of parse to forbid bad constructions.
+    @SuppressWarnings("fallthrough")
+    protected DCReference reference(boolean allowMember) throws ParseException {
+        int pos = bp;
+        int depth = 0;
+
+        // scan to find the end of the signature, by looking for the first
+        // whitespace not enclosed in () or <>, or the end of the tag
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fallthrough
+
+                case ' ': case '\t':
+                    if (depth == 0)
+                        break loop;
+                    break;
+
+                case '(':
+                case '<':
+                    newline = false;
+                    depth++;
+                    break;
+
+                case ')':
+                case '>':
+                    newline = false;
+                    --depth;
+                    break;
+
+                case '}':
+                    if (bp == pos)
+                        return null;
+                    newline = false;
+                    break loop;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    // fallthrough
+
+                default:
+                    newline = false;
+
+            }
+            nextChar();
+        }
+
+        if (depth != 0)
+            throw new ParseException("dc.unterminated.signature");
+
+        String sig = newString(pos, bp);
+
+        // Break sig apart into qualifiedExpr member paramTypes.
+        JCTree qualExpr;
+        Name member;
+        List<JCTree> paramTypes;
+
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler
+                = new Log.DeferredDiagnosticHandler(fac.log);
+
+        try {
+            int hash = sig.indexOf("#");
+            int lparen = sig.indexOf("(", hash + 1);
+            if (hash == -1) {
+                if (lparen == -1) {
+                    qualExpr = parseType(sig);
+                    member = null;
+                } else {
+                    qualExpr = null;
+                    member = parseMember(sig.substring(0, lparen));
+                }
+            } else {
+                qualExpr = (hash == 0) ? null : parseType(sig.substring(0, hash));
+                if (lparen == -1)
+                    member = parseMember(sig.substring(hash + 1));
+                else
+                    member = parseMember(sig.substring(hash + 1, lparen));
+            }
+
+            if (lparen < 0) {
+                paramTypes = null;
+            } else {
+                int rparen = sig.indexOf(")", lparen);
+                if (rparen != sig.length() - 1)
+                    throw new ParseException("dc.ref.bad.parens");
+                paramTypes = parseParams(sig.substring(lparen + 1, rparen));
+            }
+
+            if (!deferredDiagnosticHandler.getDiagnostics().isEmpty())
+                throw new ParseException("dc.ref.syntax.error");
+
+        } finally {
+            fac.log.popDiagnosticHandler(deferredDiagnosticHandler);
+        }
+
+        return m.at(pos).Reference(sig, qualExpr, member, paramTypes);
+    }
+
+    JCTree parseType(String s) throws ParseException {
+        JavacParser p = fac.newParser(s, false, false, false);
+        JCTree tree = p.parseType();
+        if (p.token().kind != TokenKind.EOF)
+            throw new ParseException("dc.ref.unexpected.input");
+        return tree;
+    }
+
+    Name parseMember(String s) throws ParseException {
+        JavacParser p = fac.newParser(s, false, false, false);
+        Name name = p.ident();
+        if (p.token().kind != TokenKind.EOF)
+            throw new ParseException("dc.ref.unexpected.input");
+        return name;
+    }
+
+    List<JCTree> parseParams(String s) throws ParseException {
+        if (s.trim().isEmpty())
+            return List.nil();
+
+        JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false);
+        ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>();
+        paramTypes.add(p.parseType());
+
+        if (p.token().kind == TokenKind.IDENTIFIER)
+            p.nextToken();
+
+        while (p.token().kind == TokenKind.COMMA) {
+            p.nextToken();
+            paramTypes.add(p.parseType());
+
+            if (p.token().kind == TokenKind.IDENTIFIER)
+                p.nextToken();
+        }
+
+        if (p.token().kind != TokenKind.EOF)
+            throw new ParseException("dc.ref.unexpected.input");
+
+        return paramTypes.toList();
+    }
+
+    /**
+     * Read Java identifier
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected DCIdentifier identifier() throws ParseException {
+        skipWhitespace();
+        int pos = bp;
+
+        if (isJavaIdentifierStart(ch)) {
+            nextChar();
+            while (isJavaIdentifierPart(ch))
+                nextChar();
+            return m.at(pos).Identifier(names.fromChars(buf, pos, bp - pos));
+        }
+
+        throw new ParseException("dc.identifier.expected");
+    }
+
+    /**
+     * Read a quoted string.
+     * It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected DCText quotedString() {
+        int pos = bp;
+        nextChar();
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    break;
+
+                case ' ': case '\t':
+                    break;
+
+                case '"':
+                    nextChar();
+                    // trim trailing white-space?
+                    return m.at(pos).Text(newString(pos, bp));
+
+                case '@':
+                    if (newline)
+                        break loop;
+
+            }
+            nextChar();
+        }
+        return null;
+    }
+
+    /**
+     * Read general text content of an inline tag, including HTML entities and elements.
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected List<DCTree> inlineContent() {
+        ListBuffer<DCTree> trees = new ListBuffer<DCTree>();
+
+        skipWhitespace();
+        int pos = bp;
+        int depth = 1;
+        textStart = -1;
+
+        loop:
+        while (bp < buflen) {
+
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fall through
+
+                case ' ': case '\t':
+                    nextChar();
+                    break;
+
+                case '&':
+                    entity(trees);
+                    break;
+
+                case '<':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(html());
+                    break;
+
+                case '{':
+                    newline = false;
+                    depth++;
+                    nextChar();
+                    break;
+
+                case '}':
+                    newline = false;
+                    if (--depth == 0) {
+                        addPendingText(trees, bp - 1);
+                        nextChar();
+                        return trees.toList();
+                    }
+                    nextChar();
+                    break;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    // fallthrough
+
+                default:
+                    if (textStart == -1)
+                        textStart = bp;
+                    nextChar();
+                    break;
+            }
+        }
+
+        return List.<DCTree>of(erroneous("dc.unterminated.inline.tag", pos));
+    }
+
+    protected void entity(ListBuffer<DCTree> list) {
+        newline = false;
+        addPendingText(list, bp - 1);
+        list.add(entity());
+        if (textStart == -1) {
+            textStart = bp;
+            lastNonWhite = -1;
+        }
+    }
+
+    /**
+     * Read an HTML entity.
+     * {@literal &identifier; } or {@literal &#digits; } or {@literal &#xhex-digits; }
+     */
+    protected DCTree entity() {
+        int p = bp;
+        nextChar();
+        int namep = bp;
+        boolean checkSemi = false;
+        if (ch == '#') {
+            nextChar();
+            if (isDecimalDigit(ch)) {
+                nextChar();
+                while (isDecimalDigit(ch))
+                    nextChar();
+                checkSemi = true;
+            } else if (ch == 'x' || ch == 'X') {
+                nextChar();
+                if (isHexDigit(ch)) {
+                    nextChar();
+                    while (isHexDigit(ch))
+                        nextChar();
+                    checkSemi = true;
+                }
+            }
+        } else if (isIdentifierStart(ch)) {
+            nextChar();
+            while (isIdentifierPart(ch))
+                nextChar();
+            checkSemi = true;
+        }
+
+        if (checkSemi && ch == ';') {
+            nextChar();
+            return m.at(p).Entity(names.fromChars(buf, namep, bp - namep - 1));
+        } else {
+            String code = checkSemi ? "dc.missing.semicolon" : "dc.bad.entity";
+            return erroneous(code, p);
+        }
+    }
+
+    /**
+     * Read the start or end of an HTML tag, or an HTML comment
+     * {@literal <identifier attrs> } or {@literal </identifier> }
+     */
+    protected DCTree html() {
+        int p = bp;
+        nextChar();
+        if (isIdentifierStart(ch)) {
+            int namePos = bp;
+            nextChar();
+            while (isIdentifierPart(ch))
+                nextChar();
+            int nameLen = bp - namePos;
+            List<DCTree> attrs = htmlAttrs();
+            if (attrs != null) {
+                boolean selfClosing = false;
+                if (ch == '/') {
+                    nextChar();
+                    selfClosing = true;
+                }
+                if (ch == '>') {
+                    nextChar();
+                    Name name = names.fromChars(buf, namePos, nameLen);
+                    return m.at(p).StartElement(name, attrs, selfClosing);
+                }
+            }
+        } else if (ch == '/') {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                int namePos = bp;
+                nextChar();
+                while (isIdentifierPart(ch))
+                    nextChar();
+                int nameLen = bp - namePos;
+                skipWhitespace();
+                if (ch == '>') {
+                    nextChar();
+                    Name name = names.fromChars(buf, namePos, nameLen);
+                    return m.at(p).EndElement(name);
+                }
+            }
+        } else if (ch == '!') {
+            nextChar();
+            if (ch == '-') {
+                nextChar();
+                if (ch == '-') {
+                    nextChar();
+                    while (bp < buflen) {
+                        int dash = 0;
+                        while (ch == '-') {
+                            dash++;
+                            nextChar();
+                        }
+                        // strictly speaking, a comment should not contain "--"
+                        // so dash > 2 is an error, dash == 2 implies ch == '>'
+                        if (dash >= 2 && ch == '>') {
+                            nextChar();
+                            return m.at(p).Comment(newString(p, bp));
+                        }
+
+                        nextChar();
+                    }
+                }
+            }
+        }
+
+        bp = p + 1;
+        ch = buf[bp];
+        return erroneous("dc.malformed.html", p);
+    }
+
+    /**
+     * Read a series of HTML attributes, terminated by {@literal > }.
+     * Each attribute is of the form {@literal identifier[=value] }.
+     * "value" may be unquoted, single-quoted, or double-quoted.
+     */
+    protected List<DCTree> htmlAttrs() {
+        ListBuffer<DCTree> attrs = new ListBuffer<DCTree>();
+        skipWhitespace();
+
+        loop:
+        while (isIdentifierStart(ch)) {
+            int namePos = bp;
+            nextChar();
+            while (isIdentifierPart(ch))
+                nextChar();
+            int nameLen = bp - namePos;
+            skipWhitespace();
+            List<DCTree> value = null;
+            ValueKind vkind = ValueKind.EMPTY;
+            if (ch == '=') {
+                ListBuffer<DCTree> v = new ListBuffer<DCTree>();
+                nextChar();
+                skipWhitespace();
+                if (ch == '\'' || ch == '"') {
+                    vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE;
+                    char quote = ch;
+                    nextChar();
+                    textStart = bp;
+                    while (bp < buflen && ch != quote) {
+                        if (newline && ch == '@') {
+                            attrs.add(erroneous("dc.unterminated.string", namePos));
+                            // No point trying to read more.
+                            // In fact, all attrs get discarded by the caller
+                            // and superseded by a malformed.html node because
+                            // the html tag itself is not terminated correctly.
+                            break loop;
+                        }
+                        attrValueChar(v);
+                    }
+                    addPendingText(v, bp - 1);
+                    nextChar();
+                } else {
+                    vkind = ValueKind.UNQUOTED;
+                    textStart = bp;
+                    while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) {
+                        attrValueChar(v);
+                    }
+                    addPendingText(v, bp - 1);
+                }
+                skipWhitespace();
+                value = v.toList();
+            }
+            Name name = names.fromChars(buf, namePos, nameLen);
+            DCAttribute attr = m.at(namePos).Attribute(name, vkind, value);
+            attrs.add(attr);
+        }
+
+        return attrs.toList();
+    }
+
+    protected void attrValueChar(ListBuffer<DCTree> list) {
+        switch (ch) {
+            case '&':
+                entity(list);
+                break;
+
+            case '{':
+                inlineTag(list);
+                break;
+
+            default:
+                nextChar();
+        }
+    }
+
+    protected void addPendingText(ListBuffer<DCTree> list, int textEnd) {
+        if (textStart != -1 && textStart <= textEnd) {
+            list.add(m.at(textStart).Text(newString(textStart, textEnd + 1)));
+            textStart = -1;
+        }
+    }
+
+    protected DCErroneous erroneous(String code, int pos) {
+        int i = bp - 1;
+        loop:
+        while (i > 0) {
+            switch (buf[i]) {
+                case '\f': case '\n': case '\r':
+                    newline = true;
+                    break;
+                case '\t': case ' ':
+                    break;
+                default:
+                    break loop;
+            }
+            i--;
+        }
+        textStart = -1;
+        return m.at(pos).Erroneous(newString(pos, i + 1), diagSource, code);
+    }
+
+    @SuppressWarnings("unchecked")
+    <T> T getFirst(List<T>... lists) {
+        for (List<T> list: lists) {
+            if (list.nonEmpty())
+                return list.head;
+        }
+        return null;
+    }
+
+    protected boolean isIdentifierStart(char ch) {
+        return Character.isUnicodeIdentifierStart(ch);
+    }
+
+    protected boolean isIdentifierPart(char ch) {
+        return Character.isUnicodeIdentifierPart(ch);
+    }
+
+    protected boolean isJavaIdentifierStart(char ch) {
+        return Character.isJavaIdentifierStart(ch);
+    }
+
+    protected boolean isJavaIdentifierPart(char ch) {
+        return Character.isJavaIdentifierPart(ch);
+    }
+
+    protected boolean isDecimalDigit(char ch) {
+        return ('0' <= ch && ch <= '9');
+    }
+
+    protected boolean isHexDigit(char ch) {
+        return ('0' <= ch && ch <= '9')
+                || ('a' <= ch && ch <= 'f')
+                || ('A' <= ch && ch <= 'F');
+    }
+
+    protected boolean isUnquotedAttrValueTerminator(char ch) {
+        switch (ch) {
+            case '\f': case '\n': case '\r': case '\t':
+            case ' ':
+            case '"': case '\'': case '`':
+            case '=': case '<': case '>':
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    protected boolean isWhitespace(char ch) {
+        return Character.isWhitespace(ch);
+    }
+
+    protected void skipWhitespace() {
+        while (isWhitespace(ch))
+            nextChar();
+    }
+
+    protected int getSentenceBreak(String s) {
+        if (sentenceBreaker != null) {
+            sentenceBreaker.setText(s);
+            int i = sentenceBreaker.next();
+            return (i == s.length()) ? -1 : i;
+        }
+
+        // scan for period followed by whitespace
+        boolean period = false;
+        for (int i = 0; i < s.length(); i++) {
+            switch (s.charAt(i)) {
+                case '.':
+                    period = true;
+                    break;
+
+                case ' ':
+                case '\f':
+                case '\n':
+                case '\r':
+                case '\t':
+                    if (period)
+                        return i;
+                    break;
+
+                default:
+                    period = false;
+                    break;
+            }
+        }
+        return -1;
+    }
+
+
+    Set<String> htmlBlockTags = new HashSet<String>(Arrays.asList(
+                    "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre"));
+
+    protected boolean isSentenceBreak(Name n) {
+        return htmlBlockTags.contains(n.toString().toLowerCase());
+    }
+
+    protected boolean isSentenceBreak(DCTree t) {
+        switch (t.getKind()) {
+            case START_ELEMENT:
+                return isSentenceBreak(((DCStartElement) t).getName());
+
+            case END_ELEMENT:
+                return isSentenceBreak(((DCEndElement) t).getName());
+        }
+        return false;
+    }
+
+    /**
+     * @param start position of first character of string
+     * @param end position of character beyond last character to be included
+     */
+    String newString(int start, int end) {
+        return new String(buf, start, end - start);
+    }
+
+    static abstract class TagParser {
+        enum Kind { INLINE, BLOCK }
+
+        Kind kind;
+        DCTree.Kind treeKind;
+
+        TagParser(Kind k, DCTree.Kind tk) {
+            kind = k;
+            treeKind = tk;
+        }
+
+        Kind getKind() {
+            return kind;
+        }
+
+        DCTree.Kind getTreeKind() {
+            return treeKind;
+        }
+
+        abstract DCTree parse(int pos) throws ParseException;
+    }
+
+    /**
+     * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a>
+     */
+    private void initTagParsers() {
+        TagParser[] parsers = {
+            // @author name-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.AUTHOR) {
+                public DCTree parse(int pos) {
+                    List<DCTree> name = blockContent();
+                    return m.at(pos).Author(name);
+                }
+            },
+
+            // {@code text}
+            new TagParser(Kind.INLINE, DCTree.Kind.CODE) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCTree text = inlineText();
+                    nextChar();
+                    return m.at(pos).Code((DCText) text);
+                }
+            },
+
+            // @deprecated deprecated-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.DEPRECATED) {
+                public DCTree parse(int pos) {
+                    List<DCTree> reason = blockContent();
+                    return m.at(pos).Deprecated(reason);
+                }
+            },
+
+            // {@docRoot}
+            new TagParser(Kind.INLINE, DCTree.Kind.DOC_ROOT) {
+                public DCTree parse(int pos) throws ParseException {
+                    if (ch == '}') {
+                        nextChar();
+                        return m.at(pos).DocRoot();
+                    }
+                    inlineText(); // skip unexpected content
+                    nextChar();
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // @exception class-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.EXCEPTION) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCReference ref = reference(false);
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Exception(ref, description);
+                }
+            },
+
+            // {@inheritDoc}
+            new TagParser(Kind.INLINE, DCTree.Kind.INHERIT_DOC) {
+                public DCTree parse(int pos) throws ParseException {
+                    if (ch == '}') {
+                        nextChar();
+                        return m.at(pos).InheritDoc();
+                    }
+                    inlineText(); // skip unexpected content
+                    nextChar();
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // {@link package.class#member label}
+            new TagParser(Kind.INLINE, DCTree.Kind.LINK) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    List<DCTree> label = inlineContent();
+                    return m.at(pos).Link(ref, label);
+                }
+            },
+
+            // {@linkplain package.class#member label}
+            new TagParser(Kind.INLINE, DCTree.Kind.LINK_PLAIN) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    List<DCTree> label = inlineContent();
+                    return m.at(pos).LinkPlain(ref, label);
+                }
+            },
+
+            // {@literal text}
+            new TagParser(Kind.INLINE, DCTree.Kind.LITERAL) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCTree text = inlineText();
+                    nextChar();
+                    return m.at(pos).Literal((DCText) text);
+                }
+            },
+
+            // @param parameter-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.PARAM) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+
+                    boolean typaram = false;
+                    if (ch == '<') {
+                        typaram = true;
+                        nextChar();
+                    }
+
+                    DCIdentifier id = identifier();
+
+                    if (typaram) {
+                        if (ch != '>')
+                            throw new ParseException("dc.gt.expected");
+                        nextChar();
+                    }
+
+                    skipWhitespace();
+                    List<DCTree> desc = blockContent();
+                    return m.at(pos).Param(typaram, id, desc);
+                }
+            },
+
+            // @return description
+            new TagParser(Kind.BLOCK, DCTree.Kind.RETURN) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Return(description);
+                }
+            },
+
+            // @see reference | quoted-string | HTML
+            new TagParser(Kind.BLOCK, DCTree.Kind.SEE) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    switch (ch) {
+                        case '"':
+                            DCText string = quotedString();
+                            if (string != null) {
+                                skipWhitespace();
+                                if (ch == '@')
+                                    return m.at(pos).See(List.<DCTree>of(string));
+                            }
+                            break;
+
+                        case '<':
+                            List<DCTree> html = blockContent();
+                            if (html != null)
+                                return m.at(pos).See(html);
+                            break;
+
+                        default:
+                            if (isJavaIdentifierStart(ch) || ch == '#') {
+                                DCReference ref = reference(true);
+                                List<DCTree> description = blockContent();
+                                return m.at(pos).See(description.prepend(ref));
+                            }
+                    }
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // @serialData data-description
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_DATA) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).SerialData(description);
+                }
+            },
+
+            // @serialField field-name field-type description
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_FIELD) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCIdentifier name = identifier();
+                    skipWhitespace();
+                    DCReference type = reference(false);
+                    List<DCTree> description = null;
+                    if (isWhitespace(ch)) {
+                        skipWhitespace();
+                        description = blockContent();
+                    }
+                    return m.at(pos).SerialField(name, type, description);
+                }
+            },
+
+            // @serial field-description | include | exclude
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Serial(description);
+                }
+            },
+
+            // @since since-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.SINCE) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Since(description);
+                }
+            },
+
+            // @throws class-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.THROWS) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCReference ref = reference(false);
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Throws(ref, description);
+                }
+            },
+
+            // {@value package.class#field}
+            new TagParser(Kind.INLINE, DCTree.Kind.VALUE) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    skipWhitespace();
+                    if (ch == '}') {
+                        nextChar();
+                        return m.at(pos).Value(ref);
+                    }
+                    nextChar();
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // @version version-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.VERSION) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Version(description);
+                }
+            },
+        };
+
+        tagParsers = new HashMap<Name,TagParser>();
+        for (TagParser p: parsers)
+            tagParsers.put(names.fromString(p.getTreeKind().tagName), p);
+
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Jul 05 18:30:46 2017 +0200
@@ -47,8 +47,8 @@
 import static com.sun.tools.javac.parser.Tokens.TokenKind.GT;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT;
 import static com.sun.tools.javac.parser.Tokens.TokenKind.LT;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.util.ListBuffer.lb;
-import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** The parser maps a token sequence into an abstract syntax
  *  tree. It operates by recursive descent, with code derived
@@ -121,14 +121,11 @@
         this.allowDiamond = source.allowDiamond();
         this.allowMulticatch = source.allowMulticatch();
         this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
-        this.allowLambda = source.allowLambda() &&
-                fac.options.isSet("allowLambda"); //pre-lambda guard
-        this.allowMethodReferences = source.allowMethodReferences() &&
-                fac.options.isSet("allowMethodReferences"); //pre-lambda guard
-        this.allowDefaultMethods = source.allowDefaultMethods() &&
-                fac.options.isSet("allowDefaultMethods"); //pre-lambda guard
+        this.allowLambda = source.allowLambda();
+        this.allowMethodReferences = source.allowMethodReferences();
+        this.allowDefaultMethods = source.allowDefaultMethods();
         this.keepDocComments = keepDocComments;
-        docComments = newDocCommentTable(keepDocComments);
+        docComments = newDocCommentTable(keepDocComments, fac);
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
         endPosTable = newEndPosTable(keepEndPositions);
@@ -140,8 +137,8 @@
                 : new EmptyEndPosTable();
     }
 
-    protected DocCommentTable newDocCommentTable(boolean keepDocComments) {
-        return keepDocComments ? new SimpleDocCommentTable() : null;
+    protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFactory fac) {
+        return keepDocComments ? new LazyDocCommentTable(fac) : null;
     }
 
     /** Switch: Should generics be recognized?
@@ -232,7 +229,11 @@
 
     protected Token token;
 
-    protected void nextToken() {
+    public Token token() {
+        return token;
+    }
+
+    public void nextToken() {
         S.nextToken();
         token = S.token();
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Wed Jul 05 18:30:46 2017 +0200
@@ -234,10 +234,12 @@
             // If we find an exact match for pos, the other item in the pair
             // gives the source pos; otherwise, compute the source position
             // relative to the best match found in the array.
+            if (pos == Position.NOPOS)
+                return Position.NOPOS;
             if (pos < 0 || pos >= docComment.length())
-                throw new StringIndexOutOfBoundsException();
+                throw new StringIndexOutOfBoundsException(String.valueOf(pos));
             if (docPosns == null)
-                return -1;
+                return Position.NOPOS;
             int start = 0;
             int end = docPosns.length;
             while (start < end - 2) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DocCommentTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.DiagnosticSource;
+
+
+/**
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class LazyDocCommentTable implements DocCommentTable {
+    private static class Entry {
+        final Comment comment;
+        DCDocComment tree;
+
+        Entry(Comment c) {
+            comment = c;
+        }
+    }
+
+    ParserFactory fac;
+    DiagnosticSource diagSource;
+    Map<JCTree, Entry> table;
+
+    LazyDocCommentTable(ParserFactory fac) {
+        this.fac = fac;
+        diagSource = fac.log.currentSource();
+        table = new HashMap<JCTree, Entry>();
+    }
+
+    public boolean hasComment(JCTree tree) {
+        return table.containsKey(tree);
+    }
+
+    public Comment getComment(JCTree tree) {
+        Entry e = table.get(tree);
+        return (e == null) ? null : e.comment;
+    }
+
+    public String getCommentText(JCTree tree) {
+        Comment c = getComment(tree);
+        return (c == null) ? null : c.getText();
+    }
+
+    public DCDocComment getCommentTree(JCTree tree) {
+        Entry e = table.get(tree);
+        if (e == null)
+            return null;
+        if (e.tree == null)
+            e.tree = new DocCommentParser(fac, diagSource, e.comment).parse();
+        return e.tree;
+    }
+
+    public void putComment(JCTree tree, Comment c) {
+        table.put(tree, new Entry(c));
+    }
+
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,10 @@
 
 package com.sun.tools.javac.parser;
 
+import java.util.Locale;
+
 import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.tree.DocTreeMaker;
 import com.sun.tools.javac.tree.TreeMaker;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
@@ -54,26 +57,30 @@
     }
 
     final TreeMaker F;
+    final DocTreeMaker docTreeMaker;
     final Log log;
     final Tokens tokens;
     final Source source;
     final Names names;
     final Options options;
     final ScannerFactory scannerFactory;
+    final Locale locale;
 
     protected ParserFactory(Context context) {
         super();
         context.put(parserFactoryKey, this);
         this.F = TreeMaker.instance(context);
+        this.docTreeMaker = DocTreeMaker.instance(context);
         this.log = Log.instance(context);
         this.names = Names.instance(context);
         this.tokens = Tokens.instance(context);
         this.source = Source.instance(context);
         this.options = Options.instance(context);
         this.scannerFactory = ScannerFactory.instance(context);
+        this.locale = context.get(Locale.class);
     }
 
-    public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
+    public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
         Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
         return new JavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos);
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.parser;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.sun.tools.javac.parser.Tokens.Comment;
-import com.sun.tools.javac.tree.DocCommentTable;
-import com.sun.tools.javac.tree.JCTree;
-
-
-/**
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class SimpleDocCommentTable implements DocCommentTable {
-    Map<JCTree, Comment> table;
-
-    SimpleDocCommentTable() {
-        table = new HashMap<JCTree, Comment>();
-    }
-
-    public boolean hasComment(JCTree tree) {
-        return table.containsKey(tree);
-    }
-
-    public Comment getComment(JCTree tree) {
-        return table.get(tree);
-    }
-
-    public String getCommentText(JCTree tree) {
-        Comment c = getComment(tree);
-        return (c == null) ? null : c.getText();
-    }
-
-    public void putComment(JCTree tree, Comment c) {
-        table.put(tree, c);
-    }
-
-}
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -145,6 +145,7 @@
     Source source;
 
     private ClassLoader processorClassLoader;
+    private SecurityException processorClassLoaderException;
 
     /**
      * JavacMessages object used for localization
@@ -155,7 +156,15 @@
 
     private Context context;
 
-    public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) {
+    /** Get the JavacProcessingEnvironment instance for this context. */
+    public static JavacProcessingEnvironment instance(Context context) {
+        JavacProcessingEnvironment instance = context.get(JavacProcessingEnvironment.class);
+        if (instance == null)
+            instance = new JavacProcessingEnvironment(context);
+        return instance;
+    }
+
+    protected JavacProcessingEnvironment(Context context) {
         this.context = context;
         log = Log.instance(context);
         source = Source.instance(context);
@@ -184,6 +193,11 @@
         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
         messages = JavacMessages.instance(context);
         taskListener = MultiTaskListener.instance(context);
+        initProcessorClassLoader();
+    }
+
+    public void setProcessors(Iterable<? extends Processor> processors) {
+        Assert.checkNull(discoveredProcs);
         initProcessorIterator(context, processors);
     }
 
@@ -199,6 +213,23 @@
         return Collections.unmodifiableSet(platformAnnotations);
     }
 
+    private void initProcessorClassLoader() {
+        JavaFileManager fileManager = context.get(JavaFileManager.class);
+        try {
+            // If processorpath is not explicitly set, use the classpath.
+            processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
+                ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
+                : fileManager.getClassLoader(CLASS_PATH);
+
+            if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
+                JavaCompiler compiler = JavaCompiler.instance(context);
+                compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
+            }
+        } catch (SecurityException e) {
+            processorClassLoaderException = e;
+        }
+    }
+
     private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) {
         Log   log   = Log.instance(context);
         Iterator<? extends Processor> processorIterator;
@@ -217,18 +248,7 @@
             processorIterator = processors.iterator();
         } else {
             String processorNames = options.get(PROCESSOR);
-            JavaFileManager fileManager = context.get(JavaFileManager.class);
-            try {
-                // If processorpath is not explicitly set, use the classpath.
-                processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
-                    ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
-                    : fileManager.getClassLoader(CLASS_PATH);
-
-                if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
-                    JavaCompiler compiler = JavaCompiler.instance(context);
-                    compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
-                }
-
+            if (processorClassLoaderException == null) {
                 /*
                  * If the "-processor" option is used, search the appropriate
                  * path for the named class.  Otherwise, use a service
@@ -239,14 +259,15 @@
                 } else {
                     processorIterator = new ServiceIterator(processorClassLoader, log);
                 }
-            } catch (SecurityException e) {
+            } else {
                 /*
                  * A security exception will occur if we can't create a classloader.
                  * Ignore the exception if, with hindsight, we didn't need it anyway
                  * (i.e. no processor was specified either explicitly, or implicitly,
                  * in service configuration file.) Otherwise, we cannot continue.
                  */
-                processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", e);
+                processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader",
+                        processorClassLoaderException);
             }
         }
         discoveredProcs = new DiscoveredProcessors(processorIterator);
@@ -781,6 +802,8 @@
         final JavaCompiler compiler;
         /** The log for the round. */
         final Log log;
+        /** The diagnostic handler for the round. */
+        final Log.DeferredDiagnosticHandler deferredDiagnosticHandler;
 
         /** The ASTs to be compiled. */
         List<JCCompilationUnit> roots;
@@ -798,7 +821,8 @@
         int nMessagerErrors;
 
         /** Create a round (common code). */
-        private Round(Context context, int number, int priorErrors, int priorWarnings) {
+        private Round(Context context, int number, int priorErrors, int priorWarnings,
+                Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
             this.context = context;
             this.number = number;
 
@@ -806,7 +830,12 @@
             log = Log.instance(context);
             log.nerrors = priorErrors;
             log.nwarnings += priorWarnings;
-            log.deferAll();
+            if (number == 1) {
+                Assert.checkNonNull(deferredDiagnosticHandler);
+                this.deferredDiagnosticHandler = deferredDiagnosticHandler;
+            } else {
+                this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
+            }
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
             JavacProcessingEnvironment.this.context = context;
@@ -817,8 +846,9 @@
         }
 
         /** Create the first round. */
-        Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
-            this(context, 1, 0, 0);
+        Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols,
+                Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
+            this(context, 1, 0, 0, deferredDiagnosticHandler);
             this.roots = roots;
             genClassFiles = new HashMap<String,JavaFileObject>();
 
@@ -841,7 +871,8 @@
             this(prev.nextContext(),
                     prev.number+1,
                     prev.nMessagerErrors,
-                    prev.compiler.log.nwarnings);
+                    prev.compiler.log.nwarnings,
+                    null);
             this.genClassFiles = prev.genClassFiles;
 
             List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
@@ -912,7 +943,7 @@
             if (messager.errorRaised())
                 return true;
 
-            for (JCDiagnostic d: log.deferredDiagnostics) {
+            for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
                 switch (d.getKind()) {
                     case WARNING:
                         if (werror)
@@ -1006,7 +1037,8 @@
                 // suppress errors, which are all presumed to be transient resolve errors
                 kinds.remove(JCDiagnostic.Kind.ERROR);
             }
-            log.reportDeferredDiagnostics(kinds);
+            deferredDiagnosticHandler.reportDeferredDiagnostics(kinds);
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
         }
 
         /** Print info about this round. */
@@ -1112,7 +1144,8 @@
     public JavaCompiler doProcessing(Context context,
                                      List<JCCompilationUnit> roots,
                                      List<ClassSymbol> classSymbols,
-                                     Iterable<? extends PackageSymbol> pckSymbols) {
+                                     Iterable<? extends PackageSymbol> pckSymbols,
+                                     Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
         log = Log.instance(context);
 
         Set<PackageSymbol> specifiedPackages = new LinkedHashSet<PackageSymbol>();
@@ -1120,7 +1153,7 @@
             specifiedPackages.add(psym);
         this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages);
 
-        Round round = new Round(context, roots, classSymbols);
+        Round round = new Round(context, roots, classSymbols, deferredDiagnosticHandler);
 
         boolean errorStatus;
         boolean moreToDo;
@@ -1461,13 +1494,19 @@
     }
 
     /**
-     * For internal use only.  This method will be
-     * removed without warning.
+     * For internal use only.  This method may be removed without warning.
      */
     public Context getContext() {
         return context;
     }
 
+    /**
+     * For internal use only.  This method may be removed without warning.
+     */
+    public ClassLoader getProcessorClassLoader() {
+        return processorClassLoader;
+    }
+
     public String toString() {
         return "javac ProcessingEnvironment";
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 18:30:46 2017 +0200
@@ -170,19 +170,6 @@
 compiler.misc.cant.apply.symbols=\
     no suitable {0} found for {1}({2})
 
-
-# 0: type
-compiler.err.cant.access.arg.type.in.functional.desc=\
-    cannot access parameter type {0} in target functional descriptor
-
-# 0: type
-compiler.err.cant.access.return.in.functional.desc=\
-    cannot access return type {0} in target functional descriptor
-
-# 0: type
-compiler.err.cant.access.thrown.in.functional.desc=\
-    cannot access thrown type {0} in target functional descriptor
-
 # 0: symbol kind, 1: symbol
 compiler.misc.no.abstracts=\
     no abstract method found in {0} {1}
@@ -257,9 +244,6 @@
 compiler.err.cant.ref.before.ctor.called=\
     cannot reference {0} before supertype constructor has been called
 
-compiler.err.cant.ret.val.from.meth.decl.void=\
-    cannot return a value from method whose result type is void
-
 compiler.err.cant.select.static.class.from.param.type=\
     cannot select a static class from a parameterized type
 
@@ -661,8 +645,8 @@
 compiler.misc.missing.ret.val=\
     missing return value
 
-compiler.err.missing.ret.val=\
-    missing return value
+compiler.misc.unexpected.ret.val=\
+    unexpected return value
 
 # 0: set of modifier
 compiler.err.mod.not.allowed.here=\
@@ -708,6 +692,9 @@
 compiler.misc.incompatible.type.in.conditional=\
     bad type in conditional expression; {0}
 
+compiler.misc.conditional.target.cant.be.void=\
+    target-type for conditional expression cannot be void
+
 # 0: type
 compiler.misc.incompatible.ret.type.in.lambda=\
     bad return type in lambda expression\n\
@@ -960,7 +947,7 @@
 
 # 0: symbol, 1: type
 compiler.misc.overridden.default=\
-    method {0} is overridden in {2}
+    method {0} is overridden in {1}
 
 # 0: symbol, 1: symbol
 compiler.misc.redundant.supertype=\
@@ -2336,4 +2323,52 @@
 compiler.misc.where.description.intersection.1=\
     where {0} are intersection types:
 
-
+###
+# errors related to doc comments
+
+compiler.err.dc.bad.entity=\
+    bad HTML entity
+
+compiler.err.dc.bad.gt=\
+    bad use of ''>''
+
+compiler.err.dc.bad.inline.tag=\
+    incorrect use of inline tag
+
+compiler.err.dc.identifier.expected=\
+    identifier expected
+
+compiler.err.dc.malformed.html=\
+    malformed HTML
+
+compiler.err.dc.missing.semicolon=\
+    semicolon missing
+
+compiler.err.dc.no.tag.name=\
+    no tag name after '@'
+
+compiler.err.dc.gt.expected=\
+    ''>'' expected
+
+compiler.err.dc.ref.bad.parens=\
+    '')'' missing in reference
+
+compiler.err.dc.ref.syntax.error=\
+    syntax error in reference
+
+compiler.err.dc.ref.unexpected.input=\
+    unexpected text
+
+compiler.err.dc.unexpected.content=\
+    unexpected content
+
+compiler.err.dc.unterminated.inline.tag=\
+    unterminated inline tag
+
+compiler.err.dc.unterminated.signature=\
+    unterminated signature
+
+compiler.err.dc.unterminated.string=\
+    unterminated string
+
+
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 18:30:46 2017 +0200
@@ -99,6 +99,10 @@
     <release>
 javac.opt.arg.number=\
     <number>
+javac.opt.plugin=\
+    Name and optional arguments for a plug-in to be run
+javac.opt.arg.plugin=\
+    "name args"
 
 ## extended options
 
@@ -185,6 +189,8 @@
     not a directory: {0}
 javac.err.file.not.file=\
     not a file: {0}
+javac.msg.plugin.not.found=\
+    plug-in not found: {0}
 ## messages
 
 javac.msg.usage.header=\
@@ -212,6 +218,10 @@
 \n\nAn annotation processor threw an uncaught exception.\n\
 Consult the following stack trace for details.\n
 
+javac.msg.plugin.uncaught.exception=\
+\n\nA plugin threw an uncaught exception.\n\
+Consult the following stack trace for details.\n
+
 javac.msg.resource=\
 \n\nThe system is out of resources.\n\
 Consult the following stack trace for details.\n
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DCTree.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,848 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+
+import javax.tools.Diagnostic;
+
+import com.sun.source.doctree.*;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Name;
+import javax.tools.JavaFileObject;
+
+/**
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public abstract class DCTree implements DocTree {
+
+    /**
+     * The position in the comment string.
+     * Use {@link #getSourcePosition getSourcePosition} to convert
+     * it to a position in the source file.
+     *
+     * TODO: why not simply translate all these values into
+     * source file positions? Is it useful to have string-offset
+     * positions as well?
+     */
+    public int pos;
+
+    public long getSourcePosition(DCDocComment dc) {
+        return dc.comment.getSourcePos(pos);
+    }
+
+    public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
+        return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
+    }
+
+    public static class DCDocComment extends DCTree implements DocCommentTree {
+        final Comment comment; // required for the implicit source pos table
+
+        public final List<DCTree> firstSentence;
+        public final List<DCTree> body;
+        public final List<DCTree> tags;
+
+        public DCDocComment(Comment comment,
+                List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
+            this.comment = comment;
+            this.firstSentence = firstSentence;
+            this.body = body;
+            this.tags = tags;
+        }
+
+        public Kind getKind() {
+            return Kind.DOC_COMMENT;
+        }
+
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDocComment(this, d);
+        }
+
+        public List<? extends DocTree> getFirstSentence() {
+            return firstSentence;
+        }
+
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+
+        public List<? extends DocTree> getBlockTags() {
+            return tags;
+        }
+
+    }
+
+    public static abstract class DCBlockTag extends DCTree implements InlineTagTree {
+        public String getTagName() {
+            return getKind().tagName;
+        }
+    }
+
+    public static abstract class DCInlineTag extends DCTree implements InlineTagTree {
+        public String getTagName() {
+            return getKind().tagName;
+        }
+    }
+
+    public static class DCAttribute extends DCTree implements AttributeTree {
+        public final Name name;
+        public final ValueKind vkind;
+        public final List<DCTree> value;
+
+        DCAttribute(Name name, ValueKind vkind, List<DCTree> value) {
+            Assert.check((vkind == ValueKind.EMPTY) ? (value == null) : (value != null));
+            this.name = name;
+            this.vkind = vkind;
+            this.value = value;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ATTRIBUTE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitAttribute(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+
+        @Override
+        public ValueKind getValueKind() {
+            return vkind;
+        }
+
+        @Override
+        public List<DCTree> getValue() {
+            return value;
+        }
+    }
+
+    public static class DCAuthor extends DCInlineTag implements AuthorTree {
+        public final List<DCTree> name;
+
+        DCAuthor(List<DCTree> name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.AUTHOR;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitAuthor(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getName() {
+            return name;
+        }
+    }
+
+    public static class DCComment extends DCTree implements CommentTree {
+        public final String body;
+
+        DCComment(String body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.COMMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitComment(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return body;
+        }
+    }
+
+    public static class DCDeprecated extends DCBlockTag implements DeprecatedTree {
+        public final List<DCTree> body;
+
+        DCDeprecated(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.DEPRECATED;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDeprecated(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+    public static class DCDocRoot extends DCInlineTag implements DocRootTree {
+
+        @Override
+        public Kind getKind() {
+            return Kind.DOC_ROOT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDocRoot(this, d);
+        }
+    }
+
+    public static class DCEndElement extends DCTree implements EndElementTree {
+        public final Name name;
+
+        DCEndElement(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.END_ELEMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitEndElement(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCEntity extends DCTree implements EntityTree {
+        public final Name name;
+
+        DCEntity(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ENTITY;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitEntity(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCErroneous extends DCTree implements ErroneousTree, JCDiagnostic.DiagnosticPosition {
+        public final String body;
+        public final JCDiagnostic diag;
+
+        DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) {
+            this.body = body;
+            this.diag = diags.error(diagSource, this, code, args);
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ERRONEOUS;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitErroneous(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return body;
+        }
+
+        @Override
+        public Diagnostic<JavaFileObject> getDiagnostic() {
+            return diag;
+        }
+
+        @Override
+        public JCTree getTree() {
+            return null;
+        }
+
+        @Override
+        public int getStartPosition() {
+            return pos;
+        }
+
+        @Override
+        public int getPreferredPosition() {
+            return pos + body.length() - 1;
+        }
+
+        @Override
+        public int getEndPosition(EndPosTable endPosTable) {
+            return pos + body.length();
+        }
+    }
+
+    public static class DCIdentifier extends DCTree implements IdentifierTree {
+        public final Name name;
+
+        DCIdentifier(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.IDENTIFIER;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitIdentifier(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCInheritDoc extends DCInlineTag implements InheritDocTree {
+        @Override
+        public Kind getKind() {
+            return Kind.INHERIT_DOC;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitInheritDoc(this, d);
+        }
+    }
+
+    public static class DCLink extends DCInlineTag implements LinkTree {
+        public final Kind kind;
+        public final DCReference ref;
+        public final List<DCTree> label;
+
+        DCLink(Kind kind, DCReference ref, List<DCTree> label) {
+            Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN);
+            this.kind = kind;
+            this.ref = ref;
+            this.label = label;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitLink(this, d);
+        }
+
+        @Override
+        public ReferenceTree getReference() {
+            return ref;
+        }
+
+        @Override
+        public List<? extends DocTree> getLabel() {
+            return label;
+        }
+    }
+
+    public static class DCLiteral extends DCInlineTag implements LiteralTree {
+        public final Kind kind;
+        public final DCText body;
+
+        DCLiteral(Kind kind, DCText body) {
+            Assert.check(kind == Kind.CODE || kind == Kind.LITERAL);
+            this.kind = kind;
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitLiteral(this, d);
+        }
+
+        @Override
+        public DCText getBody() {
+            return body;
+        }
+    }
+
+    public static class DCParam extends DCBlockTag implements ParamTree {
+        public final boolean isTypeParameter;
+        public final DCIdentifier name;
+        public final List<DCTree> description;
+
+        DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
+            this.isTypeParameter = isTypeParameter;
+            this.name = name;
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.PARAM;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitParam(this, d);
+        }
+
+        @Override
+        public boolean isTypeParameter() {
+            return isTypeParameter;
+        }
+
+        @Override
+        public IdentifierTree getName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCReference extends DCTree implements ReferenceTree {
+        public final String signature;
+
+        // The following are not directly exposed through ReferenceTree
+        // use DocTrees.getElement(TreePath,ReferenceTree)
+        public final JCTree qualifierExpression;
+        public final Name memberName;
+        public final List<JCTree> paramTypes;
+
+
+        DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
+            this.signature = signature;
+            qualifierExpression = qualExpr;
+            memberName = member;
+            this.paramTypes = paramTypes;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.REFERENCE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitReference(this, d);
+        }
+
+        @Override
+        public String getSignature() {
+            return signature;
+        }
+    }
+
+    public static class DCReturn extends DCBlockTag implements ReturnTree {
+        public final List<DCTree> description;
+
+        DCReturn(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.RETURN;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitReturn(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSee extends DCBlockTag implements SeeTree {
+        public final List<DCTree> reference;
+
+        DCSee(List<DCTree> reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SEE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSee(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getReference() {
+            return reference;
+        }
+    }
+
+    public static class DCSerial extends DCBlockTag implements SerialTree {
+        public final List<DCTree> description;
+
+        DCSerial(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerial(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSerialData extends DCBlockTag implements SerialDataTree {
+        public final List<DCTree> description;
+
+        DCSerialData(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL_DATA;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerialData(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSerialField extends DCBlockTag implements SerialFieldTree {
+        public final DCIdentifier name;
+        public final DCReference type;
+        public final List<DCTree> description;
+
+        DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
+            this.description = description;
+            this.name = name;
+            this.type = type;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL_FIELD;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerialField(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+
+        @Override
+        public IdentifierTree getName() {
+            return name;
+        }
+
+        @Override
+        public ReferenceTree getType() {
+            return type;
+        }
+    }
+
+    public static class DCSince extends DCInlineTag implements SinceTree {
+        public final List<DCTree> body;
+
+        DCSince(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SINCE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSince(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+    public static class DCStartElement extends DCTree implements StartElementTree {
+        public final Name name;
+        public final List<DCTree> attrs;
+        public final boolean selfClosing;
+
+        DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
+            this.name = name;
+            this.attrs = attrs;
+            this.selfClosing = selfClosing;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.START_ELEMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitStartElement(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getAttributes() {
+            return attrs;
+        }
+
+        @Override
+        public boolean isSelfClosing() {
+            return selfClosing;
+        }
+    }
+
+    public static class DCText extends DCTree implements TextTree {
+        public final String text;
+
+        DCText(String text) {
+            this.text = text;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.TEXT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitText(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return text;
+        }
+    }
+
+    public static class DCThrows extends DCBlockTag implements ThrowsTree {
+        public final Kind kind;
+        public final DCReference name;
+        public final List<DCTree> description;
+
+        DCThrows(Kind kind, DCReference name, List<DCTree> description) {
+            Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS);
+            this.kind = kind;
+            this.name = name;
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitThrows(this, d);
+        }
+
+        @Override
+        public ReferenceTree getExceptionName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree {
+        public final Name name;
+        public final List<DCTree> content;
+
+        DCUnknownBlockTag(Name name, List<DCTree> content) {
+            this.name = name;
+            this.content = content;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.UNKNOWN_BLOCK_TAG;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitUnknownBlockTag(this, d);
+        }
+
+        @Override
+        public String getTagName() {
+            return name.toString();
+        }
+
+        @Override
+        public List<? extends DocTree> getContent() {
+            return content;
+        }
+    }
+
+    public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree {
+        public final Name name;
+        public final List<DCTree> content;
+
+        DCUnknownInlineTag(Name name, List<DCTree> content) {
+            this.name = name;
+            this.content = content;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.UNKNOWN_INLINE_TAG;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitUnknownInlineTag(this, d);
+        }
+
+        @Override
+        public String getTagName() {
+            return name.toString();
+        }
+
+        @Override
+        public List<? extends DocTree> getContent() {
+            return content;
+        }
+    }
+
+    public static class DCValue extends DCInlineTag implements ValueTree {
+        public final DCReference ref;
+
+        DCValue(DCReference ref) {
+            this.ref = ref;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.VALUE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitValue(this, d);
+        }
+
+        @Override
+        public ReferenceTree getReference() {
+            return ref;
+        }
+    }
+
+    public static class DCVersion extends DCBlockTag implements VersionTree {
+        public final List<DCTree> body;
+
+        DCVersion(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.VERSION;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitVersion(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,9 @@
  */
 package com.sun.tools.javac.tree;
 
+import com.sun.source.doctree.ErroneousTree;
 import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
 
 /**
  * A table giving the doc comment, if any, for any tree node.
@@ -51,6 +53,13 @@
     public String getCommentText(JCTree tree);
 
     /**
+     * Get the parsed form of the doc comment as a DocTree. If any errors
+     * are detected during parsing, they will be reported via
+     * {@link ErroneousTree ErroneousTree} nodes within the resulting tree.
+     */
+    public DCDocComment getCommentTree(JCTree tree);
+
+    /**
      * Set the Comment to be associated with a tree node.
      */
     public void putComment(JCTree tree, Comment c);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocPretty.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+import java.io.Writer;
+
+import com.sun.source.doctree.*;
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.tools.javac.util.Convert;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Prints out a doc comment tree.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class DocPretty implements DocTreeVisitor<Void,Void> {
+
+    /**
+     * The output stream on which trees are printed.
+     */
+    final Writer out;
+
+    /**
+     * The left margin.
+     */
+    int lmargin = 0;
+
+    public DocPretty(Writer out) {
+        this.out = out;
+    }
+
+    /** Visitor method: print expression tree.
+     */
+    public void print(DocTree tree) throws IOException {
+        try {
+            if (tree == null)
+                print("/*missing*/");
+            else {
+                tree.accept(this, null);
+            }
+        } catch (UncheckedIOException ex) {
+            throw new IOException(ex.getMessage(), ex);
+        }
+    }
+
+    /**
+     * Print string, replacing all non-ascii character with unicode escapes.
+     */
+    protected void print(Object s) throws IOException {
+        out.write(Convert.escapeUnicode(s.toString()));
+    }
+
+    /**
+     * Print list.
+     */
+    protected void print(List<? extends DocTree> list) throws IOException {
+        for (DocTree t: list) {
+            print(t);
+        }
+    }
+
+    /**
+     * Print list., with separators
+     */
+    protected void print(List<? extends DocTree> list, String sep) throws IOException {
+        if (list.isEmpty())
+            return;
+        boolean first = true;
+        for (DocTree t: list) {
+            if (!first)
+                print(sep);
+            print(t);
+            first = false;
+        }
+    }
+
+    /** Print new line.
+     */
+    protected void println() throws IOException {
+        out.write(lineSep);
+    }
+
+    protected void printTagName(DocTree node) throws IOException {
+        out.write("@");
+        out.write(node.getKind().tagName);
+    }
+
+    final String lineSep = System.getProperty("line.separator");
+
+    /**************************************************************************
+     * Traversal methods
+     *************************************************************************/
+
+    /** Exception to propagate IOException through visitXXX methods */
+    private static class UncheckedIOException extends Error {
+        static final long serialVersionUID = -4032692679158424751L;
+        UncheckedIOException(IOException e) {
+            super(e.getMessage(), e);
+        }
+    }
+
+
+    public Void visitAttribute(AttributeTree node, Void p) {
+        try {
+            print(node.getName());
+            String quote;
+            switch (node.getValueKind()) {
+                case EMPTY:
+                    quote = null;
+                    break;
+                case UNQUOTED:
+                    quote = "";
+                    break;
+                case SINGLE:
+                    quote = "'";
+                    break;
+                case DOUBLE:
+                    quote = "\"";
+                    break;
+                default:
+                    throw new AssertionError();
+            }
+            if (quote != null) {
+                print("=" + quote);
+                print(node.getValue());
+                print(quote);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitAuthor(AuthorTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getName());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitComment(CommentTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDeprecated(DeprecatedTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getBody().isEmpty()) {
+                print(" ");
+                print(node.getBody());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDocComment(DocCommentTree node, Void p) {
+        try {
+            List<? extends DocTree> fs = node.getFirstSentence();
+            List<? extends DocTree> b = node.getBody();
+            List<? extends DocTree> t = node.getBlockTags();
+            print(fs);
+            if (!fs.isEmpty() && !b.isEmpty())
+                print(" ");
+            print(b);
+            if ((!fs.isEmpty() || !b.isEmpty()) && !t.isEmpty())
+                print("\n");
+            print(t, "\n");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDocRoot(DocRootTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitEndElement(EndElementTree node, Void p) {
+        try {
+            print("</");
+            print(node.getName());
+            print(">");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitEntity(EntityTree node, Void p) {
+        try {
+            print("&");
+            print(node.getName());
+            print(";");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitErroneous(ErroneousTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitIdentifier(IdentifierTree node, Void p) {
+        try {
+            print(node.getName());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitInheritDoc(InheritDocTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitLink(LinkTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print(" ");
+            print(node.getReference());
+            if (!node.getLabel().isEmpty()) {
+                print(" ");
+                print(node.getLabel());
+            }
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitLiteral(LiteralTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitParam(ParamTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            if (node.isTypeParameter()) print("<");
+            print(node.getName());
+            if (node.isTypeParameter()) print(">");
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitReference(ReferenceTree node, Void p) {
+        try {
+            print(node.getSignature());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitReturn(ReturnTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getDescription());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSee(SeeTree node, Void p) {
+        try {
+            printTagName(node);
+            boolean first = true;
+            boolean needSep = true;
+            for (DocTree t: node.getReference()) {
+                if (needSep) print(" ");
+                needSep = (first && (t instanceof ReferenceTree));
+                first = false;
+                print(t);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerial(SerialTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerialData(SerialDataTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerialField(SerialFieldTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getName());
+            print(" ");
+            print(node.getType());
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSince(SinceTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitStartElement(StartElementTree node, Void p) {
+        try {
+            print("<");
+            print(node.getName());
+            List<? extends DocTree> attrs = node.getAttributes();
+            if (!attrs.isEmpty()) {
+                print(" ");
+                print(attrs);
+                DocTree last = node.getAttributes().get(attrs.size() - 1);
+                if (node.isSelfClosing() && last instanceof AttributeTree
+                        && ((AttributeTree) last).getValueKind() == ValueKind.UNQUOTED)
+                    print(" ");
+            }
+            if (node.isSelfClosing())
+                print("/");
+            print(">");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitText(TextTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitThrows(ThrowsTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getExceptionName());
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
+        try {
+            print("@");
+            print(node.getTagName());
+            print(" ");
+            print(node.getContent());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
+        try {
+            print("{");
+            print("@");
+            print(node.getTagName());
+            print(" ");
+            print(node.getContent());
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitValue(ValueTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            if (node.getReference() != null) {
+                print(" ");
+                print(node.getReference());
+            }
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitVersion(VersionTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitOther(DocTree node, Void p) {
+        try {
+            print("(UNKNOWN: " + node + ")");
+            println();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.source.doctree.DocTree.Kind;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.*;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Position;
+
+/**
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class DocTreeMaker {
+
+    /** The context key for the tree factory. */
+    protected static final Context.Key<DocTreeMaker> treeMakerKey =
+        new Context.Key<DocTreeMaker>();
+
+    /** Get the TreeMaker instance. */
+    public static DocTreeMaker instance(Context context) {
+        DocTreeMaker instance = context.get(treeMakerKey);
+        if (instance == null)
+            instance = new DocTreeMaker(context);
+        return instance;
+    }
+
+    /** The position at which subsequent trees will be created.
+     */
+    public int pos = Position.NOPOS;
+
+    /** Access to diag factory for ErroneousTrees. */
+    private final JCDiagnostic.Factory diags;
+
+    /** Create a tree maker with NOPOS as initial position.
+     */
+    protected DocTreeMaker(Context context) {
+        context.put(treeMakerKey, this);
+        diags = JCDiagnostic.Factory.instance(context);
+        this.pos = Position.NOPOS;
+    }
+
+    /** Reassign current position.
+     */
+    public DocTreeMaker at(int pos) {
+        this.pos = pos;
+        return this;
+    }
+
+    /** Reassign current position.
+     */
+    public DocTreeMaker at(DiagnosticPosition pos) {
+        this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition());
+        return this;
+    }
+
+    public DCAttribute Attribute(Name name, ValueKind vkind, List<DCTree> value) {
+        DCAttribute tree = new DCAttribute(name, vkind, value);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCAuthor Author(List<DCTree> name) {
+        DCAuthor tree = new DCAuthor(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLiteral Code(DCText text) {
+        DCLiteral tree = new DCLiteral(Kind.CODE, text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCComment Comment(String text) {
+        DCComment tree = new DCComment(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDeprecated Deprecated(List<DCTree> text) {
+        DCDeprecated tree = new DCDeprecated(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDocComment DocComment(Comment comment, List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
+        DCDocComment tree = new DCDocComment(comment, firstSentence, body, tags);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDocRoot DocRoot() {
+        DCDocRoot tree = new DCDocRoot();
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCEndElement EndElement(Name name) {
+        DCEndElement tree = new DCEndElement(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCEntity Entity(Name name) {
+        DCEntity tree = new DCEntity(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) {
+        DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCThrows Exception(DCReference name, List<DCTree> description) {
+        DCThrows tree = new DCThrows(Kind.EXCEPTION, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCIdentifier Identifier(Name name) {
+        DCIdentifier tree = new DCIdentifier(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCInheritDoc InheritDoc() {
+        DCInheritDoc tree = new DCInheritDoc();
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLink Link(DCReference ref, List<DCTree> label) {
+        DCLink tree = new DCLink(Kind.LINK, ref, label);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLink LinkPlain(DCReference ref, List<DCTree> label) {
+        DCLink tree = new DCLink(Kind.LINK_PLAIN, ref, label);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLiteral Literal(DCText text) {
+        DCLiteral tree = new DCLiteral(Kind.LITERAL, text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCParam Param(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
+        DCParam tree = new DCParam(isTypeParameter, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCReference Reference(String signature,
+            JCTree qualExpr, Name member, List<JCTree> paramTypes) {
+        DCReference tree = new DCReference(signature, qualExpr, member, paramTypes);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCReturn Return(List<DCTree> description) {
+        DCReturn tree = new DCReturn(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSee See(List<DCTree> reference) {
+        DCSee tree = new DCSee(reference);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerial Serial(List<DCTree> description) {
+        DCSerial tree = new DCSerial(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerialData SerialData(List<DCTree> description) {
+        DCSerialData tree = new DCSerialData(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerialField SerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
+        DCSerialField tree = new DCSerialField(name, type, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSince Since(List<DCTree> text) {
+        DCSince tree = new DCSince(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCStartElement StartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
+        DCStartElement tree = new DCStartElement(name, attrs, selfClosing);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCText Text(String text) {
+        DCText tree = new DCText(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCThrows Throws(DCReference name, List<DCTree> description) {
+        DCThrows tree = new DCThrows(Kind.THROWS, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCUnknownBlockTag UnknownBlockTag(Name name, List<DCTree> content) {
+        DCUnknownBlockTag tree = new DCUnknownBlockTag(name, content);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCUnknownInlineTag UnknownInlineTag(Name name, List<DCTree> content) {
+        DCUnknownInlineTag tree = new DCUnknownInlineTag(name, content);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCValue Value(DCReference ref) {
+        DCValue tree = new DCValue(ref);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCVersion Version(List<DCTree> text) {
+        DCVersion tree = new DCVersion(text);
+        tree.pos = pos;
+        return tree;
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1110,7 +1110,7 @@
     public void visitReference(JCMemberReference tree) {
         try {
             printExpr(tree.expr);
-            print("#");
+            print("::");
             if (tree.typeargs != null) {
                 print("<");
                 printExprs(tree.typeargs);
--- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -31,6 +31,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
@@ -43,9 +44,8 @@
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.CapturedType;
+import com.sun.tools.javac.file.BaseFileObject;
 import com.sun.tools.javac.tree.JCTree.*;
-
-import com.sun.tools.javac.file.BaseFileObject;
 import com.sun.tools.javac.tree.Pretty;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
 
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Jul 05 18:30:46 2017 +0200
@@ -73,6 +73,95 @@
         final String value;
     }
 
+    /**
+     * DiagnosticHandler's provide the initial handling for diagnostics.
+     * When a diagnostic handler is created and has been initialized, it
+     * should install itself as the current diagnostic handler. When a
+     * client has finished using a handler, the client should call
+     * {@code log.removeDiagnosticHandler();}
+     *
+     * Note that javax.tools.DiagnosticListener (if set) is called later in the
+     * diagnostic pipeline.
+     */
+    public static abstract class DiagnosticHandler {
+        /**
+         * The previously installed diagnostic handler.
+         */
+        protected DiagnosticHandler prev;
+
+        /**
+         * Install this diagnostic handler as the current one,
+         * recording the previous one.
+         */
+        protected void install(Log log) {
+            prev = log.diagnosticHandler;
+            log.diagnosticHandler = this;
+        }
+
+        /**
+         * Handle a diagnostic.
+         */
+        public abstract void report(JCDiagnostic diag);
+    }
+
+    /**
+     * A DiagnosticHandler that discards all diagnostics.
+     */
+    public static class DiscardDiagnosticHandler extends DiagnosticHandler {
+        public DiscardDiagnosticHandler(Log log) {
+            install(log);
+        }
+
+        public void report(JCDiagnostic diag) { }
+    }
+
+    /**
+     * A DiagnosticHandler that can defer some or all diagnostics,
+     * by buffering them for later examination and/or reporting.
+     * If a diagnostic is not deferred, or is subsequently reported
+     * with reportAllDiagnostics(), it will be reported to the previously
+     * active diagnostic handler.
+     */
+    public static class DeferredDiagnosticHandler extends DiagnosticHandler {
+        private Queue<JCDiagnostic> deferred = ListBuffer.lb();
+        private final Filter<JCDiagnostic> filter;
+
+        public DeferredDiagnosticHandler(Log log) {
+            this(log, null);
+        }
+
+        public DeferredDiagnosticHandler(Log log, Filter<JCDiagnostic> filter) {
+            this.filter = filter;
+            install(log);
+        }
+
+        public void report(JCDiagnostic diag) {
+            if (filter == null || filter.accepts(diag))
+                deferred.add(diag);
+            else
+                prev.report(diag);
+        }
+
+        public Queue<JCDiagnostic> getDiagnostics() {
+            return deferred;
+        }
+
+        /** Report all deferred diagnostics. */
+        public void reportDeferredDiagnostics() {
+            reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
+        }
+
+        /** Report selected deferred diagnostics. */
+        public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
+            JCDiagnostic d;
+            while ((d = deferred.poll()) != null) {
+                if (kinds.contains(d.getKind()))
+                    prev.report(d);
+            }
+            deferred = null; // prevent accidental ongoing use
+        }
+    }
+
     public enum WriterKind { NOTICE, WARNING, ERROR };
 
     protected PrintWriter errWriter;
@@ -128,10 +217,9 @@
     private JavacMessages messages;
 
     /**
-     * Deferred diagnostics
++     * Handler for initial dispatch of diagnostics.
      */
-    public Filter<JCDiagnostic> deferredDiagFilter;
-    public Queue<JCDiagnostic> deferredDiagnostics = new ListBuffer<JCDiagnostic>();
+    private DiagnosticHandler diagnosticHandler;
 
     /** Construct a log with given I/O redirections.
      */
@@ -147,6 +235,8 @@
             context.get(DiagnosticListener.class);
         this.diagListener = dl;
 
+        diagnosticHandler = new DefaultDiagnosticHandler();
+
         messages = JavacMessages.instance(context);
         messages.add(Main.javacBundleName);
 
@@ -305,6 +395,17 @@
         this.sourceMap = other.sourceMap;
     }
 
+    /**
+     * Replace the specified diagnostic handler with the
+     * handler that was current at the time this handler was created.
+     * The given handler must be the currently installed handler;
+     * it must be specified explicitly for clarity and consistency checking.
+     */
+    public void popDiagnosticHandler(DiagnosticHandler h) {
+        Assert.check(diagnosticHandler == h);
+        diagnosticHandler = h.prev;
+    }
+
     /** Flush the logs
      */
     public void flush() {
@@ -443,64 +544,54 @@
         nwarnings++;
     }
 
-    /** Report all deferred diagnostics, and clear the deferDiagnostics flag. */
-    public void reportDeferredDiagnostics() {
-        reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
-    }
-
-    /** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */
-    public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
-        deferredDiagFilter = null;
-        JCDiagnostic d;
-        while ((d = deferredDiagnostics.poll()) != null) {
-            if (kinds.contains(d.getKind()))
-                report(d);
-        }
-    }
+    /**
+     * Primary method to report a diagnostic.
+     * @param diagnostic
+     */
+    public void report(JCDiagnostic diagnostic) {
+        diagnosticHandler.report(diagnostic);
+     }
 
     /**
      * Common diagnostic handling.
      * The diagnostic is counted, and depending on the options and how many diagnostics have been
      * reported so far, the diagnostic may be handed off to writeDiagnostic.
      */
-    public void report(JCDiagnostic diagnostic) {
-        if (deferredDiagFilter != null && deferredDiagFilter.accepts(diagnostic)) {
-            deferredDiagnostics.add(diagnostic);
-            return;
-        }
+    private class DefaultDiagnosticHandler extends DiagnosticHandler {
+        public void report(JCDiagnostic diagnostic) {
+            if (expectDiagKeys != null)
+                expectDiagKeys.remove(diagnostic.getCode());
+
+            switch (diagnostic.getType()) {
+            case FRAGMENT:
+                throw new IllegalArgumentException();
 
-        if (expectDiagKeys != null)
-            expectDiagKeys.remove(diagnostic.getCode());
-
-        switch (diagnostic.getType()) {
-        case FRAGMENT:
-            throw new IllegalArgumentException();
+            case NOTE:
+                // Print out notes only when we are permitted to report warnings
+                // Notes are only generated at the end of a compilation, so should be small
+                // in number.
+                if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) {
+                    writeDiagnostic(diagnostic);
+                }
+                break;
 
-        case NOTE:
-            // Print out notes only when we are permitted to report warnings
-            // Notes are only generated at the end of a compilation, so should be small
-            // in number.
-            if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) {
-                writeDiagnostic(diagnostic);
-            }
-            break;
+            case WARNING:
+                if (emitWarnings || diagnostic.isMandatory()) {
+                    if (nwarnings < MaxWarnings) {
+                        writeDiagnostic(diagnostic);
+                        nwarnings++;
+                    }
+                }
+                break;
 
-        case WARNING:
-            if (emitWarnings || diagnostic.isMandatory()) {
-                if (nwarnings < MaxWarnings) {
+            case ERROR:
+                if (nerrors < MaxErrors
+                    && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) {
                     writeDiagnostic(diagnostic);
-                    nwarnings++;
+                    nerrors++;
                 }
+                break;
             }
-            break;
-
-        case ERROR:
-            if (nerrors < MaxErrors
-                && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) {
-                writeDiagnostic(diagnostic);
-                nerrors++;
-            }
-            break;
         }
     }
 
@@ -551,18 +642,6 @@
         }
     }
 
-    public void deferAll() {
-        deferredDiagFilter = new Filter<JCDiagnostic>() {
-            public boolean accepts(JCDiagnostic t) {
-                return true;
-            }
-        };
-    }
-
-    public void deferNone() {
-        deferredDiagFilter = null;
-    }
-
     /** Find a localized string in the resource bundle.
      *  Because this method is static, it ignores the locale.
      *  Use localize(key, args) when possible.
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -525,7 +525,8 @@
                     bound = ((ErrorType)bound).getOriginalType();
                 //retrieve the bound list - if the type variable
                 //has not been attributed the bound is not set
-                List<Type> bounds = bound != null ?
+                List<Type> bounds = (bound != null) &&
+                        (bound.hasTag(CLASS) || bound.hasTag(TYPEVAR)) ?
                     types.getBounds(t) :
                     List.<Type>nil();
 
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java	Wed Jul 05 18:30:46 2017 +0200
@@ -39,7 +39,6 @@
  * deletion without notice.</b>
  */
 public class Warner {
-    public static final Warner noWarnings = new Warner();
 
     private DiagnosticPosition pos = null;
     protected boolean warned = false;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Wed Jul 05 18:30:46 2017 +0200
@@ -102,6 +102,7 @@
     Check chk;
     Types types;
     JavaFileManager fileManager;
+    Context context;
 
     /** Allow documenting from class files? */
     boolean docClasses = false;
@@ -122,6 +123,7 @@
      */
     protected DocEnv(Context context) {
         context.put(docEnvKey, this);
+        this.context = context;
 
         messager = Messager.instance0(context);
         syms = Symtab.instance(context);
@@ -209,8 +211,8 @@
     public void setLocale(String localeName) {
         // create locale specifics
         doclocale = new DocLocale(this, localeName, breakiterator);
-        // reset Messager if locale has changed.
-        messager.reset();
+        // update Messager if locale has changed.
+        messager.setLocale(doclocale.locale);
     }
 
     /** Check whether this member should be documented. */
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocLocale.java	Wed Jul 05 18:30:46 2017 +0200
@@ -49,7 +49,7 @@
     final String localeName;
 
     /**
-     * The locale to be used. If user doesen't provide this,
+     * The locale to be used. If user doesn't provide this,
      * then set it to default locale value.
      */
     final Locale locale;
@@ -98,7 +98,7 @@
         if (locale == null) {
             docenv.exit();
         } else {
-            Locale.setDefault(locale);
+            Locale.setDefault(locale); // NOTE: updating global state
         }
         collator = Collator.getInstance(locale);
         sentenceBreaker = BreakIterator.getSentenceInstance(locale);
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Wed Jul 05 18:30:46 2017 +0200
@@ -32,7 +32,12 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+
 import com.sun.javadoc.*;
+import com.sun.tools.javac.file.Locations;
+import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.List;
 import static com.sun.javadoc.LanguageVersion.*;
 
@@ -57,6 +62,12 @@
 
     private final Messager messager;
 
+    /**
+     * In API mode, exceptions thrown while calling the doclet are
+     * propagated using ClientCodeException.
+     */
+    private final boolean apiMode;
+
     private static class DocletInvokeException extends Exception {
         private static final long serialVersionUID = 0;
     }
@@ -71,31 +82,45 @@
         }
     }
 
-    public DocletInvoker(Messager messager,
+    public DocletInvoker(Messager messager, Class<?> docletClass, boolean apiMode) {
+        this.messager = messager;
+        this.docletClass = docletClass;
+        docletClassName = docletClass.getName();
+        appClassLoader = null;
+        this.apiMode = apiMode;
+    }
+
+    public DocletInvoker(Messager messager, JavaFileManager fileManager,
                          String docletClassName, String docletPath,
-                         ClassLoader docletParentClassLoader) {
+                         ClassLoader docletParentClassLoader,
+                         boolean apiMode) {
         this.messager = messager;
         this.docletClassName = docletClassName;
+        this.apiMode = apiMode;
 
-        // construct class loader
-        String cpString = null;   // make sure env.class.path defaults to dot
+        if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.DOCLET_PATH)) {
+            appClassLoader = fileManager.getClassLoader(DocumentationTool.Location.DOCLET_PATH);
+        } else {
+            // construct class loader
+            String cpString = null;   // make sure env.class.path defaults to dot
 
-        // do prepends to get correct ordering
-        cpString = appendPath(System.getProperty("env.class.path"), cpString);
-        cpString = appendPath(System.getProperty("java.class.path"), cpString);
-        cpString = appendPath(docletPath, cpString);
-        URL[] urls = com.sun.tools.javac.file.Locations.pathToURLs(cpString);
-        if (docletParentClassLoader == null)
-            appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
-        else
-            appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
+            // do prepends to get correct ordering
+            cpString = appendPath(System.getProperty("env.class.path"), cpString);
+            cpString = appendPath(System.getProperty("java.class.path"), cpString);
+            cpString = appendPath(docletPath, cpString);
+            URL[] urls = Locations.pathToURLs(cpString);
+            if (docletParentClassLoader == null)
+                appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
+            else
+                appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
+        }
 
         // attempt to find doclet
         Class<?> dc = null;
         try {
             dc = appClassLoader.loadClass(docletClassName);
         } catch (ClassNotFoundException exc) {
-            messager.error(null, "main.doclet_class_not_found", docletClassName);
+            messager.error(Messager.NOPOS, "main.doclet_class_not_found", docletClassName);
             messager.exit();
         }
         docletClass = dc;
@@ -168,7 +193,7 @@
         if (retVal instanceof Boolean) {
             return ((Boolean)retVal).booleanValue();
         } else {
-            messager.error(null, "main.must_return_boolean",
+            messager.error(Messager.NOPOS, "main.must_return_boolean",
                            docletClassName, methodName);
             return false;
         }
@@ -192,7 +217,7 @@
         if (retVal instanceof Integer) {
             return ((Integer)retVal).intValue();
         } else {
-            messager.error(null, "main.must_return_int",
+            messager.error(Messager.NOPOS, "main.must_return_int",
                            docletClassName, methodName);
             return -1;
         }
@@ -217,7 +242,7 @@
         if (retVal instanceof Boolean) {
             return ((Boolean)retVal).booleanValue();
         } else {
-            messager.error(null, "main.must_return_boolean",
+            messager.error(Messager.NOPOS, "main.must_return_boolean",
                            docletClassName, methodName);
             return false;
         }
@@ -241,7 +266,7 @@
             if (retVal instanceof LanguageVersion) {
                 return (LanguageVersion)retVal;
             } else {
-                messager.error(null, "main.must_return_languageversion",
+                messager.error(Messager.NOPOS, "main.must_return_languageversion",
                                docletClassName, methodName);
                 return JAVA_1_1;
             }
@@ -261,45 +286,48 @@
                 meth = docletClass.getMethod(methodName, paramTypes);
             } catch (NoSuchMethodException exc) {
                 if (returnValueIfNonExistent == null) {
-                    messager.error(null, "main.doclet_method_not_found",
+                    messager.error(Messager.NOPOS, "main.doclet_method_not_found",
                                    docletClassName, methodName);
                     throw new DocletInvokeException();
                 } else {
                     return returnValueIfNonExistent;
                 }
             } catch (SecurityException exc) {
-                messager.error(null, "main.doclet_method_not_accessible",
+                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             }
             if (!Modifier.isStatic(meth.getModifiers())) {
-                messager.error(null, "main.doclet_method_must_be_static",
+                messager.error(Messager.NOPOS, "main.doclet_method_must_be_static",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             }
             ClassLoader savedCCL =
                 Thread.currentThread().getContextClassLoader();
             try {
-                Thread.currentThread().setContextClassLoader(appClassLoader);
+                if (appClassLoader != null) // will be null if doclet class provided via API
+                    Thread.currentThread().setContextClassLoader(appClassLoader);
                 return meth.invoke(null , params);
             } catch (IllegalArgumentException exc) {
-                messager.error(null, "main.internal_error_exception_thrown",
+                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                                docletClassName, methodName, exc.toString());
                 throw new DocletInvokeException();
             } catch (IllegalAccessException exc) {
-                messager.error(null, "main.doclet_method_not_accessible",
+                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             } catch (NullPointerException exc) {
-                messager.error(null, "main.internal_error_exception_thrown",
+                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                                docletClassName, methodName, exc.toString());
                 throw new DocletInvokeException();
             } catch (InvocationTargetException exc) {
                 Throwable err = exc.getTargetException();
+                if (apiMode)
+                    throw new ClientCodeException(err);
                 if (err instanceof java.lang.OutOfMemoryError) {
-                    messager.error(null, "main.out.of.memory");
+                    messager.error(Messager.NOPOS, "main.out.of.memory");
                 } else {
-                messager.error(null, "main.exception_thrown",
+                    messager.error(Messager.NOPOS, "main.exception_thrown",
                                docletClassName, methodName, exc.toString());
                     exc.getTargetException().printStackTrace();
                 }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Jul 05 18:30:46 2017 +0200
@@ -38,7 +38,6 @@
 import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
-import com.sun.tools.javac.comp.Annotate;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
@@ -65,11 +64,9 @@
 public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
     DocEnv docenv;
 
-    final Context context;
     final Messager messager;
-    final JavadocClassReader reader;
-    final JavadocEnter enter;
-    final Annotate annotate;
+    final JavadocClassReader javadocReader;
+    final JavadocEnter javadocEnter;
 
     /**
      * Construct a new JavaCompiler processor, using appropriately
@@ -77,11 +74,9 @@
      */
     protected JavadocTool(Context context) {
         super(context);
-        this.context = context;
         messager = Messager.instance0(context);
-        reader = JavadocClassReader.instance0(context);
-        enter = JavadocEnter.instance0(context);
-        annotate = Annotate.instance(context);
+        javadocReader = JavadocClassReader.instance0(context);
+        javadocEnter = JavadocEnter.instance0(context);
     }
 
     /**
@@ -124,6 +119,7 @@
                                       ModifierFilter filter,
                                       List<String> javaNames,
                                       List<String[]> options,
+                                      Iterable<? extends JavaFileObject> fileObjects,
                                       boolean breakiterator,
                                       List<String> subPackages,
                                       List<String> excludedPackages,
@@ -138,17 +134,18 @@
         docenv.setEncoding(encoding);
         docenv.docClasses = docClasses;
         docenv.legacyDoclet = legacyDoclet;
-        reader.sourceCompleter = docClasses ? null : this;
+        javadocReader.sourceCompleter = docClasses ? null : this;
 
         ListBuffer<String> names = new ListBuffer<String>();
         ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<JCCompilationUnit>();
         ListBuffer<JCCompilationUnit> packTrees = new ListBuffer<JCCompilationUnit>();
 
         try {
-            StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager;
+            StandardJavaFileManager fm = docenv.fileManager instanceof StandardJavaFileManager
+                    ? (StandardJavaFileManager) docenv.fileManager : null;
             for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
                 String name = it.head;
-                if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
+                if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) {
                     JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
                     docenv.notice("main.Loading_source_file", name);
                     JCCompilationUnit tree = parse(fo);
@@ -156,11 +153,19 @@
                 } else if (isValidPackageName(name)) {
                     names = names.append(name);
                 } else if (name.endsWith(".java")) {
-                    docenv.error(null, "main.file_not_found", name);
+                    if (fm == null)
+                        throw new IllegalArgumentException();
+                    else
+                        docenv.error(null, "main.file_not_found", name);
                 } else {
                     docenv.error(null, "main.illegal_package_name", name);
                 }
             }
+            for (JavaFileObject fo: fileObjects) {
+                docenv.notice("main.Loading_source_file", fo.getName());
+                JCCompilationUnit tree = parse(fo);
+                classTrees.append(tree);
+            }
 
             if (!docClasses) {
                 // Recursively search given subpackages.  If any packages
@@ -179,7 +184,7 @@
 
                 // Enter symbols for all files
                 docenv.notice("main.Building_tree");
-                enter.main(classTrees.toList().appendList(packTrees.toList()));
+                javadocEnter.main(classTrees.toList().appendList(packTrees.toList()));
             }
         } catch (Abort ex) {}
 
@@ -240,7 +245,7 @@
         }
 
         if (!hasFiles) {
-            messager.warning(null, "main.no_source_files_for_package",
+            messager.warning(Messager.NOPOS, "main.no_source_files_for_package",
                     name.replace(File.separatorChar, '.'));
         }
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,13 +25,16 @@
 
 package com.sun.tools.javadoc;
 
-import java.io.PrintWriter;  // Access to 'javac' output streams
+import java.io.PrintWriter;
 import java.text.MessageFormat;
-import java.util.MissingResourceException;
+import java.util.Locale;
 import java.util.ResourceBundle;
 
 import com.sun.javadoc.*;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
+import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.Log;
 
 /**
@@ -51,6 +54,7 @@
  * @author Neal Gafter (rewrite)
  */
 public class Messager extends Log implements DocErrorReporter {
+    public static final SourcePosition NOPOS = null;
 
     /** Get the current messager, which is also the compiler log. */
     public static Messager instance0(Context context) {
@@ -91,7 +95,9 @@
 
     final String programName;
 
-    private ResourceBundle messageRB = null;
+    private Locale locale;
+    private final JavacMessages messages;
+    private final JCDiagnostic.Factory javadocDiags;
 
     /** The default writer for diagnostics
      */
@@ -121,6 +127,9 @@
                        PrintWriter warnWriter,
                        PrintWriter noticeWriter) {
         super(context, errWriter, warnWriter, noticeWriter);
+        messages = JavacMessages.instance(context);
+        messages.add("com.sun.tools.javadoc.resources.javadoc");
+        javadocDiags = new JCDiagnostic.Factory(messages, "javadoc");
         this.programName = programName;
     }
 
@@ -134,94 +143,18 @@
         return Integer.MAX_VALUE;
     }
 
-    /**
-     * Reset resource bundle, eg. locale has changed.
-     */
-    public void reset() {
-        messageRB = null;
-    }
-
-    /**
-     * Get string from ResourceBundle, initialize ResourceBundle
-     * if needed.
-     */
-    private String getString(String key) {
-        if (messageRB == null) {
-            try {
-                messageRB = ResourceBundle.getBundle(
-                          "com.sun.tools.javadoc.resources.javadoc");
-            } catch (MissingResourceException e) {
-                throw new Error("Fatal: Resource for javadoc is missing");
-            }
-        }
-        return messageRB.getString(key);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     */
-    String getText(String key) {
-        return getText(key, (String)null);
+    public void setLocale(Locale locale) {
+        this.locale = locale;
     }
 
     /**
      * get and format message string from resource
      *
      * @param key selects message from resource
-     * @param a1 first argument
-     */
-    String getText(String key, String a1) {
-        return getText(key, a1, null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    String getText(String key, String a1, String a2) {
-        return getText(key, a1, a2, null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
+     * @param args arguments for the message
      */
-    String getText(String key, String a1, String a2, String a3) {
-        return getText(key, a1, a2, a3, null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     * @param a4 fourth argument
-     */
-    String getText(String key, String a1, String a2, String a3,
-                          String a4) {
-        try {
-            String message = getString(key);
-            String[] args = new String[4];
-            args[0] = a1;
-            args[1] = a2;
-            args[2] = a3;
-            args[3] = a4;
-            return MessageFormat.format(message, (Object[])args);
-        } catch (MissingResourceException e) {
-            return "********** Resource for javadoc is broken. There is no " +
-                key + " key in resource.";
-        }
+    String getText(String key, Object... args) {
+        return messages.getLocalizedString(locale, key, args);
     }
 
     /**
@@ -242,6 +175,11 @@
      * @param msg message to print
      */
     public void printError(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.ERROR, pos, msg);
+            return;
+        }
+
         if (nerrors < MaxErrors) {
             String prefix = (pos == null) ? programName : pos.toString();
             errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
@@ -269,6 +207,11 @@
      * @param msg message to print
      */
     public void printWarning(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.WARNING, pos, msg);
+            return;
+        }
+
         if (nwarnings < MaxWarnings) {
             String prefix = (pos == null) ? programName : pos.toString();
             warnWriter.println(prefix +  ": " + getText("javadoc.warning") +" - " + msg);
@@ -295,6 +238,11 @@
      * @param msg message to print
      */
     public void printNotice(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.NOTE, pos, msg);
+            return;
+        }
+
         if (pos == null)
             noticeWriter.println(msg);
         else
@@ -307,41 +255,8 @@
      *
      * @param key selects message from resource
      */
-    public void error(SourcePosition pos, String key) {
-        printError(pos, getText(key));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    public void error(SourcePosition pos, String key, String a1) {
-        printError(pos, getText(key, a1));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2) {
-        printError(pos, getText(key, a1, a2));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printError(pos, getText(key, a1, a2, a3));
+    public void error(SourcePosition pos, String key, Object... args) {
+        printError(pos, getText(key, args));
     }
 
     /**
@@ -349,54 +264,8 @@
      *
      * @param key selects message from resource
      */
-    public void warning(SourcePosition pos, String key) {
-        printWarning(pos, getText(key));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    public void warning(SourcePosition pos, String key, String a1) {
-        printWarning(pos, getText(key, a1));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2) {
-        printWarning(pos, getText(key, a1, a2));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printWarning(pos, getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2, String a3,
-                        String a4) {
-        printWarning(pos, getText(key, a1, a2, a3, a4));
+    public void warning(SourcePosition pos, String key, Object... args) {
+        printWarning(pos, getText(key, args));
     }
 
     /**
@@ -404,41 +273,8 @@
      *
      * @param key selects message from resource
      */
-    public void notice(String key) {
-        printNotice(getText(key));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    public void notice(String key, String a1) {
-        printNotice(getText(key, a1));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void notice(String key, String a1, String a2) {
-        printNotice(getText(key, a1, a2));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void notice(String key, String a1, String a2, String a3) {
-        printNotice(getText(key, a1, a2, a3));
+    public void notice(String key, Object... args) {
+        printNotice(getText(key, args));
     }
 
     /**
@@ -476,4 +312,21 @@
         throw new ExitJavadoc();
     }
 
+    private void report(DiagnosticType type, SourcePosition pos, String msg) {
+        switch (type) {
+            case ERROR:
+            case WARNING:
+                Object prefix = (pos == null) ? programName : pos;
+                report(javadocDiags.create(type, null, null, "msg", prefix, msg));
+                break;
+
+            case NOTE:
+                String key = (pos == null) ? "msg" : "pos.msg";
+                report(javadocDiags.create(type, null, null, key, pos, msg));
+                break;
+
+            default:
+                throw new IllegalArgumentException(type.toString());
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -43,7 +43,7 @@
  */
 class ParamTagImpl extends TagImpl implements ParamTag {
 
-    private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
+    private static final Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
 
     private final String parameterName;
     private final String parameterComment;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -27,6 +27,7 @@
 
 import java.io.IOException;
 import java.util.Locale;
+import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
 
@@ -368,4 +369,11 @@
     public Locale getLocale() {
         return env.doclocale.locale;
     }
+
+    /**
+     * Return the current file manager.
+     */
+    public JavaFileManager getFileManager() {
+        return env.fileManager;
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,14 @@
 
 package com.sun.tools.javadoc;
 
+import java.io.File;
+import java.util.Locale;
+
 import com.sun.javadoc.*;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Printer;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type.CapturedType;
 import com.sun.tools.javac.util.*;
 
 /**
@@ -75,9 +82,63 @@
                 container = (ClassDocImpl)holder;
             }
             findReferenced(container);
+            if (showRef) showRef();
         }
     }
 
+    private static final boolean showRef = false;
+
+    private void showRef() {
+        Symbol sym;
+        if (referencedMember != null) {
+            if (referencedMember instanceof MethodDocImpl)
+                sym = ((MethodDocImpl) referencedMember).sym;
+            else if (referencedMember instanceof FieldDocImpl)
+                sym = ((FieldDocImpl) referencedMember).sym;
+            else
+                sym = ((ConstructorDocImpl) referencedMember).sym;
+        } else if (referencedClass != null) {
+            sym = ((ClassDocImpl) referencedClass).tsym;
+        } else if (referencedPackage != null) {
+            sym = ((PackageDocImpl) referencedPackage).sym;
+        } else
+            return;
+
+        final JavacMessages messages = JavacMessages.instance(docenv().context);
+        Locale locale = Locale.getDefault();
+        Printer printer = new Printer() {
+            int count;
+            @Override
+            protected String localize(Locale locale, String key, Object... args) {
+                return messages.getLocalizedString(locale, key, args);
+            }
+            @Override
+            protected String capturedVarId(CapturedType t, Locale locale) {
+                return "CAP#" + (++count);
+            }
+        };
+
+        String s = text.replaceAll("\\s+", " ");  // normalize white space
+        int sp = s.indexOf(" ");
+        int lparen = s.indexOf("(");
+        int rparen = s.indexOf(")");
+        String seetext = (sp == -1) ? s
+                : (lparen == -1 || sp < lparen) ? s.substring(0, sp)
+                : s.substring(0, rparen + 1);
+
+        File file = new File(holder.position().file().getAbsoluteFile().toURI().normalize());
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("+++ ").append(file).append(": ")
+                .append(name()).append(" ").append(seetext).append(": ");
+        sb.append(sym.getKind()).append(" ");
+        if (sym.kind == Kinds.MTH || sym.kind == Kinds.VAR)
+            sb.append(printer.visit(sym.owner, locale)).append(".");
+        sb.append(printer.visit(sym, locale));
+
+        System.err.println(sb);
+    }
+
     /**
      * get the class name part of @see, For instance,
      * if the comment is @see String#startsWith(java.lang.String) .
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java	Wed Jul 05 18:30:46 2017 +0200
@@ -29,10 +29,16 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.StringTokenizer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
 
 import com.sun.javadoc.*;
 import com.sun.tools.javac.main.CommandLine;
+import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
@@ -53,7 +59,7 @@
  * @author Robert Field
  * @author Neal Gafter (rewrite)
  */
-class Start {
+public class Start extends ToolOption.Helper {
     /** Context for this invocation. */
     private final Context context;
 
@@ -65,24 +71,17 @@
     private static final String standardDocletClassName =
         "com.sun.tools.doclets.standard.Standard";
 
-    private ListBuffer<String[]> options = new ListBuffer<String[]>();
-
-    private ModifierFilter showAccess = null;
-
     private long defaultFilter = PUBLIC | PROTECTED;
 
     private final Messager messager;
 
-    String docLocale = "";
-
-    boolean breakiterator = false;
-    boolean quiet = false;
-    String encoding = null;
-
     private DocletInvoker docletInvoker;
 
-    /* Treat warnings as errors. */
-    private boolean rejectWarnings = false;
+    /**
+     * In API mode, exceptions thrown while calling the doclet are
+     * propagated using ClientCodeException.
+     */
+    private boolean apiMode;
 
     Start(String programName,
           PrintWriter errWriter,
@@ -132,23 +131,59 @@
         this(javadocName);
     }
 
+    public Start(Context context) {
+        context.getClass(); // null check
+        this.context = context;
+        apiMode = true;
+        defaultDocletClassName = standardDocletClassName;
+        docletParentClassLoader = null;
+
+        Log log = context.get(Log.logKey);
+        if (log instanceof Messager)
+            messager = (Messager) log;
+        else {
+            PrintWriter out = context.get(Log.outKey);
+            messager = (out == null) ? new Messager(context, javadocName)
+                    : new Messager(context, javadocName, out, out, out);
+        }
+    }
+
     /**
      * Usage
      */
-    private void usage() {
+    @Override
+    void usage() {
+        usage(true);
+    }
+
+
+    /**
+     * Usage
+     */
+    private void usage(boolean exit) {
+        // RFE: it would be better to replace the following with code to
+        // write a header, then help for each option, then a footer.
         messager.notice("main.usage");
 
         // let doclet print usage information (does nothing on error)
         if (docletInvoker != null) {
             docletInvoker.optionLength("-help");
         }
+
+        if (exit) exit();
+    }
+
+    @Override
+    void Xusage() {
+        Xusage(true);
     }
 
     /**
      * Usage
      */
-    private void Xusage() {
+    private void Xusage(boolean exit) {
         messager.notice("main.Xusage");
+        if (exit) exit();
     }
 
     /**
@@ -163,22 +198,36 @@
      * Main program - external wrapper
      */
     int begin(String... argv) {
+        boolean ok = begin(null, argv, Collections.<JavaFileObject> emptySet());
+        return ok ? 0 : 1;
+    }
+
+    public boolean begin(Class<?> docletClass, Iterable<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+        Collection<String> opts = new ArrayList<String>();
+        for (String opt: options) opts.add(opt);
+        return begin(docletClass, opts.toArray(new String[opts.size()]), fileObjects);
+    }
+
+    private boolean begin(Class<?> docletClass, String[] options, Iterable<? extends JavaFileObject> fileObjects) {
         boolean failed = false;
 
         try {
-            failed = !parseAndExecute(argv);
-        } catch(Messager.ExitJavadoc exc) {
+            failed = !parseAndExecute(docletClass, options, fileObjects);
+        } catch (Messager.ExitJavadoc exc) {
             // ignore, we just exit this way
         } catch (OutOfMemoryError ee) {
-            messager.error(null, "main.out.of.memory");
+            messager.error(Messager.NOPOS, "main.out.of.memory");
             failed = true;
+        } catch (ClientCodeException e) {
+            // simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl
+            throw e;
         } catch (Error ee) {
             ee.printStackTrace(System.err);
-            messager.error(null, "main.fatal.error");
+            messager.error(Messager.NOPOS, "main.fatal.error");
             failed = true;
         } catch (Exception ee) {
             ee.printStackTrace(System.err);
-            messager.error(null, "main.fatal.exception");
+            messager.error(Messager.NOPOS, "main.fatal.exception");
             failed = true;
         } finally {
             messager.exitNotice();
@@ -186,22 +235,16 @@
         }
         failed |= messager.nerrors() > 0;
         failed |= rejectWarnings && messager.nwarnings() > 0;
-        return failed ? 1 : 0;
-    }
-
-    private void addToList(ListBuffer<String> list, String str){
-        StringTokenizer st = new StringTokenizer(str, ":");
-        String current;
-        while(st.hasMoreTokens()){
-            current = st.nextToken();
-            list.append(current);
-        }
+        return !failed;
     }
 
     /**
      * Main program - internal
      */
-    private boolean parseAndExecute(String... argv) throws IOException {
+    private boolean parseAndExecute(
+            Class<?> docletClass,
+            String[] argv,
+            Iterable<? extends JavaFileObject> fileObjects) throws IOException {
         long tm = System.currentTimeMillis();
 
         ListBuffer<String> javaNames = new ListBuffer<String>();
@@ -210,124 +253,39 @@
         try {
             argv = CommandLine.parse(argv);
         } catch (FileNotFoundException e) {
-            messager.error(null, "main.cant.read", e.getMessage());
+            messager.error(Messager.NOPOS, "main.cant.read", e.getMessage());
             exit();
         } catch (IOException e) {
             e.printStackTrace(System.err);
             exit();
         }
 
-        setDocletInvoker(argv);
-        ListBuffer<String> subPackages = new ListBuffer<String>();
-        ListBuffer<String> excludedPackages = new ListBuffer<String>();
 
-        Options compOpts = Options.instance(context);
-        boolean docClasses = false;
+        JavaFileManager fileManager = context.get(JavaFileManager.class);
+        setDocletInvoker(docletClass, fileManager, argv);
+
+        compOpts = Options.instance(context);
 
         // Parse arguments
         for (int i = 0 ; i < argv.length ; i++) {
             String arg = argv[i];
-            if (arg.equals("-subpackages")) {
-                oneArg(argv, i++);
-                addToList(subPackages, argv[i]);
-            } else if (arg.equals("-exclude")){
-                oneArg(argv, i++);
-                addToList(excludedPackages, argv[i]);
-            } else if (arg.equals("-verbose")) {
-                setOption(arg);
-                compOpts.put("-verbose", "");
-            } else if (arg.equals("-encoding")) {
-                oneArg(argv, i++);
-                encoding = argv[i];
-                compOpts.put("-encoding", argv[i]);
-            } else if (arg.equals("-breakiterator")) {
-                breakiterator = true;
-                setOption("-breakiterator");
-            } else if (arg.equals("-quiet")) {
-                quiet = true;
-                setOption("-quiet");
-            } else if (arg.equals("-help")) {
-                usage();
-                exit();
-            } else if (arg.equals("-Xclasses")) {
-                setOption(arg);
-                docClasses = true;
-            } else if (arg.equals("-Xwerror")) {
-                setOption(arg);
-                rejectWarnings = true;
-            } else if (arg.equals("-private")) {
-                setOption(arg);
-                setFilter(ModifierFilter.ALL_ACCESS);
-            } else if (arg.equals("-package")) {
-                setOption(arg);
-                setFilter(PUBLIC | PROTECTED |
-                          ModifierFilter.PACKAGE );
-            } else if (arg.equals("-protected")) {
-                setOption(arg);
-                setFilter(PUBLIC | PROTECTED );
-            } else if (arg.equals("-public")) {
-                setOption(arg);
-                setFilter(PUBLIC);
-            } else if (arg.equals("-source")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-source") != null) {
-                    usageError("main.option.already.seen", arg);
+
+            ToolOption o = ToolOption.get(arg);
+            if (o != null) {
+                // hack: this restriction should be removed
+                if (o == ToolOption.LOCALE && i > 0)
+                    usageError("main.locale_first");
+
+                if (o.hasArg) {
+                    oneArg(argv, i++);
+                    o.process(this, argv[i]);
+                } else {
+                    setOption(arg);
+                    o.process(this);
                 }
-                compOpts.put("-source", argv[i]);
-            } else if (arg.equals("-prompt")) {
-                compOpts.put("-prompt", "-prompt");
-                messager.promptOnError = true;
-            } else if (arg.equals("-sourcepath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-sourcepath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-sourcepath", argv[i]);
-            } else if (arg.equals("-classpath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-classpath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-classpath", argv[i]);
-            } else if (arg.equals("-sysclasspath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-bootclasspath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-bootclasspath", argv[i]);
-            } else if (arg.equals("-bootclasspath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-bootclasspath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-bootclasspath", argv[i]);
-            } else if (arg.equals("-extdirs")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-extdirs") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-extdirs", argv[i]);
-            } else if (arg.equals("-overview")) {
-                oneArg(argv, i++);
-            } else if (arg.equals("-doclet")) {
-                i++;  // handled in setDocletInvoker
-            } else if (arg.equals("-docletpath")) {
-                i++;  // handled in setDocletInvoker
-            } else if (arg.equals("-locale")) {
-                if (i != 0)
-                    usageError("main.locale_first");
-                oneArg(argv, i++);
-                docLocale = argv[i];
-            } else if (arg.equals("-Xmaxerrs") || arg.equals("-Xmaxwarns")) {
-                oneArg(argv, i++);
-                if (compOpts.get(arg) != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put(arg, argv[i]);
-            } else if (arg.equals("-X")) {
-                Xusage();
-                exit();
+
             } else if (arg.startsWith("-XD")) {
+                // hidden javac options
                 String s = arg.substring("-XD".length());
                 int eq = s.indexOf('=');
                 String key = (eq < 0) ? s : s.substring(0, eq);
@@ -336,7 +294,7 @@
             }
             // call doclet for its options
             // other arg starts with - is invalid
-            else if ( arg.startsWith("-") ) {
+            else if (arg.startsWith("-")) {
                 int optionLength;
                 optionLength = docletInvoker.optionLength(arg);
                 if (optionLength < 0) {
@@ -362,7 +320,7 @@
         }
         compOpts.notifyListeners();
 
-        if (javaNames.isEmpty() && subPackages.isEmpty()) {
+        if (javaNames.isEmpty() && subPackages.isEmpty() && isEmpty(fileObjects)) {
             usageError("main.No_packages_or_classes_specified");
         }
 
@@ -380,12 +338,19 @@
 
         LanguageVersion languageVersion = docletInvoker.languageVersion();
         RootDocImpl root = comp.getRootDocImpl(
-                docLocale, encoding, showAccess,
-                javaNames.toList(), options.toList(), breakiterator,
-                subPackages.toList(), excludedPackages.toList(),
+                docLocale,
+                encoding,
+                showAccess,
+                javaNames.toList(),
+                options.toList(),
+                fileObjects,
+                breakiterator,
+                subPackages.toList(),
+                excludedPackages.toList(),
                 docClasses,
                 // legacy?
-                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, quiet);
+                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1,
+                quiet);
 
         // release resources
         comp = null;
@@ -403,21 +368,43 @@
         return ok;
     }
 
-    private void setDocletInvoker(String[] argv) {
+    private <T> boolean isEmpty(Iterable<T> iter) {
+        return !iter.iterator().hasNext();
+    }
+
+    /**
+     * Init the doclet invoker.
+     * The doclet class may be given explicitly, or via the -doclet option in
+     * argv.
+     * If the doclet class is not given explicitly, it will be loaded from
+     * the file manager's DOCLET_PATH location, if available, or via the
+     * -doclet path option in argv.
+     * @param docletClass The doclet class. May be null.
+     * @param fileManager The file manager used to get the class loader to load
+     * the doclet class if required. May be null.
+     * @param argv Args containing -doclet and -docletpath, in case they are required.
+     */
+    private void setDocletInvoker(Class<?> docletClass, JavaFileManager fileManager, String[] argv) {
+        if (docletClass != null) {
+            docletInvoker = new DocletInvoker(messager, docletClass, apiMode);
+            // TODO, check no -doclet, -docletpath
+            return;
+        }
+
         String docletClassName = null;
         String docletPath = null;
 
         // Parse doclet specifying arguments
         for (int i = 0 ; i < argv.length ; i++) {
             String arg = argv[i];
-            if (arg.equals("-doclet")) {
+            if (arg.equals(ToolOption.DOCLET.opt)) {
                 oneArg(argv, i++);
                 if (docletClassName != null) {
                     usageError("main.more_than_one_doclet_specified_0_and_1",
                                docletClassName, argv[i]);
                 }
                 docletClassName = argv[i];
-            } else if (arg.equals("-docletpath")) {
+            } else if (arg.equals(ToolOption.DOCLETPATH.opt)) {
                 oneArg(argv, i++);
                 if (docletPath == null) {
                     docletPath = argv[i];
@@ -432,18 +419,10 @@
         }
 
         // attempt to find doclet
-        docletInvoker = new DocletInvoker(messager,
-                                          docletClassName, docletPath,
-                                          docletParentClassLoader);
-    }
-
-    private void setFilter(long filterBits) {
-        if (showAccess != null) {
-            messager.error(null, "main.incompatible.access.flags");
-            usage();
-            exit();
-        }
-        showAccess = new ModifierFilter(filterBits);
+        docletInvoker = new DocletInvoker(messager, fileManager,
+                docletClassName, docletPath,
+                docletParentClassLoader,
+                apiMode);
     }
 
     /**
@@ -458,22 +437,10 @@
         }
     }
 
-    private void usageError(String key) {
-        messager.error(null, key);
-        usage();
-        exit();
-    }
-
-    private void usageError(String key, String a1) {
-        messager.error(null, key, a1);
-        usage();
-        exit();
-    }
-
-    private void usageError(String key, String a1, String a2) {
-        messager.error(null, key, a1, a2);
-        usage();
-        exit();
+    @Override
+    void usageError(String key, Object... args) {
+        messager.error(Messager.NOPOS, key, args);
+        usage(true);
     }
 
     /**
@@ -502,7 +469,6 @@
         for (List<String> i = arguments; i.nonEmpty(); i=i.tail) {
             args[k++] = i.head;
         }
-        options = options.append(args);
+        options.append(args);
     }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ToolOption.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javadoc;
+
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Options;
+import java.util.StringTokenizer;
+
+
+/**
+ * javadoc tool options.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public enum ToolOption {
+    // ----- options for underlying compiler -----
+
+    BOOTCLASSPATH("-bootclasspath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    CLASSPATH("-classpath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    EXTDIRS("-extdirs", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SOURCEPATH("-sourcepath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SYSCLASSPATH("-sysclasspath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt("-bootclasspath", arg);
+        }
+    },
+
+    ENCODING("-encoding", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.encoding = arg;
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SOURCE("-source", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    XMAXERRS("-Xmaxerrs", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    XMAXWARNS("-Xmaxwarns", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    // ----- doclet options -----
+
+    DOCLET("-doclet", true), // handled in setDocletInvoker
+
+    DOCLETPATH("-docletpath", true), // handled in setDocletInvoker
+
+    // ----- selection options -----
+
+    SUBPACKAGES("-subpackages", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.addToList(helper.subPackages, arg);
+        }
+    },
+
+    EXCLUDE("-exclude", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.addToList(helper.excludedPackages, arg);
+        }
+    },
+
+    // ----- filtering options -----
+
+    PACKAGE("-package") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(
+                    Flags.PUBLIC | Flags.PROTECTED | ModifierFilter.PACKAGE);
+        }
+    },
+
+    PRIVATE("-private") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(ModifierFilter.ALL_ACCESS);
+        }
+    },
+
+    PROTECTED("-protected") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(Flags.PUBLIC | Flags.PROTECTED);
+        }
+    },
+
+    PUBLIC("-public") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(Flags.PUBLIC);
+        }
+    },
+
+    // ----- output control options -----
+
+    PROMPT("-prompt") {
+        @Override
+        public void process(Helper helper) {
+            helper.compOpts.put("-prompt", "-prompt");
+            helper.promptOnError = true;
+        }
+    },
+
+    QUIET("-quiet") {
+        @Override
+        public void process(Helper helper) {
+            helper.quiet = true;
+        }
+    },
+
+    VERBOSE("-verbose") {
+        @Override
+        public void process(Helper helper) {
+            helper.compOpts.put("-verbose", "");
+        }
+    },
+
+    XWERROR("-Xwerror") {
+        @Override
+        public void process(Helper helper) {
+            helper.rejectWarnings = true;
+
+        }
+    },
+
+    // ----- other options -----
+
+    BREAKITERATOR("-breakiterator") {
+        @Override
+        public void process(Helper helper) {
+            helper.breakiterator = true;
+        }
+    },
+
+    LOCALE("-locale", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.docLocale = arg;
+        }
+    },
+
+    OVERVIEW("-overview", true),
+
+    XCLASSES("-Xclasses") {
+        @Override
+        public void process(Helper helper) {
+            helper.docClasses = true;
+
+        }
+    },
+
+    // ----- help options -----
+
+    HELP("-help") {
+        @Override
+        public void process(Helper helper) {
+            helper.usage();
+        }
+    },
+
+    X("-X") {
+        @Override
+        public void process(Helper helper) {
+            helper.Xusage();
+        }
+    };
+
+    public final String opt;
+    public final boolean hasArg;
+
+    ToolOption(String opt) {
+        this(opt, false);
+    }
+
+    ToolOption(String opt, boolean hasArg) {
+        this.opt = opt;
+        this.hasArg = hasArg;
+    }
+
+    void process(Helper helper, String arg) { }
+
+    void process(Helper helper) { }
+
+    static ToolOption get(String name) {
+        for (ToolOption o: values()) {
+            if (name.equals(o.opt))
+                return o;
+        }
+        return null;
+    }
+
+    static abstract class Helper {
+        /** List of decoded options. */
+        final ListBuffer<String[]> options = new ListBuffer<String[]>();
+
+        /** Selected packages, from -subpackages. */
+        final ListBuffer<String> subPackages = new ListBuffer<String>();
+
+        /** Excluded packages, from -exclude. */
+        final ListBuffer<String> excludedPackages = new ListBuffer<String>();
+
+        /** javac options, set by various options. */
+        Options compOpts; // = Options.instance(context)
+
+        /* Encoding for javac, and files written? set by -encoding. */
+        String encoding = null;
+
+        /** Set by -breakiterator. */
+        boolean breakiterator = false;
+
+        /** Set by -quiet. */
+        boolean quiet = false;
+
+        /** Set by -Xclasses. */
+        boolean docClasses = false;
+
+        /** Set by -Xwerror. */
+        boolean rejectWarnings = false;
+
+        /** Set by -prompt. */
+        boolean promptOnError;
+
+        /** Set by -locale. */
+        String docLocale = "";
+
+        /** Set by -public, private, -protected, -package. */
+        ModifierFilter showAccess = null;
+
+        abstract void usage();
+        abstract void Xusage();
+
+        abstract void usageError(String msg, Object... args);
+
+        protected void addToList(ListBuffer<String> list, String str){
+            StringTokenizer st = new StringTokenizer(str, ":");
+            String current;
+            while(st.hasMoreTokens()){
+                current = st.nextToken();
+                list.append(current);
+            }
+        }
+
+        protected void setFilter(long filterBits) {
+            if (showAccess != null) {
+                usageError("main.incompatible.access.flags");
+            }
+            showAccess = new ModifierFilter(filterBits);
+        }
+
+        private void setCompilerOpt(String opt, String arg) {
+            if (compOpts.get(opt) != null) {
+                usageError("main.option.already.seen", opt);
+            }
+            compOpts.put(opt, arg);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.javadoc.api;
+
+import com.sun.tools.javac.util.ClientCodeException;
+import java.util.Locale;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.Start;
+import java.util.Collections;
+
+/**
+ * Provides access to functionality specific to the JDK documentation tool,
+ * javadoc.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk.  This code and its internal interfaces are subject to change
+ * or deletion without notice.</b></p>
+ */
+public class JavadocTaskImpl implements DocumentationTask {
+    private final AtomicBoolean used = new AtomicBoolean();
+
+    private final Context context;
+    private Class<?> docletClass;
+    private Iterable<String> options;
+    private Iterable<? extends JavaFileObject> fileObjects;
+    private Locale locale;
+
+    public JavadocTaskImpl(Context context, Class<?> docletClass,
+            Iterable<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+        this.context = context;
+        this.docletClass = docletClass;
+
+        this.options = (options == null) ? Collections.<String>emptySet()
+                : nullCheck(options);
+        this.fileObjects = (fileObjects == null) ? Collections.<JavaFileObject>emptySet()
+                : nullCheck(fileObjects);
+        setLocale(Locale.getDefault());
+    }
+
+    public void setLocale(Locale locale) {
+        if (used.get())
+            throw new IllegalStateException();
+        this.locale = locale;
+    }
+
+    public Boolean call() {
+        if (!used.getAndSet(true)) {
+            initContext();
+            Start jdoc = new Start(context);
+            try {
+                return jdoc.begin(docletClass, options, fileObjects);
+            } catch (ClientCodeException e) {
+                throw new RuntimeException(e.getCause());
+            }
+        } else {
+            throw new IllegalStateException("multiple calls to method 'call'");
+        }
+    }
+
+    private void initContext() {
+        //initialize compiler's default locale
+        context.put(Locale.class, locale);
+    }
+
+    private static <T> Iterable<T> nullCheck(Iterable<T> items) {
+        for (T item: items) {
+            if (item == null)
+                throw new NullPointerException();
+        }
+        return items;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javadoc.api;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+import javax.tools.DiagnosticListener;
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.ClientCodeException;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javadoc.ToolOption;
+
+/**
+ * Provides access to functionality specific to the JDK documentation tool,
+ * javadoc.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk.  This code and its internal interfaces are subject to change
+ * or deletion without notice.</b></p>
+ */
+public class JavadocTool implements DocumentationTool {
+    @Override
+    public DocumentationTask getTask(
+            Writer out,
+            JavaFileManager fileManager,
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Class<?> docletClass,
+            Iterable<String> options,
+            Iterable<? extends JavaFileObject> compilationUnits) {
+        Context context = new Context();
+        return getTask(out, fileManager, diagnosticListener,
+                docletClass, options, compilationUnits, context);
+    }
+
+    public DocumentationTask getTask(
+            Writer out,
+            JavaFileManager fileManager,
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Class<?> docletClass,
+            Iterable<String> options,
+            Iterable<? extends JavaFileObject> compilationUnits,
+            Context context) {
+        try {
+            ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
+
+            if (options != null) {
+                for (String option : options)
+                    option.getClass(); // null check
+            }
+
+            if (compilationUnits != null) {
+                compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
+                for (JavaFileObject cu : compilationUnits) {
+                    if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
+                        final String kindMsg = "All compilation units must be of SOURCE kind";
+                        throw new IllegalArgumentException(kindMsg);
+                    }
+                }
+            }
+
+            if (diagnosticListener != null)
+                context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
+
+            if (out == null)
+                context.put(Log.outKey, new PrintWriter(System.err, true));
+            else if (out instanceof PrintWriter)
+                context.put(Log.outKey, ((PrintWriter) out));
+            else
+                context.put(Log.outKey, new PrintWriter(out, true));
+
+            if (fileManager == null)
+                fileManager = getStandardFileManager(diagnosticListener, null, null);
+            fileManager = ccw.wrap(fileManager);
+            context.put(JavaFileManager.class, fileManager);
+
+            return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
+        } catch (ClientCodeException ex) {
+            throw new RuntimeException(ex.getCause());
+        }
+    }
+
+    // TODO: used shared static method in JavacFileManager
+    @Override
+    public StandardJavaFileManager getStandardFileManager(
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Locale locale,
+            Charset charset) {
+        Context context = new Context();
+        context.put(Locale.class, locale);
+        if (diagnosticListener != null)
+            context.put(DiagnosticListener.class, diagnosticListener);
+        PrintWriter pw = (charset == null)
+                ? new PrintWriter(System.err, true)
+                : new PrintWriter(new OutputStreamWriter(System.err, charset), true);
+        context.put(Log.outKey, pw);
+        return new JavacFileManager(context, true, charset);
+    }
+
+    @Override
+    public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
+        PrintWriter err_pw = new PrintWriter(err, true);
+        PrintWriter out_pw = new PrintWriter(out);
+        try {
+            String standardDocletName = "com.sun.tools.doclets.standard.Standard";
+            return com.sun.tools.javadoc.Main.execute(
+                    "javadoc", err_pw, err_pw, out_pw, standardDocletName, arguments);
+        } finally {
+            err_pw.flush();
+            out_pw.flush();
+        }
+    }
+
+    @Override
+    public Set<SourceVersion> getSourceVersions() {
+        return Collections.unmodifiableSet(
+                EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest()));
+    }
+
+    @Override
+    public int isSupportedOption(String option) {
+        if (option == null)
+            throw new NullPointerException();
+        for (ToolOption o: ToolOption.values()) {
+            if (o.opt.equals(option))
+                return o.hasArg ? 1 : 0;
+        }
+        return -1;
+    }
+
+}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Wed Jul 05 18:30:46 2017 +0200
@@ -108,3 +108,8 @@
 javadoc.class_not_found=Class {0} not found.
 javadoc.error=error
 javadoc.warning=warning
+
+javadoc.error.msg={0}: error - {1}
+javadoc.warning.msg={0}: warning - {1}
+javadoc.note.msg = {1}
+javadoc.note.pos.msg= {0}: {1}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/javax/tools/DocumentationTool.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javax.tools;
+
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Locale;
+import java.util.concurrent.Callable;
+
+/**
+ * Interface to invoke Java&trade; programming language documentation tools from
+ * programs.
+ */
+public interface DocumentationTool extends Tool, OptionChecker {
+    /**
+     * Creates a future for a documentation task with the given
+     * components and arguments.  The task might not have
+     * completed as described in the DocumentationTask interface.
+     *
+     * <p>If a file manager is provided, it must be able to handle all
+     * locations defined in {@link DocumentationTool.Location},
+     * as well as
+     * {@link StandardLocation#SOURCE_PATH},
+     * {@link StandardLocation#CLASS_PATH}, and
+     * {@link StandardLocation#PLATFORM_CLASS_PATH}.
+     *
+     * @param out a Writer for additional output from the tool;
+     * use {@code System.err} if {@code null}
+     *
+     * @param fileManager a file manager; if {@code null} use the
+     * tool's standard filemanager
+     *
+     * @param diagnosticListener a diagnostic listener; if {@code null}
+     * use the tool's default method for reporting diagnostics
+     *
+     * @param docletClass a class providing the necessary methods required
+     * of a doclet
+     *
+     * @param options documentation tool options and doclet options,
+     * {@code null} means no options
+     *
+     * @param compilationUnits the compilation units to compile, {@code
+     * null} means no compilation units
+     *
+     * @return an object representing the compilation
+     *
+     * @throws RuntimeException if an unrecoverable error
+     * occurred in a user supplied component.  The
+     * {@linkplain Throwable#getCause() cause} will be the error in
+     * user code.
+     *
+     * @throws IllegalArgumentException if any of the given
+     * compilation units are of other kind than
+     * {@linkplain JavaFileObject.Kind#SOURCE source}
+     */
+    DocumentationTask getTask(Writer out,
+                            JavaFileManager fileManager,
+                            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+                            Class<?> docletClass,
+                            Iterable<String> options,
+                            Iterable<? extends JavaFileObject> compilationUnits);
+
+    /**
+     * Gets a new instance of the standard file manager implementation
+     * for this tool.  The file manager will use the given diagnostic
+     * listener for producing any non-fatal diagnostics.  Fatal errors
+     * will be signaled with the appropriate exceptions.
+     *
+     * <p>The standard file manager will be automatically reopened if
+     * it is accessed after calls to {@code flush} or {@code close}.
+     * The standard file manager must be usable with other tools.
+     *
+     * @param diagnosticListener a diagnostic listener for non-fatal
+     * diagnostics; if {@code null} use the compiler's default method
+     * for reporting diagnostics
+     *
+     * @param locale the locale to apply when formatting diagnostics;
+     * {@code null} means the {@linkplain Locale#getDefault() default locale}.
+     *
+     * @param charset the character set used for decoding bytes; if
+     * {@code null} use the platform default
+     *
+     * @return the standard file manager
+     */
+    StandardJavaFileManager getStandardFileManager(
+        DiagnosticListener<? super JavaFileObject> diagnosticListener,
+        Locale locale,
+        Charset charset);
+
+    /**
+     * Interface representing a future for a documentation task.  The
+     * task has not yet started.  To start the task, call
+     * the {@linkplain #call call} method.
+     *
+     * <p>Before calling the call method, additional aspects of the
+     * task can be configured, for example, by calling the
+     * {@linkplain #setLocale setLocale} method.
+     */
+    interface DocumentationTask extends Callable<Boolean> {
+        /**
+         * Set the locale to be applied when formatting diagnostics and
+         * other localized data.
+         *
+         * @param locale the locale to apply; {@code null} means apply no
+         * locale
+         * @throws IllegalStateException if the task has started
+         */
+        void setLocale(Locale locale);
+
+        /**
+         * Performs this documentation task.  The task may only
+         * be performed once.  Subsequent calls to this method throw
+         * IllegalStateException.
+         *
+         * @return true if and only all the files were processed without errors;
+         * false otherwise
+         *
+         * @throws RuntimeException if an unrecoverable error occurred
+         * in a user-supplied component.  The
+         * {@linkplain Throwable#getCause() cause} will be the error
+         * in user code.
+         *
+         * @throws IllegalStateException if called more than once
+         */
+        Boolean call();
+    }
+
+    /**
+     * Locations specific to {@link DocumentationTool}.
+     *
+     * @see StandardLocation
+     */
+    enum Location implements JavaFileManager.Location {
+        /**
+         * Location of new documentation files.
+         */
+        DOCUMENTATION_OUTPUT,
+
+        /**
+         * Location to search for doclets.
+         */
+        DOCLET_PATH,
+
+        /**
+         * Location to search for taglets.
+         */
+        TAGLET_PATH;
+
+        public String getName() { return name(); }
+
+        public boolean isOutputLocation() {
+            switch (this) {
+                case DOCUMENTATION_OUTPUT:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+    }
+
+}
--- a/langtools/src/share/classes/javax/tools/JavaCompiler.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/JavaCompiler.java	Wed Jul 05 18:30:46 2017 +0200
@@ -266,7 +266,7 @@
      * Gets a new instance of the standard file manager implementation
      * for this tool.  The file manager will use the given diagnostic
      * listener for producing any non-fatal diagnostics.  Fatal errors
-     * will be signalled with the appropriate exceptions.
+     * will be signaled with the appropriate exceptions.
      *
      * <p>The standard file manager will be automatically reopened if
      * it is accessed after calls to {@code flush} or {@code close}.
--- a/langtools/src/share/classes/javax/tools/ToolProvider.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/src/share/classes/javax/tools/ToolProvider.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -102,6 +102,19 @@
         return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName);
     }
 
+    private static final String defaultDocumentationToolName
+        = "com.sun.tools.javadoc.api.JavadocTool";
+
+    /**
+     * Gets the Java&trade; programming language documentation tool provided
+     * with this platform.
+     * @return the documentation tool provided with this platform or
+     * {@code null} if no documentation tool is provided
+     */
+    public static DocumentationTool getSystemDocumentationTool() {
+        return instance().getSystemTool(DocumentationTool.class, defaultDocumentationToolName);
+    }
+
     /**
      * Returns the class loader for tools provided with this platform.
      * This does not include user-installed tools.  Use the
--- a/langtools/test/Makefile	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/Makefile	Wed Jul 05 18:30:46 2017 +0200
@@ -146,10 +146,15 @@
 endif
 
 # Concurrency is the number of tests that can execute at once. 
-# Supported for JCK, not supported for jtreg.
 # On an otherwise empty machine, suggest setting to (#cpus + 2)
 # If unset, the default is (#cpus)
 ### RFE: determine and use #cpus
+ifdef CONCURRENCY
+  JTREG_OPTIONS += -agentvm -concurrency:$(CONCURRENCY)
+else
+  JTREG_OPTIONS += -samevm
+endif
+
 ifdef JCK_CONCURRENCY
   JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY)
 endif
@@ -266,7 +271,7 @@
 	@mkdir -p $(JTREG_OUTPUT_DIR)
 	JT_JAVA=$(JT_JAVA) $(JTREG) \
 	  -J-Xmx512m \
-	  -a -samevm -ignore:quiet -v:fail,error,nopass \
+	  -a -ignore:quiet -v:fail,error,nopass \
           -r:$(JTREG_OUTPUT_DIR)/JTreport \
           -w:$(JTREG_OUTPUT_DIR)/JTwork \
           -jdk:$(TESTJAVA) \
--- a/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,6 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import com.sun.tools.doclets.formats.html.ConfigurationImpl;
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-
 /*
  * @test
  * @bug      4034096 4764726 6235799
@@ -135,13 +132,7 @@
      */
     public static void main(String[] args) {
         MetaTag tester = new MetaTag();
-        Configuration config = ConfigurationImpl.getInstance();
-        boolean defaultKeywordsSetting = config.keywords;
-        boolean defaultTimestampSetting = config.notimestamp;
         run(tester, ARGS, TEST, NEGATED_TEST);
-        //Variable needs to be reset because Configuration is a singleton.
-        config.keywords = defaultKeywordsSetting;
-        config.notimestamp = defaultTimestampSetting;
         run(tester, ARGS_NO_TIMESTAMP_NO_KEYWORDS, TEST2, NEGATED_TEST2);
         tester.printSummary();
     }
--- a/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
     // Generate the HTML output using the HTML document generation within doclet.
     public static String generateHtmlTree() {
         // Document type for the HTML document
-        DocType htmlDocType = DocType.Transitional();
+        DocType htmlDocType = DocType.TRANSITIONAL;
         HtmlTree html = new HtmlTree(HtmlTag.HTML);
         HtmlTree head = new HtmlTree(HtmlTag.HEAD);
         HtmlTree title = new HtmlTree(HtmlTag.TITLE);
--- a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java	Wed Jul 05 18:30:46 2017 +0200
@@ -201,7 +201,15 @@
             "<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>"
         },
         {BUG_ID + FS + "pkg1" + FS + "C1.html",
-            "<caption><span>Methods</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "</caption>"
         },
         {BUG_ID + FS + "pkg2" + FS + "C2.html",
             "<caption><span>Nested Classes</span><span class=\"tabEnd\">&nbsp;</span></caption>"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug      8002304
+ * @summary  Test for various method types in the method summary table
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestMethodTypes
+ * @run main TestMethodTypes
+ */
+
+public class TestMethodTypes extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8002304";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
+    };
+
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "var methods = {"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:show(1);\">" +
+            "Static Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<tr id=\"i0\" class=\"altColor\">"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "B.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "var methods = {"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "<span id=\"t5\" class=\"tableTab\"><span><a href=\"javascript:show(16);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "<tr id=\"i0\" class=\"altColor\">"
+        },
+    };
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\">&nbsp;</span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "B.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\">&nbsp;</span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\">&nbsp;</span>" +
+            "</caption>"
+        },
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestMethodTypes tester = new TestMethodTypes();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/A.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+/**
+ * This class has a mixture of different types of methods. The methods summary
+ * table should appear with "All Methods", "Static Methods", "Instance Methods",
+ * "Concrete Methods" and "Deprecated Methods".
+ */
+public class A {
+
+    /**
+     * This is the first concrete instance method.
+     */
+    public void readObject() {
+    }
+
+    /**
+     * This is the second concrete instance method.
+     */
+    public final void setStub() {
+    }
+
+    /**
+     * This is the third concrete instance method.
+     */
+    public String getParameter() {
+         return "test";
+     }
+
+    /**
+     * This is the first concrete instance deprecated method.
+     * @deprecated This is a deprecated method that should appear in the tab.
+     */
+    public void resize() {
+    }
+
+    /**
+     * This is the fourth concrete instance method.
+     */
+    public void showStatus() {
+    }
+
+    /**
+     * This is the first concrete static method.
+     */
+    public final static void staticMethod() {
+    }
+
+    /**
+     * This is the second concrete instance deprecated method.
+     */
+    @Deprecated
+    public void init() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/B.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+/**
+ * This interface has different types of methods such as "Instance Methods" and
+ * "Abstract Methods". All the tabs will display same list of methods.
+ */
+public interface B {
+
+    /**
+     * This is the first abstract instance method.
+     */
+    public void setName();
+
+    /**
+     * This is the second abstract instance method.
+     */
+    public String getName();
+
+    /**
+     * This is the third abstract instance method.
+     */
+    public boolean addEntry();
+
+    /**
+     * This is the fourth abstract instance method.
+     */
+    public boolean removeEntry();
+
+    /**
+     * This is the fifth abstract instance method.
+     */
+    public String getPermissions();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testMethodTypes/pkg1/D.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+/**
+ * This class is marked as deprecated and has a mixture of different types of
+ * methods such as "Instance Methods", "Abstract Methods" and "Concrete
+ * Methods". None of the methods are marked as deprecated but since the class is
+ * deprecated, the methods will also be deprecated and "Deprecated Methods" tab
+ * will also be shown with all the methods.
+ */
+@Deprecated
+public abstract class D {
+
+    /**
+     * This is the first abstract instance method.
+     */
+    public abstract void readObject();
+
+    /**
+     * This is the first concrete instance method.
+     */
+    public final void setStub() {
+    }
+
+    /**
+     * This is the second concrete instance method.
+     */
+    public String getParameter() {
+         return "test";
+     }
+}
--- a/langtools/test/tools/javac/conditional/Conditional.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/conditional/Conditional.java	Wed Jul 05 18:30:46 2017 +0200
@@ -27,8 +27,8 @@
  * @summary Conditional operator applies assignment conversion
  * @author Tim Hanson, BEA
  *
- * @compile -XDallowPoly Conditional.java
- * @compile/fail Conditional.java
+ * @compile Conditional.java
+ * @compile/fail -source 7 Conditional.java
  */
 
 import java.util.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/defaultMethodExecution/DefaultMethodRegressionTests.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng DefaultMethodRegressionTests
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+/**
+ * This set of classes/interfaces (K/I/C) is specially designed to expose a
+ * bug in the JVM where it did not find some overloaded methods in some
+ * specific situations. (fixed by hotspot changeset ffb9316fd9ed)
+ */
+interface K {
+    int bbb(Long l);
+}
+
+interface I extends K {
+    default void aaa() {}
+    default void aab() {}
+    default void aac() {}
+
+    default int bbb(Integer i) { return 22; }
+    default int bbb(Float f) { return 33; }
+    default int bbb(Long l) { return 44; }
+    default int bbb(Double d) { return 55; }
+    default int bbb(String s) { return 66; }
+
+    default void caa() {}
+    default void cab() {}
+    default void cac() {}
+}
+
+class C implements I {}
+
+public class DefaultMethodRegressionTests {
+
+    @Test(groups = "vm")
+    public void testLostOverloadedMethod() {
+        C c = new C();
+        assertEquals(c.bbb(new Integer(1)), 22);
+        assertEquals(c.bbb(new Float(1.1)), 33);
+        assertEquals(c.bbb(new Long(1L)), 44);
+        assertEquals(c.bbb(new Double(0.01)), 55);
+        assertEquals(c.bbb(new String("")), 66);
+    }
+
+    // Test to ensure that the inference verifier accepts older classfiles
+    // with classes that implement interfaces with defaults.
+    @Test(groups = "vm")
+    public void testInferenceVerifier() {
+        // interface I { int m() default { return 99; } }
+        byte I_bytes[] = {
+            (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x33,
+            0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07,
+            0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00,
+            0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43,
+            0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01,
+            0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+            0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+            0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01,
+            0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05,
+            0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01,
+            0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00
+        };
+        // public class C implements I {}  /* -target 1.5 */
+        byte C_bytes[] = {
+            (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31,
+            0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07,
+            0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b,
+            0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74,
+            0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01,
+            0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00,
+            0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01,
+            0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+            0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+            0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21,
+            0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04,
+            0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05,
+            0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00,
+            0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
+            0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00
+        };
+
+        ClassLoader cl = new ClassLoader() {
+            protected Class<?> findClass(String name) {
+                if (name.equals("I")) {
+                    return defineClass("I", I_bytes, 0, I_bytes.length);
+                } else if (name.equals("C")) {
+                    return defineClass("C", C_bytes, 0, C_bytes.length);
+                } else {
+                    return null;
+                }
+            }
+        };
+        try {
+            Class.forName("C", true, cl);
+        } catch (Exception e) {
+            // unmodified verifier will throw VerifyError
+            fail("No exception should be thrown");
+        }
+    }
+}
--- a/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that default methods don't cause ClassReader to complete classes recursively
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods pkg/Foo.java
+ * @compile pkg/Foo.java
  * @compile ClassReaderTest.java
  */
 
--- a/langtools/test/tools/javac/defaultMethods/Neg01.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary negative test for ambiguous defaults
- * @compile/fail/ref=Neg01.out -XDallowDefaultMethods -XDrawDiagnostics Neg01.java
+ * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java
  */
 
 class Neg01 {
--- a/langtools/test/tools/javac/defaultMethods/Neg02.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that ill-formed MI hierarchies do not compile
- * @compile/fail/ref=Neg02.out -XDallowDefaultMethods -XDrawDiagnostics Neg02.java
+ * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java
  */
 
 class Neg02 {
--- a/langtools/test/tools/javac/defaultMethods/Neg03.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that re-abstraction works properly
- * @compile/fail/ref=Neg03.out -XDallowDefaultMethods -XDrawDiagnostics Neg03.java
+ * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java
  */
 
 class Neg03 {
--- a/langtools/test/tools/javac/defaultMethods/Neg04.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default method must have most specific return type
- * @compile/fail/ref=Neg04.out -XDallowDefaultMethods -XDrawDiagnostics Neg04.java
+ * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java
  */
 
 class Neg04 {
--- a/langtools/test/tools/javac/defaultMethods/Neg05.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that abstract methods are compatible with inherited defaults
- * @compile/fail/ref=Neg05.out -XDallowDefaultMethods -XDrawDiagnostics Neg05.java
+ * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
  */
 
 class Neg05 {
--- a/langtools/test/tools/javac/defaultMethods/Neg06.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary flow analysis is not run on inlined default bodies
- * @compile/fail/ref=Neg06.out -XDallowDefaultMethods -XDrawDiagnostics Neg06.java
+ * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java
  */
 
 class Neg06 {
--- a/langtools/test/tools/javac/defaultMethods/Neg07.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg07.out -XDallowDefaultMethods -XDrawDiagnostics Neg07.java
+ * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java
  */
 
 class Neg07 {
--- a/langtools/test/tools/javac/defaultMethods/Neg08.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg08.out -XDallowDefaultMethods -XDrawDiagnostics Neg08.java
+ * @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java
  */
 class Neg08 {
     interface I {
--- a/langtools/test/tools/javac/defaultMethods/Neg09.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg09.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg09.java
+ * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java
  */
 import java.util.List;
 
--- a/langtools/test/tools/javac/defaultMethods/Neg10.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg10.java
+ * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java
  */
 class Neg10 {
     interface I<X extends Exception> {
--- a/langtools/test/tools/javac/defaultMethods/Neg11.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg11.out -XDallowDefaultMethods -XDrawDiagnostics Neg11.java
+ * @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java
  */
 class Neg11 {
     interface I {
--- a/langtools/test/tools/javac/defaultMethods/Neg12.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that abstract methods are discarded in overload resolution diags
- * @compile/fail/ref=Neg12.out -XDallowDefaultMethods -XDrawDiagnostics Neg12.java
+ * @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java
  */
 class Neg12 {
 
--- a/langtools/test/tools/javac/defaultMethods/Neg12.out	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg12.out	Wed Jul 05 18:30:46 2017 +0200
@@ -1,4 +1,4 @@
 Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
-Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
+Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
 Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
 3 errors
--- a/langtools/test/tools/javac/defaultMethods/Neg13.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default method overriding object members are flagged as error
- * @compile/fail/ref=Neg13.out -XDallowDefaultMethods -XDrawDiagnostics Neg13.java
+ * @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java
  */
 interface Neg13 {
     default protected Object clone() { return null; } //protected not allowed here
--- a/langtools/test/tools/javac/defaultMethods/Neg14.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg14.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that a class cannot have two sibling interfaces with a default and abstract method
- * @compile/fail/ref=Neg14.out -XDallowDefaultMethods -XDrawDiagnostics Neg14.java
+ * @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java
  */
 class Neg14 {
     interface IA { int m(); }
--- a/langtools/test/tools/javac/defaultMethods/Neg15.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg15.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that level skipping in default super calls is correctly rejected
- * @compile/fail/ref=Neg15.out -XDallowDefaultMethods -XDrawDiagnostics Neg15.java
+ * @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java
  */
 class Neg15 {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/defaultMethods/Neg16.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Neg16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that level skipping in default super calls is correctly rejected
- * @compile/fail/ref=Neg16.out -XDallowDefaultMethods -XDrawDiagnostics Neg16.java
+ * @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java
  */
 class Neg16 {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/defaultMethods/Pos01.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,14 +24,12 @@
 /*
  * @test
  * @summary basic test for default methods
- * @ignore awaits lambda support
  * @author  Maurizio Cimadamore
- * @compile -XDallowLambda -XDallowPoly -XDallowDefaultMethods Pos01.java
  */
 
 import java.util.*;
 
-class Pos01 {
+public class Pos01 {
 
     interface Mapper<T> {
         T map(T in);
--- a/langtools/test/tools/javac/defaultMethods/Pos02.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary test for explicit resolution of ambiguous default methods
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos02.java
+ * @compile Pos02.java
  */
 
 class Pos02 {
--- a/langtools/test/tools/javac/defaultMethods/Pos04.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary test for overriding with default method
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos04.java
+ * @compile Pos04.java
  */
 
 class Pos04 {
--- a/langtools/test/tools/javac/defaultMethods/Pos05.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that indirectly inherited default methods are discovered during resolution
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos05.java
+ * @compile Pos05.java
  */
 
 class Pos05  {
--- a/langtools/test/tools/javac/defaultMethods/Pos06.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities)
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos06.java
+ * @compile Pos06.java
  */
 
 class Pos06 {
--- a/langtools/test/tools/javac/defaultMethods/Pos07.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that compilation order does not matter
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos07.java
+ * @compile Pos07.java
  */
 
 class Pos07 {
--- a/langtools/test/tools/javac/defaultMethods/Pos08.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that common overrider solves default method conflicts
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos08.java
+ * @compile Pos08.java
  */
 
 class Pos08 {
--- a/langtools/test/tools/javac/defaultMethods/Pos10.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary check that type-variables in generic extension decl can be accessed from default impl
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos10.java
+ * @compile Pos10.java
  */
 
 class Pos10 {
--- a/langtools/test/tools/javac/defaultMethods/Pos11.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary complex test with conflict resolution via overriding
  * @author  Brian Goetz
- * @compile -XDallowDefaultMethods Pos11.java
+ * @compile Pos11.java
  */
 
 class Pos11 {
--- a/langtools/test/tools/javac/defaultMethods/Pos12.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that 'this' can be used from within an extension method
- * @compile -XDallowDefaultMethods Pos12.java
+ * @compile Pos12.java
  */
 
 interface Pos12 {
--- a/langtools/test/tools/javac/defaultMethods/Pos13.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary qualified 'this' inside default method causes StackOverflowException
- * @compile -XDallowDefaultMethods Pos13.java
+ * @compile Pos13.java
  */
 
 public class Pos13 {
--- a/langtools/test/tools/javac/defaultMethods/Pos14.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos14.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that overload resolution selects most specific signature
- * @compile -XDallowDefaultMethods Pos14.java
+ * @compile Pos14.java
  */
 
 class Pos14 {
--- a/langtools/test/tools/javac/defaultMethods/Pos15.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos15.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that overload resolution selects most specific signature
- * @compile -XDallowDefaultMethods Pos15.java
+ * @compile Pos15.java
  */
 
 class Pos15 {
--- a/langtools/test/tools/javac/defaultMethods/Pos16.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/Pos16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary 'class wins' should not short-circuit overload resolution
- * @compile -XDallowDefaultMethods Pos16.java
+ * @compile Pos16.java
  */
 
 class Pos16 {
--- a/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,10 +23,7 @@
 
 /*
  * @test
- * @ignore awaits for VM support
  * @summary  check that code attributed for default methods is correctly generated
- * @compile -XDallowDefaultMethods TestDefaultBody.java
- * @run main TestDefaultBody
  */
 
 import com.sun.tools.classfile.AccessFlags;
--- a/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,8 +25,6 @@
  * @test
  * @ignore awaits for VM support
  * @summary  check that javac does not generate bridge methods for defaults
- * @compile -XDallowDefaultMethods TestNoBridgeOnDefaults.java
- * @run main TestNoBridgeOnDefaults
  */
 
 import com.sun.tools.classfile.ClassFile;
--- a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary Automatic test for checking correctness of default resolution
- */
-
-import shapegen.*;
-
-import com.sun.source.util.JavacTask;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.tools.Diagnostic;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-public class FDTest {
-
-    enum TestKind {
-        POSITIVE,
-        NEGATIVE;
-
-        Collection<Hierarchy> getHierarchy(HierarchyGenerator hg) {
-            return this == POSITIVE ?
-                    hg.getOK() : hg.getErr();
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        //create default shared JavaCompiler - reused across multiple compilations
-        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
-
-        HierarchyGenerator hg = new HierarchyGenerator();
-        for (TestKind tk : TestKind.values()) {
-            for (Hierarchy hs : tk.getHierarchy(hg)) {
-                new FDTest(tk, hs).run(comp, fm);
-            }
-        }
-    }
-
-    TestKind tk;
-    Hierarchy hs;
-    DefenderTestSource source;
-    DiagnosticChecker diagChecker;
-
-    FDTest(TestKind tk, Hierarchy hs) {
-        this.tk = tk;
-        this.hs = hs;
-        this.source = new DefenderTestSource();
-        this.diagChecker = new DiagnosticChecker();
-    }
-
-    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
-        try {
-            ct.analyze();
-        } catch (Throwable ex) {
-            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
-        }
-        check();
-    }
-
-    void check() {
-        boolean errorExpected = tk == TestKind.NEGATIVE;
-        if (errorExpected != diagChecker.errorFound) {
-            throw new AssertionError("problem in source: \n" +
-                    "\nerror found = " + diagChecker.errorFound +
-                    "\nerror expected = " + errorExpected +
-                    "\n" + dumpHierarchy() +
-                    "\n" + source.getCharContent(true));
-        }
-    }
-
-    String dumpHierarchy() {
-        StringBuilder buf = new StringBuilder();
-        buf.append("root = " + hs.root + "\n");
-        for (ClassCase cc : hs.all) {
-            buf.append("  class name = " + cc.getName() + "\n");
-            buf.append("    class OK = " + cc.get_OK() + "\n");
-            buf.append("    prov = " + cc.get_mprov() + "\n");
-
-        }
-        return buf.toString();
-    }
-
-    class DefenderTestSource extends SimpleJavaFileObject {
-
-        String source;
-
-        public DefenderTestSource() {
-            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            StringBuilder buf = new StringBuilder();
-            List<ClassCase> defaultRef = new ArrayList<>();
-            for (ClassCase cc : hs.all) {
-                hs.genClassDef(buf, cc, null, defaultRef);
-            }
-            source = buf.toString();
-        }
-
-        @Override
-        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
-            return source;
-        }
-    }
-
-    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
-
-        boolean errorFound;
-
-        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
-                errorFound = true;
-            }
-        }
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/ClassCase.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
- * @author Robert Field
- */
-public class ClassCase {
-
-    public enum Kind {
-        IVAC        (true,  "v"),
-        IPRESENT    (true,  "p"),
-        IDEFAULT    (true,  "d"),
-        CNONE       (false, "n"),
-        CABSTRACT   (false, "a"),
-        CCONCRETE   (false, "c");
-
-        private final String prefix;
-        public final boolean isInterface;
-
-        Kind(boolean isInterface, String prefix) {
-            this.isInterface = isInterface;
-            this.prefix = prefix;
-        }
-    }
-
-    public final Kind kind;
-    private final ClassCase superclass;
-    private final List<ClassCase> supertypes;
-
-    private String name;
-    private boolean _OK;
-    private boolean _HasClassMethod;
-    private Set<ClassCase> _mprov;
-    private boolean _IsConcrete;
-    private boolean _HasDefault;
-    private ClassCase _mres;
-    private ClassCase _mdefend;
-
-    private Set<RuleGroup> executed = new HashSet<RuleGroup>() {};
-
-    public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
-        this.kind = kind;
-        this.superclass = superclass;
-
-        // Set supertypes from superclass (if any) and interfaces
-        List<ClassCase> lc;
-        if (superclass == null) {
-            lc = interfaces;
-        } else {
-            lc = new ArrayList<>();
-            lc.add(superclass);
-            lc.addAll(interfaces);
-        }
-        this.supertypes = lc;
-    }
-
-    public final boolean isInterface() { return kind.isInterface; }
-    public final boolean isClass() { return !kind.isInterface; }
-
-    public Set<ClassCase> get_mprov() {
-        exec(RuleGroup.PROVENENCE);
-        return _mprov;
-    }
-
-    public void set_mprov(ClassCase cc) {
-        Set<ClassCase> s = new HashSet<>();
-        s.add(cc);
-        _mprov = s;
-    }
-
-    public void set_mprov(Set<ClassCase> s) {
-        _mprov = s;
-    }
-
-    public ClassCase get_mres() {
-        exec(RuleGroup.RESOLUTION);
-        return _mres;
-    }
-
-    public void set_mres(ClassCase cc) {
-        _mres = cc;
-    }
-
-    public ClassCase get_mdefend() {
-        exec(RuleGroup.DEFENDER);
-        return _mdefend;
-    }
-
-    public void set_mdefend(ClassCase cc) {
-        _mdefend = cc;
-    }
-
-    public boolean get_HasClassMethod() {
-        exec(RuleGroup.PROVENENCE);
-        return _HasClassMethod;
-    }
-
-    public void set_HasClassMethod(boolean bool) {
-        _HasClassMethod = bool;
-    }
-
-    public boolean get_HasDefault() {
-        exec(RuleGroup.MARKER);
-        return _HasDefault;
-    }
-
-    public void set_HasDefault(boolean bool) {
-        _HasDefault = bool;
-    }
-
-    public boolean get_IsConcrete() {
-        exec(RuleGroup.MARKER);
-        return _IsConcrete;
-    }
-
-    public void set_IsConcrete(boolean bool) {
-        _IsConcrete = bool;
-    }
-
-    public boolean get_OK() {
-        exec(RuleGroup.CHECKING);
-        return _OK;
-    }
-
-    public void set_OK(boolean bool) {
-        _OK = bool;
-    }
-
-    public boolean isMethodDefined() {
-        for (ClassCase cc : supertypes) {
-            if (cc.isMethodDefined()) {
-                return true;
-            }
-        }
-        switch (kind) {
-            case CCONCRETE:
-            case CABSTRACT:
-            case IPRESENT:
-            case IDEFAULT:
-                return true;
-            default:
-                return false;
-        }
-    }
-
-    public boolean isAbstract() {
-        return isMethodDefined() && (get_mres()==null);
-    }
-
-    public boolean hasSuperclass() {
-        return superclass != null;
-    }
-
-    public ClassCase getSuperclass() {
-        return superclass;
-    }
-
-    public List<ClassCase> getSupertypes() {
-        return supertypes;
-    }
-
-    public List<ClassCase> getInterfaces() {
-        if (superclass != null) {
-            if (supertypes.get(0) != superclass) {
-                throw new AssertionError("superclass missing from supertypes");
-            }
-            return supertypes.subList(1, supertypes.size());
-        } else {
-            return supertypes;
-        }
-    }
-
-    public boolean isSubtypeOf(ClassCase cc) {
-        // S-Refl
-        if (cc.equals(this)) {
-            return true;
-        }
-
-        // S-Def
-        for (ClassCase sp : getSupertypes()) {
-            if (cc.equals(sp)) {
-                return true;
-            }
-        }
-
-        // _S-Trans
-        for (ClassCase sp : getSupertypes()) {
-            if (sp.isSubtypeOf(cc)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    public void init(Map<String, Integer> namingContext) {
-        if (name != null) {
-            return; // Already inited
-        }
-
-        for (ClassCase sup : supertypes) {
-            sup.init(namingContext);
-        }
-
-        // Build name
-        StringBuilder sb = new StringBuilder();
-        if (!supertypes.isEmpty()) {
-            sb.append(isInterface() ? "I" : "C");
-            for (ClassCase cc : supertypes) {
-                sb.append(cc.getName());
-            }
-            sb.append(kind.isInterface ? "i" : "c");
-        }
-        sb.append(kind.prefix);
-        String pname = sb.toString();
-        Integer icnt = namingContext.get(pname);
-        int cnt = icnt == null ? 0 : icnt;
-        ++cnt;
-        namingContext.put(pname, cnt);
-        if (cnt > 1) {
-            sb.append(cnt);
-        }
-        this.name = sb.toString();
-    }
-
-    public boolean isa(Kind... kinds) {
-        for (Kind k : kinds) {
-            if (kind == k) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void exec(RuleGroup rg ) {
-        if (!executed.contains(rg)) {
-            rg.exec(this);
-            executed.add(rg);
-        }
-    }
-
-    public void collectClasses(Set<ClassCase> seen) {
-        seen.add(this);
-        for (ClassCase cc : supertypes) {
-            cc.collectClasses(seen);
-        }
-    }
-
-    public String getID() {
-        if (name == null) {
-            throw new Error("Access to uninitialized ClassCase");
-        } else {
-            return name;
-        }
-    }
-
-    public final String getName() {
-        if (name == null) {
-            return "ClassCase uninited@" + hashCode();
-        } else {
-            return name;
-        }
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
-    }
-
-    @Override
-    public int hashCode() {
-        return getID().hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return getName();
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Hierarchy.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.List;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- *
- * @author Robert Field
- */
-public class Hierarchy {
-
-    public final ClassCase root;
-    public final Set<ClassCase> all;
-
-    public Hierarchy(ClassCase root) {
-        this.root = root;
-        root.init(new HashMap<String,Integer>());
-        Set<ClassCase> allClasses = new HashSet<>();
-        root.collectClasses(allClasses);
-        this.all = allClasses;
-    }
-
-    public boolean anyDefaults() {
-        for (ClassCase cc : all) {
-            if (cc.kind == IDEFAULT) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public boolean get_OK() {
-        return root.get_OK();
-    }
-
-    public String testName() {
-        return root + "Test";
-    }
-
-    private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
-        if (!interfaces.isEmpty()) {
-            buf.append(" ");
-            buf.append(prefix);
-            buf.append(" ");
-            buf.append(interfaces.get(0));
-            for (int i = 1; i < interfaces.size(); ++i) {
-                buf.append(", " + interfaces.get(i));
-            }
-        }
-    }
-
-    public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
-        if (cc.isInterface()) {
-            buf.append("interface ");
-            buf.append(cc.getName() + " ");
-            genInterfaceList(buf, "extends", cc.getInterfaces());
-            buf.append(" {\n");
-
-            switch (cc.kind) {
-                case IDEFAULT:
-                    buf.append("    default String m() { return \"\"; }\n");
-                    defaultRef.add(cc);
-                    break;
-                case IPRESENT:
-                    buf.append("    String m();\n");
-                    break;
-                case IVAC:
-                    break;
-                default:
-                    throw new AssertionError("Unexpected kind");
-            }
-            buf.append("}\n\n");
-        } else {
-            buf.append((cc.isAbstract()? "abstract " : ""));
-            buf.append(" class " + cc.getName());
-            if (cc.getSuperclass() != null) {
-                buf.append(" extends " + cc.getSuperclass());
-            }
-
-            genInterfaceList(buf, "implements", cc.getInterfaces());
-            buf.append(" {\n");
-
-            switch (cc.kind) {
-                case CCONCRETE:
-                    buf.append("   public String m() { return \"\"; }\n");
-                    break;
-                case CABSTRACT:
-                    buf.append("   public abstract String m();\n");
-                    break;
-                case CNONE:
-                    break;
-                default:
-                    throw new AssertionError("Unexpected kind");
-            }
-            buf.append("}\n\n");
-        }
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
-    }
-
-    @Override
-    public int hashCode() {
-        return root.getID().hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return root.getName();
-    }
-
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import shapegen.ClassCase.Kind;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import java.util.ArrayList;
-import java.util.List;
-
-import static shapegen.ClassCase.Kind.*;
-
-import static java.lang.Math.pow;
-
-/**
- *
- * @author Robert Field
- */
-public final class HierarchyGenerator {
-
-    private static int okcnt = 0;
-    private static int errcnt = 0;
-    private static Set<Hierarchy> uniqueOK = new HashSet<>();
-    private static Set<Hierarchy> uniqueErr = new HashSet<>();
-
-    /**
-     * @param args the command line arguments
-     */
-    public HierarchyGenerator() {
-        organize("exhaustive interface", iExhaustive(2));
-        organize("exhaustive class", cExhaustive());
-        organize("shapes interface", iShapes());
-        organize("shapes class/interface", ciShapes());
-
-        System.out.printf("\nExpect OK:    %d -- unique %d",   okcnt,  uniqueOK.size());
-        System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size());
-    }
-
-    public Collection<Hierarchy> getOK() {
-        return uniqueOK;
-    }
-
-    public Collection<Hierarchy> getErr() {
-        return uniqueErr;
-    }
-
-    private void organize(String tname, List<Hierarchy> totest) {
-        System.out.printf("\nTesting %s....\n", tname);
-        int nodefault = 0;
-        List<Hierarchy> ok = new ArrayList<>();
-        List<Hierarchy> err = new ArrayList<>();
-        for (Hierarchy cc : totest) {
-            if (cc.anyDefaults()) {
-                //System.out.printf("  %s\n", cc);
-                if (cc.get_OK()) {
-                    ok.add(cc);
-                } else {
-                    err.add(cc);
-                }
-            } else {
-                ++nodefault;
-            }
-        }
-
-        errcnt += err.size();
-        okcnt += ok.size();
-        uniqueErr.addAll(err);
-        uniqueOK.addAll(ok);
-
-        System.out.printf("  %5d No default\n  %5d Error\n  %5d OK\n  %5d Total\n",
-                nodefault, err.size(), ok.size(), totest.size());
-    }
-
-    public List<Hierarchy> iExhaustive(int idepth) {
-        List<ClassCase> current = new ArrayList<>();
-        for (int i = 0; i < idepth; ++i) {
-            current = ilayer(current);
-        }
-        return wrapInClassAndHierarchy(current);
-    }
-
-    private List<ClassCase> ilayer(List<ClassCase> srcLayer) {
-        List<ClassCase> lay = new ArrayList<>();
-        for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) {
-            List<ClassCase> itfs = new ArrayList<>();
-            for (int b = srcLayer.size() - 1; b >= 0; --b) {
-                if ((i & (1<<b)) != 0) {
-                    itfs.add(srcLayer.get(b));
-                }
-            }
-            lay.add(new ClassCase(IVAC, null, itfs));
-            lay.add(new ClassCase(IPRESENT, null, itfs));
-            lay.add(new ClassCase(IDEFAULT, null, itfs));
-            lay.add(new ClassCase(IDEFAULT, null, itfs));
-        }
-        return lay;
-    }
-
-    public List<Hierarchy> cExhaustive() {
-        final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null};
-        final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE};
-        List<Hierarchy> totest = new ArrayList<>();
-        for (int i1 = 0; i1 < iKinds.length; ++i1) {
-            for (int i2 = 0; i2 < iKinds.length; ++i2) {
-                for (int i3 = 0; i3 < iKinds.length; ++i3) {
-                    for (int c1 = 0; c1 < cKinds.length; ++c1) {
-                        for (int c2 = 0; c2 < cKinds.length; ++c2) {
-                            for (int c3 = 0; c3 < cKinds.length; ++c3) {
-                                totest.add( new Hierarchy(
-                                        new ClassCase(cKinds[c1],
-                                            new ClassCase(cKinds[c2],
-                                                new ClassCase(cKinds[c3],
-                                                    null,
-                                                    iList(iKinds[i1])
-                                                ),
-                                                iList(iKinds[i2])
-                                            ),
-                                            iList(iKinds[i3])
-                                        )));
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return totest;
-    }
-
-    private List<ClassCase> iList(Kind kind) {
-        if (kind == null) {
-            return Collections.EMPTY_LIST;
-        } else {
-            List<ClassCase> itfs = new ArrayList<>();
-            itfs.add(new ClassCase(kind, null, Collections.EMPTY_LIST));
-            return itfs;
-        }
-    }
-
-    public List<Hierarchy> ciShapes() {
-        return wrapInHierarchy(TTShape.allCases(true));
-    }
-
-    public List<Hierarchy> iShapes() {
-        return wrapInClassAndHierarchy(TTShape.allCases(false));
-    }
-
-    public List<Hierarchy> wrapInClassAndHierarchy(List<ClassCase> ihs) {
-        List<Hierarchy> totest = new ArrayList<>();
-        for (ClassCase cc : ihs) {
-            List<ClassCase> interfaces = new ArrayList<>();
-            interfaces.add(cc);
-            totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces)));
-        }
-        return totest;
-    }
-
-    public List<Hierarchy> wrapInHierarchy(List<ClassCase> ihs) {
-        List<Hierarchy> totest = new ArrayList<>();
-        for (ClassCase cc : ihs) {
-            totest.add(new Hierarchy(cc));
-        }
-        return totest;
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/Rule.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-/**
- *
- * @author Robert Field
- */
-public abstract class Rule {
-
-    public final String name;
-
-    public Rule(String name) {
-        this.name = name;
-    }
-
-    abstract boolean guard(ClassCase cc);
-
-    abstract void eval(ClassCase cc);
-
-    @Override
-    public String toString() {
-        return name;
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- *
- * @author Robert Field
- */
-public class RuleGroup {
-
-    final String name;
-    private final Rule[] rules;
-
-    public RuleGroup(String name, Rule[] rules) {
-        this.name = name;
-        this.rules = rules;
-    }
-
-    public boolean exec(ClassCase cc) {
-        boolean found = false;
-        for (Rule rule : rules) {
-            if (rule.guard(cc)) {
-                if (found) {
-                    throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc);
-                } else {
-                    rule.eval(cc);
-                    found = true;
-                }
-            }
-        }
-        return found;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-
-    public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] {
-        new Rule("P-CDeclare") {
-            boolean guard(ClassCase cc) {
-                return cc.isa(CCONCRETE, CABSTRACT);
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_mprov(cc);
-                cc.set_HasClassMethod(true);
-            }
-        },
-
-        new Rule("P-IDeclare") {
-            boolean guard(ClassCase cc) {
-                return cc.isa(IDEFAULT, IPRESENT);
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_mprov(cc);
-            }
-        },
-
-        new Rule("P-IntfInh") {
-            boolean guard(ClassCase cc) {
-                return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
-            }
-
-            void eval(ClassCase cc) {
-                Set<ClassCase> _S = new HashSet<>();
-                for (ClassCase t : cc.getSupertypes()) {
-                    _S.addAll(t.get_mprov());
-                }
-                Set<ClassCase> tops = new HashSet<>();
-                for (ClassCase _W : _S) {
-                    for (ClassCase _V : _S) {
-                        if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) {
-                            tops.add(_W);
-                        }
-                    }
-                }
-                cc.set_mprov(tops);
-            }
-        },
-
-        new Rule("P-ClassInh") {
-            boolean guard(ClassCase cc) {
-                return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_mprov(cc.getSuperclass());
-                cc.set_HasClassMethod(true);
-            }
-        },
-
-    });
-
-    public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] {
-        new Rule("M-Default") {
-            boolean guard(ClassCase cc) {
-                return cc.isa(IDEFAULT);
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_HasDefault(true);
-            }
-        },
-
-        new Rule("M-Conc") {
-            boolean guard(ClassCase cc) {
-              return cc.isa(CCONCRETE);
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_IsConcrete(true);
-            }
-        },
-
-    });
-
-    public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] {
-        new Rule("R-Resolve") {
-            boolean guard(ClassCase cc) {
-                if (!(cc.isClass() && cc.get_mprov().size() == 1)) {
-                    return false;
-                }
-                ClassCase _V = cc.get_mprov().iterator().next();
-                return _V.get_IsConcrete() || _V.get_HasDefault();
-            }
-
-            void eval(ClassCase cc) {
-                ClassCase _V = cc.get_mprov().iterator().next();
-                cc.set_mres(_V);
-            }
-        },
-
-    });
-
-    public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] {
-        new Rule("D-Defend") {
-            boolean guard(ClassCase cc) {
-                ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null;
-                boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper);
-                return cc.isa(CNONE) && !eq;
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_mdefend(cc.get_mres());
-            }
-        },
-
-    });
-
-    public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] {
-        new Rule("C-Check") {
-            boolean guard(ClassCase cc) {
-                for (ClassCase t : cc.getSupertypes()) {
-                    if (! t.get_OK()) {
-                        return false;
-                    }
-                }
-                int defenderCount = 0;
-                int provCount = 0;
-                for (ClassCase prov : cc.get_mprov()) {
-                    if (prov.get_HasDefault()) {
-                        defenderCount++;
-                    }
-                    provCount++;
-                }
-                return provCount <= 1 || defenderCount == 0;
-            }
-
-            void eval(ClassCase cc) {
-                cc.set_OK(true);
-            }
-        },
-
-    });
-
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTNode.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import shapegen.ClassCase.Kind;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- * Type Template Node
- *
- * @author Robert Field
- */
-public class TTNode {
-
-    final List<TTNode> supertypes;
-    final boolean canBeClass;
-
-    private int currentKindIndex;
-    private Kind[] kinds;
-
-    public TTNode(List<TTNode> subtypes, boolean canBeClass) {
-        this.supertypes = subtypes;
-        this.canBeClass = canBeClass;
-    }
-
-    public void start(boolean includeClasses) {
-        kinds =
-             supertypes.isEmpty()?
-                (new Kind[]{IDEFAULT, IPRESENT})
-             :  ((includeClasses && canBeClass)?
-                  new Kind[]{CNONE, IVAC, IDEFAULT, IPRESENT}
-                : new Kind[]{IVAC, IDEFAULT, IPRESENT});
-        currentKindIndex = 0;
-
-        for (TTNode sub : supertypes) {
-            sub.start(includeClasses);
-        }
-    }
-
-    public boolean next() {
-        ++currentKindIndex;
-        if (currentKindIndex >= kinds.length) {
-            currentKindIndex = 0;
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    public void collectAllSubtypes(Set<TTNode> subs) {
-        subs.add(this);
-        for (TTNode n : supertypes) {
-            n.collectAllSubtypes(subs);
-        }
-    }
-
-    private Kind getKind() {
-        return kinds[currentKindIndex];
-    }
-
-    boolean isInterface() {
-        return getKind().isInterface;
-    }
-
-    boolean isClass() {
-        return !isInterface();
-    }
-
-    boolean hasDefault() {
-        return getKind() == IDEFAULT;
-    }
-
-    public boolean isValid() {
-        for (TTNode n : supertypes) {
-            if (!n.isValid() || (isInterface() && n.isClass())) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public ClassCase genCase() {
-        ClassCase subclass;
-        List<TTNode> ttintfs;
-        if (isClass() && !supertypes.isEmpty() && supertypes.get(0).isClass()) {
-            subclass = supertypes.get(0).genCase();
-            ttintfs = supertypes.subList(1, supertypes.size());
-        } else {
-            subclass = null;
-            ttintfs = supertypes;
-        }
-        List<ClassCase> intfs = new ArrayList<>();
-        for (TTNode node : ttintfs) {
-            intfs.add(node.genCase());
-        }
-        return new ClassCase(getKind(), subclass, intfs);
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTParser.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.io.IOException;
-import java.io.StringReader;
-
-import static java.lang.Character.isLetter;
-import static java.lang.Character.isUpperCase;
-import static java.lang.Character.isWhitespace;
-
-/**
- * Parse a type template definition string
- *
- *   input     :: classDef
- *   classDef  :: letter [ ( classDef* ) ]
- *
- * @author Robert Field
- */
-public class TTParser extends StringReader {
-
-    private Map<Character, TTNode> letterMap = new HashMap<>();
-    private char ch;
-
-    private final String def;
-
-    public TTParser(String s) {
-        super(s);
-        this.def = s;
-    }
-
-    private void advance() throws IOException {
-        do {
-            ch = (char)read();
-        } while (isWhitespace(ch));
-    }
-
-    public TTNode parse() {
-        try {
-            advance();
-            return classDef();
-        } catch (IOException t) {
-            throw new RuntimeException(t);
-        }
-    }
-
-    private TTNode classDef() throws IOException {
-        if (!isLetter(ch)) {
-            if (ch == (char)-1) {
-                throw new IOException("Unexpected end of type template in " + def);
-            } else {
-                throw new IOException("Unexpected character in type template: " + (Character)ch + " in " + def);
-            }
-        }
-        char nodeCh = ch;
-        TTNode node = letterMap.get(nodeCh);
-        boolean canBeClass = isUpperCase(nodeCh);
-        advance();
-        if (node == null) {
-            List<TTNode> subtypes = new ArrayList<>();
-            if (ch == '(') {
-                advance();
-                while (ch != ')') {
-                    subtypes.add(classDef());
-                }
-                advance();
-            }
-            node = new TTNode(subtypes, canBeClass);
-            letterMap.put(nodeCh, node);
-        }
-        return node;
-    }
-}
--- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/TTShape.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- *
- * @author Robert Field
- */
-public class TTShape {
-
-    private final TTNode root;
-    private final TTNode[] nodes;
-
-    TTShape(TTNode root) {
-        this.root = root;
-        Set<TTNode> subs = new HashSet<>();
-        root.collectAllSubtypes(subs);
-        nodes = subs.toArray(new TTNode[subs.size()]);
-    }
-
-    private List<ClassCase> toCases(boolean includeClasses) {
-        List<ClassCase> ccs = new ArrayList<>();
-        root.start(includeClasses);
-        int i;
-        outer:
-        while (true) {
-            if (root.isValid()) {
-                ClassCase cc = root.genCase();
-                //System.out.println(cc);
-                ccs.add(cc);
-            }
-
-            i = 0;
-            do {
-                if (i >= nodes.length) {
-                    break outer;
-                }
-            } while(!nodes[i++].next());
-        }
-        return ccs;
-    }
-
-   public static List<ClassCase> allCases(boolean includeClasses) {
-        List<ClassCase> ccs = new ArrayList<>();
-        for (TTShape shape : SHAPES) {
-            ccs.addAll(shape.toCases(includeClasses));
-        }
-        return ccs;
-    }
-
-    public static TTShape parse(String s) {
-        return new TTShape(new TTParser(s).parse());
-    }
-
-    public static final TTShape[] SHAPES = new TTShape[] {
-        parse("a"),
-        parse("a(b)"),
-        parse("A(bb)"),
-        parse("A(B(d)c(d))"),
-        parse("A(b(c))"),
-        parse("A(B(cd)d)"),
-        parse("A(B(c)c)"),
-        parse("A(B(Ce)d(e))"),
-        parse("A(B(C)d(e))"),
-        parse("A(Bc(d))"),
-        parse("A(B(d)dc)"),
-        parse("A(B(dc)dc)"),
-        parse("A(B(c(d))d)"),
-        parse("A(B(C(d))d)"),
-        parse("A(B(C(e)d(e))e)"),
-        parse("A(B(c(d))c)"),
-        parse("A(B(dc(d))c)"),
-        parse("A(B(C(d))d)"),
-    };
-
-}
--- a/langtools/test/tools/javac/defaultMethods/separate/Separate.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/separate/Separate.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,8 +25,8 @@
  * @test
  * @summary smoke test for separate compilation of default methods
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods pkg1/A.java
- * @compile -XDallowDefaultMethods Separate.java
+ * @compile  pkg1/A.java
+ * @compile  Separate.java
  */
 
 import pkg1.A;
--- a/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Wed Jul 05 18:30:46 2017 +0200
@@ -323,7 +323,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
--- a/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Wed Jul 05 18:30:46 2017 +0200
@@ -54,7 +54,7 @@
         }
 
         List<String> getOptions() {
-            return Arrays.asList("-XDallowDefaultMethods", "-source", versionString);
+            return Arrays.asList("-source", versionString);
         }
     }
 
--- a/langtools/test/tools/javac/diags/CheckExamples.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/CheckExamples.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,9 +25,10 @@
  * @test
  * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
- * @build Example CheckExamples
+ * @build Example CheckExamples DocCommentProcessor
  * @run main/othervm CheckExamples
  */
+
 /*
  *      See CR 7127924 for info on why othervm is used.
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/DocCommentProcessor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.*;
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.tree.DocPretty;
+import java.io.PrintWriter;
+import javax.tools.Diagnostic;
+
+/**
+ * Standard annotation processor for use by examples to
+ * scan DocCommentTree nodes looking for ErroneousTree,
+ * on which to call {@code getMessage}.
+ */
+@SupportedAnnotationTypes("*")
+public class DocCommentProcessor extends AbstractProcessor {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        trees = DocTrees.instance(pEnv);
+        messager = pEnv.getMessager();
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
+        for (Element e : rEnv.getRootElements()) {
+            new DocCommentScanner().scan(e);
+        }
+        return true;
+    }
+
+    class DocCommentScanner extends TreePathScanner<Void,Void> {
+        public void scan(Element e) {
+            scan(trees.getPath(e), null);
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            check();
+            return super.visitClass(tree, ignore);
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            check();
+            return super.visitMethod(tree, ignore);
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            check();
+            return super.visitVariable(tree, ignore);
+        }
+
+        private void check() {
+            DocCommentTree dc = trees.getDocCommentTree(getCurrentPath());
+            if (dc == null)
+                return;
+
+            DocTreeScanner<Void, Void> s = new DocTreeScanner<Void, Void>() {
+                @Override
+                public Void visitErroneous(ErroneousTree tree, Void ignore) {
+                    messager.printMessage(Diagnostic.Kind.NOTE, tree.getDiagnostic().getMessage(null));
+                    return null;
+                }
+            };
+
+            s.scan(dc, null);
+        }
+
+    }
+
+    private DocTrees trees;
+    private Messager messager;
+}
--- a/langtools/test/tools/javac/diags/Example.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/Example.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -209,6 +209,13 @@
             opts.add("-classpath"); // avoid using -processorpath for now
             opts.add(classesDir.getPath());
             createAnnotationServicesFile(classesDir, procFiles);
+        } else if (options != null) {
+            int i = options.indexOf("-processor");
+            // check for built-in anno-processor(s)
+            if (i != -1 && options.get(i + 1).equals("DocCommentProcessor")) {
+                opts.add("-classpath");
+                opts.add(System.getProperty("test.classes"));
+            }
         }
 
         if (srcPathDir != null) {
--- a/langtools/test/tools/javac/diags/RunExamples.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/RunExamples.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
- * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples
+ * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples DocCommentProcessor
  * @run main/othervm RunExamples
  */
 /*
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Jul 05 18:30:46 2017 +0200
@@ -3,6 +3,7 @@
 compiler.err.annotation.value.not.allowable.type        # cannot happen: precluded by complete type-specific tests
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
+compiler.err.dc.unterminated.string                     # cannot happen
 compiler.err.illegal.char.for.encoding
 compiler.err.invalid.containedby.annotation             # should not happen
 compiler.err.invalid.containedby.annotation.invalid.value # "can't" happen
@@ -105,3 +106,4 @@
 compiler.warn.unexpected.archive.file                   # Paths: zip file with unknown extn
 compiler.warn.unknown.enum.constant                     # in bad class file
 compiler.warn.unknown.enum.constant.reason              # in bad class file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/BadEntity.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.bad.entity
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** & */
+class BadEntity { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/BadGreaterThan.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.bad.gt
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** > */
+class BadGreaterThan { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/BadInlineTag.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.bad.inline.tag
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @inheritDoc */
+class BadInlineTag { }
+
--- a/langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.cant.access.arg.type.in.functional.desc
-// key: compiler.err.report.access
-// options: -XDallowLambda
-
-interface SAM_InaccessibleArg {
-    void m(Foo.Bar bar);
-    static class Foo { private class Bar { } }
-}
-
-class CantAccessArgTypeInFunctionalDesc {
-    SAM_InaccessibleArg s = x-> { };
-}
--- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.cant.access.inner.cls.constr
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantAccessInnerClsConstructor {
 
--- a/langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.cant.access.return.in.functional.desc
-// options: -XDallowLambda
-
-interface SAM_InaccessibleRet {
-    Foo.Bar m();
-    static class Foo { private class Bar { } }
-}
-
-class CantAccessReturnTypeInFunctionalDesc {
-    SAM_InaccessibleRet s = ()->null;
-}
--- a/langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.cant.access.thrown.in.functional.desc
-// options: -XDallowLambda
-
-interface SAM_InaccessibleThrown {
-    void m() throws Foo.Bar;
-    static class Foo { private class Bar extends Exception { } }
-}
-
-class CantAccessThrownTypesInFunctionalDesc {
-    SAM_InaccessibleThrown s = ()-> { };
-}
--- a/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,7 +26,6 @@
 // key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.cant.apply.symbol
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantApplySymbolFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -28,7 +28,6 @@
 // key: compiler.misc.inapplicable.method
 // key: compiler.misc.cant.apply.symbols
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantApplySymbolsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.cant.ref.non.effectively.final.var
 // key: compiler.misc.inner.cls
 // key: compiler.misc.lambda
-// options: -XDallowLambda -XDallowEffectivelyFinalInInnerClasses
 
 class CantRefNonEffectivelyFinalVar {
     void test() {
--- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.misc.cant.resolve.location.args
 // key: compiler.misc.location
 // key: compiler.err.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantResolveLocationArgsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.misc.cant.resolve.location.args.params
 // key: compiler.misc.location
 // key: compiler.err.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantResolveLocationArgsParamsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java	Wed Jul 05 18:30:37 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.cant.ret.val.from.meth.decl.void
-
-class CantReturnValueForVoid {
-    void m() {
-        return 3;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.incompatible.ret.type.in.lambda
+// key: compiler.misc.conditional.target.cant.be.void
+
+class ConditionalTargetCantBeVoid {
+
+    interface SAM {
+        void m();
+    }
+
+    void test(boolean cond, Object o1, Object o2) {
+        SAM s = ()-> cond ? o1 : o2;
+    }
+}
--- a/langtools/test/tools/javac/diags/examples/CyclicInference.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/CyclicInference.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.cant.apply.symbol
 // key: compiler.misc.cyclic.inference
-// options: -XDallowLambda -XDallowPoly
 
 class CyclicInference {
     interface SAM<X> {
--- a/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.default.overrides.object.member
-// options: -XDallowDefaultMethods
 
 interface DefaultOverridesObjectMember {
     default String toString() { return ""; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/GreaterThanExpected.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.gt.expected
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+class GreaterThanExpected {
+    /** @param <T */
+    <T> void m(T t) { }
+}
+
--- a/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf.1
 // key: compiler.misc.incompatible.abstracts
-// options: -XDallowLambda
 
 class IncompatibleAbstracts {
 
--- a/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.arg.types.in.lambda
-// options: -XDallowLambda -XDallowPoly
 
 class IncompatibleArgTypesInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java	Wed Jul 05 18:30:46 2017 +0200
@@ -26,7 +26,6 @@
 // key: compiler.misc.incompatible.descs.in.functional.intf
 // key: compiler.misc.descriptor
 // key: compiler.misc.descriptor.throws
-// options: -XDallowLambda
 
 class IncompatibleDescsInFunctionalIntf {
     interface A {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.incompatible.ret.type.in.lambda
-// options: -XDallowLambda -XDallowPoly
 
 class IncompatibleRetTypeInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.incompatible.ret.type.in.mref
-// options: -XDallowMethodReferences -XDallowPoly
 
 class IncompatibleRetTypeInMref {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.incompatible.thrown.types.in.lambda
-// options: -XDallowLambda
 
 class IncompatibleThrownTypesInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.incompatible.thrown.types.in.mref
-// options: -XDallowMethodReferences
 
 class IncompatibleThrownTypesInMref {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.type.in.conditional
 // key: compiler.misc.inconvertible.types
-// options: -XDallowPoly
 
 class IncompatibleTypesInConditional {
 
--- a/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.invalid.generic.desc.in.functional.intf
-// options: -XDallowLambda
 
 class InvalidGenericDescInFunctionalIntf {
 
--- a/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,6 +22,7 @@
  */
 
 // key: compiler.err.local.var.accessed.from.icls.needs.final
+// options: -Xlint:-options -source 7
 
 class LocalVarNeedsFinal {
     Runnable m() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/MalformedHTML.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.malformed.html
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** <b */
+class MalformedHTML { }
--- a/langtools/test/tools/javac/diags/examples/MissingReturnValue.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/MissingReturnValue.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,8 @@
  * questions.
  */
 
-// key: compiler.err.missing.ret.val
+// key: compiler.err.prob.found.req
+// key: compiler.misc.missing.ret.val
 
 class MissingReturnValue {
     int m() {
--- a/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.ret.type.in.lambda
 // key: compiler.misc.missing.ret.val
-// options: -XDallowLambda
 
 class MissingReturnValueFragment {
     interface SAM {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/MissingSemicolon.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.missing.semicolon
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** &lt */
+class MissingSemicolon { }
+
--- a/langtools/test/tools/javac/diags/examples/NoAbstracts.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NoAbstracts.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf.1
 // key: compiler.misc.no.abstracts
-// options: -XDallowLambda
 
 class NoAbstracts {
 
--- a/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.no.suitable.functional.intf.inst
-// options: -XDallowLambda
 
 class NoSuitableFunctionalIntfInst {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoTagName.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.no.tag.name
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @ */
+class NoTagName { }
+
--- a/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.non-static.cant.be.ref
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class NonStaticCantBeRefFragment {
 
--- a/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf
-// options: -XDallowLambda
 
 class NotAFunctionalIntf {
 
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.def.access.class.intf.cant.access
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class NotDefAccessClassIntfCantAccessFragment {
 
--- a/langtools/test/tools/javac/diags/examples/OverriddenDefault.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/OverriddenDefault.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.illegal.default.super.call
 // key: compiler.misc.overridden.default
-// options: -XDallowDefaultMethods
 
 class OverriddenDefault {
     interface I { default void m() {  } }
@@ -33,4 +32,4 @@
     static class C implements J, K {
         void foo() { K.super.m(); }
     }
-}
\ No newline at end of file
+}
--- a/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.note.potential.lambda.found
-// options: -XDallowLambda -XDidentifyLambdaCandidate=true
+// options: -XDidentifyLambdaCandidate=true
 
 class PotentialLambdaFound {
 
--- a/langtools/test/tools/javac/diags/examples/RedundantSupertype.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/RedundantSupertype.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,6 @@
 
 // key: compiler.err.illegal.default.super.call
 // key: compiler.misc.redundant.supertype
-// options: -XDallowDefaultMethods
 
 class RedundantSupertype {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.ref.ambiguous
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class RefAmbiguousFragment {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RefBadParens.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.ref.bad.parens
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see #m((int)) */
+class RefBadParens { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RefIdentifierExpected.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.identifier.expected
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+class IdentifierExpected2 {
+    /** @param 123 */
+    void m() { }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RefSyntaxError.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.ref.syntax.error
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see #m(int [) */
+class RefSyntaxError { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/RefUnexpectedInput.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.ref.unexpected.input
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see String#isEmpty% */
+class UnexpectedInput { }
+
--- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.types.incompatible.abstract.default
-// options: -XDallowDefaultMethods
 
 class TypesIncompatibleAbstractDefault {
     interface A {
--- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.types.incompatible.unrelated.defaults
-// options: -XDallowDefaultMethods
 
 class TypesIncompatibleUnrelatedDefaults {
     interface A {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedContent.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.unexpected.content
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** {@docRoot a} */
+class UnterminatedSignature { }
+
--- a/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.unexpected.lambda
-// options: -XDallowLambda
 
 class UnexpectedLambda {
     { (()-> { })++; }
--- a/langtools/test/tools/javac/diags/examples/UnexpectedMref.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedMref.java	Wed Jul 05 18:30:46 2017 +0200
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.unexpected.mref
-// options: -XDallowMethodReferences
 
 class UnexpectedLambda {
     { (Foo::bar)++; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.unexpected.ret.val
+
+class UnexpectedReturnValue {
+    void m() {
+        return 3;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnterminatedInlineTag.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.unterminated.inline.tag
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** {@code */
+class UnterminatedInlineTag { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnterminatedSignature.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.dc.unterminated.signature
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see String#equals( */
+class UnterminatedSignature { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/AttrTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester AttrTest.java
+ */
+
+class AttrTest {
+    /**
+     * <a name=unquoted>foo</a>
+     */
+    void unquoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: UNQUOTED
+          value: 1
+            Text[TEXT, pos:9, unquoted]
+        ]
+    ]
+    Text[TEXT, pos:18, foo]
+    EndElement[END_ELEMENT, pos:21, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name="double_quoted">foo</a>
+     */
+    void double_quoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: DOUBLE
+          value: 1
+            Text[TEXT, pos:10, double_quoted]
+        ]
+    ]
+    Text[TEXT, pos:25, foo]
+    EndElement[END_ELEMENT, pos:28, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name='single_quoted'>foo</a>
+     */
+    void single_quoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: SINGLE
+          value: 1
+            Text[TEXT, pos:10, single_quoted]
+        ]
+    ]
+    Text[TEXT, pos:25, foo]
+    EndElement[END_ELEMENT, pos:28, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <hr size="3">
+     */
+    void numeric_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:5
+          name: size
+          vkind: DOUBLE
+          value: 1
+            Text[TEXT, pos:11, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a href="{@docRoot}/index.html">
+     */
+    void docRoot_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: href
+          vkind: DOUBLE
+          value: 2
+            DocRoot[DOC_ROOT, pos:10]
+            Text[TEXT, pos:20, /index.html]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name="abc&quot;def">
+     */
+    void entity_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: DOUBLE
+          value: 3
+            Text[TEXT, pos:10, abc]
+            Entity[ENTITY, pos:13, quot]
+            Text[TEXT, pos:19, def]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <hr noshade>
+     */
+    void no_value_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:5
+          name: noshade
+          vkind: EMPTY
+          value: null
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size='3'/>
+     */
+    void self_closing_attr_1() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:9
+          name: size
+          vkind: SINGLE
+          value: 1
+            Text[TEXT, pos:15, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size=3 />
+     */
+    void self_closing_attr_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:9
+          name: size
+          vkind: UNQUOTED
+          value: 1
+            Text[TEXT, pos:14, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size="3
+     */
+    void unterminated_attr_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr_size="3]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size="3
+     * @author jjg
+     */
+    void unterminated_attr_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr_size="3]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:18
+      name: 1
+        Text[TEXT, pos:26, jjg]
+    ]
+]
+*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/AuthorTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester AuthorTest.java
+ */
+
+class AuthorTest {
+    /** abc @author jjg &amp; others */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, abc_@author_jjg_]
+    Entity[ENTITY, pos:16, amp]
+    Text[TEXT, pos:21, _others]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/BadTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester Bad.java
+ */
+
+class BadTest {
+
+    /**
+     * abc {@value java.awt.Color#RED junk}
+     */
+    int trailing_junk() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.unexpected.content
+      body: {@value_java.awt.Color#RED_j
+    ]
+    Text[TEXT, pos:33, unk}]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/CodeTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester CodeTest.java
+ */
+
+class CodeTest {
+    /** {@code if (a < b) { }} */
+    void minimal() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Literal[CODE, pos:0, if_(a_<_b)_{_}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [{@code if (a < b) { }}] */
+    void in_brackets() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, []
+    Literal[CODE, pos:1, if_(a_<_b)_{_}]
+    Text[TEXT, pos:23, ]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [ {@code if (a < b) { }} ] */
+    void in_brackets_with_whitespace() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, [_]
+    Literal[CODE, pos:2, if_(a_<_b)_{_}]
+    Text[TEXT, pos:24, _]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code {@code nested} }
+     */
+    void nested() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[CODE, pos:1, {@code_nested}_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code if (a < b) {
+     *        }
+     * }
+     */
+    void embedded_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[CODE, pos:1, if_(a_<_b)_{|________}|_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** {@code if (a < b) { } */
+    void unterminated_1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:0
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@code_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code if (a < b) { }
+     * @author jjg */
+    void unterminated_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@code_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:24
+      name: 1
+        Text[TEXT, pos:32, jjg]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/DeprecatedTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester DeprecatedTest.java
+ */
+
+class DeprecatedTest {
+    /**
+     * @deprecated
+     */
+    void deprecated() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Deprecated[DEPRECATED, pos:1
+      body: empty
+    ]
+]
+*/
+
+    /**
+     * @deprecated text
+     */
+    void deprecated_text() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Deprecated[DEPRECATED, pos:1
+      body: 1
+        Text[TEXT, pos:13, text]
+    ]
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/DocCommentTester.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,779 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.doctree.*;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DocPretty;
+
+public class DocCommentTester {
+
+    public static void main(String... args) throws Exception {
+        new DocCommentTester().run(args);
+    }
+
+    public void run(String... args) throws Exception {
+        String testSrc = System.getProperty("test.src");
+
+        List<File> files = new ArrayList<File>();
+        for (String arg: args)
+            files.add(new File(testSrc, arg));
+
+        JavacTool javac = JavacTool.create();
+        StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+
+        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+        JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+        final DocTrees trees = DocTrees.instance(t);
+
+        final Checker[] checkers = {
+            new ASTChecker(this, trees),
+            new PosChecker(this, trees),
+            new PrettyChecker(this, trees)
+        };
+
+        DeclScanner d = new DeclScanner() {
+            @Override
+            public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+                for (Checker c: checkers)
+                    c.visitCompilationUnit(tree);
+                return super.visitCompilationUnit(tree, ignore);
+            }
+
+            @Override
+            void visitDecl(Tree tree, Name name) {
+                TreePath path = getCurrentPath();
+                String dc = trees.getDocComment(path);
+                if (dc != null) {
+                    for (Checker c : checkers) {
+                        try {
+                            System.err.println(path.getLeaf().getKind()
+                                    + " " + name
+                                    + " " + c.getClass().getSimpleName());
+
+                            c.check(path, name);
+
+                            System.err.println();
+                        } catch (Exception e) {
+                            error("Exception " + e);
+                            e.printStackTrace(System.err);
+                        }
+                    }
+                }
+            }
+        };
+
+        Iterable<? extends CompilationUnitTree> units = t.parse();
+        for (CompilationUnitTree unit: units) {
+            d.scan(unit, null);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static abstract class DeclScanner extends TreePathScanner<Void, Void> {
+        abstract void visitDecl(Tree tree, Name name);
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            super.visitClass(tree, ignore);
+            visitDecl(tree, tree.getSimpleName());
+            return null;
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            super.visitMethod(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            super.visitVariable(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+    }
+
+    /**
+     * Base class for checkers to check the doc comment on a declaration
+     * (when present.)
+     */
+    abstract class Checker {
+        final DocTrees trees;
+
+        Checker(DocTrees trees) {
+            this.trees = trees;
+        }
+
+        void visitCompilationUnit(CompilationUnitTree tree) { }
+
+        abstract void check(TreePath tree, Name name) throws Exception;
+
+        void error(String msg) {
+            DocCommentTester.this.error(msg);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    /**
+     * Verify the structure of the DocTree AST by comparing it against golden text.
+     */
+    static class ASTChecker extends Checker {
+        static final String NEWLINE = System.getProperty("line.separator");
+        Printer printer = new Printer();
+        String source;
+
+        ASTChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void visitCompilationUnit(CompilationUnitTree tree) {
+            try {
+                source = tree.getSourceFile().getCharContent(true).toString();
+            } catch (IOException e) {
+                source = "";
+            }
+        }
+
+        void check(TreePath path, Name name) {
+            StringWriter out = new StringWriter();
+            DocCommentTree dc = trees.getDocCommentTree(path);
+            printer.print(dc, out);
+            out.flush();
+            String found = out.toString().replace(NEWLINE, "\n");
+
+            // Look for the first block comment after the first occurrence of name
+            int start = source.indexOf("\n/*\n", findName(source, name));
+            int end = source.indexOf("\n*/\n", start);
+            String expect = source.substring(start + 4, end + 1);
+            if (!found.equals(expect)) {
+                System.err.println("Expect:\n" + expect);
+                System.err.println("Found:\n" + found);
+                error("AST mismatch for " + name);
+            }
+        }
+
+        /**
+         * This main program is to set up the golden comments used by this
+         * checker.
+         * Usage:
+         *     java DocCommentTester$ASTChecker -o dir file...
+         * The given files are written to the output directory with their
+         * golden comments updated. The intent is that the files should
+         * then be compared with the originals, e.g. with meld, and if the
+         * changes are approved, the new files can be used to replace the old.
+         */
+        public static void main(String... args) throws Exception {
+            List<File> files = new ArrayList<File>();
+            File o = null;
+            for (int i = 0; i < args.length; i++) {
+                String arg = args[i];
+                if (arg.equals("-o"))
+                    o = new File(args[++i]);
+                else if (arg.startsWith("-"))
+                    throw new IllegalArgumentException(arg);
+                else {
+                    files.add(new File(arg));
+                }
+            }
+
+            if (o == null)
+                throw new IllegalArgumentException("no output dir specified");
+            final File outDir = o;
+
+            JavacTool javac = JavacTool.create();
+            StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+            Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+            JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+            final DocTrees trees = DocTrees.instance(t);
+
+            DeclScanner d = new DeclScanner() {
+                Printer p = new Printer();
+                String source;
+
+                @Override
+                public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+                    System.err.println("processing " + tree.getSourceFile().getName());
+                    try {
+                        source = tree.getSourceFile().getCharContent(true).toString();
+                    } catch (IOException e) {
+                        source = "";
+                    }
+
+                    // remove existing gold by removing all block comments after the first '{'.
+                    int start = source.indexOf("{");
+                    while ((start = source.indexOf("\n/*\n", start)) != -1) {
+                        int end = source.indexOf("\n*/\n");
+                        source = source.substring(0, start + 1) + source.substring(end + 4);
+                    }
+
+                    // process decls in compilation unit
+                    super.visitCompilationUnit(tree, ignore);
+
+                    // write the modified source
+                    File f = new File(tree.getSourceFile().getName());
+                    File outFile = new File(outDir, f.getName());
+                    try {
+                        FileWriter out = new FileWriter(outFile);
+                        try {
+                            out.write(source);
+                        } finally {
+                            out.close();
+                        }
+                    } catch (IOException e) {
+                        System.err.println("Can't write " + tree.getSourceFile().getName()
+                                + " to " + outFile + ": " + e);
+                    }
+                    return null;
+                }
+
+                @Override
+                void visitDecl(Tree tree, Name name) {
+                    DocTree dc = trees.getDocCommentTree(getCurrentPath());
+                    if (dc != null) {
+                        StringWriter out = new StringWriter();
+                        p.print(dc, out);
+                        String found = out.toString();
+
+                        // Look for the empty line after the first occurrence of name
+                        int pos = source.indexOf("\n\n", findName(source, name));
+
+                        // Insert the golden comment
+                        source = source.substring(0, pos)
+                                + "\n/*\n"
+                                + found
+                                + "*/"
+                                + source.substring(pos);
+                    }
+                }
+
+            };
+
+            Iterable<? extends CompilationUnitTree> units = t.parse();
+            for (CompilationUnitTree unit: units) {
+                d.scan(unit, null);
+            }
+        }
+
+        static int findName(String source, Name name) {
+            Pattern p = Pattern.compile("\\s" + name + "[(;]");
+            Matcher m = p.matcher(source);
+            if (!m.find())
+                throw new Error("cannot find " + name);
+            return m.start();
+        }
+
+        static class Printer implements DocTreeVisitor<Void, Void> {
+            PrintWriter out;
+
+            void print(DocTree tree, Writer out) {
+                this.out = (out instanceof PrintWriter)
+                        ? (PrintWriter) out : new PrintWriter(out);
+                tree.accept(this, null);
+                this.out.flush();
+            }
+
+            public Void visitAttribute(AttributeTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName().toString());
+                print("vkind", node.getValueKind().toString());
+                print("value", node.getValue());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitAuthor(AuthorTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitComment(CommentTree node, Void p) {
+                header(node, compress(node.getBody()));
+                return null;
+            }
+
+            public Void visitDeprecated(DeprecatedTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitDocComment(DocCommentTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("firstSentence", node.getFirstSentence());
+                print("body", node.getBody());
+                print("block tags", node.getBlockTags());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitDocRoot(DocRootTree node, Void p) {
+                header(node, "");
+                return null;
+            }
+
+            public Void visitEndElement(EndElementTree node, Void p) {
+                header(node, node.getName().toString());
+                return null;
+            }
+
+            public Void visitEntity(EntityTree node, Void p) {
+                header(node, node.getName().toString());
+                return null;
+            }
+
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("code", ((DCErroneous) node).diag.getCode());
+                print("body", compress(node.getBody()));
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitIdentifier(IdentifierTree node, Void p) {
+                header(node, compress(node.getName().toString()));
+                return null;
+            }
+
+            public Void visitInheritDoc(InheritDocTree node, Void p) {
+                header(node, "");
+                return null;
+            }
+
+            public Void visitLink(LinkTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                print("body", node.getLabel());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitLiteral(LiteralTree node, Void p) {
+                header(node, compress(node.getBody().getBody()));
+                return null;
+            }
+
+            public Void visitParam(ParamTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitReference(ReferenceTree node, Void p) {
+                header(node, compress(node.getSignature()));
+                return null;
+            }
+
+            public Void visitReturn(ReturnTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSee(SeeTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerial(SerialTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerialData(SerialDataTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerialField(SerialFieldTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                print("type", node.getType());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSince(SinceTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitStartElement(StartElementTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("name:" + node.getName());
+                print("attributes", node.getAttributes());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitText(TextTree node, Void p) {
+                header(node, compress(node.getBody()));
+                return null;
+            }
+
+            public Void visitThrows(ThrowsTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("exceptionName", node.getExceptionName());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("tag:" + node.getTagName());
+                print("content", node.getContent());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("tag:" + node.getTagName());
+                print("content", node.getContent());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitValue(ValueTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitVersion(VersionTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitOther(DocTree node, Void p) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            void header(DocTree node) {
+                indent();
+                out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos);
+            }
+
+            void header(DocTree node, String rest) {
+                indent();
+                out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos
+                        + (rest.isEmpty() ? "" : ", " + rest)
+                        + "]");
+            }
+
+            String simpleClassName(DocTree node) {
+                return node.getClass().getSimpleName().replaceAll("DC(.*)", "$1");
+            }
+
+            void print(String name, DocTree item) {
+                indent();
+                if (item == null)
+                    out.println(name + ": null");
+                else {
+                    out.println(name + ":");
+                    indent(+1);
+                    item.accept(this, null);
+                    indent(-1);
+                }
+            }
+
+            void print(String name, String s) {
+                indent();
+                out.println(name + ": " + s);
+            }
+
+            void print(String name, List<? extends DocTree> list) {
+                indent();
+                if (list == null)
+                    out.println(name + ": null");
+                else if (list.isEmpty())
+                    out.println(name + ": empty");
+                else {
+                    out.println(name + ": " + list.size());
+                    indent(+1);
+                    for (DocTree tree: list) {
+                        tree.accept(this, null);
+                    }
+                    indent(-1);
+                }
+            }
+
+            int indent = 0;
+
+            void indent() {
+                for (int i = 0; i < indent; i++) {
+                    out.print("  ");
+                }
+            }
+
+            void indent(int n) {
+                indent += n;
+            }
+
+            String compress(String s) {
+                s = s.replace("\n", "|").replace(" ", "_");
+                return (s.length() < 32)
+                        ? s
+                        : s.substring(0, 16) + "..." + s.substring(16);
+            }
+
+            String quote(String s) {
+                if (s.contains("\""))
+                    return "'" + s + "'";
+                else if (s.contains("'") || s.contains(" "))
+                    return '"' + s + '"';
+                else
+                    return s;
+            }
+
+
+        }
+    }
+
+    /**
+     * Verify the reported tree positions by comparing the characters found
+     * at and after the reported position with the beginning of the pretty-
+     * printed text.
+     */
+    static class PosChecker extends Checker {
+        PosChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void check(TreePath path, Name name) throws Exception {
+            JavaFileObject fo = path.getCompilationUnit().getSourceFile();
+            final CharSequence cs = fo.getCharContent(true);
+
+            final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
+            DCTree t = (DCTree) trees.getDocCommentTree(path);
+
+            DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
+                @Override
+                public Void scan(DocTree node, Void ignore) {
+                    if (node != null) {
+                        try {
+                            String expect = getExpectText(node);
+                            long pos = ((DCTree) node).getSourcePosition(dc);
+                            String found = getFoundText(cs, (int) pos, expect.length());
+                            if (!found.equals(expect)) {
+                                System.err.println("expect: " + expect);
+                                System.err.println("found:  " + found);
+                                error("mismatch");
+                            }
+
+                        } catch (StringIndexOutOfBoundsException e) {
+                            error(node.getClass() + ": " + e.toString());
+                                e.printStackTrace();
+                        }
+                    }
+                    return super.scan(node, ignore);
+                }
+            };
+
+            scanner.scan(t, null);
+        }
+
+        String getExpectText(DocTree t) {
+            StringWriter sw = new StringWriter();
+            DocPretty p = new DocPretty(sw);
+            try { p.print(t); } catch (IOException never) { }
+            String s = sw.toString();
+            if (s.length() <= 1)
+                return s;
+            int ws = s.replaceAll("\\s+", " ").indexOf(" ");
+            if (ws != -1) s = s.substring(0, ws);
+            return (s.length() < 5) ? s : s.substring(0, 5);
+        }
+
+        String getFoundText(CharSequence cs, int pos, int len) {
+            return (pos == -1) ? "" : cs.subSequence(pos, Math.min(pos + len, cs.length())).toString();
+        }
+    }
+
+    /**
+     * Verify the pretty printed text against a normalized form of the
+     * original doc comment.
+     */
+    static class PrettyChecker extends Checker {
+
+        PrettyChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void check(TreePath path, Name name) throws Exception {
+            String raw = trees.getDocComment(path);
+            String normRaw = normalize(raw);
+
+            StringWriter out = new StringWriter();
+            DocPretty dp = new DocPretty(out);
+            dp.print(trees.getDocCommentTree(path));
+            String pretty = out.toString();
+
+            if (!pretty.equals(normRaw)) {
+                error("mismatch");
+                System.err.println("*** expected:");
+                System.err.println(normRaw.replace(" ", "_"));
+                System.err.println("*** found:");
+                System.err.println(pretty.replace(" ", "_"));
+    //            throw new Error();
+            }
+        }
+
+        /**
+         * Normalize white space in places where the tree does not preserve it.
+         */
+        String normalize(String s) {
+            return s.trim()
+                    .replaceFirst("\\.\\s++([^@])", ". $1")
+                    .replaceFirst("\\.\\s*\\n *@", ".\n@")
+                    .replaceFirst("\\s+<(/?p|pre|h[1-6])>", " <$1>")
+                    .replaceAll("\\{@docRoot\\s+\\}", "{@docRoot}")
+                    .replaceAll("\\{@inheritDoc\\s+\\}", "{@inheritDoc}")
+                    .replaceAll("(\\{@value\\s+[^}]+)\\s+(\\})", "$1$2")
+                    .replaceAll("\n[ \t]+@", "\n@");
+        }
+
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/DocRootTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester DocRootTest.java
+ */
+
+class DocRootTest {
+    /** abc {@docRoot} */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot } */
+    void standard_ws1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot  } */
+    void standard_ws2() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot junk} */
+    void error() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    Erroneous[ERRONEOUS, pos:4
+      code: compiler.err.dc.unexpected.content
+      body: {@docRoot_junk}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ElementTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ElementTest.java
+ */
+
+class ElementTest {
+    /**
+     * <p>para</p>
+     */
+    void simple() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: 3
+    StartElement[START_ELEMENT, pos:1
+      name:p
+      attributes: empty
+    ]
+    Text[TEXT, pos:4, para]
+    EndElement[END_ELEMENT, pos:8, p]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr/>
+     */
+    void self_closing() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: empty
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc < def
+     */
+    void bad_lt() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc > def
+     */
+    void bad_gt() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:6, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <p 123> def
+     */
+    void bad_chars_start();
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 5
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, p_123]
+    Erroneous[ERRONEOUS, pos:11
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc </p 123> def
+     */
+    void bad_chars_end();
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 5
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p_123]
+    Erroneous[ERRONEOUS, pos:12
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:13, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr
+     */
+    void unterminated_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr
+     * @author jjg
+     */
+    void unterminated_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:10
+      name: 1
+        Text[TEXT, pos:18, jjg]
+    ]
+]
+*/
+
+
+    /**
+     * abc </p
+     */
+    void unterminated_end_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc </p
+     * @author jjg
+     */
+    void unterminated_end_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:10
+      name: 1
+        Text[TEXT, pos:18, jjg]
+    ]
+]
+*/
+
+    /**
+     * abc
+     * <!-- comment -->
+     * def
+     */
+    void comment() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc|_]
+    Comment[COMMENT, pos:6, <!--_comment_-->]
+    Text[TEXT, pos:22, |_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/EntityTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester EntityTest.java
+ */
+
+class EntityTest {
+    /**
+     *  abc &lt; def
+     */
+    public void name() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, lt]
+    Text[TEXT, pos:10, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#160; def
+     */
+    public void decimal_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #160]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#xa0; def
+     */
+    public void lower_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #xa0]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#XA0; def
+     */
+    public void upper_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #XA0]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc & def
+     */
+    public void bad_amp() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.bad.entity
+      body: &
+    ]
+    Text[TEXT, pos:7, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &1 def
+     */
+    public void bad_entity_name() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.bad.entity
+      body: &
+    ]
+    Text[TEXT, pos:7, 1_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#012.3; def
+     */
+    public void bad_entity_decimal_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.missing.semicolon
+      body: &#012
+    ]
+    Text[TEXT, pos:11, .3;_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#x012azc; def
+     */
+    public void bad_entity_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.missing.semicolon
+      body: &#x012a
+    ]
+    Text[TEXT, pos:13, zc;_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ExceptionTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ExceptionTest.java
+ */
+
+class ExceptionTest {
+    /**
+     * @exception Exception
+     */
+    void exception() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[EXCEPTION, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:12, Exception]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @exception Exception text
+     */
+    void exception_text() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[EXCEPTION, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:12, Exception]
+      description: 1
+        Text[TEXT, pos:22, text]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/FirstSentenceTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester FirstSentenceTest.java
+ */
+
+class FirstSentenceTest {
+    /** */
+    void empty() { }
+/*
+DocComment[DOC_COMMENT, pos:-1
+  firstSentence: empty
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc def ghi */
+    void no_terminator() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Text[TEXT, pos:0, abc_def_ghi]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi.
+     */
+    void no_body() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi. jkl mno pqr.
+     */
+    void dot_space() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: 1
+    Text[TEXT, pos:14, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi.
+     * jkl mno pqr
+     */
+    void dot_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: 1
+    Text[TEXT, pos:15, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * <p>jkl mno pqr
+     */
+    void dot_p() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: 2
+    StartElement[START_ELEMENT, pos:14
+      name:p
+      attributes: empty
+    ]
+    Text[TEXT, pos:17, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * </p>jkl mno pqr
+     */
+    void dot_end_p() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: 2
+    EndElement[END_ELEMENT, pos:14, p]
+    Text[TEXT, pos:18, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc &lt; ghi. jkl mno pqr.
+     */
+    void entity() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Entity[ENTITY, pos:5, lt]
+    Text[TEXT, pos:9, _ghi.]
+  body: 1
+    Text[TEXT, pos:15, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@code code} ghi. jkl mno pqr.
+     */
+    void inline_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Literal[CODE, pos:5, code]
+    Text[TEXT, pos:17, _ghi.]
+  body: 1
+    Text[TEXT, pos:23, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * @author jjg
+     */
+    void block_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:14
+      name: 1
+        Text[TEXT, pos:22, jjg]
+    ]
+]
+*/
+
+    /**
+     * @author jjg
+     */
+    void just_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:1
+      name: 1
+        Text[TEXT, pos:9, jjg]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/InheritDocTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester InheritDocTest.java
+ */
+
+class InheritDocTest {
+    /** abc {@inheritDoc} */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc } */
+    void standard_ws1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc  } */
+    void standard_ws2() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc junk} */
+    void error() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    Erroneous[ERRONEOUS, pos:4
+      code: compiler.err.dc.unexpected.content
+      body: {@inheritDoc_junk}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/LinkPlainTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LinkPlainTest.java
+ */
+
+class LinkPlainTest {
+    /**
+     * abc {@linkplain String} def
+      */
+    void simple_name() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, String]
+      body: empty
+    ]
+    Text[TEXT, pos:24, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain String desc} def
+     */
+    void simple_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, String]
+      body: 1
+        Text[TEXT, pos:24, desc]
+    ]
+    Text[TEXT, pos:29, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String desc} def
+     */
+    void pkg_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String]
+      body: 1
+        Text[TEXT, pos:34, desc]
+    ]
+    Text[TEXT, pos:39, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#isEmpty desc} def
+     */
+    void method_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#isEmpty]
+      body: 1
+        Text[TEXT, pos:42, desc]
+    ]
+    Text[TEXT, pos:47, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#isEmpty() desc} def
+     */
+    void method_0_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#isEmpty()]
+      body: 1
+        Text[TEXT, pos:44, desc]
+    ]
+    Text[TEXT, pos:49, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#substring(int) desc} def
+     */
+    void method_1_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#substring(int)]
+      body: 1
+        Text[TEXT, pos:49, desc]
+    ]
+    Text[TEXT, pos:54, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#substring(int, int) desc} def
+     */
+    void method_2_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String...#substring(int,_int)]
+      body: 1
+        Text[TEXT, pos:54, desc]
+    ]
+    Text[TEXT, pos:59, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.util.List<T> desc} def
+     */
+    void pkg_name_typarams_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.util.List<T>]
+      body: 1
+        Text[TEXT, pos:35, desc]
+    ]
+    Text[TEXT, pos:40, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/LinkTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LinkTest.java
+ */
+
+class LinkTest {
+    /**
+     * abc {@link String} def
+      */
+    void simple_name() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, String]
+      body: empty
+    ]
+    Text[TEXT, pos:19, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link String desc} def
+     */
+    void simple_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, String]
+      body: 1
+        Text[TEXT, pos:19, desc]
+    ]
+    Text[TEXT, pos:24, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String desc} def
+     */
+    void pkg_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String]
+      body: 1
+        Text[TEXT, pos:29, desc]
+    ]
+    Text[TEXT, pos:34, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#isEmpty desc} def
+     */
+    void method_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#isEmpty]
+      body: 1
+        Text[TEXT, pos:37, desc]
+    ]
+    Text[TEXT, pos:42, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#isEmpty() desc} def
+     */
+    void method_0_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#isEmpty()]
+      body: 1
+        Text[TEXT, pos:39, desc]
+    ]
+    Text[TEXT, pos:44, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#substring(int) desc} def
+     */
+    void method_1_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#substring(int)]
+      body: 1
+        Text[TEXT, pos:44, desc]
+    ]
+    Text[TEXT, pos:49, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#substring(int, int) desc} def
+     */
+    void method_2_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String...#substring(int,_int)]
+      body: 1
+        Text[TEXT, pos:49, desc]
+    ]
+    Text[TEXT, pos:54, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.util.List<T> desc} def
+     */
+    void pkg_name_typarams_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.util.List<T>]
+      body: 1
+        Text[TEXT, pos:30, desc]
+    ]
+    Text[TEXT, pos:35, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/LiteralTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LiteralTest.java
+ */
+
+class LiteralTest {
+    /** {@literal if (a < b) { }} */
+    void minimal() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [{@literal if (a < b) { }}] */
+    void in_brackets() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, []
+    Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
+    Text[TEXT, pos:26, ]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [ {@literal if (a < b) { }} ] */
+    void in_brackets_with_whitespace() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, [_]
+    Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
+    Text[TEXT, pos:27, _]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal {@literal nested} }
+     */
+    void nested() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[LITERAL, pos:1, {@literal_nested}_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal if (a < b) {
+     *        }
+     * }
+     */
+    void embedded_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
+  body: empty
+  block tags: empty
+]
+*/
+
+
+    /** {@literal if (a < b) { } */
+    void unterminated_1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:0
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@literal_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal if (a < b) { }
+     * @author jjg */
+    void unterminated_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@literal_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:27
+      name: 1
+        Text[TEXT, pos:35, jjg]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ParamTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ParamTest.java
+ */
+
+class ParamTest {
+    /**
+     * @param x
+     */
+    void no_description(int x) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Param[PARAM, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:8, x]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @param x description
+     */
+    void with_description(int x) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Param[PARAM, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:8, x]
+      description: 1
+        Text[TEXT, pos:10, description]
+    ]
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ReferenceTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @summary check references in at-see and {at-link} tags
+ * @build ReferenceTest
+ * @compile -processor ReferenceTest -proc:only ReferenceTest.java
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.LinkTree;
+import com.sun.source.doctree.ReferenceTree;
+import com.sun.source.doctree.SeeTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+/**
+ * {@link java.lang        Package}
+ * {@link java.lang.ERROR  Bad}
+ *
+ * {@link java.lang.String Class}
+ * {@link           String Class}
+ * {@link java.lang.String#CASE_INSENSITIVE_ORDER Field}
+ * {@link java.lang.String#String Constructor}
+ * {@link java.lang.String#String(byte[]) Constructor}
+ * {@link java.lang.String#String(byte[] bytes) Constructor}
+ * {@link java.lang.String#String(byte[], String) Constructor}
+ * {@link java.lang.String#String(byte[] bytes, String charSetName) Constructor}
+ * {@link java.lang.String#isEmpty Method}
+ * {@link java.lang.String#isEmpty() Method}
+ * {@link java.lang.String#ERROR Bad}
+ * {@link java.lang.String#equals(Object) Method}
+ *
+ * {@link AbstractProcessor Class}
+ *
+ * {@link List#add(Object) Method}
+ *
+ * {@link #trees Field}
+ * {@link #getSupportedSourceVersion Method}
+ * {@link #init(ProcessingEnvironment Method}
+ *
+ * @see java.lang        Package
+ * @see java.lang.ERROR  Bad
+ *
+ * @see java.lang.String Class
+ * @see           String Class
+ * @see java.lang.String#CASE_INSENSITIVE_ORDER Field
+ * @see java.lang.String#String Constructor
+ * @see java.lang.String#String(byte[]) Constructor
+ * @see java.lang.String#String(byte[] bytes) Constructor
+ * @see java.lang.String#String(byte[],String) Constructor
+ * @see java.lang.String#String(byte[] bytes, String charsetName) Constructor
+ * @see java.lang.String#isEmpty Method
+ * @see java.lang.String#isEmpty() Method
+ * @see java.lang.String#ERROR Bad
+ * @see java.lang.String#equals(Object) Method
+ *
+ * @see AbstractProcessor Class
+ *
+ * @see List#add(Object) Method
+ *
+ * @see #trees Field
+ * @see #getSupportedSourceVersion Method
+ * @see #init(ProcessingEnvironment) Method
+ *
+ * @see java.io.BufferedInputStream#BufferedInputStream(InputStream) Constructor
+ */
+@SupportedAnnotationTypes("*")
+public class ReferenceTest extends AbstractProcessor {
+    DocTrees trees;
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        trees = DocTrees.instance(pEnv);
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        for (Element e: roundEnv.getRootElements()) {
+            new DocCommentScanner(trees.getPath(e)).scan();
+        }
+        return true;
+    }
+
+    class DocCommentScanner extends DocTreeScanner<Void, Void> {
+        TreePath path;
+        DocCommentTree dc;
+
+        DocCommentScanner(TreePath path) {
+            this.path = path;
+        }
+
+        void scan() {
+            dc = trees.getDocCommentTree(path);
+            scan(dc, null);
+        }
+
+        @Override
+        public Void visitLink(LinkTree tree, Void ignore) {
+            checkReference(tree.getReference(), tree.getLabel());
+            return null;
+        }
+
+        @Override
+        public Void visitSee(SeeTree tree, Void ignore) {
+            List<? extends DocTree> refLabel = tree.getReference();
+            if (refLabel.size() > 1 && (refLabel.get(0) instanceof ReferenceTree)) {
+                ReferenceTree ref = (ReferenceTree) refLabel.get(0);
+                List<? extends DocTree> label = refLabel.subList(1, refLabel.size());
+                checkReference(ref, label);
+            }
+            return null;
+        }
+
+        void checkReference(ReferenceTree tree, List<? extends DocTree> label) {
+            String sig = tree.getSignature();
+
+            Element found = trees.getElement(path, tree);
+            if (found == null) {
+                System.err.println(sig + " NOT FOUND");
+            } else {
+                System.err.println(sig + " found " + found.getKind() + " " + found);
+            }
+
+            String expect = "UNKNOWN";
+            if (label.size() > 0 && label.get(0) instanceof TextTree)
+                expect = ((TextTree) label.get(0)).getBody();
+
+            if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) {
+                error(tree, "Unexpected value found: " + found +", expected: " + expect);
+            }
+        }
+
+        void error(DocTree tree, String msg) {
+            trees.printMessage(Kind.ERROR, msg, tree, dc, path.getCompilationUnit());
+        }
+    }
+}
+
+/**
+ * @see ReferenceTestExtras    Class
+ * @see #ReferenceTestExtras   Field
+ * @see #ReferenceTestExtras() Constructor
+ *
+ * @see #X    Field
+ * @see #X()  Method
+ *
+ * @see #m    Method
+ *
+ * @see #varargs(int...)        Method
+ * @see #varargs(int... args)   Method
+ * @see #varargs(int[])         Method
+ * @see #varargs(int[] args)    Method
+ */
+class ReferenceTestExtras {
+    int ReferenceTestExtras;            // field
+    ReferenceTestExtras() { }           // constructor
+    void ReferenceTestExtras() { }      // method
+
+    int X;
+    void X() { }
+    static class X { }
+
+    void m() { }
+    void m(int i) { }
+    void m(int i, int j) { }
+
+    void varargs(int... args) { }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ReturnTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ReturnTest.java
+ */
+
+class ReturnTest {
+    /**
+     * @return something
+     */
+    int an_int() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Return[RETURN, pos:1
+      description: 1
+        Text[TEXT, pos:9, something]
+    ]
+]
+*/
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SeeTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SeeTest.java
+ */
+
+class SeeTest {
+    /**
+     * abc.
+     * @see "String"
+     */
+    void quoted_text() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:7
+      code: compiler.err.dc.unexpected.content
+      body: @see_"String"
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see <a href="url">url</a>
+     */
+    void url() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 3
+        StartElement[START_ELEMENT, pos:12
+          name:a
+          attributes: 1
+            Attribute[ATTRIBUTE, pos:15
+              name: href
+              vkind: DOUBLE
+              value: 1
+                Text[TEXT, pos:21, url]
+            ]
+        ]
+        Text[TEXT, pos:26, url]
+        EndElement[END_ELEMENT, pos:29, a]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see String text
+     */
+    void string() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, String]
+        Text[TEXT, pos:19, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String text
+     */
+    void j_l_string() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String]
+        Text[TEXT, pos:29, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String#length text
+     */
+    void j_l_string_length() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String#length]
+        Text[TEXT, pos:36, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String#matches(String regex) text
+     */
+    void j_l_string_matches() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String...#matches(String_regex)]
+        Text[TEXT, pos:51, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see 123 text
+     */
+    void bad_numeric() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:7
+      code: compiler.err.dc.unexpected.content
+      body: @see_123_text
+    ]
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SerialDataTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialDataTest.java
+ */
+
+class SerialDataTest {
+    /**
+     * @serialData description
+     */
+    void writeObject(ObjectOutputStream stream) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialData[SERIAL_DATA, pos:1
+      description: 1
+        Text[TEXT, pos:13, description]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SerialFieldTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialFieldTest.java
+ */
+
+class SerialFieldTest {
+
+    /**
+     * @serialField field String
+     */
+    String f1;
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialField[SERIAL_FIELD, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:14, field]
+      type:
+        Reference[REFERENCE, pos:20, String]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @serialField field String f2 is a String
+     */
+    String f2;
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialField[SERIAL_FIELD, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:14, field]
+      type:
+        Reference[REFERENCE, pos:20, String]
+      description: 1
+        Text[TEXT, pos:27, f2_is_a_String]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SerialTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialTest.java
+ */
+
+class SerialTest {
+    /**
+     * @serial include
+     */
+    void include() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, include]
+    ]
+]
+*/
+
+    /**
+     * @serial exclude
+     */
+    void exclude() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, exclude]
+    ]
+]
+*/
+
+    /**
+     * @serial description
+     */
+    void description() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, description]
+    ]
+]
+*/
+
+    /**
+     * @serial
+     */
+    void empty() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: empty
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTreeVisitor;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.SimpleDocTreeVisitor;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTool;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+public class SimpleDocTreeVisitorTest {
+    public static void main(String... args) throws Exception {
+        SimpleDocTreeVisitorTest t = new SimpleDocTreeVisitorTest();
+        t.run();
+    }
+
+    void run() throws Exception {
+        List<File> files = new ArrayList<File>();
+        File testSrc = new File(System.getProperty("test.src"));
+        for (File f: testSrc.listFiles()) {
+            if (f.isFile() && f.getName().endsWith(".java"))
+                files.add(f);
+        }
+
+        JavacTool javac = JavacTool.create();
+        StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+
+        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+        JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+        DocTrees trees = DocTrees.instance(t);
+
+        Iterable<? extends CompilationUnitTree> units = t.parse();
+
+        Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
+        DeclScanner ds = new DeclScanner(trees, found);
+        for (CompilationUnitTree unit: units) {
+            ds.scan(unit, null);
+        }
+
+        for (DocTree.Kind k: DocTree.Kind.values()) {
+            if (!found.contains(k) && k != DocTree.Kind.OTHER)
+                error("not found: " + k);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    static class DeclScanner extends TreePathScanner<Void, Void> {
+        DocTrees trees;
+        DocTreeScanner<Void,Void> cs;
+
+        DeclScanner(DocTrees trees, final Set<DocTree.Kind> found) {
+            this.trees = trees;
+            cs = new CommentScanner(found);
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            super.visitClass(tree, ignore);
+            visitDecl(tree, tree.getSimpleName());
+            return null;
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            super.visitMethod(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            super.visitVariable(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+
+        void visitDecl(Tree tree, Name name) {
+            TreePath path = getCurrentPath();
+            DocCommentTree dc = trees.getDocCommentTree(path);
+            if (dc != null)
+                cs.scan(dc, null);
+        }
+    }
+
+    static class CommentScanner extends DocTreeScanner<Void, Void> {
+        DocTreeVisitor<Void, Void> visitor;
+
+        CommentScanner(Set<DocTree.Kind> found) {
+            visitor = new Visitor(found);
+        }
+
+        @Override
+        public Void scan(DocTree tree, Void ignore) {
+            if (tree != null)
+                tree.accept(visitor, ignore);
+            return super.scan(tree, ignore);
+        }
+    }
+
+    static class Visitor extends SimpleDocTreeVisitor<Void, Void> {
+        Set<DocTree.Kind> found;
+
+        Visitor(Set<DocTree.Kind> found) {
+            this.found = found;
+        }
+
+        @Override
+        public Void defaultAction(DocTree tree, Void ignore) {
+            found.add(tree.getKind());
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/SinceTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SinceTest.java
+ */
+
+class SinceTest {
+    /**
+     * abc.
+     * @since then &amp; now.
+     */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Since[SINCE, pos:7
+      body: 3
+        Text[TEXT, pos:14, then_]
+        Entity[ENTITY, pos:19, amp]
+        Text[TEXT, pos:24, _now.]
+    ]
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/TagTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester TagTest.java
+ */
+
+class TagTest {
+    /**
+     * @author jjg
+     */
+    void simple_standard_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:1
+      name: 1
+        Text[TEXT, pos:9, jjg]
+    ]
+]
+*/
+
+    /**
+     * @ abc
+     */
+    void no_name_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.no.tag.name
+      body: @_abc
+    ]
+]
+*/
+
+    /**
+     * @abc def ghi
+     */
+    void unknown_name_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    UnknownBlockTag[UNKNOWN_BLOCK_TAG, pos:1
+      tag:abc
+      content: 1
+        Text[TEXT, pos:6, def_ghi]
+    ]
+]
+*/
+
+    /**
+     * {@link String}
+     */
+    void simple_standard_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Link[LINK, pos:1
+      reference:
+        Reference[REFERENCE, pos:8, String]
+      body: empty
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@ abc}
+     */
+    void no_name_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.no.tag.name
+      body: {@
+    ]
+    Text[TEXT, pos:3, _abc}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@abc def ghi}
+     */
+    void unknown_name_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    UnknownInlineTag[UNKNOWN_INLINE_TAG, pos:1
+      tag:abc
+      content: 1
+        Text[TEXT, pos:7, def_ghi]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@abc def ghi
+     */
+    void unterminated_standard_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@abc_def_ghi
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ThrowableTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ThrowableTest.java
+ */
+
+class ThrowableTest {
+    /**
+     * @throws Exception
+     */
+    void exception() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[THROWS, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:9, Exception]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @throws Exception text
+     */
+    void exception_text() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[THROWS, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:9, Exception]
+      description: 1
+        Text[TEXT, pos:19, text]
+    ]
+]
+*/
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/ValueTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ValueTest.java
+ */
+
+class ValueTest {
+    /**
+     * abc {@value}
+     */
+    int no_ref() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference: null
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED}
+     */
+    int typical() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference:
+        Reference[REFERENCE, pos:13, java.awt.Color#RED]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED }
+     */
+    int trailing_ws() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference:
+        Reference[REFERENCE, pos:13, java.awt.Color#RED]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED junk}
+     */
+    int trailing_junk() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.unexpected.content
+      body: {@value_java.awt.Color#RED_j
+    ]
+    Text[TEXT, pos:33, unk}]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/VersionTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester VersionTest.java
+ */
+
+class VersionTest {
+    /**
+     * @version 1.2
+     */
+    void version() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Version[VERSION, pos:1
+      body: 1
+        Text[TEXT, pos:10, 1.2]
+    ]
+]
+*/
+
+}
+
+
--- a/langtools/test/tools/javac/generics/7022054/T7022054pos1.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -27,7 +27,7 @@
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
  * @compile -source 7 T7022054pos1.java
- * @compile/fail -XDstrictMethodClashCheck T7022054pos1.java
+ * @compile/fail/ref=T7022054pos1.out -XDrawDiagnostics T7022054pos1.java
  *
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: <X>m(java.lang.String), T7022054pos1.B, m(java.lang.String), T7022054pos1.A, <X>m(java.lang.String), T7022054pos1.B
+1 error
--- a/langtools/test/tools/javac/generics/7022054/T7022054pos2.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -27,7 +27,7 @@
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
  * @compile -source 7 T7022054pos2.java
- * @compile/fail -XDstrictMethodClashCheck T7022054pos2.java
+ * @compile/fail/ref=T7022054pos2.out -XDrawDiagnostics T7022054pos2.java
  */
 
 class T7022054pos2 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+T7022054pos2.java:38:32: compiler.err.name.clash.same.erasure.no.hide: <X>m(java.lang.String), T7022054pos2.B, m(java.lang.String), T7022054pos2.A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-static variables are not accessible from static lambdas
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess.out -XDrawDiagnostics BadAccess.java
+ */
+
+public class BadAccess {
+
+    int i;
+    static int I;
+
+    interface SAM {
+        int m();
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadAccess.java:22:22: compiler.err.non-static.cant.be.ref: kindname.variable, i
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda can access only effectively-final locals
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess02.out -XDrawDiagnostics BadAccess02.java
+ */
+
+public class BadAccess02 {
+
+    interface SAM {
+        int m(int h);
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + j + l + L; };
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + k + j + l + L; };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess02.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+BadAccess02.java:21:52: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+BadAccess02.java:29:56: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda cannot assign non-effectively final locals
+ * @compile/fail/ref=BadAccess03.out -XDrawDiagnostics BadAccess03.java
+ */
+
+class BadAccess03 {
+    void test() {
+        int k = 0;
+        int n = 2; //effectively final variable
+        Runnable r = ()-> { k = n; }; //error
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess03.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadAccess03.java:13:29: compiler.err.cant.ref.non.effectively.final.var: k, (compiler.misc.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadBreakContinue.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that break/continue is disallowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadBreakContinue.out -XDrawDiagnostics BadBreakContinue.java
+ */
+
+class BadBreakContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { break; };
+    SAM s2 = ()-> { continue; };
+    SAM s3 = ()-> {
+        SAM s3_1 = ()-> { break; };
+        SAM s3_2 = ()-> { continue; };
+    };
+
+    void testLabelled() {
+        loop: while (true) {
+            SAM s1 = ()-> { break loop; };
+            SAM s2 = ()-> { continue loop; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break loop; };
+                SAM s3_2 = ()-> { continue loop; };
+            };
+        }
+    }
+
+    void testNonLabelled() {
+        while (true) {
+            SAM s1 = ()-> { break; };
+            SAM s2 = ()-> { continue; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break; };
+                SAM s3_2 = ()-> { continue; };
+            };
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadBreakContinue.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,13 @@
+BadBreakContinue.java:16:21: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:17:21: compiler.err.cont.outside.loop
+BadBreakContinue.java:19:27: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:20:27: compiler.err.cont.outside.loop
+BadBreakContinue.java:25:29: compiler.err.undef.label: loop
+BadBreakContinue.java:26:29: compiler.err.undef.label: loop
+BadBreakContinue.java:28:35: compiler.err.undef.label: loop
+BadBreakContinue.java:29:35: compiler.err.undef.label: loop
+BadBreakContinue.java:36:29: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:37:29: compiler.err.cont.outside.loop
+BadBreakContinue.java:39:35: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:40:35: compiler.err.cont.outside.loop
+12 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  NPE while checking if subinterface is a SAM type
+ * @compile/fail/ref=BadConv03.out -XDrawDiagnostics BadConv03.java
+ */
+
+class BadConv03 {
+
+    interface A {
+        void a();
+    }
+
+    interface B extends A { //not a SAM (2 non-override equivalent abstracts!)
+        void a(int i);
+    }
+
+    B b = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv03.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadConv03.java:19:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, BadConv03.B))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that ill-formed SAM type generates right diagnostic when SAM converted
+ * @compile/fail/ref=BadConv04.out -XDrawDiagnostics BadConv04.java
+ */
+
+class BadConv04 {
+
+    interface I1 {
+        int m();
+    }
+
+    interface I2 {
+        long m();
+    }
+
+    interface SAM extends I1, I2 {}
+
+    SAM s = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv04.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+BadConv04.java:19:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m()
+BadConv04.java:21:13: compiler.err.prob.found.req: (compiler.misc.incompatible.descs.in.functional.intf: kindname.interface, BadConv04.SAM,{(compiler.misc.descriptor: m, , long, ),(compiler.misc.descriptor: m, , int, )})
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that a conditonal can't be void
+ * @compile/fail/ref=BadExpressionLambda.out -XDrawDiagnostics BadExpressionLambda.java
+ */
+
+class BadExpressionLambda {
+
+    interface SAM {
+        void invoke();
+    }
+
+    public static void m() {}
+
+    void test() {
+        SAM sam1 = () -> m(); //ok
+        SAM sam2 = () -> true ? m() : m(); //not ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadExpressionLambda.java:19:31: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaExpr.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compile crashes on partial lambda expressions
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class BadLambdaExpr {
+
+    static int checkCount = 0;
+
+    enum ParameterListKind {
+        ZERO_ARY("()"),
+        UNARY("(#P)"),
+        TWO_ARY("(#P, #P)"),
+        THREE_ARY("(#P, #P, #P)");
+
+        String parametersTemplateStr;
+
+        ParameterListKind(String parametersTemplateStr) {
+            this.parametersTemplateStr = parametersTemplateStr;
+        }
+
+        String getParameterString(ParameterKind pk) {
+            return parametersTemplateStr.replaceAll("#P", pk.parameterStr);
+        }
+    }
+
+    enum ParameterKind {
+        IMPLICIT("a"),
+        EXPLIICT("A a");
+
+        String parameterStr;
+
+        ParameterKind(String parameterStr) {
+            this.parameterStr = parameterStr;
+        }
+    }
+
+    enum ArrowKind {
+        NONE(""),
+        SEMI("-"),
+        FULL("->");
+
+        String arrowStr;
+
+        ArrowKind(String arrowStr) {
+            this.arrowStr = arrowStr;
+        }
+    }
+
+    enum ExprKind {
+        NONE("#P#A"),
+        METHOD_CALL("m(#P#A)"),
+        CONSTR_CALL("new Foo(#P#A)");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(ParameterListKind plk, ParameterKind pk,
+                ArrowKind ak) {
+            return expressionTemplate.replaceAll("#P", plk.getParameterString(pk))
+                    .replaceAll("#A", ak.arrowStr);
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (ParameterListKind plk : ParameterListKind.values()) {
+            for (ParameterKind pk : ParameterKind.values()) {
+                for (ArrowKind ak : ArrowKind.values()) {
+                    for (ExprKind ek : ExprKind.values()) {
+                        new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    ParameterListKind plk;
+    ParameterKind pk;
+    ArrowKind ak;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    BadLambdaExpr(ParameterListKind plk, ParameterKind pk, ArrowKind ak, ExprKind ek) {
+        this.plk = plk;
+        this.pk = pk;
+        this.ak = ak;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.expressionString(plk, pk, ak));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected =
+                ak != ArrowKind.NONE ||
+                plk != ParameterListKind.UNARY ||
+                pk != ParameterKind.IMPLICIT;
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("bad diag for source:\n" +
+                source.getCharContent(true));
+        }
+        checkCount++;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        @Override
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaPos.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda is only allowed in argument/cast/assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadLambdaPos.out -XDrawDiagnostics BadLambdaPos.java
+ */
+
+interface SAM {
+    void m(Integer x);
+}
+
+class Test {
+    void test(Object x) {}
+
+    void test1() {
+        test((int x)-> { } + (int x)-> { } );
+        test((int x)-> { } instanceof Object );
+    }
+
+    void test2() {
+        int i2 = (int x)-> { } + (int x)-> { };
+        boolean b = (int x)-> { } instanceof Object;
+    }
+
+    void test3() {
+        test((Object)(int x)-> { });
+        Object o = (Object)(int x)-> { };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaPos.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,9 @@
+BadLambdaPos.java:18:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:18:30: compiler.err.unexpected.lambda
+BadLambdaPos.java:19:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:18: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:34: compiler.err.unexpected.lambda
+BadLambdaPos.java:24:21: compiler.err.unexpected.lambda
+BadLambdaPos.java:28:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadLambdaPos.java:29:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadMethodCall.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diagnostics on nested erroneous deferred types are flushed
+ * @compile/fail/ref=BadMethodCall.out -XDrawDiagnostics BadMethodCall.java
+ */
+import java.util.*;
+
+class BadMethodCall {
+    <I> List<I> id(List<I> z) { return null; };
+
+    List<String> cons(String s, List<String> ls) { return null; }
+
+    void test(List<Object> lo) { Object t = cons(id(""),lo); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadMethodCall.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadMethodCall.java:15:50: compiler.err.cant.apply.symbol: kindname.method, id, java.util.List<I>, java.lang.String, kindname.class, BadMethodCall, (compiler.misc.infer.no.conforming.assignment.exists: I, (compiler.misc.inconvertible.types: java.lang.String, java.util.List<I>))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadRecovery.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that recovery of speculative types is not attempted if receiver is erroneous
+ * @compile/fail/ref=BadRecovery.out -XDrawDiagnostics BadRecovery.java
+ */
+class BadRecovery {
+
+    interface SAM1 {
+        void m(Object o);
+    }
+
+    void m(SAM1 m) { };
+
+    void test() {
+        m((receiver, t) -> { receiver.someMemberOfReceiver(()->{ Object x = f; }); });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadRecovery.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+BadRecovery.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @369, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
+BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadReturn.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that incompatible return types in lambdas are flagged with error
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadReturn.out -XDrawDiagnostics BadReturn.java
+ */
+
+class BadReturn {
+
+    interface SAM {
+        Comparable<?> m();
+    }
+
+    static void testNeg1() {
+        SAM s = ()-> {
+            if (true) {
+                return "";
+            } else {
+                return System.out.println("");
+            }};
+    }
+
+    static void testNeg2() {
+        SAM s = ()-> { return System.out.println(""); };
+    }
+
+    static void testPos() {
+        SAM s = ()-> {
+            if (false) {
+                return 10;
+            }
+            else {
+                return true;
+            }};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadReturn.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+BadReturn.java:21:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+BadReturn.java:26:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda.out -XDrawDiagnostics BadStatementInLambda.java
+ */
+
+class BadStatementInLambda {
+
+    interface SAM{
+        Object m();
+    }
+
+    SAM t1 = ()-> { null; };
+    SAM t2 = ()-> { 1; };
+    SAM t3 = ()-> { 1 + 5; };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+BadStatementInLambda.java:16:21: compiler.err.not.stmt
+BadStatementInLambda.java:17:21: compiler.err.not.stmt
+BadStatementInLambda.java:18:23: compiler.err.not.stmt
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda02.out -XDrawDiagnostics BadStatementInLambda02.java
+ */
+
+class BadStatementInLambda02 {
+
+    interface SAM {
+        void m();
+    }
+
+    { call(()-> { System.out.println(new NonExistentClass() + ""); }); }
+
+    void call(SAM s) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+BadStatementInLambda02.java:16:42: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, BadStatementInLambda02, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadTargetType.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that only SAM are allowed as target types for lambda expressions
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java
+ */
+
+class BadTargetType {
+
+    static void m1(Object o) {}
+    void m2(Object o) {}
+
+    static Object l1 = (int pos)-> { };
+    Object l2 = (int pos)-> { };
+
+    {
+        m1((int pos)-> { });
+        m2((int pos)-> { });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadTargetType.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+BadTargetType.java:16:24: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Object, @460, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+BadTargetType.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, java.lang.Object, @489, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  conditional and varargs
+ * @compile -XDcomplexinference Conditional01.java
+ */
+
+import java.util.*;
+
+class Conditional01 {
+    void varargs(Object ... args) {  }
+
+    void test(boolean flag, List<String> ls) {
+       varargs(flag ? "" : ls);
+       varargs(null, flag ? "" : ls);
+       varargs(flag ? "" : ls());
+       varargs(null, flag ? "" : ls());
+    }
+
+    List<String> ls() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  inference and conditionals
+ * @compile -XDcomplexinference Conditional02.java
+ */
+
+class Conditional02 {
+
+    <Z> void m1(Z z) { }
+    <Z> void m2(Z... z) { }
+
+    void test(boolean flag) {
+        m1(flag ? "" : "");
+        m2(flag ? "" : "");
+        m2("", flag ? "" : "");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  conditionals and boxing
+ * @compile -XDcomplexinference Conditional03.java
+ */
+
+class Conditional03 {
+
+   void m1(Object o) { }
+   void m2(int i) { }
+
+   void test(boolean cond) {
+       m1((cond ? 1 : 1));
+       m1((cond ? box(1) : box(1)));
+   }
+
+   Integer box(int i) { return i; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conformance01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  lambda compiler regression with uninferred type-variables in generic constructor call
+ * @compile Conformance01.java
+ */
+
+class Conformance01 {
+    <T1, T2> Conformance01(T1 t) { }
+
+    Conformance01 c01 = new Conformance01(null);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Defender01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  routine that checks for SAM types should skip defender methods in extended interfaces
+ * @author  Maurizio Cimadamore
+ * @compile Defender01.java
+ */
+
+class Defender01 {
+
+    interface A{
+        Object m();
+        default void n() { E.n(this); }
+    }
+
+    static class E{
+        static void n(A a){};
+    }
+
+    A t = ()-> null;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that subtyping between disjunctive and non disjunctive type works
+ * @author  Maurizio Cimadamore
+ * @compile DisjunctiveTypeTest.java
+ */
+
+class DisjunctiveTypeTest {
+
+    static class A extends IllegalArgumentException {
+       A(String a) { super(a); }
+    }
+
+    class B extends IllegalArgumentException {
+       B(String b) { super(b); }
+    }
+
+    void m() throws A,B {}
+
+    void test() {
+        try {
+            m();
+        } catch (A|B e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  effectively final check fails on method parameter
+ * @compile/fail/ref=EffectivelyFinal01.out -XDrawDiagnostics EffectivelyFinal01.java
+ */
+class EffectivelyFinal01 {
+
+    interface SAM {
+        Integer m(Integer i);
+    }
+
+    void test(Integer nefPar) {
+        SAM s = (Integer h) ->  { Integer k = 0; return k + h + nefPar; };
+        nefPar++;  //non-effectively final
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+EffectivelyFinal01.java:15:65: compiler.err.cant.ref.non.effectively.final.var: nefPar, (compiler.misc.lambda)
+1 error
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -1,30 +1,9 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary Integrate efectively final check with DA/DU analysis
- * @compile/fail/ref=EffectivelyFinalTest01.out -XDallowEffectivelyFinalInInnerClasses -XDrawDiagnostics EffectivelyFinalTest.java
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate effectively final check with DA/DU analysis
+ * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java
  * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java
  */
 class EffectivelyFinalTest {
@@ -62,7 +41,7 @@
 
     void m6(int x) {
         new Object() { { System.out.println(x+1); } }; //error - x not EF
-        x++;
+        x++; // Illegal: x is not effectively final.
     }
 
     void m7(int x) {
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out	Wed Jul 05 18:30:46 2017 +0200
@@ -1,6 +1,6 @@
-EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
-EffectivelyFinalTest.java:60:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:64:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:69:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:74:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:39:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:43:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:48:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:53:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
 5 errors
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out	Wed Jul 05 18:30:46 2017 +0200
@@ -1,14 +1,14 @@
-EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
-EffectivelyFinalTest.java:34:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:34:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:40:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:40:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:46:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:53:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:60:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:60:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:64:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:69:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:74:45: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:13:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:13:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:19:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:19:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:25:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:39:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:39:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:43:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:48:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: y
 13 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousArg.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache mismatches between Resolve.access and Attr.checkId leads to compiler crashes
+ * @compile/fail/ref=ErroneousArg.out -XDrawDiagnostics ErroneousArg.java
+ */
+class ErroneousArg {
+
+    private static class Foo {
+        static int j() { return 1; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(String s) { return 1; }
+    static int g(Double s) { return 1; }
+
+    int h() { return 1; }
+}
+
+class TestErroneousArg extends ErroneousArg {
+    static void test() {
+        m(unknown()); //method not found
+        m(f(1)); //inapplicable method
+        m(g(1)); //inapplicable methods
+        m(g(null)); //ambiguous
+        m(h()); //static error
+        m(foo.j()); //inaccessible method
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousArg.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,7 @@
+ErroneousArg.java:29:11: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, TestErroneousArg, null)
+ErroneousArg.java:30:11: compiler.err.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, ErroneousArg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))
+ErroneousArg.java:31:11: compiler.err.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.Double)))}
+ErroneousArg.java:32:11: compiler.err.ref.ambiguous: g, kindname.method, g(java.lang.String), ErroneousArg, kindname.method, g(java.lang.Double), ErroneousArg
+ErroneousArg.java:33:11: compiler.err.non-static.cant.be.ref: kindname.method, h()
+ErroneousArg.java:34:14: compiler.err.not.def.access.class.intf.cant.access: j(), ErroneousArg.Foo
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  stale state after speculative attribution round leads to missing classfiles
+ */
+public class ErroneousLambdaExpr<T> {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1<X> {
+        X m(X t, String s);
+    }
+
+    interface SAM2 {
+        void m(String s, int i);
+    }
+
+    interface SAM3<X> {
+        X m(X t, String s, int i);
+    }
+
+    void call(SAM1<T> s1) { assertTrue(true); }
+
+    void call(SAM2 s2) { assertTrue(false); }
+
+    void call(SAM3<T> s3) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        ErroneousLambdaExpr<StringBuilder> test =
+                new ErroneousLambdaExpr<>();
+
+        test.call((builder, string) -> { builder.append(string); return builder; });
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/InnerConstructor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Regression test JDK-8003306 inner class constructor in lambda
+ * @author  Robert Field
+ */
+
+public class InnerConstructor {
+
+    public static void main(String... args) {
+        InnerConstructor ic = new InnerConstructor();
+        String res = ic.seq1().m().toString();
+        if (!res.equals("Cbl.toString")) {
+            throw new AssertionError(String.format("Unexpected result: %s", res));
+        }
+    }
+
+    Ib1 seq1() {
+        return () -> new Cbl();
+    }
+
+    class Cbl {
+        Cbl() {  }
+        public String toString() {
+            return "Cbl.toString";
+        }
+    }
+
+    interface Ib1 {
+        Object m();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture01
+ */
+
+public class LambdaCapture01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    //Simple local capture
+    void test1() {
+        final int N = 1;
+        int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final int N = 1;
+        new Tester() {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final int N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final int N = 4;
+        int res1 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + LambdaCapture01.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture01 t = new LambdaCapture01();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture02
+ */
+
+public class LambdaCapture02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public Integer n = 5;
+
+    //Simple local capture
+    void test1() {
+        final Integer N = 1;
+        int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final Integer N = 1;
+        new Tester() {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final Integer N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final Integer N = 4;
+        int res1 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + LambdaCapture02.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture02 t = new LambdaCapture02();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture03
+ */
+
+public class LambdaCapture03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                           assertTrue(res == 66);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                        assertTrue(res == 66);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture03 t = new LambdaCapture03();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture04
+ */
+
+public class LambdaCapture04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<U> {
+        public void foo(U u);
+    }
+
+    public static <U> void exec(TU<U> lambda, U x) {
+        lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> {
+                               class LocTester implements Tester {
+                                   public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                               };
+                               new LocTester().test();
+                           },30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test3() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    void test4() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> {
+                            class LocTester implements Tester {
+                                public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                            };
+                            new LocTester().test();
+                        },30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture04 t = new LambdaCapture04();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 4);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  test for capture in nested lambda expressions
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture05
+ */
+
+public class LambdaCapture05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    int i = 40;
+
+    void test1(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(106 == (a0 + a1 + a2 + a3 + x2 + x3 + i)); return null; }, 3);
+                return null;
+            },2);
+            return null;
+        },1);
+    }
+
+    static void test2(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(66 == (a0 + a1 + a2 + a3 + x2 + x3)); return null; }, 3);
+                return null;
+            }, 2);
+            return null;
+        }, 1);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture05 t = new LambdaCapture05();
+        t.test1(30);
+        test2(30);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @ignore investigate as to whether code generation fails
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Compiler crash when local inner class nested inside lambda captures local variables from enclosing scope
+ */
+public class LambdaCapture06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m(int n);
+    }
+
+    public static void main(String[] args) {
+        int n = 5;
+        SAM s = k -> {
+            new Object() {
+                void test() { int j = n; assertTrue(j == 5); }
+            }.test();
+        };
+        s.m(42);
+        assertTrue(assertionCount == 1);
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for lambda conversion
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv01
+ */
+
+public class LambdaConv01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface IntToInt {
+      public int foo(int x);
+    }
+
+    interface IntToVoid {
+      public void foo(int x);
+    }
+
+    interface VoidToInt {
+      public int foo();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv01().test2();
+        assertTrue(assertionCount == 16);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  SAM types and method type inference
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv03
+ */
+
+public class LambdaConv03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv03().test2();
+        assertTrue(assertionCount == 12);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  function type and method type inference
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv05
+ */
+
+import java.util.*;
+
+public class LambdaConv05 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    int count = 0;
+
+    void sort(List<String> data) {
+      Collections.sort(data,
+                       (String a, String b) -> { LambdaConv05.this.count++; return a.length()-b.length(); });
+    }
+
+    public static void main(String[] args) {
+        ArrayList<String> arr = new ArrayList<>();
+        arr.add("Three");
+        arr.add("Four");
+        arr.add("One");
+        LambdaConv05 sorter = new LambdaConv05();
+        sorter.sort(arr);
+        assertTrue(arr.get(0).equals("One"));
+        assertTrue(arr.get(1).equals("Four"));
+        assertTrue(arr.get(2).equals("Three"));
+        assertTrue(sorter.count == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  ensure that definite assignment analysis doesn't mess up with lambda attribution
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv06.java
+ */
+
+class LambdaConv06 {
+
+    private int t() {
+        return a((final Object indexed) -> {
+            return b(new R() {
+                public String build(final Object index) {
+                    return "";
+                }
+            });
+        });
+    }
+
+    private int a(R r) {return 0;}
+    private String b(R r) {return null;}
+
+    public static interface R {
+        public String build(Object o);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles covarinat return types correctly
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv08
+ */
+
+public class LambdaConv08 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public interface ObjectF { Object invoke(); }
+    public interface StringF extends ObjectF { String invoke(); }
+
+    public static void call(StringF stringFunc) {
+        assertTrue(true);
+    }
+
+    public static void call(ObjectF objectFunc) {  }
+
+    public static void main(String[] args)   {
+        call(()-> "Hello");
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv09.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles Object members correctly
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv09.out -XDrawDiagnostics LambdaConv09.java
+ */
+
+class LambdaConv09 {
+
+    // Not a SAM type; not enough abstract methods
+    interface Foo1 {}
+
+    // SAM type; Foo has no abstract methods
+    interface Foo2 { boolean equals(Object object); }
+
+
+    // Not a SAM type; Foo still has no abstract methods
+    interface Foo3 extends Foo2 { public abstract String toString(); }
+
+    // SAM type; Bar has one abstract non-Object method
+    interface Foo4<T> extends Foo2 { int compare(T o1, T o2); }
+
+    // Not a SAM type; still no valid abstract methods
+    interface Foo5 {
+        boolean equals(Object object);
+        String toString();
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo6<T> {
+        boolean equals(Object obj);
+        int compare(T o1, T o2);
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo7<T> extends Foo2, Foo6<T> { }
+
+    void test() {
+        Foo1 f1 = ()-> { };
+        Foo2 f2 = ()-> { };
+        Foo3 f3 = x -> true;
+        Foo4 f4 = (x, y) -> 1;
+        Foo5 f5 = x -> true;
+        Foo6 f6 = (x, y) -> 1;
+        Foo7 f7 = (x, y) -> 1;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv09.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+LambdaConv09.java:42:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo1))
+LambdaConv09.java:43:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo2))
+LambdaConv09.java:44:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo3))
+LambdaConv09.java:46:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo5))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda conversion does not allow boxing of lambda parameters
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv10.out -XDrawDiagnostics LambdaConv10.java
+ */
+
+class LambdaConv10 {
+
+    interface Method1<R, A1> { public R call( A1 a1 ); }
+
+    public static void main( final String... notUsed ) {
+        Method1<Integer,Integer> m1 = (int i) -> 2 * i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv10.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+LambdaConv10.java:15:39: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  issues with lambda conversion involving generic class hierarchies
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv11.java
+ */
+
+import java.util.Comparator;
+
+class LambdaConv11<T> {
+
+    interface SAM<X> extends Comparator<X> {
+        public int compare(X left, X right);
+    }
+
+    SAM<T> y = (l, r) -> 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  instance creation expression should allow lambda expressions as constrcutor arguments
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv12.java
+ */
+
+class LambdaConv12 {
+
+    LambdaConv12(SAM s) {}
+
+    interface SAM {
+        public abstract void m();
+    }
+
+    void test() {
+        new LambdaConv12(()-> { });
+        new LambdaConv12(()-> { }) {};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  interface methods in diamond shaped inheritance trees shouldn't be counted twice
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv13.java
+ */
+
+class LambdaConv13 {
+
+    interface I {
+        void m();
+    }
+
+    interface A extends I {}
+    interface B extends I {}
+    interface C extends A, B {}
+    interface D extends A, I {}
+    interface E extends B, I {}
+
+    C c = ()-> { };
+    D d = ()-> { };
+    D e = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  SAM conversion and raw types in argument/return types
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv16
+ */
+
+import java.util.*;
+
+public class LambdaConv16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        Iterable m(List<String> ls);
+    }
+
+    interface B {
+        Iterable<String> m(List l);
+    }
+
+    interface AB extends A, B {} //SAM type ([List], Iterable<String>, {})
+
+    static void test(AB ab, List l) { ab.m(l); }
+
+    public static void main(String[] args) {
+        AB ab = (List list) -> { assertTrue(true); return new ArrayList<String>(); };
+        ab.m(null);
+        test((List list) -> { assertTrue(true); return new ArrayList<String>(); }, null);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv17.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  lambda compiler crashes if lambda has try-with-resources
+ * @compile LambdaConv17.java
+ */
+
+class LambdaConv17 {
+    interface SAM {
+       void m() throws Exception;
+    }
+
+    SAM s = ()-> { try (AutoCloseable ac = null){ } };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv18.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  simple test for lambda candidate check
+ * @compile/fail/ref=LambdaConv18.out -XDrawDiagnostics -XDidentifyLambdaCandidate=true LambdaConv18.java
+ */
+
+class LambdaConv18 {
+
+    interface SAM {
+        void m();
+    }
+
+    interface NonSAM {
+        void m1();
+        void m2();
+    }
+
+    SAM s1 = new SAM() { public void m() {} };
+    NonSAM s2 = new NonSAM() { public void m1() {}
+                              public void m2() {} };
+    NonExistent s3 = new NonExistent() { public void m() {} };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv18.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+LambdaConv18.java:23:5: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+LambdaConv18.java:20:24: compiler.note.potential.lambda.found
+LambdaConv18.java:23:26: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv19.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that redundant cast warnings are not generated for SAM conversions
+ * @compile -Xlint:cast -Werror LambdaConv19.java
+ */
+
+class LambdaConv19 {
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s = (SAM)()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv20.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts are added when erased type of lambda body
+ *          ends up being too general
+ * @run main LambdaConv20
+ */
+
+import java.util.*;
+
+public class LambdaConv20 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m(List<X> l);
+    }
+
+    public static void main(String[] args) {
+        SAM<Integer> si1 = l -> l.get(0);
+        assertTrue(si1.m(Arrays.asList(1)) == 1);
+        SAM<Integer> si2 = l -> { return l.get(0); };
+        assertTrue(si2.m(Arrays.asList(1)) == 1);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv21.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @compile/fail/ref=LambdaConv21.out -XDrawDiagnostics LambdaConv21.java
+ */
+
+class LambdaConv21 {
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void {
+        Void m();
+    }
+
+    static void m_void() { }
+
+    static Void m_java_lang_Void() { return null; }
+
+    static void testExpressionLambda() {
+        SAM_void s1 = ()->m_void(); //ok
+        SAM_java_lang_Void s2 = ()->m_void(); //no - incompatible target
+        SAM_void s3 = ()->m_java_lang_Void(); //no - incompatible target
+        SAM_java_lang_Void s4 = ()->m_java_lang_Void(); //ok
+    }
+
+    static void testStatementLambda() {
+        SAM_void s1 = ()-> { m_void(); }; //ok
+        SAM_java_lang_Void s2 = ()-> { m_void(); }; //no - missing return value
+        SAM_void s3 = ()-> { return m_java_lang_Void(); }; //no - unexpected return value
+        SAM_java_lang_Void s4 = ()-> { return m_java_lang_Void(); }; //ok
+        SAM_void s5 = ()-> { m_java_lang_Void(); }; //ok
+        SAM_java_lang_Void s6 = ()-> { m_java_lang_Void(); }; //no - missing return value
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv21.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+LambdaConv21.java:25:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void))
+LambdaConv21.java:26:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Void, void))
+LambdaConv21.java:32:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+LambdaConv21.java:33:53: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))
+LambdaConv21.java:36:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv22.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  inner class translator fails with spurious method clash errors
+ * @compile LambdaConv22.java
+ */
+
+class LambdaConv22<U> {
+
+    interface Factory<T> { T make(); }
+
+    U make() { return null; }
+
+    void test(U u) {
+        Factory<U> fu1 = () -> u;
+        Factory<U> fu2 = this::make;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv23.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check super varargs reference is handled correctly
+ * @run main LambdaConv23
+ */
+public class LambdaConv23 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { void m(Integer a, Integer b); }
+
+    static class Super {
+        void m(Object... vi) { assertTrue(true); }
+    }
+
+
+    static class Sub extends Super {
+
+        void m(Object... vi) { assertTrue(false); }
+
+        public void test() {
+            SAM q = super::m;
+            q.m(1, 2);
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv24.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda inside 'this' call is handled properly
+ * @run main LambdaConv24
+ */
+public class LambdaConv24 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    LambdaConv24(SAM<String> p) {
+        assertTrue(p.m("42"));
+    }
+
+    LambdaConv24(int i) {
+        this(s->true);
+    }
+
+    LambdaConv24(int i1, int i2) {
+        this(LambdaConv24::m);
+    }
+
+    static boolean m(String s) { return true; }
+
+    public static void main(String[] args) {
+        new LambdaConv24(1);
+        new LambdaConv24(1,2);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConversionTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  perform several automated checks in lambda conversion, esp. around accessibility
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConversionTest
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class LambdaConversionTest {
+
+    enum PackageKind {
+        NO_PKG(""),
+        PKG_A("a");
+
+        String pkg;
+
+        PackageKind(String pkg) {
+            this.pkg = pkg;
+        }
+
+        String getPkgDecl() {
+            return this == NO_PKG ?
+                "" :
+                "package " + pkg + ";";
+        }
+
+        String getImportStat() {
+            return this == NO_PKG ?
+                "" :
+                "import " + pkg + ".*;";
+        }
+    }
+
+    enum SamKind {
+        CLASS("public class Sam {  }"),
+        ABSTACT_CLASS("public abstract class Sam {  }"),
+        ANNOTATION("public @interface Sam {  }"),
+        ENUM("public enum Sam { }"),
+        INTERFACE("public interface Sam { \n #METH; \n }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(String methStr) {
+            return sam_str.replaceAll("#METH", methStr);
+        }
+    }
+
+    enum ModifierKind {
+        PUBLIC("public"),
+        PACKAGE("");
+
+        String modifier_str;
+
+        ModifierKind(String modifier_str) {
+            this.modifier_str = modifier_str;
+        }
+
+        boolean stricterThan(ModifierKind that) {
+            return this.ordinal() > that.ordinal();
+        }
+    }
+
+    enum TypeKind {
+        EXCEPTION("Exception"),
+        PKG_CLASS("PackageClass");
+
+        String typeStr;
+
+        private TypeKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+    }
+
+    enum MethodKind {
+        NONE(""),
+        NON_GENERIC("public #R m(#ARG s) throws #T;"),
+        GENERIC("public <X> #R m(#ARG s) throws #T;");
+
+        String methodTemplate;
+
+        private MethodKind(String methodTemplate) {
+            this.methodTemplate = methodTemplate;
+        }
+
+        String getMethod(TypeKind retType, TypeKind argType, TypeKind thrownType) {
+            return methodTemplate.replaceAll("#R", retType.typeStr).
+                    replaceAll("#ARG", argType.typeStr).
+                    replaceAll("#T", thrownType.typeStr);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (PackageKind samPkg : PackageKind.values()) {
+            for (ModifierKind modKind : ModifierKind.values()) {
+                for (SamKind samKind : SamKind.values()) {
+                    for (MethodKind meth : MethodKind.values()) {
+                        for (TypeKind retType : TypeKind.values()) {
+                            for (TypeKind argType : TypeKind.values()) {
+                                for (TypeKind thrownType : TypeKind.values()) {
+                                    new LambdaConversionTest(samPkg, modKind, samKind,
+                                            meth, retType, argType, thrownType).test();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    PackageKind samPkg;
+    ModifierKind modKind;
+    SamKind samKind;
+    MethodKind meth;
+    TypeKind retType;
+    TypeKind argType;
+    TypeKind thrownType;
+
+    SourceFile samSourceFile = new SourceFile("Sam.java", "#P \n #C") {
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#C", samKind.getSam(meth.getMethod(retType, argType, thrownType)));
+        }
+    };
+
+    SourceFile pkgClassSourceFile = new SourceFile("PackageClass.java",
+                                                   "#P\n #M class PackageClass extends Exception { }") {
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#M", modKind.modifier_str);
+        }
+    };
+
+    SourceFile clientSourceFile = new SourceFile("Client.java",
+                                                 "#I\n class Client { Sam s = x -> null; }") {
+        public String toString() {
+            return template.replaceAll("#I", samPkg.getImportStat());
+        }
+    };
+
+    LambdaConversionTest(PackageKind samPkg, ModifierKind modKind, SamKind samKind,
+            MethodKind meth, TypeKind retType, TypeKind argType, TypeKind thrownType) {
+        this.samPkg = samPkg;
+        this.modKind = modKind;
+        this.samKind = samKind;
+        this.meth = meth;
+        this.retType = retType;
+        this.argType = argType;
+        this.thrownType = thrownType;
+    }
+
+    void test() throws Exception {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
+                null, null, Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + pkgClassSourceFile + "\n\n" + clientSourceFile);
+        }
+    }
+
+    boolean checkSamConversion() {
+        if (samKind != SamKind.INTERFACE) {
+            //sam type must be an interface
+            return false;
+        } else if (meth != MethodKind.NON_GENERIC) {
+            //target method must be non-generic
+            return false;
+        } else if (samPkg != PackageKind.NO_PKG &&
+                modKind != ModifierKind.PUBLIC &&
+                (retType == TypeKind.PKG_CLASS ||
+                argType == TypeKind.PKG_CLASS ||
+                thrownType == TypeKind.PKG_CLASS)) {
+            //target must not contain inaccessible types
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate efectively final check with DA/DU analysis
+ * @compile/fail/ref=LambdaEffectivelyFinalTest.out -XDrawDiagnostics LambdaEffectivelyFinalTest.java
+ */
+class LambdaEffectivelyFinalTest {
+
+    interface SAM {
+        int m();
+    }
+
+    void foo(LambdaEffectivelyFinalTest.SAM s) { }
+
+    void m1(int x) {
+        int y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m2(int x) {
+        int y;
+        y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m3(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        foo(() -> x+y); // Illegal: y is effectively final, but not definitely assigned.
+    }
+
+    void m4(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        else y = 2;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m5(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        y = 2;
+        foo(() -> x+y); // Illegal: y is not effectively final.t EF
+    }
+
+    void m6(int x) {
+        foo(() -> x+1);
+        x++; // Illegal: x is not effectively final.
+    }
+
+    void m7(int x) {
+        foo(() -> x=1); // Illegal: x in the assignment does not denote a variable (see 6.5.6.1)
+    }
+
+    void m8() {
+        int y;
+        foo(() -> y=1); // Illegal: y in the assignment does not denote a variable (see 6.5.6.1)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+LambdaEffectivelyFinalTest.java:30:21: compiler.err.var.might.not.have.been.initialized: y
+LambdaEffectivelyFinalTest.java:44:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:48:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:53:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:58:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr01().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr02().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda initializers compile w/o problems
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr04.java
+ */
+
+class LambdaExpr04 {
+
+    interface SAM {
+        void m(int i);
+    }
+    static SAM lambda_01 = (int pos) -> { };
+
+    static final SAM lambda_02 = (int pos) -> { };
+
+    SAM lambda_03 = (int pos) -> { };
+
+    final SAM lambda_04 = (int pos) -> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that binary expression in lambda expression is parsed correctly
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr05.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { int foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  parser test for nested parenthesized lambda expression
+ * @run main LambdaExpr06
+ */
+
+public class LambdaExpr06 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int dup(int i);
+    }
+
+    public static void main(String[] args) {
+        A a = ()-> ((B)i -> i * 2).dup(3);
+        assertTrue(a.m() == 6);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check access to effectively final local variable from doubly nested lambda
+ * @run main LambdaExpr07
+ */
+
+public class LambdaExpr07 {
+
+    interface Block<A, R> {
+        R apply(A x);
+    }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String S = "A";
+
+    void test() {
+        Block<String, Block<String, String>> o = s1 -> s2 -> S + s1 + s2;
+        assertTrue(o.apply("B").apply("C").equals("ABC"));
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr07().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that reference to local final variable w/o initializer is accepted
+ * @compile LambdaExpr08.java
+ */
+
+class LambdaExpr08 {
+
+    interface SAM {
+       String m();
+    }
+
+    void test() {
+        final String s;
+        s = "";
+        SAM sam = () -> s;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr09.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers is correctly accepted
+ * @compile LambdaExpr09.java
+ */
+
+class LambdaExpr09 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Block<?>[] arr1 =  { t -> { }, t -> { } };
+        Block<?>[][] arr2 =  { { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test2() {
+        Block<?>[] arr1 =  new Block<?>[]{ t -> { }, t -> { } };
+        Block<?>[][] arr2 =  new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test3() {
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+        apply(new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers (with wrong type) are correctly rejected
+ * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java
+ */
+
+class LambdaExpr10 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Object[] arr1 =  { t -> { } };
+        Object[][] arr2 =  { { t -> { } } };
+    }
+
+    void test2() {
+        Object[] arr1 =  new Object[]{ t -> { } };
+        Object[][] arr2 =  new Object[][]{ { t -> { } } };
+    }
+
+    void test3() {
+        apply(new Object[]{ t -> { } });
+        apply(new Object[][]{ { t -> { } } });
+    }
+
+    void test4() {
+        Block<?>[] arr1 =  { t -> t };
+        Block<?>[] arr2 =  new Block<?>[]{ t -> t };
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr10.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,9 @@
+LambdaExpr10.java:18:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:19:32: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:23:40: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:24:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:28:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:29:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr11
+ */
+public class LambdaExpr11 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Inner {
+        Inner() { assertTrue(true); }
+    }
+
+    void test() {
+        Runnable r1 = ()-> { new Inner(); };
+        r1.run();
+        Runnable r2 = ()-> { new Inner() {}; };
+        r2.run();
+        Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+        r3.run();
+        Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+        r4.run();
+        new Inner2().test();
+    }
+
+    class Inner2 {
+        void test() {
+            Runnable r1 = ()-> { new Inner(); };
+            r1.run();
+            Runnable r2 = ()-> { new Inner() {}; };
+            r2.run();
+            Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+            r3.run();
+            Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+            r4.run();
+            new Inner3().test();
+        }
+
+        class Inner3 {
+            void test() {
+                Runnable r1 = ()-> { new Inner(); };
+                r1.run();
+                Runnable r2 = ()-> { new Inner() {}; };
+                r2.run();
+                Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+                r3.run();
+                Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+                r4.run();
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr11().test();
+        assertTrue(assertionCount == 12);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr12
+ */
+
+public class LambdaExpr12 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Getter<X> {
+        X get();
+    }
+
+
+    interface Mapper<X,Y> {
+        Y map(X x);
+    }
+
+    void test() {
+        Mapper<String, Getter<Character>> mapper =
+                (final String s) -> new Getter<Character>() {
+                     @Override
+                     public Character get() {
+                         return s.charAt(0);
+                     }
+                };
+        assertTrue(mapper.map("First").get() == 'F');
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr12().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that recursive lambda (through field ref) is accepted in all contexts
+ * @compile LambdaExpr13.java
+ */
+
+class LambdaExpr13 {
+
+    Runnable ir = () -> { ir.run(); };;
+    static Runnable sr = () -> { sr.run(); };
+
+    { ir = () -> { ir.run(); }; }
+    static { sr = () -> { sr.run(); }; }
+
+    static void m1() {
+        sr = () -> { sr.run(); };
+    }
+
+    void m2() {
+        ir = () -> { ir.run(); };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr14.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that recursion from doubly nested lambda is handled correctly
+ */
+
+public class LambdaExpr14 {
+
+    interface SAM {
+       SAM invoke();
+    }
+
+    static SAM local;
+
+    public static void main(String[] args) {
+        local = () -> () -> local.invoke();
+        local.invoke().invoke(); // Not a recursive lambda - exec should terminate
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr15.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @ignore investigate as to whether code generation fails
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that nested inner class in statement lambdas don't get corrupted return statements
+ * @run main LambdaExpr15
+ */
+public class LambdaExpr15 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Block<T> {
+       void apply(T t);
+    }
+
+    public static void main(String[] args) {
+        //anon class
+        Block<Object> ba1 = t -> {
+            new Object() {
+                String get() { return ""; }
+            };
+            assertTrue(t == 1);
+        };
+        ba1.apply(1);
+
+        //local class
+        Block<Object> ba2 = t -> {
+            class A {
+                String get() { return ""; }
+            };
+            new A();
+            assertTrue(t == 2);
+        };
+        ba2.apply(2);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that super inside lambda is handled correctly
+ * @run main LambdaExpr16
+ */
+public class LambdaExpr16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A { void m(); }
+
+    static class Sup {
+       void m() {
+          assertTrue(true);
+       }
+    }
+
+    static class Sub extends Sup {
+        void testLambda1() {
+            A a = ()->{ super.m(); };
+            a.m();
+        }
+        void testLambda2() {
+            A a = () -> { A a1 = () -> { super.m(); }; a1.m(); };
+            a.m();
+        }
+        void testRef1() {
+            A a = () -> { A a1 = super::m; a1.m(); };
+            a.m();
+        }
+        void testRef2() {
+            A a = () -> { A a1 = () -> { A a2 = super::m; a2.m(); }; a1.m(); };
+            a.m();
+        }
+    }
+
+   public static void main(String[] args) {
+      Sub s = new Sub();
+      s.testLambda1();
+      s.testLambda2();
+      s.testRef1();
+      s.testRef2();
+      assertTrue(assertionCount == 4);
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr17.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that super in argument position inside lambda is handled correctly
+ * @run main LambdaExpr17
+ */
+public class LambdaExpr17 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static class Sup {
+        protected String m() {
+            assertTrue(true);
+            return "Hello!";
+        }
+    }
+
+    static class Sub extends Sup {
+        void test() {
+            SAM s = () -> { System.out.println(super.m()); };
+            s.m();
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr18.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts from outer environment are not inserted twice
+ * @run main LambdaExpr18
+ */
+public class LambdaExpr18 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<R> {
+        R eval();
+    }
+
+    static void test(){
+        SAM<Integer> sam1 = () -> {
+            assertTrue(true);
+            SAM<String> sam2 = () -> {
+                assertTrue(true);
+                return "";
+            };
+            sam2.eval();
+            return 1;
+        };
+        sam1.eval();
+    }
+
+    public static void main(String[] args) {
+        test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr19.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that inner scopes are left after a lambda check exception has been thrown
+ * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
+ */
+class LambdaExpr19 {
+
+    interface SAM {
+        String m();
+    }
+
+    void m(SAM s) { }
+
+    void testTry() {
+        m(() -> {
+                try { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testTryWithResources() {
+        m(() -> {
+                try (AutoCloseable c = null) { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testSwitch() {
+        m(() -> {
+                switch (1) {
+                    default: return 1;
+                }
+            });
+    }
+
+    void testFor() {
+        m(() -> {
+                for (;;) {
+                    return 1;
+                }
+            });
+    }
+
+    void testForeach() {
+        m(() -> {
+                for (Object o : new Object[] { null , null }) {
+                    return 1;
+                }
+            });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr19.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+LambdaExpr19.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @363, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:24:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @512, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:31:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @676, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @824, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:47:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @965, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr20.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that default super call from lambda expression is compiled successfully
+ * @compile LambdaExpr20.java
+ */
+
+class LambdaExpr20 {
+
+    interface K {
+        default void m() { }
+    }
+
+    static class Test implements K {
+        @Override
+        public void m() {
+            Runnable r = () -> { K.super.m(); };
+            r.run();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression body (when not a block) cannot be void
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaExprNotVoid.out -XDlambdaInferenceDiags=false -XDrawDiagnostics LambdaExprNotVoid.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { void foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+2 errors
--- a/langtools/test/tools/javac/lambda/LambdaParserTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,9 @@
 /*
  * @test
  * @bug 7115050
- * @summary Add parser support for lambda expressions
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add parser support for lambda expressions
  */
 
 import com.sun.source.util.JavacTask;
@@ -234,7 +236,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowLambda"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.parse();
         } catch (Throwable ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope01
+ */
+
+public class LambdaScope01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    public int hashCode() {
+        throw new RuntimeException();
+    }
+
+    public void test1() {
+        try {
+            int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x * hashCode(), 3);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true); //should throw
+        }
+    }
+
+    public void test2() {
+        final int n = 10;
+        int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x + n, 3);
+        assertTrue(13 == res);
+    }
+
+    public static void main(String[] args) {
+        LambdaScope01 t = new LambdaScope01();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that Object members are accessible as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope02
+ */
+
+public class LambdaScope02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    @Override
+    public String toString() {
+        return "Callable1";
+    }
+
+    interface Callable {
+        void call();
+    }
+
+    static void call(Callable c) { c.call(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope02.this.toString().equals("Callable1")); });
+        call(()-> { assertTrue(toString().equals("Callable1")); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope02().test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that unqualified Object members are accessed as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope03
+ */
+
+public class LambdaScope03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void call(SAM s) { s.m(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(this.getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == this.hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(this.toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.equals(this)); });
+        call(()-> { assertTrue(equals(LambdaScope03.this)); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope03().test();
+        assertTrue(assertionCount == 8);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,163 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda cannot shadow variables from enclosing scope
+ * @compile/fail/ref=LambdaScope04.out -XDrawDiagnostics LambdaScope04.java
+ */
+
+class LambdaScope04 {
+
+    interface SAM {
+        void m(Object o);
+    }
+
+    static SAM field1 = field1->{}; //ok
+    static SAM field2 = param->{ Object field2 = null; }; //ok
+
+    SAM field3 = field3->{}; //ok
+    SAM field4 = param->{ Object field4 = null; }; //ok
+
+    {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+    }
+
+    static {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testLocalInstance() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testLocalStatic() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testParamInstance(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testParamStatic(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testForInstance() {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForStatic(Iterable<Object> elems) {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testForEachInstance(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForEachStatic(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testCatchInstance() {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testCatchStatic(Iterable<Object> elems) {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testTWRInstance(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    static void testTWRStatic(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    void testBlockLocalInstance() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testBlockLocalStatic() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testSwitchLocalInstance(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+
+    static void testSwitchLocalStatic(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope04.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,37 @@
+LambdaScope04.java:23:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:24:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:29:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:30:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:36:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:37:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:43:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:44:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:49:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:50:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:55:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:56:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:62:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:63:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:70:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:71:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:78:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:79:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:86:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:87:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:94:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:95:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:102:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:103:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:110:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:111:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:118:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:119:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:127:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:128:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:136:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:137:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:146:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:147:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:157:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+LambdaScope04.java:158:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+36 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LocalBreakAndContinue.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that local break/continue is allowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile LocalBreakAndContinue.java
+ */
+
+class LocalBreakAndContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { while (true) break; };
+    SAM s2 = ()-> { while (true) continue; };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  use method reference to sort list elements by field
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference01
+ */
+
+import java.util.*;
+
+public class MethodReference01 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    static class Foo {
+        private Integer a;
+        private String b;
+
+        Foo(Integer a, String b) {
+            this.a = a;
+            this.b = b;
+        }
+
+        static Integer getA(Foo f) { return f.a; }
+        static String getB(Foo f) { return f.b; }
+    }
+
+    public static <T, U extends Comparable<? super U>>
+           void sortBy(List<T> s, final Getter<U, T> getter) {
+        Collections.sort(s, new Comparator<T>() {
+            public int compare(T t1, T t2) {
+                return getter.get(t1).compareTo(getter.get(t2));
+            }
+        });
+    };
+
+    public static void main(String[] args) {
+        List<Foo> c = new ArrayList<Foo>();
+        c.add(new Foo(2, "Hello3!"));
+        c.add(new Foo(3, "Hello1!"));
+        c.add(new Foo(1, "Hello2!"));
+        checkSortByA(c);
+        checkSortByB(c);
+    }
+
+    static void checkSortByA(List<Foo> l) {
+        sortBy(l, Foo::getA);
+        int oldA = -1;
+        for (Foo foo : l) {
+            if (foo.a.compareTo(oldA) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+
+    static void checkSortByB(List<Foo> l) {
+        sortBy(l, Foo::getB);
+        String oldB = "";
+        for (Foo foo : l) {
+            if (foo.b.compareTo(oldB) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that seemingly ambiguous method references are resolved properly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference02.java
+ */
+
+class MethodReference02 {
+    static interface SAM {
+       void m(Integer i);
+    }
+
+    void m(Integer i) {}
+    void m(Double d) {}
+
+    SAM s = this::m; //use target type to disambiguate
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that most specific method is selected as expected
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference03
+ */
+
+public class MethodReference03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(Integer i);
+    }
+
+    static void m(Number i) {}
+    static void m(Integer d) { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference03::m;
+        s.m(1);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of a method ref is a SAM type
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference04.out -XDrawDiagnostics MethodReference04.java
+ */
+
+class MethodReference04 {
+    void m(Integer i) {}
+
+    Object o = this::m; //fail - not a valid target type
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference04.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference04.java:13:16: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-static method refernces from static context are handled correctly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference05
+ */
+
+public class MethodReference05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(MethodReference05 receiver, Integer i);
+    }
+
+    void m(Integer i) { assertTrue(this != null); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference05::m;
+        s.m(new MethodReference05(), 1);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  method references and super
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference06
+ */
+
+public class MethodReference06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { //works if SAM is an abstract class
+        abstract void meth(int i);
+    }
+
+    static class A {
+        void m(int i) { assertTrue(true); }
+    }
+
+    static class B extends A {
+        void m(int i) {
+            SAM mh = super::m;
+            mh.meth(i);
+        }
+    }
+
+    public static void main(String[] args) {
+        new B().m(10);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference07.java
+ */
+
+class MethodReference07 {
+    interface SAM {
+       String m(Foo<String> f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo<String>::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ *
+ * @compile MethodReference08.java
+ * @compile/fail/ref=MethodReference08.out -Werror -Xlint:rawtypes -XDrawDiagnostics MethodReference08.java
+ */
+
+class MethodReference08 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference08.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+MethodReference08.java:14:17: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+MethodReference08.java:21:19: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference09.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non static members cannot be referenced from a method reference qualifier
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference09.out -XDrawDiagnostics MethodReference09.java
+ */
+
+class MethodReference09 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       Foo<X> getThis() { return this; }
+
+       static void test() {
+          SAM s1 = Foo.getThis()::getX;
+          SAM s2 = this::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference09.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+MethodReference09.java:21:23: compiler.err.non-static.cant.be.ref: kindname.method, getThis()
+MethodReference09.java:21:20: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, getX, compiler.misc.no.args, MethodReference09.Foo, kindname.class, MethodReference09.Foo<X>, (compiler.misc.arg.length.mismatch)))
+MethodReference09.java:22:20: compiler.err.non-static.cant.be.ref: kindname.variable, this
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non static selectors in method refs are handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference10.java
+ */
+
+import java.util.*;
+
+class MethodReference10 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    public static <T, U extends Comparable<? super U>>
+        void sortBy(Collection<T> s, Getter<U, T> getter) {};
+
+    static class Foo {
+        private String a;
+        String getA(Foo f) { return f.a; }
+    }
+
+    public static void main(String[] args) {
+        Collection<Foo> c = new ArrayList<Foo>();
+        sortBy(c, new Foo()::getA);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that static vs. non-static selection logic in method references works
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference11
+ */
+
+import java.util.*;
+
+public class MethodReference11 {
+    public static void main(String[] args) {
+        String[] strings = new String[] { "D", "C", "B", "A" };
+        Arrays.sort( strings, String.CASE_INSENSITIVE_ORDER::compare );
+        String last = "1";
+        for (String s : strings) {
+            if (String.CASE_INSENSITIVE_ORDER.compare(last, s) > 0) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that Object methods are dispatched accordingly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference12
+ */
+
+public class MethodReference12 {
+
+    interface SAM { void foo(int i); }
+
+    static void print(int i) {
+        System.out.println(i);
+    }
+
+    public static void main(String[] args) {
+        try {
+            test(MethodReference12::print);
+            test(i -> { System.out.println(i); } );
+        }
+        catch (Throwable t) {
+            t.printStackTrace();
+            throw new AssertionError("An error occurred");
+        }
+    }
+
+    static void test(SAM s) throws Throwable {
+        s.hashCode();
+        s.equals(null);
+        s.toString();
+        try {
+            s.notify(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.notifyAll(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.wait(1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(1,1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that equals() on Proxied objects is handled accordingly
+ * @author  Maurizio Cimadamore
+ * @compile -XDuseProxy MethodReference13.java
+ * @run main MethodReference13
+ */
+
+public class MethodReference13 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference13::m;
+        assertTrue(s.equals(s));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference14.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check casting a method reference to a SAM type does not result in a CCE
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference14
+ */
+
+public class MethodReference14 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = (SAM)MethodReference14::m;
+        s.m();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference15.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that assignments involving method references do not trigger transitional 292 warnings
+ * @author  Maurizio Cimadamore
+ * @compile -Werror MethodReference15.java
+ */
+
+public class MethodReference15 {
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    static void test() {
+        SAM s = MethodReference15::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  semantics of statically qualified method reference should not depend on the context
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference16
+ */
+
+public class MethodReference16 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(MethodReference16 receiver);
+    }
+
+    void m() { assertTrue(true); }
+
+    void test() {
+        SAM s = (SAM)MethodReference16::m;
+        s.m(this);
+    }
+
+    public static void main(String[] args) {
+        MethodReference16 rec = new MethodReference16();
+        SAM s = (SAM)MethodReference16::m;
+        s.m(rec);
+        rec.test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference17.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference17
+ */
+
+public class MethodReference17 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference17() {
+        assertTrue(true);
+    }
+
+    interface SAM {
+        MethodReference17 m();
+    }
+
+    static void test(SAM s) {
+        s.m();
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference17::new;
+        s.m();
+        test(MethodReference17::new);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference18.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference18
+ */
+
+public class MethodReference18 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference18(Object o) {
+        assertTrue(true);
+    }
+
+    MethodReference18(Number n) {
+        assertTrue(false);
+    }
+
+    interface SAM {
+        MethodReference18 m(Object o);
+    }
+
+    static void test(SAM s, Object arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference18::new;
+        s.m("");
+        test(MethodReference18::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference19.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference19
+ */
+
+public class MethodReference19<X> {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference19(X x) {
+        assertTrue(true);
+    }
+
+    interface SAM<Z> {
+        MethodReference19<Z> m(Z z);
+    }
+
+    static <Y> void test(SAM<Y> s, Y arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM<String> s = MethodReference19<String>::new;
+        s.m("");
+        test(MethodReference19<String>::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference20.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference20.out -XDrawDiagnostics MethodReference20.java
+ */
+
+class MethodReference20<X> {
+
+    MethodReference20(X x) { }
+
+    interface SAM<Z> {
+        MethodReference20<Z> m(Z z);
+    }
+
+    static void test(SAM<Integer> s) {   }
+
+    public static void main(String[] args) {
+        SAM<Integer> s = MethodReference20<String>::new;
+        test(MethodReference20<String>::new);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference20.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+MethodReference20.java:21:26: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String))))
+MethodReference20.java:22:9: compiler.err.cant.apply.symbol: kindname.method, test, MethodReference20.SAM<java.lang.Integer>, @549, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)))))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference21.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference21.out -XDrawDiagnostics MethodReference21.java
+ */
+
+class MethodReference21 {
+
+    interface SAM {
+        void m();
+    }
+
+    void call(SAM s) {}
+
+    SAM s = NonExistentType::m;
+
+    {
+        call(NonExistentType::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference21.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+MethodReference21.java:18:13: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+MethodReference21.java:21:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference22.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound method references checked correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference22.out -XDrawDiagnostics MethodReference22.java
+ */
+
+class MethodReference22 {
+
+    void m1(String x) { }
+    void m1(MethodReference22 rec, String x) { }
+
+    static void m2(String x) { }
+    static void m2(MethodReference22 rec, String x) { }
+
+    static void m3(String x) { }
+    void m3(MethodReference22 rec, String x) { }
+
+    void m4(String x) { }
+    static void m4(MethodReference22 rec, String x) { }
+
+    interface SAM1 {
+        void m(String x);
+    }
+
+    interface SAM2 {
+        void m(MethodReference22 rec, String x);
+    }
+
+    static void call1(SAM1 s) {   }
+
+    static void call2(SAM2 s) {   }
+
+    static void call3(SAM1 s) {   }
+    static void call3(SAM2 s) {   }
+
+    static void test1() {
+        SAM1 s1 = MethodReference22::m1; //fail
+        call1(MethodReference22::m1); //fail
+        SAM1 s2 = MethodReference22::m2; //ok
+        call1(MethodReference22::m2); //ok
+        SAM1 s3 = MethodReference22::m3; //ok
+        call1(MethodReference22::m3); //ok
+        SAM1 s4 = MethodReference22::m4; //fail
+        call1(MethodReference22::m4); //fail
+    }
+
+    static void test2() {
+        SAM2 s1 = MethodReference22::m1; //ok
+        call2(MethodReference22::m1); //ok
+        SAM2 s2 = MethodReference22::m2; //ok
+        call2(MethodReference22::m2); //ok
+        SAM2 s3 = MethodReference22::m3; //fail
+        call2(MethodReference22::m3); //fail
+        SAM2 s4 = MethodReference22::m4; //fail
+        call2(MethodReference22::m4); //fail
+    }
+
+    static void test3() {
+        call3(MethodReference22::m1); //ok
+        call3(MethodReference22::m2); //ambiguous
+        call3(MethodReference22::m3); //ok
+        call3(MethodReference22::m4); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference22.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,11 @@
+MethodReference22.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))
+MethodReference22.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @999, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))))
+MethodReference22.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))
+MethodReference22.java:47:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1270, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))
+MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))
+MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1574, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))))
+MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))
+MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1667, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
+MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22
+MethodReference22.java:65:9: compiler.err.cant.apply.symbols: kindname.method, call3, @1881,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))))}
+10 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference23.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound constructor references is flagged as ambiguous
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference23.out -XDrawDiagnostics MethodReference23.java
+ */
+
+class MethodReference23 {
+
+    class Inner1 {
+        Inner1(MethodReference23 outer) {};
+        Inner1() {};
+    }
+
+    static class Inner2 {
+        Inner2(MethodReference23 outer) {};
+        Inner2() {};
+    }
+
+    interface SAM11 {
+        Inner1 m(MethodReference23 rec);
+    }
+
+    interface SAM12 {
+        Inner1 m();
+    }
+
+    interface SAM21 {
+        Inner2 m(MethodReference23 rec);
+    }
+
+    interface SAM22 {
+        Inner2 m();
+    }
+
+    static void call11(SAM11 s) {   }
+
+    static void call12(SAM12 s) {   }
+
+    static void call21(SAM21 s) {   }
+
+    static void call22(SAM22 s) {   }
+
+    static void call3(SAM11 s) {   }
+    static void call3(SAM12 s) {   }
+    static void call3(SAM21 s) {   }
+    static void call3(SAM22 s) {   }
+
+    static void test11() {
+        SAM11 s = MethodReference23.Inner1::new; //ok
+        call11(MethodReference23.Inner1::new); //ok
+    }
+
+    static void test12() {
+        SAM12 s = MethodReference23.Inner1::new; //fail
+        call12(MethodReference23.Inner1::new); //fail
+    }
+
+    static void test21() {
+        SAM21 s = MethodReference23.Inner2::new; //ok
+        call21(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test22() {
+        SAM22 s = MethodReference23.Inner2::new; //ok
+        call22(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test3() {
+        call3(MethodReference23.Inner2::new); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference23.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))
+MethodReference23.java:53:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)))
+MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
+MethodReference23.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)))
+MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference24.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference24
+ */
+
+public class MethodReference24 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    static void m(int i) { assertTrue(true); }
+    static void m(Integer i) { assertTrue(false); }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(SAM s) { s.m(42); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference24::m; //resolves to m(int)
+        s.m(42);
+        call(MethodReference24::m); //resolves to m(int)
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference25.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference25
+ */
+
+public class MethodReference25 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    static void m(Integer i) { assertTrue(true); }
+
+    interface SAM1 {
+        void m(int x);
+    }
+
+    interface SAM2 {
+        void m(Integer x);
+    }
+
+    static void call(int i, SAM1 s) { s.m(i); assertTrue(false); }
+    static void call(int i, SAM2 s) { s.m(i);  }
+
+    public static void main(String[] args) {
+        call(1, MethodReference25::m); //resolves to call(int, SAM2)
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference26.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check strict method conversion does not allow loose method reference conversion
+ * @compile/fail/ref=MethodReference26.out -XDrawDiagnostics MethodReference26.java
+ */
+
+class MethodReference26 {
+
+    static void m(Integer i) { }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(int i, SAM s) {   }
+    static void call(Integer i, SAM s) {   }
+
+    static void test() {
+        call(1, MethodReference26::m); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference26.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference26.java:21:9: compiler.err.ref.ambiguous: call, kindname.method, call(int,MethodReference26.SAM), MethodReference26, kindname.method, call(java.lang.Integer,MethodReference26.SAM), MethodReference26
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference27.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference27
+ */
+
+public class MethodReference27 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(int i1, int i2);
+    }
+
+    static void m1(int i1, int i2) { assertTrue(true); }
+    static void m1(Integer i1, int i2) { assertTrue(false); }
+    static void m1(int i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer... is) { assertTrue(false); }
+
+    static void m2(int... is) { assertTrue(true); }
+    static void m2(double... ds) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        SAM s1 = MethodReference27::m1;
+        s1.m(42,42);
+        SAM s2 = MethodReference27::m2;
+        s2.m(42,42);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference28.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-compatible method references are rejected
+ * @compile/fail/ref=MethodReference28.out -XDrawDiagnostics MethodReference28.java
+ */
+
+class MethodReference28 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(MethodReference28 rec, int i);
+    }
+
+    static void static_m1(Integer i) { } //ok - boxing
+    static void static_m2(Integer i1, Integer i2) { } //wrong arity
+    static void static_m3(String s) { } //type mismatch
+    static void static_m4(String... ss) { } //type mismatch - varargs
+
+    void m1(Integer i) { } //ok - boxing
+    void m2(Integer i1, Integer i2) { } //wrong arity
+    void m3(String s) { } //type mismatch
+    void m4(String... ss) { } //type mismatch - varargs
+
+    static void testStatic() {
+        SAM1 s1 = MethodReference28::static_m1;
+        SAM1 s2 = MethodReference28::static_m2;
+        SAM1 s3 = MethodReference28::static_m3;
+        SAM1 s4 = MethodReference28::static_m4;
+    }
+
+    void testBadMember() {
+        SAM1 s1 = MethodReference28::m1;
+        SAM1 s2 = MethodReference28::m2;
+        SAM1 s3 = MethodReference28::m3;
+        SAM1 s4 = MethodReference28::m4;
+    }
+
+    void testMember() {
+        SAM1 s1 = this::m1;
+        SAM1 s2 = this::m2;
+        SAM1 s3 = this::m3;
+        SAM1 s4 = this::m4;
+    }
+
+    static void testUnbound() {
+        SAM2 s1 = MethodReference28::m1;
+        SAM2 s2 = MethodReference28::m2;
+        SAM2 s3 = MethodReference28::m3;
+        SAM2 s4 = MethodReference28::m4;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference28.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,14 @@
+MethodReference28.java:31:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:32:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:33:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:37:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer)))
+MethodReference28.java:38:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:39:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:45:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:47:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: MethodReference28, java.lang.Integer))))
+MethodReference28.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:54:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: MethodReference28, java.lang.String))))
+13 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference29.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  reference to super leads to compiler crash when 292 translation scheme is enabled
+ */
+
+public class MethodReference29 {
+
+    interface SAM {
+        void m(Integer i);
+    }
+
+    static class A {
+        void m(int i) { }
+    }
+
+    static class B extends A {
+        void test() {
+            SAM s = super::m;
+            s.m(42);
+        }
+
+        void m(int i) { throw new AssertionError(); }
+    }
+
+    public static void main(String[] args) {
+        new B().test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference30.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-static qualifier of static method reference is eagerly evaluated
+ */
+
+public class MethodReference30 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m();
+    }
+
+    MethodReference30() {
+        assertTrue(true);
+    }
+
+   static void m() { }
+
+   public static void main(String[] args) {
+      SAM s = new MethodReference30()::m;
+      assertTrue(assertionCount == 1);
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference31.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that boxing of return-type works as expected
+ */
+
+public class MethodReference31 {
+
+    static class Success extends RuntimeException { }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m();
+    }
+
+    interface SAM_byte {
+        byte m();
+    }
+
+    interface SAM_short {
+        short m();
+    }
+
+    interface SAM_int {
+        int m();
+    }
+
+    interface SAM_long {
+        long m();
+    }
+
+    interface SAM_float {
+        float m();
+    }
+
+    interface SAM_double {
+        double m();
+    }
+
+    static <Z> Z test() {
+        assertTrue(true);
+        throw new Success();
+    }
+
+    static byte test_byte() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static short test_short() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static int test_int() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static long test_long() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static float test_float() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static double test_double() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static void testByte() {
+        SAM<Byte> s1 = MethodReference31::test_byte;
+        s1.m();
+        SAM_byte s2 = MethodReference31::test_byte;
+        s2.m();
+        SAM<Byte> s3 = MethodReference31::<Byte>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_byte s4 = MethodReference31::<Byte>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testShort() {
+        SAM<Short> s1 = MethodReference31::test_short;
+        s1.m();
+        SAM_short s2 = MethodReference31::test_short;
+        s2.m();
+        SAM<Short> s3 = MethodReference31::<Short>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_short s4 = MethodReference31::<Short>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testInteger() {
+        SAM<Integer> s1 = MethodReference31::test_int;
+        s1.m();
+        SAM_int s2 = MethodReference31::test_int;
+        s2.m();
+        SAM<Integer> s3 = MethodReference31::<Integer>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_int s4 = MethodReference31::<Integer>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testLong() {
+        SAM<Long> s1 = MethodReference31::test_long;
+        s1.m();
+        SAM_long s2 = MethodReference31::test_long;
+        s2.m();
+        SAM<Long> s3 = MethodReference31::<Long>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_long s4 = MethodReference31::<Long>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testFloat() {
+        SAM<Float> s1 = MethodReference31::test_float;
+        s1.m();
+        SAM_float s2 = MethodReference31::test_float;
+        s2.m();
+        SAM<Float> s3 = MethodReference31::<Float>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_float s4 = MethodReference31::<Float>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testDouble() {
+        SAM<Double> s1 = MethodReference31::test_double;
+        s1.m();
+        SAM_double s2 = MethodReference31::test_double;
+        s2.m();
+        SAM<Double> s3 = MethodReference31::<Double>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_double s4 = MethodReference31::<Double>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    public static void main(String[] args) {
+        testByte();
+        testShort();
+        testInteger();
+        testLong();
+        testFloat();
+        testDouble();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference32.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that varargs warnings are generated during SAM conversion
+ * @compile/fail/ref=MethodReference32.out -Xlint:unchecked -Werror -XDrawDiagnostics MethodReference32.java
+ */
+
+import java.util.*;
+
+class MethodReference32 {
+
+    interface SAM {
+        MethodReference32 m(List<Integer> l1, List<Integer> l2);
+    }
+
+    MethodReference32 meth(List<Integer>... lli) { return null; }
+    MethodReference32(List<Integer>... lli) { }
+
+    SAM s1 = this::meth;
+    SAM s2 = MethodReference32::new;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference32.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,7 @@
+MethodReference32.java:17:45: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:18:40: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:20:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+MethodReference32.java:21:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+- compiler.err.warnings.and.werror
+1 error
+4 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference33.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  test bridged constructor references
+ */
+
+public class MethodReference33 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Foo {
+        Foo(Integer i) { assertTrue(true); }
+        Foo() { assertTrue(true); }
+    }
+
+    interface BridgeSAMBound<X> {
+        X m(int i);
+    }
+
+    interface NonBridgeSAMBound<X> {
+        X m();
+    }
+
+    void test() {
+        BridgeSAMBound<Foo> b1 = Foo::new;
+        b1.m(1);
+        NonBridgeSAMBound<Foo> b2 = Foo::new;
+        b2.m();
+    }
+
+    public static void main(String[] args) {
+        MethodReference33 test = new MethodReference33();
+        test.test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference34.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @run main MethodReference34
+ */
+
+public class MethodReference34 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void<X> {
+        void m();
+    }
+
+    static void m_void() { assertTrue(true); }
+
+    static Void m_java_lang_Void() { assertTrue(true); return null; }
+
+    public static void main(String[] args) {
+        SAM_void s1 = MethodReference34::m_void;
+        s1.m();
+        SAM_java_lang_Void s2 = MethodReference34::m_void;
+        s2.m();
+        SAM_void s3 = MethodReference34::m_java_lang_Void;
+        s3.m();
+        SAM_java_lang_Void s4 = MethodReference34::m_java_lang_Void;
+        s4.m();
+        assertTrue(assertionCount == 4);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference35.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda/method references are valid method reference qualifiers
+ * @run main MethodReference35
+ */
+
+public class MethodReference35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        MethodReference35 invoke();
+    }
+
+    MethodReference35() {
+        assertTrue(true);
+    }
+
+    static MethodReference35 m() {
+        assertTrue(true);
+        return null;
+    }
+
+    public static void main(String[] args) {
+        SAM sam1 = ((SAM)() -> { assertTrue(true); return null; })::invoke;
+        sam1.invoke();
+        SAM sam2 = ((SAM)MethodReference35::new)::invoke;
+        sam1.invoke();
+        SAM sam3 = ((SAM)MethodReference35::m)::invoke;
+        sam1.invoke();
+        assertTrue(assertionCount == 3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference36.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that method reference handles varargs conversion properly
+ * @run main MethodReference36
+ */
+
+public class MethodReference36 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SamC { void m(char[] a); }
+    interface SamZ { void m(boolean[] a); }
+    interface SamB { void m(byte[] a); }
+    interface SamS { void m(short[] a); }
+    interface SamI { void m(int[] a); }
+    interface SamL { void m(long[] a); }
+    interface SamF { void m(float[] a); }
+    interface SamD { void m(double[] a); }
+    interface SamO { void m(Object[] a); }
+
+
+    static void m(Object... vi) {
+        assertTrue(true);
+    }
+
+    public void test() {
+
+        SamC sc = MethodReference36::m;
+        sc.m(new char[] { 'a', 'b' } );
+
+        SamZ sz = MethodReference36::m;
+        sz.m(new boolean[] { true, false } );
+
+        SamB sb = MethodReference36::m;
+        sb.m(new byte[] { 0, 1 } );
+
+        SamS ss = MethodReference36::m;
+        ss.m(new short[] { 0, 1 } );
+
+        SamI si = MethodReference36::m;
+        si.m(new int[] { 0, 1 } );
+
+        SamL sl = MethodReference36::m;
+        sl.m(new long[] { 0, 1 } );
+
+        SamF sf = MethodReference36::m;
+        sf.m(new float[] { 0, 1 } );
+
+        SamD sd = MethodReference36::m;
+        sd.m(new double[] { 0, 1 } );
+
+        SamO so = MethodReference36::m;
+        so.m(new Object[] { null, null } );
+    }
+
+    public static void main(String[] args) {
+       new MethodReference36().test();
+       assertTrue(assertionCount == 9);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference37.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious exceptions when checking references to inner constructors where
+ *          the enclosing class is not defined in any outer context
+ * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java
+ */
+
+class MethodReference37 {
+
+    interface SAM1<R> {
+        R invoke();
+    }
+
+    interface SAM2<R, A> {
+        R invoke(A a);
+    }
+
+    static class Outer {
+        class Inner { }
+
+        static void test1() {
+            SAM2<Inner, Outer> sam = Inner::new;
+        }
+
+        void test2() {
+            SAM1<Inner> sam0 = Inner::new;
+            SAM2<Inner, Outer> sam1 = Inner::new;
+        }
+    }
+
+    static void test1() {
+        SAM2<Outer.Inner, Outer> sam = Outer.Inner::new;
+    }
+
+    void test2() {
+        SAM2<Outer.Inner, Outer> sam1 = Outer.Inner::new;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference37.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+MethodReference37.java:24:38: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:29:39: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:34:40: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:38:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference38.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  The qualifier type of a constructor reference must be a concrete class
+ * @compile/fail/ref=MethodReference38.out -XDrawDiagnostics MethodReference38.java
+ */
+
+class MethodReference38 {
+
+    interface SAM<R> {
+        R invoke();
+    }
+
+    @interface A { }
+
+    interface I { }
+
+    static abstract class AC { }
+
+    enum E { }
+
+    void test() {
+        SAM s1 = A::new;
+        SAM s2 = I::new;
+        SAM s3 = AC::new;
+        SAM s4 = E::new;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference38.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:27:18: compiler.err.enum.cant.be.instantiated
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference39.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that bad enclosing class parameter type is discarded accordingly
+ * @compile/fail/ref=MethodReference39.out -XDrawDiagnostics MethodReference39.java
+ */
+class MethodReference39 {
+
+    static class Sup {}
+
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup m(Sup x, String str); }
+
+        class Inner extends Sup {
+            Inner(String val) { }
+        }
+
+        void test() {
+            SAM var = Sub.Inner::new;;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference39.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference39.java:22:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference39.Sup,java.lang.String, kindname.class, MethodReference39.Sub.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference40.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that unbound constructor reference are not accepted
+ * @compile/fail/ref=MethodReference40.out -XDrawDiagnostics MethodReference40.java
+ */
+class MethodReference40 {
+
+    static class Sup {
+        class Inner {
+            Inner(String val) { }
+        }
+    }
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup.Inner m(Sub x, String str); }
+
+        void test() {
+            SAM var = Sub.Inner::new;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference40.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference40.java:21:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference40.Sub,java.lang.String, kindname.class, MethodReference40.Sup.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference41.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference41
+ */
+public class MethodReference41 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference42.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference42
+ */
+public class MethodReference42 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference43.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference43
+ */
+public class MethodReference43 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       Foo<?> m(String s);
+    }
+
+    interface SAM2 {
+       Foo<?> m(Integer s);
+    }
+
+    interface SAM3 {
+       Foo<?> m(Object o);
+    }
+
+    interface SAM4 {
+       Foo<Number> m(Integer o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+    static void m(SAM4 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference44.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference44
+ */
+public class MethodReference44 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference44::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference45.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
+ */
+public class MethodReference45 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    void test() {
+        g1(MethodReference45::m);
+        g2(MethodReference45::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference45.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference45.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference45.SAM1), MethodReference45, kindname.method, g2(MethodReference45.SAM2), MethodReference45
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference46.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference46
+ */
+public class MethodReference46 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference46::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference47.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference47.out -XDrawDiagnostics MethodReference47.java
+ */
+public class MethodReference47 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(Integer s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    public static void main(String[] args) {
+        g1(MethodReference46::m);
+        g2(MethodReference46::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference47.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference47.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference48.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that raw qualifier in unbound method reference is inferred from descriptor
+ * @run main MethodReference48
+ */
+public class MethodReference48 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class Foo<X> {
+        X m() { return null; };
+    }
+
+    interface SAM1 {
+        Foo<Object> m(Foo<String> fs);
+    }
+
+    interface SAM2 {
+        Integer m(Foo<Integer> fi);
+    }
+
+    interface SAM3 {
+        Object m(Foo<Integer> fi);
+    }
+
+    static void g(SAM1 s) { assertTrue(false); } //return type not compatible
+    static void g(SAM2 s) { assertTrue(true); } //ok
+    static void g(SAM3 s) { assertTrue(false); } //ok but less specific
+
+    public static void main(String[] args) {
+        g(Foo::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference49.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that an array type can be used as a qualifier of an unbound method reference
+ * @run main MethodReference49
+ */
+public class MethodReference49 {
+
+    interface SAM {
+       Object m(int[] i);
+    }
+
+    public static void main(String[] args) {
+        SAM s = int[]::clone;
+        int[] iarr = { 1, 2, 3 };
+        int[] iarr2 = (int[])s.m(iarr);
+        if (iarr == iarr2) {
+            throw new AssertionError();
+        }
+        for (int i = 0 ; i < iarr.length ; i ++) {
+            if (iarr[i] != iarr2[i]) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference50.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @compile/fail/ref=MethodReference50.out -XDrawDiagnostics MethodReference50.java
+ */
+
+class MethodReference50 {
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    void call(SAM1 s) {}
+    void call(SAM2 s) {}
+
+    {
+        call(NonExistentType::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference50.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference50.java:23:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference50, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference51.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  certain cases of erroneous member reference lookup are not handled by Attr.visitReference
+ * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java
+ */
+class MethodReference51 {
+
+    private static class Foo {
+        static int j(int i) { return i; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(Integer i, Number n) { return 1; }
+    static int g(Number n, Integer i) { return 1; }
+
+    int h(int i) { return i; }
+}
+
+class TestMethodReference51 {
+
+    interface IntSam {
+        int m(int i);
+    }
+
+    interface IntegerIntegerSam {
+        int m(Integer i1, Integer i2);
+    }
+
+
+    static void test() {
+        IntSam s1 = MethodReference51::unknown; //method not found
+        IntSam s2 = MethodReference51::f; //inapplicable method
+        IntSam s3 = MethodReference51::g; //inapplicable methods
+        IntegerIntegerSam s4 = MethodReference51::g; //ambiguous
+        IntSam s5 = MethodReference51::h; //static error
+        IntSam s6 = MethodReference51.foo::j; //inaccessible method
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference51.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,7 @@
+MethodReference51.java:39:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , int, (compiler.misc.location: kindname.class, MethodReference51, null))
+MethodReference51.java:40:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, MethodReference51, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference51.java:41:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch))}))
+MethodReference51.java:42:32: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: g, kindname.method, g(java.lang.Integer,java.lang.Number), MethodReference51, kindname.method, g(java.lang.Number,java.lang.Integer), MethodReference51))
+MethodReference51.java:43:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int)))
+MethodReference51.java:44:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo))
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference52.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  special cases of method references (getClass()/Array.clone()) not handled properly
+ * @compile/fail/ref=MethodReference52.out -XDrawDiagnostics MethodReference52.java
+ */
+import java.util.*;
+
+class MethodReference52 {
+
+    interface Clone1 {
+        int[] m();
+    }
+
+    interface Clone2 {
+        Object m();
+    }
+
+    interface WrongClone {
+        long[] m();
+    }
+
+    interface GetClass {
+        Class<? extends List> m();
+    }
+
+    interface WrongGetClass {
+        Class<List<String>> m();
+    }
+
+    void test(int[] iarr, List<String> ls) {
+        Clone1 c1 = iarr::clone; //ok
+        Clone2 c2 = iarr::clone; //ok - type more generic
+        WrongClone c3 = iarr::clone; //bad return type
+        GetClass c4 = ls::getClass; //ok
+        WrongGetClass c5 = ls::getClass; //bad return type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference52.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+MethodReference52.java:35:25: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], long[]))
+MethodReference52.java:37:28: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Class<? extends java.util.List>, java.lang.Class<java.util.List<java.lang.String>>))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference53.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  the case in which no member reference is found is now treated as a normal error (not dependent on target-type)
+ * @compile/fail/ref=MethodReference53.out -XDrawDiagnostics MethodReference53.java
+ */
+class MethodReference53 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(long i);
+    }
+
+    void m(SAM1 s1) { }
+    void m(SAM2 s1) { }
+
+    void test() {
+        m(this::unknown); //should not generate outer resolution diagnostic
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference53.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference53.java:22:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, MethodReference53, null))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference54.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  method call with bad qualifier generates NPE if argument is a method reference
+ * @compile/fail/ref=MethodReference54.out -XDrawDiagnostics MethodReference54.java
+ */
+class MethodReference54 {
+
+    interface SAM {
+        void m();
+    }
+
+    void test() {
+        nonExistent.m(MethodReference54::get);
+    }
+
+    static String get() { return ""; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference54.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MethodReference54.java:15:9: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, MethodReference54, null)
+1 error
--- a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -24,7 +24,9 @@
 /*
  * @test
  * @bug 7115052
- * @summary Add parser support for method references
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add parser support for method references
  */
 
 import com.sun.source.util.JavacTask;
@@ -227,7 +229,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.parse();
         } catch (Throwable ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific01.out -XDrawDiagnostics MostSpecific01.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, String s) { }
+    void m(LongMapper lm, Integer s) { }
+
+    void test() {
+        m(()->1, null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific01.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MostSpecific01.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,java.lang.String), Test, kindname.method, m(Test.LongMapper,java.lang.Integer), Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific02.out -XDrawDiagnostics MostSpecific02.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, LongMapper s) { }
+    void m(LongMapper lm, IntMapper s) { }
+
+    void test() {
+        m(()->1, ()->1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific02.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+MostSpecific02.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,Test.LongMapper), Test, kindname.method, m(Test.LongMapper,Test.IntMapper), Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper... im) { }
+    void m(LongMapper... lm) { }
+
+    void m2(IntMapper im1, IntMapper... im) { }
+    void m2(LongMapper... lm) { }
+
+    void test1() {
+        m(); //ambiguous
+        m(()->1); //ok
+        m(()->1, ()->1); //ok
+        m(()->1, ()->1, ()->1); //ok
+    }
+
+    void test2() {
+        m(null, null); //ambiguous
+        m(()->1, null); //ambiguous
+        m(null, ()->1); //ambiguous
+        m(()->1L, null); //ok
+        m(null, ()->1L); //ok
+    }
+
+    void test3() {
+        m2(); //ok
+        m2(()->1); //ambiguous
+        m2(()->1, ()->1); //ok
+        m2(()->1, ()->1, ()->1); //ok
+    }
+
+    void test4() {
+        m2(null, null, null); //ambiguous
+        m2(()->1, null, null); //ambiguous
+        m2(null, ()->1, null); //ambiguous
+        m2(null, null, ()->1); //ambiguous
+        m2(()->1, ()->1, null); //ambiguous
+        m2(null, ()->1, ()->1); //ambiguous
+        m2(()->1, null, ()->1); //ambiguous
+
+        m2(()->1L, null, null); //ok
+        m2(null, ()->1L, null); //ok
+        m2(null, null, ()->1L); //ok
+        m2(()->1L, ()->1L, null); //ok
+        m2(null, ()->1L, ()->1L); //ok
+        m2(()->1L, null, ()->1L); //ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific03.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,13 @@
+MostSpecific03.java:26:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:33:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:34:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:35:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:42:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:48:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:49:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:50:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:51:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:52:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:53:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:54:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+12 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface DoubleMapper<T> {
+        double map(T t);
+    }
+
+    interface LongMapper<T> {
+        long map(T t);
+    }
+
+    static class MyList<E> {
+        void map(DoubleMapper<? super E> m) { assertTrue(false); }
+        void map(LongMapper<? super E> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyList<String> ls = new MyList<String>();
+        ls.map(e->e.length());
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface ObjectConverter<T extends Object> {
+        T map(Object o);
+    }
+
+    interface NumberConverter<T extends Number> {
+        T map(Object o);
+    }
+
+    static class MyMapper<A extends Object, B extends Number> {
+        void map(ObjectConverter<? extends A> m) { assertTrue(false); }
+        void map(NumberConverter<? extends B> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyMapper<Number, Double> mm = new MyMapper<Number, Double>();
+        mm.map(e->1.0);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  most specific resolution crashes on stuck lambdas
+ * @compile/fail/ref=MostSpecific06.out -XDrawDiagnostics MostSpecific06.java
+ */
+import java.util.*;
+
+class MostSpecific06 {
+
+    interface Predicate<X> {
+        boolean accept(X x);
+    }
+
+    interface ExtPredicate<X> extends Predicate<X> { }
+
+
+
+    void test(boolean cond, ArrayList<String> als) {
+        m(u -> true, als, als);
+        m((u -> true), als, als);
+        m(cond ? u -> true : u -> false, als, als);
+    }
+
+    <U> U m(Predicate<U> p, List<U> lu, ArrayList<U> au) { return null; }
+
+
+    <U> U m(ExtPredicate<U> ep, ArrayList<U> au, List<U> lu) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific06.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+MostSpecific06.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:22:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache contents are overwritten by deferred type-checking of nested stuck expressions
+ * @compile/fail/ref=MostSpecific07.out -XDrawDiagnostics MostSpecific07.java
+ */
+import java.util.*;
+
+class MostSpecific07 {
+
+    interface Predicate<X, Y> {
+        Y accept(X x);
+    }
+
+    interface VoidMapper {
+        void accept();
+    }
+
+    interface ExtPredicate<X, Y> extends Predicate<X, Y> { }
+
+    void test(boolean cond, ArrayList<String> als, VoidMapper vm) {
+        m(u -> ()->{}, als, als, vm);
+        m((u -> ()->{}), als, als, vm);
+        m(cond ? u -> ()->{} : u -> ()->{}, als, als, vm);
+    }
+
+    <U, V> U m(Predicate<U, V> p, List<U> lu, ArrayList<U> au, V v) { return null; }
+
+    <U, V> U m(ExtPredicate<U, V> ep, ArrayList<U> au, List<U> lu, V v) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific07.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+MostSpecific07.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:24:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:25:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NakedThis.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @compile NakedThis.java
+ */
+
+class NakedThis {
+
+    interface SAM {
+        NakedThis m(int x);
+    }
+
+    SAM s1 = (int x) -> this;
+    SAM s2 = (int x) -> NakedThis.this;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SourceLevelTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda features are not enabled with source < 8
+ * @compile/fail/ref=SourceLevelTest.out -XDrawDiagnostics -source 7 SourceLevelTest.java
+ */
+
+class SourceLevelTest {
+    interface I {
+        default void m() { SourceLevelTest.impl(this); }
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s1 = () -> { };
+    SAM s2 = this::m;
+
+    static void impl(I i) {}
+    void m() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SourceLevelTest.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+- compiler.warn.source.no.bootclasspath: 1.7
+SourceLevelTest.java:11:9: compiler.err.default.methods.not.supported.in.source: 1.7
+SourceLevelTest.java:18:17: compiler.err.lambda.not.supported.in.source: 1.7
+SourceLevelTest.java:19:20: compiler.err.method.references.not.supported.in.source: 1.7
+3 errors
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType01.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check nested case of overload resolution and lambda parameter inference
+ * @author  Maurizio Cimadamore
+ * @compile TargetType01.java
+ */
+
+class TargetType01 {
+
+    interface Func<A,B> {
+        B call(A a);
+    }
+
+    interface F_I_I extends Func<Integer,Integer> {}
+    interface F_S_S extends Func<String,String> {}
+
+    static Integer M(F_I_I f){ return null; }
+    static String M(F_S_S f){ return null; }
+
+    static {
+        //ambiguity here - the compiler does not try all the combinations!
+        M(x1 -> { return M( x2 -> { return x1 + x2; });});
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType02.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType02
+ */
+
+public class TargetType02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S1<X extends Number> {
+        X m(Integer x);
+    }
+
+    interface S2<X extends String> {
+        abstract X m(Integer x);
+    }
+
+    static <Z extends Number> void call(S1<Z> s) { s.m(1); assertTrue(true); }
+    static <Z extends String> void call(S2<Z> s) { s.m(2); assertTrue(false); }
+
+    void test() {
+        call(i -> { toString(); return i; });
+    }
+
+    public static void main(String[] args) {
+        new TargetType02().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType03.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType03
+ */
+import java.util.*;
+
+public class TargetType03 {
+
+    interface Mapper<X,Y> {
+        Y myMap(X a);
+    }
+
+    static class MapperList<A> extends ArrayList<A> {
+        public <B> List<B> myMap(Mapper<A, B> mapper) {
+            ArrayList<B> mappedList = new ArrayList<>();
+            for (A elem : this) {
+                mappedList.add(mapper.myMap(elem));
+            }
+            return mappedList;
+        };
+    }
+
+    public static void main(String[] args) {
+        MapperList<Integer> numbers = new MapperList<>();
+        numbers.add(1);
+        numbers.add(2);
+        numbers.add(3);
+        numbers.add(4);
+        numbers.add(5);
+        List<Integer> sqNumbers = numbers.myMap(a -> a * a);
+        //check invariants
+        if (numbers.size() != sqNumbers.size()) {
+            throw new AssertionError();
+        }
+        for (int i = 0; i < numbers.size() ; i ++) {
+            if (sqNumbers.get(i) != Math.pow(numbers.get(i), 2)) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType04.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target typing in assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType04.out -XDrawDiagnostics TargetType04.java
+ */
+class TargetType04 {
+
+    interface S<X extends Number, Y extends Number> {
+       Y m(X x);
+    }
+
+    S<Integer, Integer> s1 = i -> { return i; }; //ok
+    S<Double, Integer> s2 = i -> { return i; }; //no
+    S<Integer, Double> s3 = i -> { return i; }; //no
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType04.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType04.java:16:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Double, java.lang.Integer))
+TargetType04.java:17:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Double))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType05.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  test recursion through SAM type
+ * @author  Maurizio Cimadamore
+ * @run main TargetType05
+ */
+public class TargetType05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Func<A,R> {
+        R call(A a);
+    }
+
+    static Func<Integer, Integer> f;
+
+    public static void main(String[] args) {
+        f = i -> { return i == 1 ? 1 : f.call(i-1) * i; };
+        assertTrue(f.call(5) == 120);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType06.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check complex case of target typing
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType06.out -XDrawDiagnostics TargetType06.java
+ */
+
+import java.util.List;
+
+class TargetType06 {
+
+    class Foo {
+        Foo getFoo() { return null; }
+    }
+
+    interface Function<A,R> {
+        R invoke(A a);
+    }
+
+    static <B> List<B> map(Function<B, B> function) { return null; }
+
+    void test() {
+        List<Foo> l = map(foo -> foo.getFoo());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType06.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType06.java:25:23: compiler.err.cant.apply.symbol: kindname.method, map, TargetType06.Function<B,B>, @510, kindname.class, TargetType06, (compiler.misc.cyclic.inference: B)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType07.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that explicit generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType07.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1<X> { X m(); }
+    public interface SAM2<X> { X m(); }
+
+    public static <X> void call(SAM1<X> s) { }
+    public static <X> void call(SAM2<X> s) { }
+
+    public static void main(String[] args) {
+        call((SAM1<Integer>)()-> 1 );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType08.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that explicit non-generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType08.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1 { String m(); }
+    public interface SAM2 { Comparable<?> m(); }
+
+    public static void call(SAM1 s) { }
+    public static void call(SAM2 s) { }
+
+    public static void main(String[] args) {
+        call((SAM1)()-> "Hello!" );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType10.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType10.out -XDrawDiagnostics TargetType10.java
+ */
+
+class TargetType10 {
+    interface Function<A,R> {
+        R apply(A a);
+    }
+
+    static class Test {
+        <A,B,C> Function<A,C> compose(Function<B,C> g, Function<A,? extends B> f) { return null; }
+        { compose(x ->  "a" + x, x -> x + "b"); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType10.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType10.java:17:11: compiler.err.cant.apply.symbol: kindname.method, compose, TargetType10.Function<B,C>,TargetType10.Function<A,? extends B>, @500,@515, kindname.class, TargetType10.Test, (compiler.misc.cyclic.inference: B,A)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType11.out -Xlint:unchecked -XDrawDiagnostics TargetType11.java
+ */
+
+class TargetType11 {
+    interface Predicate<X> {
+        boolean apply(X c);
+    }
+
+    static class Test {
+        public <T> Predicate<T> and(Predicate<? super T>... first) { return null; }
+        public Predicate<Character> forPredicate(Predicate<? super Character> predicate) { return null; }
+
+        Predicate<Character> c2 = forPredicate(c -> c.compareTo('e') < 0);
+        Predicate<Integer> k = and(i -> i > 0, i -> i % 2 == 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType11.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+TargetType11.java:16:61: compiler.warn.unchecked.varargs.non.reifiable.type: TargetType11.Predicate<? super T>
+TargetType11.java:20:32: compiler.err.cant.apply.symbol: kindname.method, and, TargetType11.Predicate<? super T>[], @706,@718, kindname.class, TargetType11.Test, (compiler.misc.cyclic.inference: T)
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType12.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Flow should not analyze lambda body that contains errors due to partially specified parameter types
+ * @author  Maurizio Cimadamore
+ * @compile TargetType12.java
+ */
+
+import java.util.*;
+
+class TargetType12 {
+
+    interface Extractor<X,Y> {
+       Y get(X x);
+    }
+
+    static <T, U extends Comparable<? super U>> void sortBy2(T[] array, Extractor<T, U> extractor) {
+        Comparator<T> comparator = (left,right) -> extractor.get(left).compareTo(extractor.get(right));
+        Arrays.sort(array, comparator);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType13.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  failure to infer exception thrown types from lambda body causes checked exception to be skipped
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType13.out -XDlambdaInferenceDiags=false -XDrawDiagnostics TargetType13.java
+ */
+
+class TargetType13 {
+
+    interface SAM<E extends Throwable> {
+       void m(Integer x) throws E;
+    }
+
+    static <E extends Throwable> void call(SAM<E> s) throws E { }
+
+    void test() {
+        call(i -> { if (i == 2) throw new Exception(); return; });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType13.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType13.java:19:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType14.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that return type is inferred from target type when cyclic inference found
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType14.out -XDrawDiagnostics TargetType14.java
+ */
+
+class TargetType14 {
+
+    interface SAM<X> {
+        X m(int i, int j);
+    }
+
+    static void test() {
+        SAM<Integer> s1 = (i, j) -> i + j;
+        m((i, j) -> i + j);
+        SAM<Integer> s2 = m2((i, j) -> i + j); //ok
+        SAM<Integer> s3 = m2((i, j) -> "" + i + j); //no
+    }
+
+    static void m(SAM<Integer> s) { }
+    static <X> SAM<X> m2(SAM<X> s) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType14.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType14.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType14.SAM<java.lang.String>, TargetType14.SAM<java.lang.Integer>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType15.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  bad target-type inference lead to compiler crash
+ * @author  Maurizio Cimadamore
+ * @compile TargetType15.java
+ */
+
+class TargetType15 {
+
+    interface SAM<T> {
+        T foo(T a, T b);
+    }
+
+    void m1(SAM<? extends String> f_1) {}
+    void m2(SAM<? super String> f_2) {}
+    void m3(SAM<?> f_3) {}
+
+    SAM<? extends String> f_1 = (a, b) -> a;
+    SAM<? super String> f_2 = (a, b) -> a;
+    SAM<?> f_3 = (a, b) -> a;
+
+    {
+        m1((a, b) -> a);
+        m2((a, b) -> a);
+        m3((a, b) -> a);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType16.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Check void-compatibility in strict vs. loose conversion contexts
+ * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java
+ */
+
+class TargetType16 {
+
+    interface SAM1 {
+        void m1();
+    }
+
+    interface SAM2<X> {
+        X m2();
+    }
+
+    static void m(SAM1 s1) { }
+    static <T> void m(SAM2<T> s2) { }
+
+    public static void main(String[] args) {
+        m(() -> { throw new AssertionError(); }); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType16.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, <T>m(TargetType16.SAM2<T>), TargetType16
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType17.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that javac recovers succesfully from bad cast conversion to primitive type
+ * @compile/fail/ref=TargetType17.out -XDrawDiagnostics TargetType17.java
+ */
+
+class TargetType17 {
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    byte b = (byte) ()-> true;
+    short s = (short) ()-> 1;
+    int i = (int) ()-> 1;
+    long l = (long) ()-> 1L;
+    float f = (float) ()-> 1.0F;
+    double d = (double) ()-> 1.0;
+    char c = (char) ()-> 'c';
+    boolean z = (boolean) ()-> true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType17.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,9 @@
+TargetType17.java:14:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:15:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:16:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:17:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:18:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:19:25: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:20:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:21:27: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType18.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that javac doesn't crash if implicit lambda parameter is involved in cast
+ * @compile TargetType18.java
+ */
+
+class TargetType18 {
+
+    interface Folder<T> {
+        public T fold(T a, T b);
+    }
+
+
+    public static <T> Folder<T> max() {
+        return (a, b) -> (((Comparable)a).compareTo(b)<0)? b: a;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType19.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of generic method call with lambda argument where target
+ *          is a wildcard SAM
+ * @compile TargetType19.java
+ */
+import java.util.List;
+
+class TargetType19 {
+
+    interface SAM<X> {
+        void f(List<? extends X> i);
+    }
+
+    <Z> void call(SAM<? extends Z> s, Z z) {  }
+
+   { call((List<? extends String> p) -> { }, 1); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType19.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType19.java:40:10: compiler.err.invalid.inferred.types: (compiler.misc.no.conforming.assignment.exists: TargetType19.SAM<java.lang.String>, TargetType19.SAM<? extends java.lang.Integer>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType20.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of lambda return type that depends on generic method
+ *          inference variable
+ * @compile/fail/ref=TargetType20.out -XDrawDiagnostics TargetType20.java
+ */
+import java.util.*;
+
+class TargetType20 {
+
+    interface SAM2<X> {
+      List<X> f();
+    }
+
+    class Test {
+       <Z> void call(SAM2<Z> x, SAM2<Z> y) { }
+       { call(() -> Collections.emptyList(), () -> new ArrayList<String>()); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType20.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType20.java:19:10: compiler.err.cant.apply.symbol: kindname.method, call, TargetType20.SAM2<Z>,TargetType20.SAM2<Z>, @428,@459, kindname.class, TargetType20.Test, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType21.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with cyclic type-inference are removed from the
+ *          set of applicable methods
+ * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
+ */
+
+class TargetType21 {
+    interface SAM1 {
+        String m1(Integer n) throws Exception;
+    }
+
+    interface SAM2 {
+        void m2(Integer n);
+    }
+
+    interface SAM3<R,A> {
+        R m3(A n);
+    }
+
+    void call(SAM1 sam) { }
+    void call(SAM2 sam) { }
+    <R,A> void call(SAM3<R,A> sam) { }
+
+    void test() {
+        call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1)
+        call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2)
+        call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference
+        call(x -> { return null; }); ////ok - resolves to call(SAM1)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType21.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21
+TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @755,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType22.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with incompatible SAM descriptor args length
+            are removed from the set of applicable methods
+ * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java
+ */
+
+class TargetType22 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1<A> {
+        void m(A a);
+    }
+
+    interface Sam2<A> {
+        void m(A a1, A a2);
+    }
+
+    interface Sam3<A> {
+        void m(A a1, A a2, A a3);
+    }
+
+    interface SamX<A> {
+        void m(A... as);
+    }
+
+    void call(Sam0 s) { }
+    void call(Sam1<String> s) { }
+    void call(Sam2<String> s) { }
+    void call(Sam3<String> s) { }
+    void call(SamX<String> s) { }
+
+    void test() {
+        call(() -> { });
+        call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match
+        call((a1, a2) -> { });
+        call((a1, a2, a3) -> { });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType22.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+TargetType22.java:29:21: compiler.warn.unchecked.varargs.non.reifiable.type: A
+TargetType22.java:40:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType22.Sam1<java.lang.String>), TargetType22, kindname.method, call(TargetType22.SamX<java.lang.String>), TargetType22
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType23.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of ambiguous method call with lambda whose body cannot
+            complete normally
+ * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java
+ */
+
+class TargetType23 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1 {
+        int m();
+    }
+
+    interface Sam2 {
+        String m();
+    }
+
+    interface Sam3<A> {
+        A m();
+    }
+
+
+    void call(Sam0 s) { }
+    void call(Sam1 s) { }
+    void call(Sam2 s) { }
+    <Z> void call(Sam3<Z> s) { }
+
+    void test() {
+        call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType23.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, <Z>call(TargetType23.Sam3<Z>), TargetType23
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType24.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of nested method calls with lambda expression
+ * @compile/fail/ref=TargetType24.out -XDrawDiagnostics TargetType24.java
+ */
+
+class TargetType24 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    interface FSub<A, B> extends F<A,B> { }
+
+    static class Array<A> {
+        boolean forAll(final F<A, Boolean> f) {
+            return false;
+        }
+
+        String forAll(final FSub<A, String> f) {
+            return "";
+        }
+
+        String forAll2(final FSub<A, String> f) {
+            return "";
+        }
+    }
+
+    void test(Array<String> as, final Array<Character> ac) {
+        final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok
+        final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok
+        final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail
+        final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail
+        final boolean b3 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail
+        final String s3 = as.forAll((FSub<String, String>)s -> ac.forAll((FSub<Character, String>)c -> false)); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType24.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+TargetType24.java:34:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean)
+TargetType24.java:35:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @945, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)))
+TargetType24.java:36:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean))
+TargetType24.java:37:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType25.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression can appear in
+ * @compile TargetType25.java
+ */
+
+class TargetType25 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    <Z> void m1(F<String, Z> f) {  }
+    <Z> void m2(F<String, F<String, Z>> f) {  }
+    <Z> void m3(F<String, F<String, F<String, Z>>> f) {  }
+
+    void testExprLambdaInMethodContext() {
+        m1(s1 -> 1);
+        m2(s1 -> s2 -> 1);
+        m3(s1 -> s2 -> s3 -> 1);
+    }
+
+    void testExprLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> 1;
+        F<String, F<String, Integer>> fn2 = s1 -> s2 -> 1;
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> s2 -> s3 -> 1;
+    }
+
+    void testStatementLambdaInMethodContext() {
+        m1(s1 -> { return 1; });
+        m2(s1 -> { return s2 -> { return 1; }; });
+        m3(s1 -> { return s2 -> { return s3 -> { return 1; }; }; });
+    }
+
+    void testStatementLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> { return 1; };
+        F<String, F<String, Integer>> fn2 = s1 -> { return s2 -> { return 1; }; };
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> { return s2 -> { return s3 -> { return 1; }; }; };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType26.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  case of cyclic type inference (lambda passed where inference var expected)
+ * @compile/fail/ref=TargetType26.out -XDrawDiagnostics TargetType26.java
+ */
+
+class TargetType26 {
+    interface SAM {
+       void m();
+    }
+
+    <Z> void call(Z z) { }
+
+    { call(() -> { }); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType26.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType26.java:16:7: compiler.err.cant.apply.symbol: kindname.method, call, Z, @340, kindname.class, TargetType26, (compiler.misc.cyclic.inference: Z)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType27.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of cyclic type inference (lambda returned where inference var expected)
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics -XDcomplexinference TargetType27.java
+ */
+
+class TargetType27 {
+    interface F<X, Y>  {
+        Y f(X a);
+    }
+
+    <A, R> F<A, R> m(F<A, R>  f) { return null; }
+
+    void test() {
+        m((String s1) ->  (String s2) ->  new Integer(1));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType27.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType27.java:18:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType27.F<A,R>, @490, kindname.class, TargetType27, (compiler.misc.cyclic.inference: R)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType28.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target type inference in a case where lambda expression returns diamond
+ * @compile/fail/ref=TargetType28.out -XDrawDiagnostics TargetType28.java
+ */
+
+class TargetType28 {
+    static class SuperFoo<X> {}
+
+    static class Foo<X extends Number> extends SuperFoo<X> {}
+
+    interface A<X, Y> {
+       SuperFoo<Y> m(X x);
+    }
+
+    <Z, R> SuperFoo<R> apply(A<Z, R> ax, Z x) { return null; }
+
+    SuperFoo<String> ls = apply(x-> new Foo<>(), 1);
+    SuperFoo<Integer> li = apply(x-> new Foo<>(), 1);
+    SuperFoo<?> lw = apply(x-> new Foo<>(), 1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType28.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo<java.lang.Number>, TargetType28.SuperFoo<java.lang.String>)
+TargetType28.java:21:33: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo<java.lang.Number>, TargetType28.SuperFoo<java.lang.Integer>)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType29.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check type-substitution in SAM type wildcards inference
+ * @compile TargetType29.java
+ */
+
+import java.util.*;
+
+class TargetType29 {
+    interface Reducer<E, V> {
+        public V reduce(E element, V value);
+    }
+
+    private static <E> int reduce(Iterable<? extends E> iterable, Reducer<? super E, Integer> reducer) { return 0;  }
+
+    void test(List<Integer> li) {
+        reduce(li, (e, v) -> e + v);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType30.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type is propagated through parenthesized expressions
+ * @compile TargetType30.java
+ */
+
+class TargetType30 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (x-> { System.out.println("Hello!"); });
+        SAM s2 = ((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((x-> { System.out.println("Hello!"); }));
+        m(((x-> { System.out.println("Hello!"); })));
+        m((((x-> { System.out.println("Hello!"); }))));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType31.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of a cast is propagated through parenthesized expressions
+ * @compile TargetType31.java
+ */
+
+class TargetType31 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (SAM)(x-> { System.out.println("Hello!"); });
+        SAM s2 = (SAM)((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (SAM)(((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((SAM)(x-> { System.out.println("Hello!"); }));
+        m((SAM)((x-> { System.out.println("Hello!"); })));
+        m((SAM)(((x-> { System.out.println("Hello!"); }))));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType32.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target-typing and conditional operator
+ */
+
+public class TargetType32 {
+
+    interface A<X> {
+        X m();
+    }
+
+    interface B<X> extends A<X> {}
+
+    void m(A<Integer> a) { }
+    void m(B<String> b) { }
+
+    <Z extends Integer> void m2(A<Z> a) { }
+    <Z extends String> void m2(B<Z> b) { }
+
+    void m3(A<TargetType32> a) { }
+    void m3(B<String> b) { }
+
+    <Z> void m4(A<Z> a) { }
+    <Z extends String> void m4(B<Z> b) { }
+
+    int intRes() { return 42; }
+
+    void testLambda(boolean flag) {
+        A<Integer> c = flag ? (() -> 23) : (() -> 42);
+        m(flag ? (() -> 23) : (() -> 42));
+        m2(flag ? (() -> 23) : (() -> 23));
+    }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+
+    void testConstrRef(boolean flag) {
+        A<TargetType32> c = flag ? TargetType32::new : TargetType32::new;
+        m3(flag ? TargetType32::new : TargetType32::new);
+        m4(flag ? TargetType32::new : TargetType32::new);
+    }
+
+    public static void main(String[] args) {
+        TargetType32 test = new TargetType32();
+        test.testLambda(true);
+        test.testMethodRef(true);
+        test.testConstrRef(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType33.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  crash when incompatible method reference is found in conditional expression
+ * @compile/fail/ref=TargetType33.out -XDrawDiagnostics TargetType33.java
+ */
+
+class TargetType33 {
+
+    interface A<X> {
+        X m();
+    }
+
+    void m(A<Integer> a) { }
+    <Z> void m2(A<Z> a) { }
+
+    int intRes(Object o) { return 42; }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType33.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+TargetType33.java:21:31: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:21:46: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:22:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType33.A<java.lang.Integer>, @509, kindname.class, TargetType33, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+TargetType33.java:23:9: compiler.err.cant.apply.symbol: kindname.method, m2, TargetType33.A<Z>, @557, kindname.class, TargetType33, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType34.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious resolution diagnostics when diamond constructor contains poly expression
+ * @compile -XDcomplexinference TargetType34.java
+ */
+
+class TargetType34<X> {
+
+    TargetType34(X x) {}
+
+    Object next;
+
+    void test() {
+        new TargetType34<>(next==null ? null : null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType35.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  missing erasure on intersection supertype of generated lambda class
+ */
+public class TargetType35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {}
+
+    interface B {}
+
+    static class C implements A, B {}
+
+    static class D implements A, B {}
+
+    interface SAM<Y, X> {
+        Y invoke(X arg);
+    }
+
+    static class Sup {
+       <Z> Z m(Z z) { return z; }
+    }
+
+    static class Sub extends Sup {
+        <Z> Z m(Z z) { return z; }
+
+        void test(C c, D d) {
+            choose(c, d, x->x);
+            choose(c, d, this::m);
+            choose(c, d, super::m);
+        }
+
+        <T> void choose(T t1, T t2, SAM<T, T> t3) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args)
+    {
+        new Sub().test(null, null);
+        assertTrue(assertionCount == 3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType36.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @ignore
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of cast is propagated to conditional subexpressions
+ * @compile TargetType36.java
+ */
+class TargetType36 { //awaits spec wording on cast vs. poly
+
+    interface SAM {
+       int m(int i, int j);
+    }
+
+    void test() {
+        SAM s1 = (SAM)((a,b)->a+b);
+        SAM s2 = (SAM)(true? (SAM)((a,b)->a+b) : (SAM)((a,b)->a+b));
+        SAM s3 = (SAM)(true? (a,b)->a+b : (a,b)->a+b);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType37.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context is propagated to conditional subexpressions
+ * @compile TargetType37.java
+ */
+class TargetType37 {
+
+    interface I { }
+
+    void test(Object o, boolean cond) {
+        I i = (I)(cond ? o : o);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType38.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context does not affect compatibility of lambda
+ * @compile/fail/ref=TargetType38.out -XDrawDiagnostics TargetType38.java
+ */
+class TargetType38 {
+
+    interface I { }
+
+    interface SAM {
+        I m();
+    }
+
+    static Object m() { return null; }
+
+    void test() {
+        Object o1 = (SAM)()->new Object();
+        Object o2 = (SAM)TargetType38::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType38.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType38.java:19:30: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+TargetType38.java:20:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType39.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that type-checking fails because of recursive analysis of stuck expressions
+  * @compile/fail/ref=TargetType39.out -XDrawDiagnostics TargetType39.java
+ */
+class TargetType39 {
+
+    interface I { }
+
+    interface SAM<A, R> {
+        R m(A a);
+    }
+
+    <U, V> void call(SAM<U, V> s) { }
+
+    void test(boolean cond, SAM<String, Void> ssv) {
+        call(cond ? x-> null : ssv);
+        call((String s)-> cond ? x-> null : ssv);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType39.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType39.java:19:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @442, kindname.class, TargetType39, (compiler.misc.cyclic.inference: U)
+TargetType39.java:20:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @479, kindname.class, TargetType39, (compiler.misc.cyclic.inference: V)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType40.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler silently crashes when void method is passed as argument in overloaded call site
+ * @compile/fail/ref=TargetType40.out -XDrawDiagnostics TargetType40.java
+ */
+
+class TargetType40 {
+    void m(String s) { }
+    void m(Integer i) { }
+
+    void void_method() {}
+
+    void test() {
+       m(void_method());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType40.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType40.java:16:21: compiler.err.void.not.allowed.here
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType41.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  out-of-order method checking should check as many arguments as possible
+ * @compile/fail/ref=TargetType41.out -XDrawDiagnostics TargetType41.java
+ */
+
+class TargetType41 {
+    <X> void m(String s, java.util.List<String> lx) { }
+
+    void test() {
+        m(1, new java.util.ArrayList<>());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType41.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType41.java:13:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.String,java.util.List<java.lang.String>, int,java.util.ArrayList<java.lang.Object>, kindname.class, TargetType41, (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.lang.String))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType42.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  effects of speculative attribution are undone on a per-argument basis rather than on a per-resolution basis
+ * @compile TargetType42.java
+ */
+class TargetType42 {
+
+    interface SAM<X, Y> {
+      Y f(X x);
+    }
+
+    <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { }
+
+    void test(Object obj) {
+        m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType43.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  recovery attribution step for unchecked arguments
+ * @compile/fail/ref=TargetType43.out -XDrawDiagnostics TargetType43.java
+ */
+class TargetType43 {
+
+    void m(Object o) { }
+
+    void test(Object obj) {
+        Object o = x-> { new NonExistentClass(x); return 5; };
+        m(x-> { new NonExistentClass(x); return 5; });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType43.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+TargetType43.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @359, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType44.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler throw AssertionError while backtracing from speculative attribution round
+ * @compile/fail/ref=TargetType44.out -XDrawDiagnostics TargetType44.java
+ */
+class TargetType44 {
+
+    interface Unary {
+        void m(int i1);
+    }
+
+    interface Binary {
+        void m(int i1, int i2);
+    }
+
+    void m(Unary u) { }
+    void m(Binary u) { }
+
+    void test() {
+        m(()-> { new Object() { }; }); //fail
+        m(x -> { new Object() { }; }); //ok
+        m((x, y) -> { new Object() { }; }); //ok
+        m((x, y, z) -> { new Object() { }; }); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType44.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType44.java:22:9: compiler.err.cant.apply.symbols: kindname.method, m, @458,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+TargetType44.java:25:9: compiler.err.cant.apply.symbols: kindname.method, m, @597,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType45.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler crashes during flow analysis as it fails to report diagnostics during attribution
+ * @compile/fail/ref=TargetType45.out -XDrawDiagnostics TargetType45.java
+ */
+class TargetType45 {
+
+    interface Predicate<X> {
+        boolean apply(X x);
+    }
+
+    interface Mapper<X, Y> {
+        Y apply(X x);
+    }
+
+    class Foo<X> {
+        Foo<X> filter(Predicate<? super X> p) { return null; }
+    }
+
+    static <U, V> Predicate<U> compose(Predicate<? super V> pi, Mapper<? super U, ? extends V> m) { return null; }
+
+    static Predicate<Integer> isOdd = i -> i % 2 != 0;
+
+    void top10Counties(Foo<String> foos) {
+        foos.filter(compose(isOdd, (String e) -> e.length()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType45.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TargetType45.java:27:28: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U,V, (compiler.misc.inconvertible.types: TargetType45.Mapper<java.lang.String,java.lang.Integer>, TargetType45.Mapper<? super java.lang.Object,? extends java.lang.Integer>))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType46.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler doesn't report accessibility problem due to inaccessible target
+ * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
+ */
+import java.util.*;
+
+class TargetType46Outer {
+
+    private interface PI {
+       void m();
+    }
+
+    void m(PI p) { }
+    void m(List<PI> p) { }
+}
+
+class TargetType46 {
+    void test(TargetType46Outer outer) {
+        outer.m(()->{}); //access error
+        outer.m(this::g); //access error
+        outer.m(new ArrayList<>()); //ok
+        outer.m(Collections.emptyList()); //ok
+    }
+
+    void g() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType46.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType47.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType47.java
+ */
+
+class TargetType47 {
+    interface A {
+        void a();
+        void b();
+        default void c() { };
+    }
+
+    interface B extends A {
+        default void b() { };
+    }
+
+    B b = ()-> {};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType48.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType48.java
+ */
+
+class TargetType48 {
+    interface I1 {
+        void a();
+        void b();
+        void c();
+    }
+
+    interface I2 extends I1 {
+        default void a() { }
+    }
+
+    interface I3 extends I2 {
+        default void b() { }
+    }
+
+    I3 i3 = ()->{ };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType49.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  javac accepts ill-formed lambda/method reference targets
+ * @compile/fail/ref=TargetType49.out -XDrawDiagnostics TargetType49.java
+ */
+class TargetType49 {
+
+    interface F {
+        default Object clone() { return null; }
+        void m();
+    }
+
+    F f1 = ()->{};
+    F f2 = this::g;
+
+    void g() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType49.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType49.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+TargetType49.java:16:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType50.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  bad stuck check for method reference leads to javac crash
+ * @compile/fail/ref=TargetType50.out -XDrawDiagnostics TargetType50.java
+ */
+import java.util.*;
+
+class TargetType50 {
+
+    interface Factory<F> {
+        F make();
+    }
+
+    static class Sink<T> {
+        static <Z> Sink<Z> make() { return null; }
+    }
+
+    <Y, S extends Sink<Y>> List<Y> m(Factory<S> factory) {  }
+
+    void test() {
+        List<?> l1 = m(Sink::new);
+        List<?> l2 = m(Sink::make);
+        List<String> l3 = m(Sink::new);
+        List<String> l4 = m(Sink::make);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType50.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+TargetType50.java:25:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+TargetType50.java:26:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+2 errors
--- a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java	Wed Jul 05 18:30:46 2017 +0200
@@ -25,7 +25,9 @@
  * @test
  * @bug 7194586
  *
- * @summary Add back-end support for invokedynamic
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add back-end support for invokedynamic
  *
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TestSelfRef.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Check that self/forward references from lambda expressions behave
+ *          consistently w.r.t. local inner classes
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class TestSelfRef {
+
+    static int checkCount = 0;
+
+    enum RefKind {
+        SELF_LAMBDA("SAM s = x->{ System.out.println(s); };", true, false),
+        FORWARD_LAMBDA("SAM s = x->{ System.out.println(f); };\nObject f = null;", false, true),
+        SELF_ANON("Object s = new Object() { void test() { System.out.println(s); } };", true, false),
+        FORWARD_ANON("Object s = new Object() { void test() { System.out.println(f); } }; Object f = null;", false, true);
+
+        String refStr;
+        boolean selfRef;
+        boolean forwardRef;
+
+        private RefKind(String refStr, boolean selfRef, boolean forwardRef) {
+            this.refStr = refStr;
+            this.selfRef = selfRef;
+            this.forwardRef = forwardRef;
+        }
+    }
+
+    enum EnclosingKind {
+        TOPLEVEL("class C { #S }"),
+        MEMBER_INNER("class Outer { class C { #S } }"),
+        NESTED_INNER("class Outer { static class C { #S } }");
+
+        String enclStr;
+
+        private EnclosingKind(String enclStr) {
+            this.enclStr = enclStr;
+        }
+    }
+
+    enum InnerKind {
+        NONE("#R"),
+        LOCAL_NONE("class Local { #R }"),
+        LOCAL_MTH("class Local { void test() { #R } }"),
+        ANON_NONE("new Object() { #R };"),
+        ANON_MTH("new Object() { void test() { #R } };");
+
+        String innerStr;
+
+        private InnerKind(String innerStr) {
+            this.innerStr = innerStr;
+        }
+
+        boolean inMethodContext(SiteKind sk) {
+            switch (this) {
+                case LOCAL_MTH:
+                case ANON_MTH: return true;
+                case NONE: return sk != SiteKind.NONE;
+                default:
+                    return false;
+            }
+        }
+    }
+
+    enum SiteKind {
+        NONE("#I"),
+        STATIC_INIT("static { #I }"),
+        INSTANCE_INIT("{ #I }"),
+        CONSTRUCTOR("C() { #I }"),
+        METHOD("void test() { #I }");
+
+        String siteStr;
+
+        private SiteKind(String siteStr) {
+            this.siteStr = siteStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (EnclosingKind ek : EnclosingKind.values()) {
+            for (SiteKind sk : SiteKind.values()) {
+                if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
+                    continue;
+                for (InnerKind ik : InnerKind.values()) {
+                    if (ik != InnerKind.NONE && sk == SiteKind.NONE)
+                        break;
+                    for (RefKind rk : RefKind.values()) {
+                        new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    EnclosingKind ek;
+    SiteKind sk;
+    InnerKind ik;
+    RefKind rk;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    TestSelfRef(EnclosingKind ek, SiteKind sk, InnerKind ik, RefKind rk) {
+        this.ek = ek;
+        this.sk = sk;
+        this.ik = ik;
+        this.rk = rk;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "interface SAM { void test(Object o); }\n#B";
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = bodyTemplate.replace("#B",
+                    ek.enclStr.replace("#S", sk.siteStr.replace("#I", ik.innerStr.replace("#R", rk.refStr))));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        //illegal forward ref
+        boolean errorExpected = ik.inMethodContext(sk) &&
+                (rk.selfRef || rk.forwardRef);
+        if (diagChecker.errorFound != errorExpected) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/VoidCompatibility.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that that void compatibility affects overloading as expected
+ * @compile/fail/ref=VoidCompatibility.out -XDrawDiagnostics VoidCompatibility.java
+ */
+class VoidCompatibility {
+
+    interface Runnable { void run(); } //1
+    interface Thunk<T> { T get(); } //2
+
+    void schedule(Runnable r) { }
+    void schedule(Thunk<?> t) { }
+
+    void test() {
+        schedule(() -> System.setProperty("done", "true")); //2
+        schedule(() -> { System.setProperty("done", "true"); }); //1
+        schedule(() -> { return System.setProperty("done", "true"); }); //2
+        schedule(() -> System.out.println("done")); //1
+        schedule(() -> { System.out.println("done"); }); //1
+        schedule(Thread::yield); //1
+        schedule(Thread::getAllStackTraces); //ambiguous
+        schedule(Thread::interrupted); //1 (most specific)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/VoidCompatibility.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+VoidCompatibility.java:23:9: compiler.err.ref.ambiguous: schedule, kindname.method, schedule(VoidCompatibility.Runnable), VoidCompatibility, kindname.method, schedule(VoidCompatibility.Thunk<?>), VoidCompatibility
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/abort/Abort.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that all diagnostics are dumped to output when compiler exits abruptly
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class Abort {
+
+    public static void main(String... args) throws Exception {
+
+        String SCRATCH_DIR = System.getProperty("user.dir");
+        JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
+        java.io.File testDir = new java.io.File(SCRATCH_DIR);
+
+        sourceA.dumpTo(testDir);
+        sourceB.dumpTo(testDir);
+
+        DiagnosticChecker diagChecker = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)javacTool.getTask(null, null, diagChecker,
+                Arrays.asList("-XDrawDiagnostics", "-cp", testDir.getAbsolutePath()),
+                null, Arrays.asList(sourceA.asJFO(testDir)));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            //ignore abort exception thrown by javac
+        }
+
+        if (!diagChecker.errorFound) {
+            throw new AssertionError("Missing diagnostic");
+        }
+    }
+
+    static class JavaSource {
+        String contents;
+        String filename;
+
+        public JavaSource(String filename, String contents) {
+            this.filename =  filename;
+            this.contents = contents;
+        }
+
+        void dumpTo(java.io.File loc) throws Exception {
+            java.io.File file = new java.io.File(loc, filename);
+            java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.FileWriter(file));
+            bw.append(contents);
+            bw.close();
+        }
+
+        SimpleJavaFileObject asJFO(java.io.File dir) {
+            return new SimpleJavaFileObject(new java.io.File(dir, filename).toURI(), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return contents;
+                }
+            };
+        }
+    }
+
+    static JavaSource sourceA = new JavaSource("Abort.java", "public class Abort {\n" +
+                                "    public static void main(String[] args) {\n" +
+                                "        System.out.println(C.m());\n" +
+                                "    }\n" +
+                                "}");
+
+    static JavaSource sourceB = new JavaSource("C.java", "package com.example;\n" +
+                                "public class C {\n" +
+                                "    public static String m() { return null; }\n" +
+                                "}");
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                    diagnostic.getCode().contains("compiler.err.cant.access")) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,9 @@
+import java.util.Collections;
+
+public class Main {
+
+    public static void main(String[] args) {
+        Collections.<String>sort(null, String::compareTo);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that classfiles with member ref CP entries are read correctly
+ * @author  Jan Lahoda
+ * @compile Main.java
+ * @compile Use.java
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+public class Use {
+    private Main m;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/Helper.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*SAM types:
+         1. An interface that has a single abstract method
+         2. Having more than one distinct methods, but only one is "real", the others are overriden public methods in Object - example: Comparator<T>
+         3. Having more than one methods due to inheritance, but they have the same signature
+         4. Having more than one methods due to inheritance, but one of them has a subsignature of all other methods
+                a) parameter types compatible
+                b) return type substitutable
+                c) thrown type not conflicting with the thrown clause of any other method
+                d) mixed up
+         5. Type-dependent SAM types
+  non-SAM types:
+         6. An interface that has a single abstract method, which is also public method in Object
+         7. Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+*/
+
+import java.util.List;
+import java.util.Collection;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+
+interface A {int getOldest(List<Number> list);}
+interface B {int getOldest(List list);}
+interface C {int getOldest(List<?> list);}
+interface D {int getOldest(List<Integer> list);}
+interface E {int getOldest(Collection<?> collection);}
+//Not SAM type, case #7
+interface DE extends D, E {}
+
+interface Foo {int getAge(Number n);}
+interface Bar {int getAge(Integer i);}
+//Not SAM type, case #7
+interface FooBar extends Foo, Bar {}
+
+//Not SAM type, case #6
+interface Planet {boolean equals(Object o);}
+
+// SAM type interfaces:
+// type #2:
+//only one abstract non-Ojbect method getAge()
+interface Mars<T> extends Planet {int getAge(T t);}
+//only one abstract non-Ojbect method increment()
+interface Jupiter {
+    boolean equals(Object o);
+    String toString();
+    int increment(int i);
+}
+
+// type #3:
+interface X {int getTotal(List<String> arg);}
+interface Y {int getTotal(List<String> strs);}
+//SAM type ([List<String>], int, {})
+interface XY extends X, Y {}
+//SAM type ([List<String>], int, {})
+interface XYZ extends X, Y, XY {}
+
+// type #4 a):
+//SAM type ([List], int, {})
+interface AB extends A, B {}
+
+// type #4 b):
+interface F {Number getValue(String str);}
+interface G {Integer getValue(String str);}
+interface H {Serializable getValue(String str);}
+interface I {Object getValue(String str);}
+//SAM type ([String], Integer, {})
+interface FGHI extends F, G, H, I {}
+
+interface J {List<Number> getAll(String str);}
+interface K {List<?> getAll(String str);}
+interface L {List getAll(String str);}
+interface M {Collection getAll(String str);}
+//SAM type ([String], List<Number>/List, {}) - the return type is flexible to some degree
+interface JK extends J, K {}
+//SAM type ([String], List<Number>/List, {})
+interface JL extends J, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKL extends J, K, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKLM extends J, K, L, M {}
+
+// type #4 c):
+interface N {String getText(File f) throws IOException;}
+interface O {String getText(File f) throws FileNotFoundException;}
+interface P {String getText(File f) throws NullPointerException;}
+//SAM type ([File], String, {FileNotFoundException})
+interface NO extends N, O {}
+//SAM type ([File], String, {})
+interface NOP extends N, O, P {}
+
+interface Boo {int getAge(String s) throws IOException;}
+interface Doo {int getAge(String s) throws SQLException;}
+//SAM type ([String], int, {})
+interface BooDoo extends Boo, Doo {}
+
+// type #4 d):
+interface Q {Iterable m(Iterable<String> arg);}
+interface R {Iterable<String> m(Iterable arg);}
+//SAM type ([Iterable], Iterable<String>/Iterable, {})
+interface QR extends Q, R {}
+
+interface U {Collection foo(List<String> arg) throws IOException, SQLTransientException;}
+interface V {List<?> foo(List<String> arg) throws EOFException, SQLException, TimeoutException;}
+interface W {List<String> foo(List arg) throws Exception;}
+//SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+interface UV extends U, V {}
+// SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+interface UVW extends U, V, W {}
+
+// type #5:
+// Not a SAM because sam-ness depends on instantiation of type-variables
+interface Qoo<T> {void m(T arg);}
+interface Roo<S extends Number> {void m(S arg);}
+interface QooRoo<T1, T2 extends Number, T3> extends Qoo<T1>, Roo<T2> {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for lambda expressions
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest1 {
+    public static void main(String[] args) {
+
+        LambdaTest1 test = new LambdaTest1();
+
+        test.method2((int n) -> { });
+        test.method2((int n) -> { });
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { System.out.println(n); }); // ";" is optional here
+        test.method2(n -> { System.out.println(n); }); //warning, explict type required for n?
+
+        test.method3(()-> { System.out.println("implementing VoidVoid.vvMethod()"); });
+        test.method3(() -> {});
+
+        test.method4(()-> 42);
+        test.method4(()-> { return 42; });//";" is mandatory here
+
+        test.method5((int n)-> n+1);
+        test.method5((int n) -> 42);
+        test.method5((int n) -> { return 42; });
+        test.method5(
+            (int n) -> { //"{" optional here
+                if(n > 0)
+                    return n++;
+                else
+                    return n--;
+            }
+        );
+
+        Runnable r = ()-> { System.out.println("Runnable.run() method implemented"); };
+        r.run();
+        ((Runnable)()-> { System.out.println("Runnable.run() method implemented"); }).run();
+    }
+
+    void method2(VoidInt a) {
+        System.out.println("method2()");
+        final int N = 1;
+        int n = 2; //effectively final variable
+        System.out.println("method2() \"this\":" + this);
+        ((Runnable)
+            ()->{
+                System.out.println("inside lambda \"this\":" + this);
+                System.out.println("inside lambda accessing final variable N:" + N);
+                System.out.println("inside lambda accessing effectively final variable n:" + n);
+            }
+        ).run();
+        //n++; //compile error if n is modified
+        a.viMethod(2);
+    }
+
+    void method3(VoidVoid a) {
+        System.out.println("method3()");
+        a.vvMethod();
+    }
+
+    void method4(IntVoid a) {
+        System.out.println("method4()");
+        System.out.println(a.ivMethod());
+    }
+
+    void method5(IntInt a) {
+        System.out.println("method5()");
+        System.out.println(a.iiMethod(5));
+    }
+
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify invalid lambda expressions
+ * @compile/fail/ref=LambdaTest1_neg1.out -XDrawDiagnostics LambdaTest1_neg1.java
+ */
+
+import java.util.Comparator;
+
+public class LambdaTest1_neg1 {
+    void method() {
+        Comparator<Number> c = (Number n1, Number n2) -> { 42; } //compile error, not a statement
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+LambdaTest1_neg1.java:13:60: compiler.err.not.stmt
+LambdaTest1_neg1.java:13:65: compiler.err.expected: ';'
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of accessing "this" from within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg2.out -XDrawDiagnostics LambdaTest1_neg2.java
+ */
+
+public class LambdaTest1_neg2 {
+    static void method() {
+        ((Runnable)
+            ()-> {
+                Object o = this; //use "this" inside lambda expression which is inside a static method, not allowed
+            }
+        ).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+LambdaTest1_neg2.java:13:28: compiler.err.non-static.cant.be.ref: kindname.variable, this
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of capturing local variable within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg3.out -XDrawDiagnostics LambdaTest1_neg3.java
+ */
+
+public class LambdaTest1_neg3 {
+    void method() {
+        int n = 2; //effectively final variable
+        ((Runnable)
+            ()-> {
+                int n2 = n; //inside lambda accessing effectively final variable;
+            }
+        ).run();
+        n++; //compile error if n is modified
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+LambdaTest1_neg3.java:14:26: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types 2 and 3, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM1.java Helper.java
+ * @run main LambdaTest2_SAM1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.*;
+
+public class LambdaTest2_SAM1 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<File> files = new ArrayList<File>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        files.add(new File("a.txt"));
+        files.add(new File("c.txt"));
+        files.add(new File("b.txt"));
+
+        //type #2: Comparator<T>
+        Collections.sort(files, (File f1, File f2) -> f1.getName().compareTo(f2.getName()));
+        for(File f : files)
+            System.out.println(f.getName());
+        System.out.println();
+        Collections.sort(files, (File f1, File f2) -> (int)(f1.length() - f2.length()));
+        for(File f : files)
+            System.out.println(f.getName() + " " + f.length());
+        System.out.println();
+
+        LambdaTest2_SAM1 test = new LambdaTest2_SAM1();
+
+        //type #2:
+        test.methodMars((File f) -> {
+            System.out.println("implementing Mars<File>.getAge(File f)...");
+            return (int)f.length();
+        });
+        test.methodJupiter((int n) -> n+1);
+
+        //type #3:
+        test.methodXY((List<String> strList) -> strList.size() );
+        test.methodXYZ((List<String> strList) -> 20 );
+    }
+
+    //type #2:
+    void methodMars(Mars<File> m) {
+        System.out.println("methodMars(): SAM type interface Mars object instantiated: " + m);
+        System.out.println(m.getAge(new File("a.txt")));
+    }
+
+    //type #2:
+    void methodJupiter(Jupiter j) {
+        System.out.println("methodJupiter(): SAM type interface Jupiter object instantiated: " + j);
+        System.out.println(j.increment(33));
+    }
+
+    //type #3:
+    void methodXY(XY xy) {
+        System.out.println("methodXY(): SAM type interface XY object instantiated: " + xy);
+        System.out.println(xy.getTotal(strs));
+    }
+
+    //type #3:
+    void methodXYZ(XYZ xyz) {
+        System.out.println("methodXYZ(): SAM type interface XYZ object instantiated: " + xyz);
+        System.out.println(xyz.getTotal(strs));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #4, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM2.java Helper.java
+ * @run main LambdaTest2_SAM2
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+
+public class LambdaTest2_SAM2 {
+    private static List<String> strs = new ArrayList<String>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        LambdaTest2_SAM2 test = new LambdaTest2_SAM2();
+
+        //type #4 a):
+        test.methodAB((List list) -> 100);
+
+        //type #4 b):
+        test.methodFGHI((String s) -> new Integer(22));
+        //type #4 b):
+        test.methodJK((String s) -> new ArrayList<Number>());
+        test.methodJK((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJL((String s) -> new ArrayList<Number>());
+        test.methodJL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKL((String s) -> new ArrayList<Number>());
+        test.methodJKL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKLM((String s) -> new ArrayList<Number>());
+        test.methodJKLM((String s) -> new ArrayList());
+
+        // tyep #4 c):
+        test.methodNO((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(FileNotFoundException fne){throw fne;}
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // tyep #4 c):
+        test.methodNOP((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // type #4 c):
+        test.methodBooDoo((String s) -> s.length());
+
+        //type #4 d):
+        test.methodQR((Iterable i) -> new ArrayList<String>());
+        test.methodQR((Iterable i) -> new ArrayList());
+        //type #4 d):
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+        //type #4 d):
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+    }
+
+    private void exceptionMethod1() throws EOFException{
+    }
+
+    private void exceptionMethod2() throws SQLTransientException{
+    }
+
+    //type #4 a): SAM type ([List], int, {})
+    void methodAB (AB ab) {
+        System.out.println("methodAB(): SAM type interface AB object instantiated: " + ab);
+        System.out.println(ab.getOldest(strs));
+    }
+
+    //type #4 b): SAM type ([String], Integer, {})
+    void methodFGHI(FGHI f) {
+        System.out.println("methodFGHI(): SAM type interface FGHI object instantiated: " + f);
+        System.out.println(f.getValue("str"));
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJK(JK jk) {
+        System.out.println("methodJK(): SAM type interface JK object instantiated: " + jk);
+        for(Number n : jk.getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJL(JL jl) {
+        System.out.println("methodJL(): SAM type interface JL object instantiated: " + jl);
+        for(Number n : ((J)jl).getAll("in")) //cast should be redundant - see 7062745
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKL(JKL jkl) { //commented - see 7062745
+        System.out.println("methodJKL(): SAM type interface JKL object instantiated: " + jkl);
+        for(Number n : ((J)jkl).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKLM(JKLM jklm) { //commented - see 7062745
+        System.out.println("methodJKLM(): SAM type interface JKLM object instantiated: " + jklm);
+        for(Number n : ((J)jklm).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 c): SAM type ([File], String, {FileNotFoundException})
+    void methodNO(NO no) {
+        System.out.println("methodNO(): SAM type interface \"NO\" object instantiated: " + no);
+        try {
+            System.out.println("text=" + no.getText(new File("a.txt")));
+            System.out.println("got here, no exception thrown");
+        }
+        catch(FileNotFoundException e){e.printStackTrace();}
+    }
+
+    //type #4 c): SAM type ([File]), String, {})
+    void methodNOP(NOP nop) {
+        System.out.println("methodNOP(): SAM type interface \"NOP\" object instantiated: " + nop);
+        System.out.println("text=" + nop.getText(new File("a.txt")));
+    }
+
+    //type #4 c): SAM type ([String], int, {})
+    void methodBooDoo(BooDoo bd) {
+        System.out.println("methodBooDoo(): SAM type interface BooDoo object instantiated: " + bd);
+        System.out.println("result=" + bd.getAge("lambda"));
+    }
+
+    //type #4 d): SAM type ([Iterable], Iterable<String>, {})
+    void methodQR(QR qr) {
+        System.out.println("methodQR(): SAM type interface QR object instantiated: " + qr);
+        System.out.println("Iterable returned: " + qr.m(new SQLException()));
+    }
+
+    //type #4 d): SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+    void methodUV(UV uv) {
+        System.out.println("methodUV(): SAM type interface UV object instantiated: " + uv);
+        try{
+            System.out.println("result returned: " + uv.foo(strs));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+
+    //type #4 d): SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+    void methodUVW(UVW uvw) {
+        System.out.println("methodUVW(): SAM type interface UVW object instantiated: " + uvw);
+        try{
+            System.out.println("passing List<String>: " + uvw.foo(strs));
+            System.out.println("passing List: " + uvw.foo(new ArrayList()));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile LambdaTest2_SAM3.java Helper.java
+ * @run main LambdaTest2_SAM3
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest2_SAM3 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<Integer> integers = new ArrayList<Integer>();
+
+    public static void main(String[] args) {
+        LambdaTest2_SAM3 test = new LambdaTest2_SAM3();
+
+        //type #7, Not SAM-convertible, through inner class only:
+        test.methodFooBar(new FooBar() {
+                public int getAge(Number n) {
+                    System.out.println("getAge(Number n) called");
+                    return 100;
+                }
+                public int getAge(Integer i) {
+                    System.out.println("getAge(Integer i) called");
+                    return 200;
+                }
+            }
+        );
+
+        //type #7:
+        test.methodDE(new DE(){
+                public int getOldest(List<Integer > list) {
+                    System.out.println("getOldest(List<Integer> list) called");
+                    return 100;
+                }
+                public int getOldest(Collection<?> collection) {
+                    System.out.println("getOldest(Collection<?> collection) called");
+                    return 200;
+                }
+            }
+        );
+
+    }
+
+    //type #7: Not SAM type
+    void methodFooBar(FooBar fb) {
+        System.out.println("methodFooBar(): interface FooBar object instantiated: " + fb);
+        System.out.println("result=" + fb.getAge(new Byte("10")));
+        System.out.println("result=" + fb.getAge(new Integer(10)));
+    }
+
+    //type #7: Not SAM type
+    void methodDE (DE de) {
+        System.out.println("methodDE(): interface DE object instantiated: " + de);
+        System.out.println(de.getOldest(integers));
+        System.out.println(de.getOldest(strs));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile/fail/ref=LambdaTest2_neg1.out -XDrawDiagnostics LambdaTest2_neg1.java Helper.java
+ */
+
+public class LambdaTest2_neg1 {
+
+    public static void main(String[] args) {
+        LambdaTest2_neg1 test = new LambdaTest2_neg1();
+        //not convertible - QooRoo is not a SAM
+        test.methodQooRoo((Integer i) -> { });
+    }
+
+    void methodQooRoo(QooRoo<Integer, Integer, Void> qooroo) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+LambdaTest2_neg1.java:15:13: compiler.err.cant.apply.symbol: kindname.method, methodQooRoo, QooRoo<java.lang.Integer,java.lang.Integer,java.lang.Void>, @531, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, QooRoo)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type 6: An interface that has a single abstract method, which is also public method in Object
+ * @compile/fail/ref=NonSAM1.out -XDrawDiagnostics NonSAM1.java Helper.java
+ */
+
+public class NonSAM1 {
+    void method() {
+        Planet n = (Object o) -> true;
+        System.out.println("never reach here " + n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+NonSAM1.java:11:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, Planet))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+ * @compile/fail/ref=NonSAM2.out -XDrawDiagnostics NonSAM2.java Helper.java
+ */
+
+import java.util.List;
+
+interface Foo1 { int getAge(String s);}
+interface Bar1 { Integer getAge(String s);}
+interface Foo1Bar1 extends Foo1, Bar1 {} //types Bar1 and Foo1 are incompatible; both define getAge(String), but with unrelated return types
+
+interface AC extends A, C {} //name clash: getOldest(List<?>) in C and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+interface ABC extends A, B, C {} //name clash: getOldest(List<?>) in C and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+interface AD extends A, D {} //name clash: getOldest(List<Integer>) in D and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+
+interface Foo2<T> { void m(T arg);}
+interface Bar2<S> { void m(S arg);}
+interface Foo2Bar2<T1, T2> extends Foo2<T1>, Bar2<T2> {} //name clash: m(S) in Bar and m(T) in Foo have the same erasure, yet neither overrides the other
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String)
+NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:16:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<java.lang.Integer>), D, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having overloaded methods due to inheritance
+ * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java
+ */
+
+import java.util.Collection;
+import java.util.List;
+
+public class NonSAM3 {
+    void method() {
+        //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods"
+        FooBar fb = (Number n) -> 100;
+        FooBar fb2 = (Integer i) -> 100;
+        DE de = (List<Integer> list) -> 100;
+        DE de2 = (List<?> list) -> 100;
+        DE de3 = (List list) -> 100;
+        DE de4 = (Collection<Integer> collection) -> 100;
+        DE de5 = (Collection<?> collection) -> 100;
+        DE de6 = (Collection collection) -> 100;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,9 @@
+NonSAM3.java:15:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:16:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:21:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:22:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng InInterface
+ */
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+interface LTII {
+
+    interface ILsp1 {
+        String m();
+    }
+
+    interface ILsp2 {
+        String m(String x);
+    }
+
+    default ILsp1 t1() {
+        return () -> { return "yo"; };
+    }
+
+    default ILsp2 t2() {
+        return (x) -> { return "snur" + x; };
+    }
+
+}
+
+@Test
+public class InInterface implements LTII {
+
+    public void testLambdaInDefaultMethod() {
+        assertEquals(t1().m(), "yo");
+        assertEquals(t2().m("p"), "snurp");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng InnerConstructor
+ */
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+@Test
+public class InnerConstructor  {
+
+    public void testLambdaWithInnerConstructor() {
+        assertEquals(seq1().m().toString(), "Cbl:nada");
+        assertEquals(seq2().m("rats").toString(), "Cbl:rats");
+    }
+
+    Ib1 seq1() {
+        return () -> { return new Cbl(); };
+    }
+
+    Ib2 seq2() {
+        return (x) -> { return new Cbl(x); };
+    }
+
+    class Cbl {
+        String val;
+
+        Cbl() {
+            this.val = "nada";
+        }
+
+        Cbl(String z) {
+            this.val = z;
+        }
+
+        public String toString() {
+            return "Cbl:" + val;
+        }
+    }
+
+    interface Ib1 {
+        Object m();
+    }
+
+    interface Ib2 {
+        Object m(String x);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng LambdaTranslationTest1
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+@Test
+public class LambdaTranslationTest1 extends LT1Sub {
+
+    String cntxt = "blah";
+
+    private static final ThreadLocal<Object> result = new ThreadLocal<>();
+
+    private static void setResult(Object s) { result.set(s); }
+    private static void appendResult(Object s) { result.set(result.get().toString() + s); }
+
+    private static void assertResult(String expected) {
+        assertEquals(result.get().toString(), expected);
+    }
+
+    static Integer count(String s) {
+        return s.length();
+    }
+
+    static int icount(String s) {
+        return s.length();
+    }
+
+    static void eye(Integer i) {
+        setResult(String.format("I:%d", i));
+    }
+
+    static void ieye(int i) {
+        setResult(String.format("i:%d", i));
+    }
+
+    static void deye(double d) {
+        setResult(String.format("d:%f", d));
+    }
+
+    public void testLambdas() {
+        TBlock<Object> b = t -> {setResult("Sink0::" + t);};
+        b.apply("Howdy");
+        assertResult("Sink0::Howdy");
+
+        TBlock<String> b1 = t -> {setResult("Sink1::" + t);};
+        b1.apply("Rowdy");
+        assertResult("Sink1::Rowdy");
+
+        for (int i = 5; i < 10; ++i) {
+            TBlock<Integer> b2 = t -> {setResult("Sink2::" + t);};
+            b2.apply(i);
+            assertResult("Sink2::" + i);
+        }
+
+        TBlock<Integer> b3 = t -> {setResult("Sink3::" + t);};
+        for (int i = 900; i > 0; i -= 100) {
+            b3.apply(i);
+            assertResult("Sink3::" + i);
+        }
+
+        cntxt = "blah";
+        TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
+        b4.apply("Yor");
+        assertResult("b4: blah .. Yor");
+
+        String flaw = "flaw";
+        TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
+        b5.apply("BB");
+        assertResult("b5: flaw .. BB");
+
+        cntxt = "flew";
+        TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
+        b6.apply("flee");
+        assertResult("b6: flee .. flew .. flaw");
+
+        TBlock<String> b7 = t -> {setResult(String.format("b7: %s %s", t, this.protectedSuperclassMethod()));};
+        b7.apply("this:");
+        assertResult("b7: this: instance:flew");
+
+        TBlock<String> b8 = t -> {setResult(String.format("b8: %s %s", t, super.protectedSuperclassMethod()));};
+        b8.apply("super:");
+        assertResult("b8: super: I'm the sub");
+
+        TBlock<String> b7b = t -> {setResult(String.format("b9: %s %s", t, protectedSuperclassMethod()));};
+        b7b.apply("implicit this:");
+        assertResult("b9: implicit this: instance:flew");
+
+        TBlock<Object> b10 = t -> {setResult(String.format("b10: new LT1Thing: %s", (new LT1Thing(t)).str));};
+        b10.apply("thing");
+        assertResult("b10: new LT1Thing: thing");
+
+        TBlock<Object> b11 = t -> {setResult(String.format("b11: %s", (new LT1Thing(t) {
+            String get() {
+                return "*" + str.toString() + "*";
+            }
+        }).get()));};
+        b11.apply(999);
+        assertResult("b11: *999*");
+    }
+
+    public void testMethodRefs() {
+        LT1IA ia = LambdaTranslationTest1::eye;
+        ia.doit(1234);
+        assertResult("I:1234");
+
+        LT1IIA iia = LambdaTranslationTest1::ieye;
+        iia.doit(1234);
+        assertResult("i:1234");
+
+        LT1IA da = LambdaTranslationTest1::deye;
+        da.doit(1234);
+        assertResult("d:1234.000000");
+
+        LT1SA a = LambdaTranslationTest1::count;
+        assertEquals((Integer) 5, a.doit("howdy"));
+
+        a = LambdaTranslationTest1::icount;
+        assertEquals((Integer) 6, a.doit("shower"));
+    }
+
+    public void testInner() throws Exception {
+        (new In()).doInner();
+    }
+
+    protected String protectedSuperclassMethod() {
+        return "instance:" + cntxt;
+    }
+
+    private class In {
+
+        private int that = 1234;
+
+        void doInner() {
+            TBlock<String> i4 = t -> {setResult(String.format("i4: %d .. %s", that, t));};
+            i4.apply("=1234");
+            assertResult("i4: 1234 .. =1234");
+
+            TBlock<String> i5 = t -> {setResult(""); appendResult(t); appendResult(t);};
+            i5.apply("fruit");
+            assertResult("fruitfruit");
+
+            cntxt = "human";
+            TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
+            b4.apply("bin");
+            assertResult("b4: human .. bin");
+
+            final String flaw = "flaw";
+
+/**
+ Callable<String> c5 = () ->  "["+flaw+"]" ;
+ System.out.printf("c5: %s\n", c5.call() );
+ **/
+
+            TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
+            b5.apply("BB");
+            assertResult("b5: flaw .. BB");
+
+            cntxt = "borg";
+            TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
+            b6.apply("flee");
+            assertResult("b6: flee .. borg .. flaw");
+
+            TBlock<String> b7b = t -> {setResult(String.format("b7b: %s %s", t, protectedSuperclassMethod()));};
+            b7b.apply("implicit outer this");
+            assertResult("b7b: implicit outer this instance:borg");
+
+            /**
+             TBlock<Object> b9 = t -> { System.out.printf("New: %s\n", (new LT1Thing(t)).str); };
+             b9.apply("thing");
+
+             TBlock<Object> ba = t -> { System.out.printf("Def: %s\n", (new LT1Thing(t) { String get() { return "*" + str.toString() +"*";}}).get() ); };
+             ba.apply(999);
+
+             */
+        }
+    }
+}
+
+class LT1Sub {
+    protected String protectedSuperclassMethod() {
+        return "I'm the sub";
+    }
+}
+
+class LT1Thing {
+    final Object str;
+
+    LT1Thing(Object s) {
+        str = s;
+    }
+}
+
+interface LT1SA {
+    Integer doit(String s);
+}
+
+interface LT1IA {
+    void doit(int i);
+}
+
+interface LT1IIA {
+    void doit(Integer i);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng LambdaTranslationTest2
+ */
+
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambdaTranslationTest2 -- end-to-end smoke tests for lambda evaluation
+ */
+
+@Test
+public class LambdaTranslationTest2 {
+
+    final String dummy = "dummy";
+
+    public void testLambdas() {
+        TPredicate<String> isEmpty = s -> s.isEmpty();
+        assertTrue(isEmpty.test(""));
+        assertTrue(!isEmpty.test("foo"));
+
+        TPredicate<Object> oIsEmpty = s -> ((String) s).isEmpty();
+        assertTrue(oIsEmpty.test(""));
+        assertTrue(!oIsEmpty.test("foo"));
+
+        TPredicate<Object> alwaysTrue = o -> true;
+        assertTrue(alwaysTrue.test(""));
+        assertTrue(alwaysTrue.test(null));
+
+        TPredicate<Object> alwaysFalse = o -> false;
+        assertTrue(!alwaysFalse.test(""));
+        assertTrue(!alwaysFalse.test(null));
+
+        // tests local capture
+        String foo = "foo";
+        TPredicate<String> equalsFoo = s -> s.equals(foo);
+        assertTrue(!equalsFoo.test(""));
+        assertTrue(equalsFoo.test("foo"));
+
+        // tests instance capture
+        TPredicate<String> equalsDummy = s -> s.equals(dummy);
+        assertTrue(!equalsDummy.test(""));
+        assertTrue(equalsDummy.test("dummy"));
+
+        TMapper<Object, Object> ident = s -> s;
+
+        assertEquals("blarf", ident.map("blarf"));
+        assertEquals("wooga", ident.map("wooga"));
+        assertTrue("wooga" == ident.map("wooga"));
+
+        // constant capture
+        TMapper<Object, Object> prefixer = s -> "p" + s;
+        assertEquals("pblarf", prefixer.map("blarf"));
+        assertEquals("pwooga", prefixer.map("wooga"));
+
+        // instance capture
+        TMapper<Object, Object> prefixer2 = s -> dummy + s;
+        assertEquals("dummyblarf", prefixer2.map("blarf"));
+        assertEquals("dummywooga", prefixer2.map("wooga"));
+    }
+
+    interface Factory<T> {
+        T make();
+    }
+
+    interface StringFactory extends Factory<String> { }
+
+    interface StringFactory2 extends Factory<String> {
+        String make();
+    }
+
+    public void testBridges() {
+        Factory<String> of = () -> "y";
+        Factory<?> ef = () -> "z";
+
+        assertEquals("y", of.make());
+        assertEquals("y", ((Factory<?>) of).make());
+        assertEquals("y", ((Factory) of).make());
+
+        assertEquals("z", ef.make());
+        assertEquals("z", ((Factory) ef).make());
+    }
+
+    public void testBridgesImplicitSpecialization() {
+        StringFactory sf = () -> "x";
+
+        assertEquals("x", sf.make());
+        assertEquals("x", ((Factory<String>) sf).make());
+        assertEquals("x", ((Factory<?>) sf).make());
+        assertEquals("x", ((Factory) sf).make());
+    }
+
+    public void testBridgesExplicitSpecialization() {
+        StringFactory2 sf = () -> "x";
+
+        assertEquals("x", sf.make());
+        assertEquals("x", ((Factory<String>) sf).make());
+        assertEquals("x", ((Factory<?>) sf).make());
+        assertEquals("x", ((Factory) sf).make());
+    }
+
+    public void testSuperCapture() {
+        class A {
+            String make() { return "x"; }
+        }
+
+        class B extends A {
+            void testSuperCapture() {
+                StringFactory sf = () -> super.make();
+                assertEquals("x", sf.make());
+            }
+        }
+
+        new B().testSuperCapture();
+    }
+
+    interface WidenD {
+        public String m(float a0, double a1);
+    }
+
+    interface WidenS {
+        public String m(byte a0, short a1);
+    }
+
+    interface WidenI {
+        public String m(byte a0, short a1, char a2, int a3);
+    }
+
+    interface WidenL {
+        public String m(byte a0, short a1, char a2, int a3, long a4);
+    }
+
+    interface Box {
+        public String m(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7);
+    }
+
+    static String pb(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7) {
+        return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
+    }
+
+    static String pwI1(int a0, int a1, int a2, int a3) {
+        return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
+    }
+
+    static String pwI2(Integer a0, Integer a1, Integer a2, Integer a3) {
+        return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
+    }
+
+    static String pwL1(long a0, long a1, long a2, long a3, long a4) {
+        return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
+    }
+
+    static String pwL2(Long a0, Long a1, Long a2, Long a3, Long a4) {
+        return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
+    }
+
+    static String pwS1(short a0, short a1) {
+        return String.format("b%d s%d", a0, a1);
+    }
+
+    static String pwS2(Short a0, Short a1) {
+        return String.format("b%d s%d", a0, a1);
+    }
+
+    static String pwD1(double a0, double a1) {
+        return String.format("f%f d%f", a0, a1);
+    }
+
+    static String pwD2(Double a0, Double a1) {
+        return String.format("f%f d%f", a0, a1);
+    }
+
+    public void testPrimitiveWidening() {
+        WidenS ws1 = LambdaTranslationTest2::pwS1;
+        assertEquals("b1 s2", ws1.m((byte) 1, (short) 2));
+
+        WidenD wd1 = LambdaTranslationTest2::pwD1;
+        assertEquals("f1.000000 d2.000000", wd1.m(1.0f, 2.0));
+
+        WidenI wi1 = LambdaTranslationTest2::pwI1;
+        assertEquals("b1 s2 c3 i4", wi1.m((byte) 1, (short) 2, (char) 3, 4));
+
+        WidenL wl1 = LambdaTranslationTest2::pwL1;
+        assertEquals("b1 s2 c3 i4 j5", wl1.m((byte) 1, (short) 2, (char) 3, 4, 5L));
+
+        // @@@ TODO: clarify spec on widen+box conversion
+    }
+
+    interface Unbox {
+        public String m(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7);
+    }
+
+    static String pu(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7) {
+        return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
+    }
+
+    public void testUnboxing() {
+        Unbox u = LambdaTranslationTest2::pu;
+        assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
+    }
+
+    public void testBoxing() {
+        Box b = LambdaTranslationTest2::pb;
+        assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
+    }
+
+    static boolean cc(Object o) {
+        return ((String) o).equals("foo");
+    }
+
+    public void testArgCastingAdaptation() {
+        TPredicate<String> p = LambdaTranslationTest2::cc;
+        assertTrue(p.test("foo"));
+        assertTrue(!p.test("bar"));
+    }
+
+    interface SonOfPredicate<T> extends TPredicate<T> { }
+
+    public void testExtendsSAM() {
+        SonOfPredicate<String> p = s -> s.isEmpty();
+        assertTrue(p.test(""));
+        assertTrue(!p.test("foo"));
+    }
+
+    public void testConstructorRef() {
+        Factory<List<String>> lf = ArrayList<String>::new;
+        List<String> list = lf.make();
+        assertTrue(list instanceof ArrayList);
+        assertTrue(list != lf.make());
+        list.add("a");
+        assertEquals("[a]", list.toString());
+    }
+
+    private static String privateMethod() {
+        return "private";
+    }
+
+    public void testPrivateMethodRef() {
+        Factory<String> sf = LambdaTranslationTest2::privateMethod;
+        assertEquals("private", sf.make());
+    }
+
+    private interface PrivateIntf {
+        String make();
+    }
+
+    public void testPrivateIntf() {
+        PrivateIntf p = () -> "foo";
+        assertEquals("foo", p.make());
+    }
+
+    interface Op<T> {
+        public T op(T a, T b);
+    }
+
+    public void testBoxToObject() {
+        Op<Integer> maxer = Math::max;
+        for (int i=-100000; i < 100000; i += 100)
+            for (int j=-100000; j < 100000; j += 99) {
+                assertEquals((int) maxer.op(i,j), Math.max(i,j));
+            }
+    }
+
+    protected static String protectedMethod() {
+        return "protected";
+    }
+
+    public void testProtectedMethodRef() {
+        Factory<String> sf = LambdaTranslationTest2::protectedMethod;
+        assertEquals("protected", sf.make());
+    }
+
+    class Inner1 {
+        String m1() {
+            return "Inner1.m1()";
+        }
+
+        class Inner2 {
+            public String m1() {
+                return "Inner1.Inner2.m1()";
+            }
+
+            protected String m2() {
+                return "Inner1.Inner2.m2()";
+            }
+
+            String m3() {
+                return "Inner1.Inner2.m3()";
+            }
+
+            class Inner3<T> {
+                T t = null;
+                Inner3(T t) {
+                    this.t = t;
+                }
+                T m1() {
+                    return t;
+                }
+            }
+        }
+    }
+
+    public void testInnerClassMethodRef() {
+        Factory<String> fs = new Inner1()::m1;
+        assertEquals("Inner1.m1()", fs.make());
+
+        fs = new Inner1().new Inner2()::m1;
+        assertEquals("Inner1.Inner2.m1()", fs.make());
+
+        fs = new Inner1().new Inner2()::m2;
+        assertEquals("Inner1.Inner2.m2()", fs.make());
+
+        fs = new Inner1().new Inner2()::m3;
+        assertEquals("Inner1.Inner2.m3()", fs.make());
+
+        fs = new Inner1().new Inner2().new Inner3<String>("Inner1.Inner2.Inner3")::m1;
+        assertEquals("Inner1.Inner2.Inner3", fs.make());
+
+        Factory<Integer> fsi = new Inner1().new Inner2().new Inner3<Integer>(100)::m1;
+        assertEquals(100, (int)fsi.make());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/**
+ * Performs operations upon an input object which may modify that object and/or
+ * external state (other objects).
+ *
+ * <p>All block implementations are expected to:
+ * <ul>
+ * <li>When used for aggregate operations upon many elements blocks
+ * should not assume that the {@code apply} operation will be called upon
+ * elements in any specific order.</li>
+ * </ul>
+ *
+ * @param <T> The type of input objects to {@code apply}.
+ */
+public interface TBlock<T> {
+
+    /**
+     * Performs operations upon the provided object which may modify that object
+     * and/or external state.
+     *
+     * @param t an input object
+     */
+    void apply(T t);
+
+    /**
+     * Returns a Block which performs in sequence the {@code apply} methods of
+     * multiple Blocks. This Block's {@code apply} method is performed followed
+     * by the {@code apply} method of the specified Block operation.
+     *
+     * @param other an additional Block which will be chained after this Block
+     * @return a Block which performs in sequence the {@code apply} method of
+     * this Block and the {@code apply} method of the specified Block operation
+     */
+    public default TBlock<T> chain(TBlock<? super T> other) {
+        return (T t) -> { apply(t); other.apply(t); };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/TMapper.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Given an input object maps to an appropriate output object. A mapper may
+ * variously provide a mapping between types, object instances or keys and
+ * values or any other form of transformation upon the input.
+ *
+ * <p/>All mapper implementations are expected to:
+ * <ul>
+ *  <li>Provide stable results such that for any {@code t} the result of two
+ * {@code map} operations are always equivalent. ie.<pre>
+ * Foo one = mapper.map(a);
+ * Foo two = mapper.map(a);
+ *
+ * assert one.equals(two) && two.equals(one);
+ * </pre></li>
+ * <li>Equivalent input objects should map to equivalent output objects. ie.<pre>
+ * assert a.equals(b);  // a and b are equivalent
+ *
+ * Foo x = mapper.map(a);
+ * Foo y = mapper.map(b);
+ *
+ * assert x.equals(y); // their mapped results should be as equivalent.
+ * </pre></li>
+ * <li>The mapper should not modify the input object in any way that would
+ * change the mapping.</li>
+ * <li>When used for aggregate operations upon many elements mappers
+ * should not assume that the {@code map} operation will be called upon elements
+ * in any specific order.</li>
+ * </ul>
+ *
+ * @param <R> the type of output objects from {@code map} operation. May be the
+ * @param <T> the type of input objects provided to the {@code map} operation.
+ * same type as {@code <T>}.
+ */
+public interface TMapper<R, T> {
+
+    /**
+     * Map the provided input object to an appropriate output object.
+     *
+     * @param t the input object to be mapped.
+     * @return the mapped output object.
+     */
+    R map(T t);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/TPredicate.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Determines if the input object matches some criteria.
+ *
+ * <p>All predicate implementations are expected to:
+ * <ul>
+ *  <li>Provide stable results such that for any {@code t} the result of two
+ * {@code eval} operations are always equivalent. ie.<pre>
+ * boolean one = predicate.test(a);
+ * boolean two = predicate.test(a);
+ *
+ * assert one == two;
+ * </pre></li>
+ * <li>Equivalent input objects should map to equivalent output objects. ie.<pre>
+ * assert a.equals(b);  // a and b are equivalent
+ *
+ * boolean x = predicate.test(a);
+ * boolean y = predicate.test(ab;
+ *
+ * assert x == y; // their test results should be the same.
+ * </pre></li>
+ * <li>The predicate should not modify the input object in any way that would
+ * change the evaluation.</li>
+ * <li>When used for aggregate operations upon many elements predicates
+ * should not assume that the {@code test} operation will be called upon
+ * elements in any specific order.</li>
+ * </ul>
+ *
+ * @param <T> the type of input objects provided to {@code test}.
+ */
+public interface TPredicate<T> {
+
+    /**
+     * Return {@code true} if the input object matches some criteria.
+     *
+     * @param t the input object.
+     * @return {@code true} if the input object matched some criteria.
+     */
+     boolean test(T t);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test that lambda conversion is only for SAM interface, not abstract class
+ * @compile/fail/ref=AbstractClass_neg.out -XDrawDiagnostics AbstractClass_neg.java
+ */
+
+public class AbstractClass_neg {
+
+    abstract class SAM {
+        abstract int m();
+    }
+
+    void test() {
+        SAM s = ()-> 6;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+AbstractClass_neg.java:16:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test accessing non-static variable from lambda expressions in static context
+ * @compile/fail/ref=AccessNonStatic_neg.out -XDrawDiagnostics AccessNonStatic_neg.java
+ */
+
+public class AccessNonStatic_neg {
+
+    private int n = 0;
+
+    static {
+        ((Runnable) ()-> {
+            System.out.println(this);
+            System.out.println(n);
+        }).run();
+    }
+
+    public static void test() {
+        ((Runnable) ()-> {
+            Object o = this;
+            n++;
+        }).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+AccessNonStatic_neg.java:15:32: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:16:32: compiler.err.non-static.cant.be.ref: kindname.variable, n
+AccessNonStatic_neg.java:22:24: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:23:13: compiler.err.non-static.cant.be.ref: kindname.variable, n
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Negative test of capture of "effectively final" local variable in lambda expressions
+ * @compile/fail/ref=EffectivelyFinal_neg.out -XDrawDiagnostics EffectivelyFinal_neg.java
+ */
+
+public class EffectivelyFinal_neg {
+
+    void test() {
+        String s = "a";
+        String s2 = "a";
+        int n = 1;
+        ((Runnable)
+            ()-> {
+                s2 = "b"; //re-assign illegal here
+                System.out.println(n);
+                System.out.println(s);
+                s = "b"; // not effectively final
+            }
+        ).run();
+        n = 2; // not effectively final
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+EffectivelyFinal_neg.java:17:17: compiler.err.cant.ref.non.effectively.final.var: s2, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:18:36: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:19:36: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:20:17: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression1.out -XDrawDiagnostics InvalidExpression1.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression1 {
+
+    void test() {
+        Comparator<Number> c = (Number n1, Number n2)-> { 42; }; //not a statement
+        Comparator<Number> c = (Number n1, Number n2)-> { return 42 }; //";" expected
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+InvalidExpression1.java:14:59: compiler.err.not.stmt
+InvalidExpression1.java:15:68: compiler.err.expected: ';'
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression3.out -XDrawDiagnostics InvalidExpression3.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression3 {
+
+    void test() {
+        Comparator<Integer> c2 = (Integer i1, Integer i2) -> { return "0"; }; //return type need to match
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+InvalidExpression3.java:14:71: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression4.out -XDrawDiagnostics InvalidExpression4.java
+ */
+
+public class InvalidExpression4 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (Integer i) -> { }; //parameters not match, boxing not allowed here
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+InvalidExpression4.java:16:17: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression5.out -XDrawDiagnostics InvalidExpression5.java
+ */
+
+public class InvalidExpression5 {
+
+    void test() {
+        Object o = (int n) -> { }; // Invalid target type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+InvalidExpression5.java:12:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression6.out -XDrawDiagnostics InvalidExpression6.java
+ */
+
+public class InvalidExpression6 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (int n) -> { break; }; //break not allowed
+        s = (int n) -> { continue; }; //continue not allowed
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,3 @@
+InvalidExpression6.java:16:30: compiler.err.break.outside.switch.loop
+InvalidExpression6.java:17:26: compiler.err.cont.outside.loop
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for existing SAM interfaces like Runnable and Comparator<T>
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class LambdaTest1 {
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Runnable r) {
+        r.run();
+    }
+
+    void test2(Object o) {
+        if(o instanceof Runnable)
+            ((Runnable)o).run();
+    }
+
+    Runnable test3() {
+        return ()-> { assertionStr += "Runnable6"; };
+    }
+
+    public static void main(String[] args) {
+
+        //lambda expressions for SAM interface Runnable:
+        //assign:
+        Runnable r = ()-> { assertionStr += "Runnable1 "; };
+        r.run();
+
+        //cast:
+        ((Runnable)()-> { assertionStr += "Runnable2 "; }).run();
+
+        Object o = (Runnable)()-> {};
+
+        o = (Runnable)()-> {
+                switch (assertionStr) {
+                    case "Runnable1 Runnable2 ":
+                        assertionStr += "Runnable3 ";
+                        break;
+                    default:
+                        throw new AssertionError();
+                }
+                return;
+            };
+
+        //method parameter:
+        test1(()-> { assertionStr += "Runnable4 "; return; });
+
+        LambdaTest1 test = new LambdaTest1();
+        test.test2((Runnable)()-> { assertionStr += "Runnable5 "; });
+
+        //return type:
+        r = test.test3();
+        r.run();
+
+        assertTrue(assertionStr.equals("Runnable1 Runnable2 Runnable4 Runnable5 Runnable6"));
+
+        //lambda expressions for SAM interface Comparator<T>:
+        List<Integer> list = new ArrayList<Integer>();
+        list.add(4);
+        list.add(10);
+        list.add(-5);
+        list.add(100);
+        list.add(9);
+        Collections.sort(list, (Integer i1, Integer i2)-> i2 - i1);
+        String result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("100 10 9 4 -5 "));
+
+        Collections.sort(list,
+            (i1, i2) -> {
+                String s1 = i1.toString();
+                String s2 = i2.toString();
+                return s1.length() - s2.length();
+             });
+        result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("9 4 10 -5 100 "));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for different method signatures (parameter and return type)
+ * @compile LambdaTest2.java
+ * @run main LambdaTest2
+ */
+
+public class LambdaTest2 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest2 test = new LambdaTest2();
+
+        test.method2((int n) -> { ; });
+        test.method2(n -> { }); // "int" is optional here
+        test.method2((int n) -> { }); // ";" is optional here
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { count += n; });
+        assertTrue(count == 10);
+
+        VoidInt vi = (int i) -> {
+                            switch (i) {
+                                case 0:
+                                    System.out.println("normal");
+                                    break;
+                                default:
+                                    System.out.println("invalid");
+                            }
+                       };
+
+        test.method3(()-> { count++; });
+        test.method3(() -> {});
+        assertTrue(count == 11);
+
+        VoidVoid vv = ()-> { while(true)
+                            if(false)
+                                break;
+                            else
+                                continue;
+                       };
+
+        IntVoid iv1 = () -> 42;
+        IntVoid iv2 = () -> { return 43; };//";" is mandatory here
+        assertTrue(iv1.ivMethod() == 42);
+        assertTrue(iv2.ivMethod() == 43);
+
+        IntInt ii1 = (int n) -> n+1;
+        IntInt ii2 = n -> 42;
+        IntInt ii3 = n -> { return 43; };
+        IntInt ii4 =
+            (int n) -> {
+                if(n > 0)
+                    return n+1;
+                else
+                    return n-1;
+            };
+        assertTrue(ii1.iiMethod(1) == 2);
+        assertTrue(ii2.iiMethod(1) == 42);
+        assertTrue(ii3.iiMethod(1) == 43);
+        assertTrue(ii4.iiMethod(-1) == -2);
+    }
+
+    void method2(VoidInt a) {
+        a.viMethod(10);
+    }
+
+    void method3(VoidVoid a) {
+        a.vvMethod();
+    }
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test capture of "effectively final" local variable in lambda expressions
+ * @compile LambdaTest3.java
+ * @run main LambdaTest3
+ */
+
+public class LambdaTest3 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        final int N = 100;
+        int n = 2; //effectively final variable
+
+        Runnable r = ((Runnable)
+            () -> {
+                count += N;
+                count += n;
+            }
+        );
+        assertTrue(count == 0);
+        r.run();
+        assertTrue(count == 102);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test accessing "this" in lambda expressions
+ * @compile LambdaTest4.java
+ * @run main LambdaTest4
+ */
+
+public class LambdaTest4 {
+
+    private String thisStr;
+    private static int count = 0;
+
+    {
+        ((Runnable)
+            ()-> {
+                this.init();
+                assertTrue(this.toString().equals(thisStr));
+                count++;
+            }
+        ).run();
+    }
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private void init() {
+        thisStr = this.toString();
+    }
+
+    private void m() {
+        String s1 = this.toString();
+        ((Runnable)
+            ()-> {
+                assertTrue(this.toString().equals(thisStr));
+                assertTrue(this.toString().equals(s1));
+            }
+        ).run();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest4 test = new LambdaTest4();
+        assertTrue(count == 1);
+        test.m();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions inside lambda expressions
+ * @compile LambdaTest5.java
+ * @run main LambdaTest5
+ */
+
+public class LambdaTest5 {
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int make (int i);
+    }
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static A a;
+    static A a2;
+    static A a3;
+    static A a4;
+
+    public static void main(String[] args) {
+        B b = (int i) -> ((A)()-> 5).m();
+        assertTrue(b.make(0) == 5);
+
+        a = () -> ((A)()-> { return 6; }).m(); //self reference
+        assertTrue(a.m() == 6);
+
+        a2 = ()-> {
+                  A an = ()-> { return 7; }; //self reference
+                  return an.m();
+                };
+        assertTrue(a2.m() == 7);
+
+        a3 = () -> a3.m(); //self reference
+        try {
+            a3.m();
+        } catch(StackOverflowError e) {
+            count++;
+        }
+        assertTrue(count==1);
+
+        a4 = ()-> ((B)(int i)-> ((A)()-> 9).m() ).make(0);
+        assertTrue(a4.m() == 9);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods for certain SAM conversions
+ * @compile LambdaTest6.java
+ * @run main LambdaTest6
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class LambdaTest6<T> {
+
+    interface H {Object m();}
+
+    interface K<U> {void m(U element);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    private void test1()
+    {
+        L la = s -> { };
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+    }
+
+    private void test2()
+    {
+        KM km = s -> { };
+        //km.m("hi");
+        Class<? extends KM> c2 = km.getClass();
+        Method[] methods = c2.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+
+    private void test3()
+    {
+        N na = ()-> "hi";
+        assertTrue( na.m().equals("hi") );
+        assertTrue( ((H)na).m().equals("hi") );
+        Class<? extends N> c3 = na.getClass();
+        Method[] methods = c3.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+
+
+    public static void main(String[] args) {
+        LambdaTest6 test = new LambdaTest6();
+        test.test1();
+        test.test2();
+        test.test3();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in context of assignment, method call, return statement and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws Exception;
+    }
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Foo foo) {
+        assertTrue(foo.m(1) == 2);
+    }
+
+    private static void test2(Bar bar) {
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return n -> n + 1;
+        case 1:
+            return (Integer n) -> 2 * n;
+        case 2:
+            return (Integer n) -> {return new Integer(n-1);};
+        case 3:
+            return n -> {throw new Exception();};
+        default:
+            return null;
+        }
+    }
+
+    public static void main(String[] args) {
+
+        //assign:
+        Foo foo = (int n) -> n + 1; //explicit type and boxing
+        assertTrue(foo.m(1) == 2);
+
+        foo = n -> n + 1; //type inferrred and boxing
+        assertTrue(foo.m(1) == 2);
+
+        Bar bar = (Integer n) -> n + 1; //explicit type and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = (Integer n) -> new Integer(n+1); //explicit type and unboxing twice
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n.intValue() + 1; //type inferred
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n + 1; // type inferred and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //cast:
+        assertTrue(((Foo)n -> {return n+1;}).m(1) == 2); //statement (instead of expression) in lambda body
+        try {
+            assertTrue(((Bar)n -> {return n+1;}).m(1) == 2); //statement in lambda body
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //method parameter:
+        test1((int n) -> new Integer(n+1)); //explicit type
+        test2((Integer n) -> n.intValue() + 1); //explicit type
+
+        //return statement:
+        bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(3) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(10) == 9);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            bar.m(10);
+            assertTrue(false);
+        } catch (Exception e) {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in combinations of different contexts,
+ *           lambda body types(statement/expression), explict/implicit target type etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(Integer i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+
+        String getParameterType() {
+            switch(this) {
+            case A:
+                return "int";
+            case B:
+            case C:
+                return "Integer";
+            default:
+                return null;
+            }
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #LBody;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "    void method2() {\n" +
+                    "        method1(#LBody);\n" +
+                    "    }"),
+        CONSTRUCTOR("X x = new X(#LBody);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #LBody;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (#FType)#LBody};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#LBody).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#LBody).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #LBody : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, LambdaKind lk, LambdaBody lb, ReturnValue rv) {
+            return context.replace("#FType", f.interfaceType).replace("#LBody", lb.getLambdaBody(f, lk, rv));
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}"),
+        EXCEPTION_STMT("{throw new Exception();}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ReturnValue {
+        INT("i + 1"),
+        INTEGER("new Integer(i+1)"),
+        INT2("i.intValue() + 1"),
+        STRING("i + \"\""),
+        DOUBLE("i * 1.0");
+
+        String rValue;
+
+        ReturnValue(String rValue) {
+            this.rValue = rValue;
+        }
+    }
+
+    enum LambdaBody {
+        IMPLICIT("i -> #RET"),//type inferred
+        EXPLICIT("(#Type i) -> #RET");//explicit type
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(FInterface fi, LambdaKind lk, ReturnValue rv) {
+            return bodyStr.replace("#Type", fi.getParameterType()).replace("#RET", lk.stmt.replace("#VAL", rv.rValue));
+        }
+    }
+
+    boolean checkSamConversion() {
+        if(lambdaKind != LambdaKind.EXCEPTION_STMT && (returnValue == ReturnValue.DOUBLE || returnValue == ReturnValue.STRING)) //return type mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR) {//context other than construcotr argument
+            if(fInterface != FInterface.C && lambdaKind == LambdaKind.EXCEPTION_STMT)
+                return false;
+            if(fInterface == FInterface.A && returnValue == ReturnValue.INT2)
+                return false;
+        }
+        else { //constructor argument context
+            //match X(A a) or X(B b) or X(C c)
+            if (lambdaKind == LambdaKind.EXCEPTION_STMT) {
+                return false; //ambiguous target type
+            }
+            else if(lambdaBody == LambdaBody.IMPLICIT) {
+                if(returnValue != ReturnValue.INTEGER) //ambiguous target type
+                    return false;
+            }
+            else { //explicit parameter type
+                if(fInterface.getParameterType().equals("Integer")) //ambiguous target type
+                //e.g. X x = new X((Integer i) -> i + 1);
+                    return false;
+                if(returnValue == ReturnValue.INT2)
+                //e.g. X x = new X(int i -> i.intValue() + 1);
+                    return false;
+            }
+        }
+        return true;
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(6);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(7);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(8);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n" +
+                            "}";
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, lambdaKind, lambdaBody, returnValue));
+        }
+    };
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + lambdaKind + ", " + lambdaBody + ", " + returnValue);
+        System.out.println(samSourceFile + "\n");
+        String clientFileStr = clientSourceFile.toString();
+        System.out.println(clientFileStr.substring(0, clientFileStr.indexOf("\n\n")));
+
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    LambdaBody lambdaBody;
+    LambdaKind lambdaKind;
+    ReturnValue returnValue;
+    static int count = 0;
+
+    SamConversionComboTest(FInterface f, Context c, LambdaBody lb, LambdaKind lk, ReturnValue rv) {
+        fInterface = f;
+        context = c;
+        lambdaKind = lk;
+        lambdaBody = lb;
+        returnValue = rv;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (LambdaKind lk: LambdaKind.values()) {
+                    for (LambdaBody lb : LambdaBody.values()) {
+                        for(ReturnValue rv : ReturnValue.values()) {
+                            new SamConversionComboTest(fi, ct, lb, lk, rv).test();
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods in certain SAM conversion
+ * @compile BridgeMethod.java
+ * @run main BridgeMethod
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class BridgeMethod {
+
+    interface H {Object m();}
+
+    interface K<T> {void m(T t);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar(String s) {
+        System.out.println("BridgeMethod.bar(String) " + s);
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    private static Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    public static void main(String[] args) {
+        L la = BridgeMethod::bar; //static reference
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        System.out.println("methods in SAM conversion of L:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+
+        KM km = BridgeMethod::bar;
+        //km.m("hi"); //will be uncommented when CR7028808 fixed
+        Class<? extends KM> c2 = km.getClass();
+        methods = c2.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of KM:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?>[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+
+        N n = new BridgeMethod()::moo; //instance reference
+        assertTrue( n.m().equals("moo") );
+        assertTrue( ((H)n).m().equals("moo") );
+        Class<? extends N> c3 = n.getClass();
+        methods = c3.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of N:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?> returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test static method reference
+ * @compile MethodRef1.java
+ * @run main MethodRef1
+ */
+
+public class MethodRef1 {
+
+    static interface A {void m();}
+
+    static interface B {void m(int i);}
+
+    static interface C {String m(String s);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void foo(int x) {
+        System.out.println("MethodRef1.foo(int) " + x);
+    }
+
+    static void bar() {
+        System.out.println("MethodRef1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef1.bar(int) " + x);
+    }
+
+    static String bar(String s) {
+        return "MethodRef1.bar(String) " + s;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef1::bar; //static reference to bar()
+        a.m();
+
+        B b = MethodRef1::foo; //static reference to foo(int), (int) omitted because method foo is not overloaded
+        b.m(1);
+
+        b = MethodRef1::foo; //static reference to foo(int)
+        b.m(1);
+
+        b = new MethodRef1()::foo; //instance reference to static methods, supported for now
+        b.m(1);
+
+        b = MethodRef1::bar; //static reference to bar(int)
+        b.m(2);
+
+        C c = MethodRef1::bar; //static reference to bar(String)
+        assertTrue( c.m("hi").equals("MethodRef1.bar(String) hi") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test instance method reference
+ * @compile MethodRef2.java
+ * @run main MethodRef2
+ */
+
+public class MethodRef2 {
+
+    static interface A {String m();}
+
+    static interface B {String m(int i);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef2 mr = new MethodRef2();
+
+        A a = mr::moo; //instance reference to moo()
+        assertTrue( a.m().equals("moo") );
+
+        a = new MethodRef2()::wahoo; //instance reference to wahoo()
+        assertTrue( a.m().equals("wahoo") );
+
+        B b = mr::wahoo; //instance reference to wahoo(int)
+        assertTrue( b.m(4).equals("wahoo 4") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test unbound method reference
+ * @compile MethodRef3.java
+ * @run main MethodRef3
+ */
+
+public class MethodRef3 {
+
+    static interface A { String m(MethodRef3 mr); }
+
+    static interface B { String m(MethodRef3 mr, String s); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo(String s) {
+        return "wahoo " + s;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef3 mr = new MethodRef3();
+        A a = MethodRef3::moo; //unbound reference to moo()
+        assertTrue( a.m(mr).equals("moo") );
+        B b = MethodRef3::wahoo; //unbound reference to wahoo()
+        assertTrue( b.m(mr, "hi").equals("wahoo hi") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test constructor reference
+ * @compile MethodRef4.java
+ * @run main MethodRef4
+ */
+
+public class MethodRef4 {
+
+    static interface A {Fee<String> m();}
+
+    static interface B {Fee<String> m(String s);}
+
+    static interface C {Object m();}
+
+    static class Fee<T> {
+
+        private T t;
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(T t) {
+            this.t = t;
+            System.out.println("Fee<T> instantiated: " + t);
+        }
+
+        public void make() {
+            System.out.println(this + ": make()");
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        A a = Fee<String>::new; //constructor reference to Fee<T>()
+        a.m().make();
+
+        B b = Fee<String>::new; //constructor reference to Fee<T>(String)
+        b.m("hi").make();
+
+        C c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = Fee<String>::new; //constructor reference to Fee<T>()
+        assertTrue( c.m() instanceof Fee );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test method reference with SAM interface Comparator<T>
+ * @compile MethodRef5.java
+ * @run main MethodRef5
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class MethodRef5 {
+
+    static class Person {
+
+        private String firstName;
+        private String lastName;
+        private int age;
+
+        public Person() { }
+
+        public Person(String fn, String ln, int a) {
+            firstName = fn;
+            lastName = ln;
+            age = a;
+        }
+
+        public String getLastName() {
+            return lastName;
+        }
+
+        public int getAge() {
+            return age;
+        }
+
+        //the following 2 methods are signature-compatible with Comparator<Person>.compare():
+        public static int compareByAge(Person a, Person b) {
+            return a.age - b.age;
+        }
+
+        public int compareByLastName(Person a, Person b) {
+            return a.lastName.compareToIgnoreCase(b.lastName);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        List<Person> persons = new ArrayList<Person>();
+        persons.add(new Person("John", "Smith", 49));
+        persons.add(new Person("Abraham", "Lincoln", 30));
+        persons.add(new Person("George", "Washington", 29));
+        persons.add(new Person("Peter", "Derby", 50));
+        Collections.sort(persons, Person::compareByAge);//static method reference to compareByAge(Person, Person)
+        String age = "";
+        for (Person p : persons) {
+            age += p.getAge() + " ";
+        }
+        assertTrue( (age.equals("29 30 49 50 ")) );
+        Collections.sort(persons, new Person()::compareByLastName);//instance method reference to compareByLastName(Person, Person)
+        String lastName = "";
+        for (Person p : persons) {
+            lastName += p.getLastName() + " ";
+        }
+        assertTrue( lastName.equals("Derby Lincoln Smith Washington ") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef6.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test that the most specific reference is selected when method parameters are elided
+ * @compile MethodRef6.java
+ * @run main MethodRef6
+ */
+
+public class MethodRef6 {
+
+    static interface A { String make(Integer i); }
+
+    static interface B { String make(Number i); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static String m(Object o) {
+        return "Object " + o;
+    }
+
+    static String m(Number n) {
+        return "Number " + n;
+    }
+
+    static String m(Integer i) {
+        return "Integer " + i;
+    }
+
+    static String m(int i) {
+        return "int " + i;
+    }
+
+    public static void main(String[] args) {
+        A a = MethodRef6::m;
+        assertTrue(a.make(1).equals("Integer 1"));//method parameter type inferred from SAM descriptor, boxing applied
+        B b = MethodRef6::m;
+        assertTrue(b.make(1).equals("Number 1"));//method parameter type inferred from SAM descriptor, boxing and widen applied
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef7.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test that parameter types are inferred from SAM descriptor when method parameters are elided,
+             with different types of method references
+ * @compile MethodRef7.java
+ * @run main MethodRef7
+ */
+
+public class MethodRef7 {
+
+    static interface A {void m();}
+
+    static interface A2 {void m(int n);}
+
+    static interface B {String m();}
+
+    static interface B2 {String m(int n);}
+
+    static interface C {String m(MethodRef7 mr);}
+
+    static interface C2 {String m(MethodRef7 mr, int n);}
+
+    static interface D {Fee<String> m();}
+
+    static interface D2 {Fee<String> m(String s);}
+
+    static class Fee<T> {
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(String s) {
+            System.out.println("Fee<T> instantiated: " + s);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar() {
+        System.out.println("MethodRef_neg1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef_neg1.bar(int) " + x);
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef7::bar; //static reference to bar()
+        a.m();
+        A2 a2 = MethodRef7::bar; //static reference to bar(int x)
+        a2.m(10);
+
+        MethodRef7 mr = new MethodRef7();
+        B b = mr::wahoo; //instance reference to wahoo()
+        assertTrue(b.m().equals("wahoo"));
+        B2 b2 = mr::wahoo; //instance reference to wahoo(int x)
+        assertTrue(b2.m(1).equals("wahoo 1"));
+
+        C c = MethodRef7::wahoo; //unbound reference to wahoo()
+        assertTrue(c.m(mr).equals("wahoo"));
+        C2 c2 = MethodRef7::wahoo; //unbound reference to wahoo(int x)
+        assertTrue(c2.m(mr, 2).equals("wahoo 2"));
+
+        D d = Fee<String>::new; //constructor reference to Fee()
+        D2 d2 = Fee<String>::new; //constructor reference to Fee(String s)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This is negative test for wrong parameter/return type in method references
+ * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java
+ */
+
+public class MethodRef_neg {
+
+    static interface A {void m(Integer i);}
+
+    static interface B {void m(String s);}
+
+    static interface C {Integer m();}
+
+    static interface D {String m();}
+
+
+    static void bar(int x) { }
+
+    int foo() {
+        return 5;
+    }
+
+    static void make() { }
+
+    void method() {
+        A a = MethodRef_neg::bar; //boxing on parameter type is ok
+        B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int
+        C c = this::foo; //boxing on return type is ok
+        D d = this::foo; //wrong return type, required: String, actual: int
+        a = MethodRef_neg::make; //missing parameter
+        c = MethodRef_neg::make; //missing return type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,5 @@
+MethodRef_neg.java:30:15: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, bar, int, java.lang.String, kindname.class, MethodRef_neg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int))))
+MethodRef_neg.java:32:15: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int, java.lang.String))
+MethodRef_neg.java:33:13: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, make, compiler.misc.no.args, java.lang.Integer, kindname.class, MethodRef_neg, (compiler.misc.arg.length.mismatch)))
+MethodRef_neg.java:34:13: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: void, java.lang.Integer))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/SamConversion.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in contexts of assignment, method/constructor argument,
+ *           return statement, array initializer, lambda expression body, conditional expression and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static int assertionCount = 0;
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws MyException;
+    }
+
+    private static void assertTrue(boolean b) {
+        assertionCount++;
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static int test1(Foo foo) {
+        return foo.m(1);
+    }
+
+    private static void test2(Bar bar, int result) {
+        try {
+            assertTrue(bar.m(1) == result);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return A::method1;
+        case 1:
+            return new A()::method2;
+        case 2:
+            return A::method3;
+        case 3:
+            return new A()::method4;
+        case 4:
+            return new A()::method5;
+        case 5:
+            return A::method6;
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in assignment context
+     */
+    private static void testAssignment() {
+        Foo foo = A::method1; //static reference, parameter type matching and return type matching
+        assertTrue(foo.m(1) == 2);
+
+        foo = new A()::method2; //instance reference, parameter type unboxing and return type boxing
+        assertTrue(foo.m(1) == 3);
+
+        foo = A::method3; //static reference, parameter type matching and return type boxing
+        assertTrue(foo.m(1) == 4);
+
+        foo = new A()::method4; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 5);
+
+        foo = new A()::method5; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 6);
+
+        Bar bar = A::method1;
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method2;
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = A::method3;
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method4;
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method5;
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method6;
+        try {
+            bar.m(1);
+            assertTrue(false);
+        } catch (MyException e) {
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in method/constructor argument context
+     */
+    private static void testMethodArgument() {
+        assertTrue(test1(A::method1) == 2);
+        assertTrue(test1(new A()::method2) == 3);
+        assertTrue(test1(A::method3) == 4);
+        assertTrue(test1(new A()::method4) == 5);
+        assertTrue(test1(new A()::method5) == 6);
+        test2(A::method1, 2);
+        test2(new A()::method2, 3);
+        test2(A::method3, 4);
+        test2(new A()::method4, 5);
+        test2(new A()::method5, 6);
+        A a = new A(A::method1); //A(Foo f) called
+        assertTrue(a.method2(1) == 11);
+        assertTrue(a.method4(1) == 11);
+        assertTrue(a.method5(1) == 11);
+        A a2 = new A(new A()::method2); //A(Bar b) called
+        assertTrue(a2.method2(1) == 12);
+        assertTrue(a2.method4(1) == 12);
+        assertTrue(a2.method5(1) == 12);
+    }
+
+    /**
+     * Test SAM conversion of method reference in return statement context
+     */
+    private static void testReturnStatement() {
+        Bar bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(4);
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(5);
+        try {
+            bar.m(1);
+            assertTrue(false);
+        } catch (MyException e) {
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in cast context
+     */
+    private static void testCast() {
+        assertTrue(((Foo)A::method1).m(1) == 2);
+        try {
+            assertTrue(((Bar)new A()::method2).m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in array initializer context
+     */
+    private static void testArrayInitializer() {
+        Object[] oarray = {"a", 1, (Foo)A::method3}; //last element need a cast
+        Object[] oarray2 = {"a", 1, (Bar)new A()::method4}; //last element need a cast
+        Foo[] farray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5};
+        Bar[] barray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5, A::method6};
+    }
+
+    /**
+     * Test SAM conversion of method reference in conditional expression context
+     */
+    private static void testConditionalExpression(boolean b) {
+        Foo f = b ? A::method3 : new A()::method5;
+        if(b)
+            assertTrue(f.m(1) == 4);
+        else
+            assertTrue(f.m(1) == 6);
+
+        Bar bar = b ? A::method1 : A::method6;
+        if(b) {
+            try {
+                assertTrue(bar.m(1) == 2);
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+        else {
+            try {
+                bar.m(1);
+                assertTrue(false);
+            } catch (MyException e) {
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in lambda expression body
+     */
+    private static void testLambdaExpressionBody() {
+        Foo f = n -> ((Foo)A::method3).m(n);
+        assertTrue(f.m(1) == 4);
+
+        Bar b = n -> { return ((Foo)new A()::method5).m(n); };
+        try {
+            assertTrue(b.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    public static void main(String[] args) {
+        testAssignment();
+        testMethodArgument();
+        testReturnStatement();
+        testCast();
+        testArrayInitializer();
+        testConditionalExpression(true);
+        testConditionalExpression(false);
+        testLambdaExpressionBody();
+
+        assertTrue(assertionCount == 38);
+    }
+
+    static class MyException extends Exception {}
+
+    static class A {
+
+        int value = 0;
+
+        A() {
+        }
+
+        A(Foo f) {
+            value = f.m(9);
+        }
+
+        A(Bar b) {
+            try {
+                value = b.m(9);
+            } catch (MyException e){}
+        }
+
+        static Integer method1(int n) {
+            return n + 1;
+        }
+
+        int method2(Integer n) {
+            return value == 0 ? n + 2 : n + value;
+        }
+
+        static int method3(int n) {
+            return n + 3;
+        }
+
+        Integer method4(Integer n) {
+            return value == 0 ? n + 4 : n + value;
+        }
+
+        Integer method5(Integer n) {
+            return value == 0 ? new Integer(n + 5) : new Integer(n + value);
+        }
+
+        static int method6(Integer n) throws MyException{
+            throw new MyException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in combinations of different contexts,
+ *           lambda body types(statement/expression), boxing/unboxing etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(int i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #MR;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#MR);\n" +
+                    "}"),
+        CONSTRUCTOR("X x = new X(#MR);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #MR;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("#FType[] oarray = {#MR};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#MR).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#MR).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #MR : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, MethodReference mr) {
+            return context.replace("#FType", f.interfaceType).replace("#MR", mr.mrValue);
+        }
+    }
+
+    enum MethodReference {
+        METHOD1("X::method1"),
+        METHOD2("new X()::method2"),
+        METHOD3("X::method3"),
+        METHOD4("new X()::method4"),
+        METHOD5("new X()::method5"),
+        METHOD6("X::method6"),
+        METHOD7("X::method7"),
+        METHOD8("X::method8");
+
+        String mrValue;
+
+        MethodReference(String mr) {
+            mrValue = mr;
+        }
+    }
+
+    enum MethodDef {
+        METHOD1("    static Integer method1(int n) {\n" +
+                "        return n + 1;\n" +
+                "    }\n", 0),
+        METHOD2("    int method2(Integer n) {\n" +
+                "        return value == 0 ? n + 2 : n + value;\n" +
+                "    }\n", 1),
+        METHOD3("    static int method3(int n) {\n" +
+                "        return n + 3;\n" +
+                "    }\n", 2),
+        METHOD4("    Integer method4(Integer n) {\n" +
+                "        return value == 0 ? n + 4 : n + value;\n" +
+                "    }\n", 3),
+        METHOD5("    Integer method5(Integer n) {\n" +
+                "        return value == 0 ? new Integer(n + 5) : new Integer(n + value);\n" +
+                "    }\n", 4),
+        METHOD6("    static int method6(Integer n) throws Exception{\n" +
+                "        throw new Exception();\n" +
+                "    }\n", 5),
+        METHOD7("    static int method7(String s){\n" +
+                "        return s.length();\n" +
+                "    }\n", 6),
+        METHOD8("    static String method8(Integer n){\n" +
+                "        return n + \"\";\n" +
+                "    }\n", 7);
+
+        String methodStr;
+        int index;
+
+        MethodDef(String ms, int i) {
+            methodStr = ms;
+            index = i;
+        }
+
+        MethodReference getMethodReference() {
+            return MethodReference.values()[index];
+        }
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X() {\n" +
+                            "    }\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(9);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n\n" +
+
+                            "#MethodDef" +
+                            "}";
+
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, methodReference)).replace("#MethodDef", methodDef.methodStr);
+        }
+    };
+
+    boolean checkSamConversion() {
+        if(methodDef == MethodDef.METHOD7 || methodDef == MethodDef.METHOD8)//method signature mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR && fInterface != FInterface.C && methodDef == MethodDef.METHOD6)
+        //method that throws exceptions not thrown by the interface method is a mismatch
+            return false;
+        if(context == Context.CONSTRUCTOR &&
+           methodReference != MethodReference.METHOD1 &&
+           methodReference != MethodReference.METHOD2 &&
+           methodReference != MethodReference.METHOD3)//ambiguous reference
+               return false;
+        return true;
+    }
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + methodReference);
+        System.out.println(samSourceFile + "\n" + clientSourceFile);
+
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    MethodDef methodDef;
+    MethodReference methodReference;
+    static int count = 0;
+
+    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    SamConversionComboTest(FInterface f, Context c, MethodDef md) {
+        fInterface = f;
+        context = c;
+        methodDef = md;
+        methodReference = md.getMethodReference();
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (MethodDef md: MethodDef.values()) {
+                    new SamConversionComboTest(fi, ct, md).test();
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestFDCCE
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/**
+ * Method references and raw types.
+ * @author Robert Field
+ */
+
+@Test
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class MethodReferenceTestFDCCE {
+
+    static void assertCCE(Throwable t) {
+        assertEquals(t.getClass().getName(), "java.lang.ClassCastException");
+    }
+
+    interface Pred<T> { boolean accept(T x); }
+
+    interface Ps { boolean accept(short x); }
+
+    interface Oo { Object too(int x); }
+
+    interface Reto<T> { T m(); }
+
+    class A {}
+    class B extends A {}
+
+    static boolean isMinor(int x) {
+        return x < 18;
+    }
+
+    static boolean tst(A x) {
+        return true;
+    }
+
+    static Object otst(Object x) {
+        return x;
+    }
+
+    static boolean stst(Short x) {
+        return x < 18;
+    }
+
+    static short ritst() {
+        return 123;
+    }
+
+    public void testMethodReferenceFDPrim1() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        assertTrue(p2.accept((Byte)(byte)15));
+    }
+
+    public void testMethodReferenceFDPrim2() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        assertTrue(p2.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimICCE() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        try {
+            p2.accept(15); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDPrimOCCE() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        try {
+            p2.accept(new Object()); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDRef() {
+        Pred<B> p = MethodReferenceTestFDCCE::tst;
+        Pred p2 = p;
+        assertTrue(p2.accept(new B()));
+    }
+
+    public void testMethodReferenceFDRefCCE() {
+        Pred<B> p = MethodReferenceTestFDCCE::tst;
+        Pred p2 = p;
+        try {
+            p2.accept(new A()); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDPrimPrim() {
+        Ps p = MethodReferenceTestFDCCE::isMinor;
+        assertTrue(p.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimBoxed() {
+        Ps p = MethodReferenceTestFDCCE::stst;
+        assertTrue(p.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimRef() {
+        Oo p = MethodReferenceTestFDCCE::otst;
+        assertEquals(p.too(15).getClass().getName(), "java.lang.Integer");
+    }
+
+    public void testMethodReferenceFDRet1() {
+        Reto<Short> p = MethodReferenceTestFDCCE::ritst;
+        assertEquals(p.m(), (Short)(short)123);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerDefault
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface IDSs { String m(String a); }
+
+interface InDefA {
+    default String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    default String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+}
+
+interface InDefB extends InDefA {
+
+    default String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    default String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+}
+
+@Test
+public class MethodReferenceTestInnerDefault implements InDefB {
+
+    public void testMethodReferenceInnerDefault() {
+        (new In()).testMethodReferenceInnerDefault();
+    }
+
+    class In {
+
+        public void testMethodReferenceInnerDefault() {
+            IDSs q;
+
+            q = MethodReferenceTestInnerDefault.this::xsA__;
+            assertEquals(q.m("*"), "A__xsA:*");
+
+            q = MethodReferenceTestInnerDefault.this::xsAB_;
+            assertEquals(q.m("*"), "AB_xsB:*");
+
+            q = MethodReferenceTestInnerDefault.this::xs_B_;
+            assertEquals(q.m("*"), "_B_xsB:*");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerInstance
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestInnerInstance {
+
+    public void testMethodReferenceInnerInstance() {
+        cia().cib().testMethodReferenceInstance();
+    }
+
+    public void testMethodReferenceInnerExternal() {
+        cia().cib().testMethodReferenceExternal();
+    }
+
+    interface SI {
+        String m(Integer a);
+    }
+
+    class CIA {
+
+        String xI(Integer i) {
+            return "xI:" + i;
+        }
+
+        public class CIB {
+
+            public void testMethodReferenceInstance() {
+                SI q;
+
+                q = CIA.this::xI;
+                assertEquals(q.m(55), "xI:55");
+            }
+
+            public void testMethodReferenceExternal() {
+                SI q;
+
+                q = (new E())::xI;
+                assertEquals(q.m(77), "ExI:77");
+            }
+        }
+
+        CIB cib() {
+            return new CIB();
+        }
+
+        class E {
+
+            String xI(Integer i) {
+                return "ExI:" + i;
+            }
+        }
+
+    }
+
+    CIA cia() {
+        return new CIA();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerVarArgsThis
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestInnerVarArgsThis {
+
+    interface NsII {
+
+        String m(Integer a, Integer b);
+    }
+
+    interface Nsiii {
+
+        String m(int a, int b, int c);
+    }
+
+    interface Nsi {
+
+        String m(int a);
+    }
+
+    interface NsaO {
+
+        String m(Object[] a);
+    }
+
+    interface Nsai {
+
+        String m(int[] a);
+    }
+
+    interface Nsvi {
+
+        String m(int... va);
+    }
+
+    class CIA {
+
+        String xvI(Integer... vi) {
+            StringBuilder sb = new StringBuilder("xvI:");
+            for (Integer i : vi) {
+                sb.append(i);
+                sb.append("-");
+            }
+            return sb.toString();
+        }
+
+        String xIvI(Integer f, Integer... vi) {
+            StringBuilder sb = new StringBuilder("xIvI:");
+            sb.append(f);
+            for (Integer i : vi) {
+                sb.append(i);
+                sb.append("-");
+            }
+            return sb.toString();
+        }
+
+        String xvi(int... vi) {
+            int sum = 0;
+            for (int i : vi) {
+                sum += i;
+            }
+            return "xvi:" + sum;
+        }
+
+        String xIvi(Integer f, int... vi) {
+            int sum = 0;
+            for (int i : vi) {
+                sum += i;
+            }
+            return "xIvi:(" + f + ")" + sum;
+        }
+
+        String xvO(Object... vi) {
+            StringBuilder sb = new StringBuilder("xvO:");
+            for (Object i : vi) {
+                if (i.getClass().isArray()) {
+                    sb.append("[");
+                    int len = Array.getLength(i);
+                    for (int x = 0; x < len; ++x) {
+                        sb.append(Array.get(i, x));
+                        sb.append(",");
+                    }
+                    sb.append("]");
+
+                } else {
+                    sb.append(i);
+                }
+                sb.append("*");
+            }
+            return sb.toString();
+        }
+
+        public class CIB {
+
+            // These should be processed as var args
+            public void testVarArgsNsSuperclass() {
+                NsII q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(55, 66), "xvO:55*66*");
+            }
+
+            public void testVarArgsNsArray() {
+                Nsai q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(new int[]{55, 66}), "xvO:[55,66,]*");
+            }
+
+            public void testVarArgsNsII() {
+                NsII q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(33, 7), "xvI:33-7-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(50, 40), "xIvI:5040-");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(100, 23), "xvi:123");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(9, 21), "xIvi:(9)21");
+            }
+
+            public void testVarArgsNsiii() {
+                Nsiii q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(900, 80, 7), "xvi:987");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(333, 27, 72), "xIvi:(333)99");
+            }
+
+            public void testVarArgsNsi() {
+                Nsi q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(3), "xvI:3-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(888), "xIvI:888");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(900), "xvi:900");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(333), "xIvi:(333)0");
+            }
+
+            // These should NOT be processed as var args
+            public void testVarArgsNsaO() {
+                NsaO q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(new String[]{"yo", "there", "dude"}), "xvO:yo*there*dude*");
+            }
+        }
+
+        CIB cib() {
+            return new CIB();
+        }
+
+        class E {
+
+            String xI(Integer i) {
+                return "ExI:" + i;
+            }
+        }
+    }
+
+    CIA cia() {
+        return new CIA();
+    }
+
+    // These should be processed as var args
+    public void testVarArgsNsSuperclass() {
+        cia().cib().testVarArgsNsSuperclass();
+    }
+
+    public void testVarArgsNsArray() {
+        cia().cib().testVarArgsNsArray();
+    }
+
+    public void testVarArgsNsII() {
+        cia().cib().testVarArgsNsII();
+    }
+
+    public void testVarArgsNsiii() {
+        cia().cib().testVarArgsNsiii();
+    }
+
+    public void testVarArgsNsi() {
+        cia().cib().testVarArgsNsi();
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNsaO() {
+        cia().cib().testVarArgsNsaO();
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInstance
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestInstance_E {
+    String xI(Integer i) {
+        return "ExI:" + i;
+    }
+}
+
+@Test
+public class MethodReferenceTestInstance {
+
+    interface SI { String m(Integer a); }
+
+    String xI(Integer i) {
+        return "xI:" + i;
+    }
+
+    public void testMethodReferenceInstance() {
+        SI q;
+
+        q = this::xI;
+        assertEquals(q.m(55), "xI:55");
+    }
+
+    public void testMethodReferenceExternal() {
+        SI q;
+
+        q = (new MethodReferenceTestInstance_E())::xI;
+        assertEquals(q.m(77), "ExI:77");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestKinds
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup {
+
+    interface S0 { String get(); }
+    interface S1 { String get(MethodReferenceTestKinds x); }
+    interface S2 { String get(MethodReferenceTestKinds x, MethodReferenceTestKinds y); }
+
+    interface SXN0 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x); }
+    interface SXN1 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x, String str); }
+
+    interface SN0 { MethodReferenceTestKindsBase make(); }
+    interface SN1 { MethodReferenceTestKindsBase make(String x); }
+
+    class In extends MethodReferenceTestKindsBase {
+        In(String val) {
+            this.val = val;
+        }
+
+        In() {
+            this("blank");
+        }
+    }
+
+    String instanceMethod0() { return "IM:0-" + this; }
+    String instanceMethod1(MethodReferenceTestKinds x) { return "IM:1-" + this + x; }
+
+    static String staticMethod0() { return "SM:0"; }
+    static String staticMethod1(MethodReferenceTestKinds x) { return "SM:1-" + x; }
+
+    MethodReferenceTestKinds(String val) {
+        super(val);
+    }
+
+    MethodReferenceTestKinds() {
+        super("blank");
+    }
+
+    MethodReferenceTestKinds inst(String val) {
+        return new MethodReferenceTestKinds(val);
+    }
+
+    public void testMRBound() {
+        S0 var = this::instanceMethod0;
+        assertEquals(var.get(), "IM:0-MethodReferenceTestKinds(blank)");
+    }
+
+    public void testMRBoundArg() {
+        S1 var = this::instanceMethod1;
+        assertEquals(var.get(inst("arg")), "IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRUnbound() {
+        S1 var = MethodReferenceTestKinds::instanceMethod0;
+        assertEquals(var.get(inst("rcvr")), "IM:0-MethodReferenceTestKinds(rcvr)");
+    }
+
+    public void testMRUnboundArg() {
+        S2 var = MethodReferenceTestKinds::instanceMethod1;
+        assertEquals(var.get(inst("rcvr"), inst("arg")), "IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRSuper() {
+        S0 var = super::instanceMethod0;
+        assertEquals(var.get(), "SIM:0-MethodReferenceTestKinds(blank)");
+    }
+
+    public void testMRSuperArg() {
+        S1 var = super::instanceMethod1;
+        assertEquals(var.get(inst("arg")), "SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRStatic() {
+        S0 var = MethodReferenceTestKinds::staticMethod0;
+        assertEquals(var.get(), "SM:0");
+    }
+
+    public void testMRStaticArg() {
+        S1 var = MethodReferenceTestKinds::staticMethod1;
+        assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRStaticEval() {
+        MethodReferenceTestKinds evalCheck;
+        S0 var = (evalCheck = inst("discard"))::staticMethod0;
+        assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)");
+        assertEquals(var.get(), "SM:0");
+    }
+
+    public void testMRStaticEvalArg() {
+        MethodReferenceTestKinds evalCheck;
+        S1 var = (evalCheck = inst("discard"))::staticMethod1;
+        assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)");
+        assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRTopLevel() {
+        SN0 var = MethodReferenceTestKindsBase::new;
+        assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)");
+    }
+
+    public void testMRTopLevelArg() {
+        SN1 var = MethodReferenceTestKindsBase::new;
+        assertEquals(var.make("name").toString(), "MethodReferenceTestKindsBase(name)");
+    }
+/* unbound inner case not supported anymore (dropped by EG)
+    public void testMRUnboundInner() {
+        SXN0 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make(inst("out")).toString(), "In(blank)");
+    }
+
+   public void testMRUnboundInnerArg() {
+        SXN1 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make(inst("out"), "name").toString(), "In(name)");
+    }
+*/
+    public void testMRImplicitInner() {
+        SN0 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make().toString(), "In(blank)");
+    }
+
+    public void testMRImplicitInnerArg() {
+        SN1 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make("name").toString(), "In(name)");
+    }
+
+}
+
+
+class MethodReferenceTestKindsBase {
+    String val = "unset";
+
+    public String toString() {
+        return getClass().getSimpleName() + "(" + val + ")";
+    }
+
+    MethodReferenceTestKindsBase(String val) {
+        this.val = val;
+    }
+
+    MethodReferenceTestKindsBase() {
+        this("blank");
+    }
+
+}
+
+class MethodReferenceTestKindsSup extends MethodReferenceTestKindsBase {
+    String instanceMethod0() { return "SIM:0-" + this; }
+    String instanceMethod1(MethodReferenceTestKinds x) { return "SIM:1-" + this + x; }
+
+    MethodReferenceTestKindsSup(String val) {
+        super(val);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestNew
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestNew {
+
+    interface M0<T> {
+
+        T m();
+    }
+
+    static class N0 {
+
+        N0() {
+        }
+    }
+
+    interface M1<T> {
+
+        T m(Integer a);
+    }
+
+    static class N1 {
+
+        int i;
+
+        N1(int i) {
+            this.i = i;
+        }
+    }
+
+    interface M2<T> {
+
+        T m(Integer n, String o);
+    }
+
+    static class N2 {
+
+        Number n;
+        Object o;
+
+        N2(Number n, Object o) {
+            this.n = n;
+            this.o = o;
+        }
+
+        public String toString() {
+            return "N2(" + n + "," + o + ")";
+        }
+    }
+
+    interface MV {
+
+        NV m(Integer ai, int i);
+    }
+
+    static class NV {
+
+        int i;
+
+        NV(int... v) {
+            i = 0;
+            for (int x : v) {
+                i += x;
+            }
+        }
+
+        public String toString() {
+            return "NV(" + i + ")";
+        }
+    }
+
+    public void testConstructorReference0() {
+        M0<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m().getClass().getSimpleName(), "N0");
+    }
+
+    public void testConstructorReference1() {
+        M1<N1> q;
+
+        q = N1::new;
+        assertEquals(q.m(14).getClass().getSimpleName(), "N1");
+    }
+
+    public void testConstructorReference2() {
+        M2<N2> q;
+
+        q = N2::new;
+        assertEquals(q.m(7, "hi").toString(), "N2(7,hi)");
+    }
+
+    public void testConstructorReferenceVarArgs() {
+        MV q;
+
+        q = NV::new;
+        assertEquals(q.m(5, 45).toString(), "NV(50)");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestNewInner
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestNewInner {
+
+    String note = "NO NOTE";
+
+    interface M0<T> {
+
+        T m();
+    }
+
+    interface MP<T> {
+
+        T m(MethodReferenceTestNewInner m);
+    }
+
+    class N0 {
+
+        N0() {
+        }
+    }
+
+    interface M1<T> {
+
+        T m(Integer a);
+    }
+
+    class N1 {
+
+        int i;
+
+        N1(int i) {
+            this.i = i;
+        }
+    }
+
+    interface M2<T> {
+
+        T m(Integer n, String o);
+    }
+
+    class N2 {
+
+        Number n;
+        Object o;
+
+        N2(Number n, Object o) {
+            this.n = n;
+            this.o = o;
+        }
+
+        public String toString() {
+            return note + ":N2(" + n + "," + o + ")";
+        }
+    }
+
+    interface MV {
+
+        NV m(Integer ai, int i);
+    }
+
+    class NV {
+
+        int i;
+
+        NV(int... v) {
+            i = 0;
+            for (int x : v) {
+                i += x;
+            }
+        }
+
+        public String toString() {
+            return note + ":NV(" + i + ")";
+        }
+    }
+
+/* unbound constructor case not supported anymore (dropped by EG)
+    public static void testConstructorReferenceP() {
+        MP<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m(new MethodReferenceTestNewInner()).getClass().getSimpleName(), "N0");
+    }
+*/
+    public void testConstructorReference0() {
+        M0<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m().getClass().getSimpleName(), "N0");
+    }
+
+    public void testConstructorReference1() {
+        M1<N1> q;
+
+        q = N1::new;
+        assertEquals(q.m(14).getClass().getSimpleName(), "N1");
+    }
+
+    public void testConstructorReference2() {
+        M2<N2> q;
+
+        note = "T2";
+        q = N2::new;
+        assertEquals(q.m(7, "hi").toString(), "T2:N2(7,hi)");
+    }
+
+    /***
+    public void testConstructorReferenceVarArgs() {
+        MV q;
+
+        note = "TVA";
+        q = NV::new;
+        assertEquals(q.m(5, 45).toString(), "TNV:NV(50)");
+    }
+    ***/
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase1
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestSueCase1 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    String instanceMethod(String s) { return "2"; }
+    Sam2<MethodReferenceTestSueCase1> var = MethodReferenceTestSueCase1::instanceMethod;
+
+    String m() {  return var.get(new MethodReferenceTestSueCase1(), ""); }
+
+    public void testSueCase1() {
+        assertEquals(m(), "2");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase2
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestSueCase2 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    String instanceMethod(String s) { return "2"; }
+    static Sam2<MethodReferenceTestSueCase2> var = MethodReferenceTestSueCase2::instanceMethod;
+
+    String m() {  return var.get(new MethodReferenceTestSueCase2(), ""); }
+
+    public void testSueCase2() {
+        assertEquals(m(), "2");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase4
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestSueCase4 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    Sam2<Target> var = new Object().equals(new Object()) ? Target::instanceMethod : Target::instanceMethod;
+
+    String m() {
+        return var.get(new Target(), "");
+    }
+
+    static class Target {
+        String instanceMethod(String s) { return "2"; }
+    }
+
+    public void testSueCase4() {
+        assertEquals(m(), "2");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSuper
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface SPRI { String m(String a); }
+
+class SPRA {
+    String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    String xsA_M(String s) {
+        return "A_MxsA:" + s;
+    }
+
+    String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+    String xsABM(String s) {
+        return "ABMxsA:" + s;
+    }
+
+}
+
+class SPRB extends SPRA {
+
+    String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    String xsABM(String s) {
+        return "ABMxsB:" + s;
+    }
+
+    String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+
+    String xs_BM(String s) {
+        return "_BMxsB:" + s;
+    }
+
+}
+
+@Test
+public class MethodReferenceTestSuper extends SPRB {
+
+    String xsA_M(String s) {
+        return "A_MxsM:" + s;
+    }
+
+
+    String xsABM(String s) {
+        return "ABMxsM:" + s;
+    }
+
+    String xs_BM(String s) {
+        return "_BMxsM:" + s;
+    }
+
+    public void testMethodReferenceSuper() {
+        SPRI q;
+
+        q = super::xsA__;
+        assertEquals(q.m("*"), "A__xsA:*");
+
+        q = super::xsA_M;
+        assertEquals(q.m("*"), "A_MxsA:*");
+
+        q = super::xsAB_;
+        assertEquals(q.m("*"), "AB_xsB:*");
+
+        q = super::xsABM;
+        assertEquals(q.m("*"), "ABMxsB:*");
+
+        q = super::xs_B_;
+        assertEquals(q.m("*"), "_B_xsB:*");
+
+        q = super::xs_BM;
+        assertEquals(q.m("*"), "_BMxsB:*");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSuperDefault
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface DSPRI { String m(String a); }
+
+interface DSPRA {
+    default String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    default String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+}
+
+interface DSPRB extends DSPRA {
+
+    default String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    default String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+
+}
+
+@Test
+public class MethodReferenceTestSuperDefault implements DSPRB {
+
+    public void testMethodReferenceSuper() {
+        DSPRI q;
+
+        q = DSPRB.super::xsA__;
+        assertEquals(q.m("*"), "A__xsA:*");
+
+        q = DSPRB.super::xsAB_;
+        assertEquals(q.m("*"), "AB_xsB:*");
+
+        q = DSPRB.super::xs_B_;
+        assertEquals(q.m("*"), "_B_xsB:*");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestTypeConversion
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestTypeConversion_E<T> {
+    T xI(T t) { return t; }
+}
+
+@Test
+public class MethodReferenceTestTypeConversion {
+
+    interface ISi { int m(Short a); }
+
+    interface ICc { char m(Character a); }
+
+    public void testUnboxObjectToNumberWiden() {
+        ISi q = (new MethodReferenceTestTypeConversion_E<Short>())::xI;
+        assertEquals(q.m((short)77), (short)77);
+    }
+
+    public void testUnboxObjectToChar() {
+        ICc q = (new MethodReferenceTestTypeConversion_E<Character>())::xI;
+        assertEquals(q.m('@'), '@');
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgs
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestVarArgs {
+
+    interface SII {
+
+        String m(Integer a, Integer b);
+    }
+
+    interface Siii {
+
+        String m(int a, int b, int c);
+    }
+
+    interface Si {
+
+        String m(int a);
+    }
+
+    interface SaO {
+
+        String m(Object[] a);
+    }
+
+    interface Sai {
+
+        String m(int[] a);
+    }
+
+    interface Svi {
+
+        String m(int... va);
+    }
+
+    // These should be processed as var args
+
+    static String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    static String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    static String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    static String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    static String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+    public void testVarArgsSuperclass() {
+        SII q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsArray() {
+        Sai q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsII() {
+        SII q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsiii() {
+        Siii q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsi() {
+        Si q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsaO() {
+        SaO q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsExt
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface NXII { String m(Integer a, Integer b); }
+
+interface NXiii { String m(int a, int b, int c); }
+
+interface NXi { String m(int a); }
+
+interface NXaO { String m(Object[] a); }
+
+interface NXai { String m(int[] a); }
+
+interface NXvi { String m(int... va); }
+
+@Test
+public class MethodReferenceTestVarArgsExt {
+
+    // These should be processed as var args
+
+    public void testVarArgsNXSuperclass() {
+        NXII q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsNXArray() {
+        NXai q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsNXII() {
+        NXII q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsNXiii() {
+        NXiii q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsNXi() {
+        NXi q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNXaO() {
+        NXaO q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
+
+class Ext {
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsSuper
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestVarArgsSuper_Sub {
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+}
+
+@Test
+public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsSuper_Sub {
+
+    interface SPRII { String m(Integer a, Integer b); }
+
+    interface SPRiii { String m(int a, int b, int c); }
+
+    interface SPRi { String m(int a); }
+
+    interface SPRaO { String m(Object[] a); }
+
+    interface SPRai { String m(int[] a); }
+
+    interface SPRvi { String m(int... va); }
+
+    String xvI(Integer... vi) {
+        return "ERROR";
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        return "ERROR";
+    }
+
+    String xvi(int... vi) {
+        return "ERROR";
+    }
+
+    String xIvi(Integer f, int... vi) {
+        return "ERROR";
+   }
+
+    String xvO(Object... vi) {
+        return "ERROR";
+    }
+
+    // These should be processed as var args
+
+    public void testVarArgsSPRSuperclass() {
+        SPRII q;
+
+        q = super::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsSPRArray() {
+        SPRai q;
+
+        q = super::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsSPRII() {
+        SPRII q;
+
+        q = super::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = super::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = super::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = super::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsSPRiii() {
+        SPRiii q;
+
+        q = super::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = super::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = super::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = super::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsSPRi() {
+        SPRi q;
+
+        q = super::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = super::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = super::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = super::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsSPRaO() {
+        SPRaO q;
+
+        q = super::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsSuperDefault
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface MethodReferenceTestVarArgsSuperDefault_I {
+
+    default String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    default String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    default String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    default String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    default String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+}
+
+@Test
+public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTestVarArgsSuperDefault_I {
+
+    interface DSPRII { String m(Integer a, Integer b); }
+
+    interface DSPRiii { String m(int a, int b, int c); }
+
+    interface DSPRi { String m(int a); }
+
+    interface DSPRaO { String m(Object[] a); }
+
+    interface DSPRai { String m(int[] a); }
+
+    interface DSPRvi { String m(int... va); }
+
+    // These should be processed as var args
+
+    public void testVarArgsSPRSuperclass() {
+        DSPRII q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsSPRArray() {
+        DSPRai q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsSPRII() {
+        DSPRII q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsSPRiii() {
+        DSPRiii q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsSPRi() {
+        DSPRi q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsSPRaO() {
+        DSPRaO q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsThis
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface NsII { String m(Integer a, Integer b); }
+
+interface Nsiii { String m(int a, int b, int c); }
+
+interface Nsi { String m(int a); }
+
+interface NsaO { String m(Object[] a); }
+
+interface Nsai { String m(int[] a); }
+
+interface Nsvi { String m(int... va); }
+
+@Test
+public class MethodReferenceTestVarArgsThis {
+
+    // These should be processed as var args
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+    public void testVarArgsNsSuperclass() {
+        NsII q;
+
+        q = this::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsNsArray() {
+        Nsai q;
+
+        q = this::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsNsII() {
+        NsII q;
+
+        q = this::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = this::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = this::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = this::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsNsiii() {
+        Nsiii q;
+
+        q = this::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = this::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = this::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = this::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsNsi() {
+        Nsi q;
+
+        q = this::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = this::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = this::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = this::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNsaO() {
+        NsaO q;
+
+        q = this::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Automatic test for checking correctness of structural most specific test routine
+ * @run main/timeout=360 StructuralMostSpecificTest
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class StructuralMostSpecificTest {
+
+    static int checkCount = 0;
+
+    enum RetTypeKind {
+        SHORT("short"),
+        INT("int"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        VOID("void"),
+        J_L_VOID("Void");
+
+        String retTypeStr;
+
+        RetTypeKind(String retTypeStr) {
+            this.retTypeStr = retTypeStr;
+        }
+
+        boolean moreSpecificThan(RetTypeKind rk) {
+            return moreSpecificThan[this.ordinal()][rk.ordinal()];
+        }
+
+        static boolean[][] moreSpecificThan = {
+                //              SHORT |  INT  | OBJECT | INTEGER | VOID  | J_L_VOID
+                /* SHORT */   { true  , true  , true   , false   , false , false },
+                /* INT */     { false , true  , true   , true    , false , false },
+                /* OBJECT */  { false , false , true   , false   , false , false },
+                /* INTEGER */ { false , false , true   , true    , false , false },
+                /* VOID */    { false , false , false  , false   , true  , true  },
+                /* J_L_VOID */{ false , false , true   , false   , false , true  } };
+    }
+
+    enum ArgTypeKind {
+        SHORT("short"),
+        INT("int"),
+        BOOLEAN("boolean"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        DOUBLE("Double");
+
+        String argTypeStr;
+
+        ArgTypeKind(String typeStr) {
+            this.argTypeStr = typeStr;
+        }
+    }
+
+    enum ExceptionKind {
+        NONE(""),
+        EXCEPTION("throws Exception"),
+        SQL_EXCEPTION("throws java.sql.SQLException"),
+        IO_EXCEPTION("throws java.io.IOException");
+
+        String exceptionStr;
+
+        ExceptionKind(String exceptionStr) {
+            this.exceptionStr = exceptionStr;
+        }
+    }
+
+    enum LambdaReturnKind {
+        VOID("return;"),
+        SHORT("return (short)0;"),
+        INT("return 0;"),
+        INTEGER("return (Integer)null"),
+        NULL("return null;");
+
+        String retStr;
+
+        LambdaReturnKind(String retStr) {
+            this.retStr = retStr;
+        }
+
+        boolean compatibleWith(RetTypeKind rk) {
+            return compatibleWith[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] compatibleWith = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , true  , false   , false   , false },
+                /* INT */     { false , true  , true    , true    , false },
+                /* OBJECT */  { false , true  , true    , true    , true  },
+                /* INTEGER */ { false , false , true    , true    , true  },
+                /* VOID */    { true  , false , false   , false   , false },
+                /* J_L_VOID */{ false , false , false   , false   , true  } };
+
+        boolean needsConversion(RetTypeKind rk) {
+            return needsConversion[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] needsConversion = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , false , false   , false   , false },
+                /* INT */     { false , false , false   , true    , false },
+                /* OBJECT */  { false , true  , true    , false   , false },
+                /* INTEGER */ { false , false , true    , false   , false },
+                /* VOID */    { false , false , false   , false   , false },
+                /* J_L_VOID */{ true  , false , false   , false   , false } };
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (LambdaReturnKind lrk : LambdaReturnKind.values()) {
+            for (RetTypeKind rk1 : RetTypeKind.values()) {
+                for (RetTypeKind rk2 : RetTypeKind.values()) {
+                    for (ExceptionKind ek1 : ExceptionKind.values()) {
+                        for (ExceptionKind ek2 : ExceptionKind.values()) {
+                            for (ArgTypeKind ak11 : ArgTypeKind.values()) {
+                                for (ArgTypeKind ak12 : ArgTypeKind.values()) {
+                                    new StructuralMostSpecificTest(lrk, rk1, rk2, ek1, ek2, ak11, ak12).run(comp, fm);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    LambdaReturnKind lrk;
+    RetTypeKind rt1, rt2;
+    ArgTypeKind ak1, ak2;
+    ExceptionKind ek1, ek2;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    StructuralMostSpecificTest(LambdaReturnKind lrk, RetTypeKind rt1, RetTypeKind rt2,
+            ExceptionKind ek1, ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
+        this.lrk = lrk;
+        this.rt1 = rt1;
+        this.rt2 = rt2;
+        this.ek1 = ek1;
+        this.ek2 = ek2;
+        this.ak1 = ak1;
+        this.ak2 = ak2;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface SAM1 {\n" +
+                          "   #R1 m(#A1 a1) #E1;\n" +
+                          "}\n" +
+                          "interface SAM2 {\n" +
+                          "   #R2 m(#A2 a1) #E2;\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                          "   void m(SAM1 s) { }\n" +
+                          "   void m(SAM2 s) { }\n" +
+                          "   { m(x->{ #LR }); }\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#LR", lrk.retStr)
+                    .replaceAll("#R1", rt1.retTypeStr)
+                    .replaceAll("#R2", rt2.retTypeStr)
+                    .replaceAll("#A1", ak1.argTypeStr)
+                    .replaceAll("#A2", ak2.argTypeStr)
+                    .replaceAll("#E1", ek1.exceptionStr)
+                    .replaceAll("#E2", ek2.exceptionStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"),
+                null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2))
+            return;
+
+        if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2))
+            return;
+
+        boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2);
+        boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1);
+
+        boolean ambiguous = (m1MoreSpecific == m2MoreSpecific);
+
+        if (ambiguous != diagChecker.ambiguityFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nAmbiguity found: " + diagChecker.ambiguityFound +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific +
+                "\nexpected ambiguity: " + ambiguous);
+        }
+
+        if (!ambiguous) {
+            String sigToCheck = m1MoreSpecific ? "m(SAM1)" : "m(SAM2)";
+            if (!sigToCheck.equals(diagChecker.mostSpecificSig)) {
+                throw new Error("invalid most specific method selected:\n" +
+                source.getCharContent(true) +
+                "\nMost specific found: " + diagChecker.mostSpecificSig +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific);
+            }
+        }
+    }
+
+    boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1, ExceptionKind ek2,
+            ArgTypeKind ak1, ArgTypeKind ak2) {
+        if (!rk1.moreSpecificThan(rk2))
+            return false;
+
+        if (ak1 != ak2)
+            return false;
+
+        return true;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean ambiguityFound;
+        String mostSpecificSig;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            try {
+                if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                        diagnostic.getCode().equals("compiler.err.ref.ambiguous")) {
+                    ambiguityFound = true;
+                } else if (diagnostic.getKind() == Diagnostic.Kind.NOTE &&
+                        diagnostic.getCode().equals("compiler.note.verbose.resolve.multi")) {
+                    ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
+                            (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
+                    JCDiagnostic.MultilineDiagnostic mdiag = (JCDiagnostic.MultilineDiagnostic)dsu.d;
+                    int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
+                    mostSpecificSig = ((JCDiagnostic)mdiag.getSubdiagnostics().get(mostSpecificIndex)).getArgs()[1].toString();
+                }
+            } catch (RuntimeException t) {
+                t.printStackTrace();
+                throw t;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/A.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class A {
+    public A(NonExistentClass nec) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/DiamondFinder.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious crashes when running in 'diamond finder' mode
+ * @compile -XDfindDiamond DiamondFinder.java
+ */
+import java.util.*;
+
+class DiamondFinder {
+    Collection<String> f = new HashSet<String>(Arrays.asList("a"));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/Main.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  On-demand symbol completion during speculative attribution round fails to report error messages
+ * @compile/fail/ref=Main.out -XDrawDiagnostics Main.java
+ */
+class Main {
+    void test() {
+        m(new A(new Object()));
+        m(new A(null));
+    }
+
+    void m(Object o) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/Main.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+A.java:25:14: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, A, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for self referential and recursive lambda expression that have type inference
+ * @compile InferenceTest11.java
+ * @run main InferenceTest11
+ */
+
+public class InferenceTest11 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static Func<Integer, Integer> f1;
+    static Func<Integer, ? extends Number> f2;
+
+    public static void main(String[] args) {
+
+        f1 = n -> {
+            if(n <= 0)
+                return 0;
+            if(n == 1)
+                return 1;
+            return f1.m(n-1) + f1.m(n-2);
+        };
+        assertTrue(f1.m(-1) == 0);
+        assertTrue(f1.m(0) == 0);
+        assertTrue(f1.m(10) == 55);
+
+        f2 = n -> {
+            if(n <= 1)
+            return 1.0;
+            return 2 * (Double)f2.m(n-1) + 1;
+        };
+        assertTrue(f2.m(4).doubleValue() == 15.0);
+    }
+
+    interface Func<T, V> {
+        V m(T t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.Serializable;
+import java.io.File;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics without wildcard
+ * @compile InferenceTest2.java
+ * @run main InferenceTest2
+ */
+
+public class InferenceTest2 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2 test = new InferenceTest2();
+
+        //test SAM1<T>
+        SAM1<String> sam1 = para -> { String result = "";
+                                      for(String s : para)
+                                          if(s.compareTo(result) > 0)
+                                              result = s;
+                                      return result; };
+        List<String> list = Arrays.asList("a", "b", "c");
+        assertTrue(sam1.m1(list).equals("c"));
+
+        test.method1(para -> para.get(0));
+
+        //test SAM2<T>
+        SAM2<String> sam2 = para -> {para = para.substring(0);};
+        SAM2<Double> sam2_2 = para -> {};
+        SAM2<File> sam2_3 = para -> { if(para.isDirectory())
+                                          System.out.println("directory");
+                                    };
+
+        //test SAM3<T>
+        SAM3<String> sam3 = para -> para[0].substring(0, para[0].length()-1);
+        assertTrue(sam3.m3("hello+").equals("hello"));
+
+        SAM3<Integer> sam3_2 = para -> para[0] - para[1];
+        assertTrue(sam3_2.m3(1, -1) == 2);
+
+        SAM3<Double> sam3_3 = para -> para[0] + para[1] + para[2] + para[3];
+        assertTrue(sam3_3.m3(1.0, 2.0, 3.0, 4.0) == 10.0);
+
+        test.method3(para -> para[0] + 1);
+
+        //test SAM6<T>
+        SAM6<String> sam6 = (para1, para2) -> para1.concat(para2);
+        assertTrue(sam6.m6("hello", "world").equals("helloworld"));
+
+        test.method6((para1, para2) -> para1 >= para2? para1 : para2);
+    }
+
+    void method1(SAM1<Integer> sam1) {
+        List<Integer> list = Arrays.asList(3,2,1);
+        assertTrue(sam1.m1(list) == 3);
+    }
+
+    void method3(SAM3<Double> sam3) {
+        assertTrue(sam3.m3(2.5) == 3.5);
+    }
+
+    void method6(SAM6<Long> sam6) {
+        assertTrue(sam6.m6(5L, -5L) == 5);
+    }
+
+    interface SAM1<T> {
+        T m1(List<T> x);
+    }
+
+    interface SAM2<T extends Serializable> {
+        void m2(T x);
+    }
+
+    interface SAM3<T> {
+        T m3(T... x);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.*;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics with wildcard
+ * @compile InferenceTest2b.java
+ * @run main InferenceTest2b
+ */
+
+public class InferenceTest2b {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2b test = new InferenceTest2b();
+
+        test.m1((a, b) -> {return a;});
+        test.m2((a, b) -> {return a;});
+        test.m3((a, b) -> a);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+
+    void m1(SAM6<? super List<?>> s) {
+        System.out.println("m1()");
+        Stack<String> a = new Stack<String>();
+        ArrayList<String> b = new ArrayList<String>();
+        assertTrue(s.m6(a, b) == a);
+
+        Vector<?> c = null;
+        assertTrue(s.m6(c, b) == c);
+    }
+
+    void m2(SAM6<? super Integer> s) {
+        System.out.println("m2()");
+        assertTrue(s.m6(1, 2) == 1);
+    }
+
+    void m3(SAM6<? super Calendar> s) {
+        System.out.println("m3()");
+        Calendar gc = Calendar.getInstance();
+        GregorianCalendar gc2 = new GregorianCalendar();
+        assertTrue(s.m6(gc, gc2) == gc);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Interface inheritance, sub-interface resolves the type of the super interface.
+ * @compile InferenceTest3.java
+ * @run main InferenceTest3
+ */
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+public class InferenceTest3 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest3 test = new InferenceTest3();
+        test.m1(a -> a.getTime());
+        test.m2(a -> a.toString());
+
+        C<String, Integer> c = a -> a.length();
+        assertTrue(c.m("lambda") == 6);
+
+        E<Double, String> e = a -> Double.toHexString(a);
+        assertTrue(e.m(Double.MAX_VALUE).equals("0x1.fffffffffffffp1023"));
+        assertTrue(e.m(Double.MIN_VALUE).equals("0x0.0000000000001p-1022"));
+        assertTrue(e.m(1.0).equals("0x1.0p0"));
+    }
+
+    private void m1(C<Date, Long> c) {
+        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+        cal.set(1970, 0, 1, 0, 0, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        Date date = cal.getTime();
+        assertTrue(c.m(date) == 0L);
+    }
+
+    private void m2(E<Integer, String> e) {
+        assertTrue(e.m(2).equals("2"));
+    }
+
+    interface A<T extends Serializable, U> {
+        U m(T t);
+    }
+
+    interface C<X extends Serializable, Y extends Number> extends A<X,Y> {}
+
+    interface E<X extends Serializable, Y extends String> extends A<X,Y> {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  This test is for generic methods whose type is the same as the type
+            of the generic SAM interface that is taken as the parameter of the
+            generic method; the type can be inferred from the value of the other
+            type arguments
+ * @compile InferenceTest4.java
+ * @run main InferenceTest4
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class InferenceTest4 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest4 test = new InferenceTest4();
+        test.method1(n -> n.size(), "abc", "java.lang.String");
+        test.method1(n -> n.size(), 'c', "java.lang.Character");
+        test.method1(n -> n.size(), 0, "java.lang.Integer");
+        test.method1(n -> n.size(), 0.1, "java.lang.Double");
+        test.method1(n -> n.size(), 0.1f, "java.lang.Float");
+        test.method1(n -> n.size(), 0L, "java.lang.Long");
+        test.method1(n -> n.size(), (short)0, "java.lang.Short");
+        test.method1(n -> n.size(), (byte)0, "java.lang.Byte");
+        test.method1(n -> n.size(), true, "java.lang.Boolean");
+        test.method1(n -> n.size(), new int[]{1, 2, 3}, "[I");
+        test.method1(n -> n.size(), new double[]{1.0}, "[D");
+        test.method1(n -> n.size(), new String[]{}, "[Ljava.lang.String;");
+    }
+
+    <T> void method1(SAM1<T> s, T t, String className) {
+        List<T> list = new ArrayList<T>();
+        System.out.println(className + "-" + t.getClass().getName());
+        assertTrue(t.getClass().getName().equals(className));
+        list.add(t);
+        assertTrue(s.m1(list) == 1);
+    }
+
+    interface SAM1<T> {
+        int m1(List<T> x);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  This test is for overloaded methods, verify that the specific method is
+             selected when type inference occurs
+ * @compile InferenceTest5.java
+ * @run main InferenceTest5
+ */
+
+import java.util.List;
+import java.io.File;
+
+public class InferenceTest5 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest5 test = new InferenceTest5();
+        int n = test.method1((a, b) -> {} );
+        assertTrue(n == 1);
+
+        n = test.method1(() -> null);
+        assertTrue(n == 2);
+
+        n = test.method1(a -> null);
+        assertTrue(n == 3);
+
+        n = test.method1(a -> {});
+        assertTrue(n == 4);
+
+        n = test.method1(() -> {});
+        assertTrue(n == 5);
+
+        n = test.method1((a, b) -> 0);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null, (a, b) -> null);
+        assertTrue(n == 7);
+    }
+
+    int method1(SAM1<String> s) {
+        return 1;
+    }
+
+    int method1(SAM2 s) {
+        return 2;
+    }
+
+    int method1(SAM3 s) {
+        return 3;
+    }
+
+    int method1(SAM4 s) {
+        return 4;
+    }
+
+    int method1(SAM5 s) {
+        return 5;
+    }
+
+    int method1(SAM6<?, ? super Integer> s) {
+        return 6;
+    }
+
+    int method1(SAM6<?, ?>... s) {
+        return 7;
+    }
+
+    static interface SAM1<T> {
+        void foo(List<T> a, List<T> b);
+    }
+
+    static interface SAM2 {
+        List<String> foo();
+    }
+
+    static interface SAM3 {
+        String foo(int a);
+    }
+
+    static interface SAM4 {
+        void foo(List<File> a);
+    }
+
+    static interface SAM5 {
+        void foo();
+    }
+
+    static interface SAM6<T, V> {
+        V get(T t, T t2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  This test is for when lambda return type is inferred from target type
+ * @compile InferenceTest789.java
+ * @run main InferenceTest789
+ */
+
+public class InferenceTest789 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest789 test = new InferenceTest789();
+        test.method1(() -> 1);
+        SAM1<? extends Number> sam1 = () -> 1.0;
+        SAM1<? extends Serializable> sam1_2 = () -> "a";
+        SAM1<? extends Comparable<?>> sam1_3 = () -> Calendar.getInstance();
+        SAM1<?> sam1_4 = () -> 1.5f;
+
+        SAM2<Number> sam2 = a -> 1;
+        SAM2<? extends Serializable> sam2_2 = a -> 1;
+    }
+
+    void method1(SAM1<?> s) {
+        System.out.println("s.m1()=" + s.m1() + " s.m1().getClass()=" + s.m1().getClass());
+          assertTrue(s.m1().equals(new Integer(1)));
+    }
+
+    interface SAM1<T> {
+        T m1();
+    }
+
+    interface SAM2<T extends Serializable> {
+        T m2(T t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Overloaded methods take raw SAM types that have type inference according to SAM descriptor
+             should have ambiguous resolution of method
+ * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java
+ */
+
+public class InferenceTest_neg1_2 {
+
+    public static void main(String[] args) {
+        InferenceTest_neg1_2 test = new InferenceTest_neg1_2();
+        test.method(n -> null); //method 1-5 all match
+        test.method(n -> "a"); //method 2, 4 match
+        test.method(n -> 0); //method 1, 3, 5 match
+    }
+
+    void method(SAM1 s) { //method 1
+        Integer i = s.foo("a");
+    }
+
+    void method(SAM2 s) { //method 2
+        String str = s.foo(0);
+    }
+
+    void method(SAM3<Integer> s) { //method 3
+        Integer i = s.get(0);
+    }
+
+    void method(SAM4<Double, String> s) { //method 4
+        String str = s.get(0.0);
+    }
+
+    void method(SAM5<Integer> s) { //method 5
+        Integer i = s.get(0.0);
+    }
+
+    interface SAM1 {
+        Integer foo(String a);
+    }
+
+    interface SAM2 {
+        String foo(Integer a);
+    }
+
+    interface SAM3<T> {
+        T get(T t);
+    }
+
+    interface SAM4<T, V> {
+        V get(T t);
+    }
+
+    interface SAM5<T> {
+        T get(Double i);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,4 @@
+InferenceTest_neg1_2.java:14:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM2), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM3<java.lang.Integer>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Missing cast to SAM type that causes type inference to not work.
+ * @compile/fail/ref=InferenceTest_neg5.out -XDrawDiagnostics InferenceTest_neg5.java
+ */
+
+import java.util.*;
+
+public class InferenceTest_neg5 {
+    public static void main(String[] args) {
+        InferenceTest_neg5 test = new InferenceTest_neg5();
+        test.method1(n -> {});
+        test.method1((SAM1<String>)n -> {});
+        test.method1((SAM1<Integer>)n -> {n++;});
+        test.method1((SAM1<Comparator<String>>)n -> {List<String> list = Arrays.asList("string1", "string2"); Collections.sort(list,n);});
+        test.method1((SAM1<Thread>)n -> {n.start();});
+    }
+
+    interface SAM1<X> {
+        void m1(X arg);
+    }
+
+    <X> void method1(SAM1<X> s) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+InferenceTest_neg5.java:14:13: compiler.err.cant.apply.symbol: kindname.method, method1, InferenceTest_neg5.SAM1<X>, @419, kindname.class, InferenceTest_neg5, (compiler.misc.cyclic.inference: X)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  perform automated checks in type inference in lambda expressions in different contexts
+ * @compile  TypeInferenceComboTest.java
+ * @run main/timeout=360 TypeInferenceComboTest
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+
+public class TypeInferenceComboTest {
+    enum Context {
+        ASSIGNMENT("SAM#Type s = #LBody;"),
+        METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#LBody);\n" +
+                    "}"),
+        RETURN_OF_METHOD("SAM#Type method1() {\n" +
+                "    return #LBody;\n" +
+                "}"),
+        LAMBDA_RETURN_EXPRESSION("SAM2 s2 = () -> {return (SAM#Type)#LBody;};\n"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (SAM#Type)#LBody};");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(SamKind sk, TypeKind samTargetT, Keyword kw, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) {
+            String result = context;
+            if (sk == SamKind.GENERIC) {
+                if(this == Context.METHOD_CALL) {
+                    result = result.replaceAll("#GenericDeclKind", gdk.getGenericDeclKind(samTargetT));
+                    if(gdk == GenericDeclKind.NON_GENERIC)
+                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
+                    else //#GenericDeclKind is <T> or <T extends xxx>
+                        result = result.replaceAll("#Type", "<T>");
+                }
+                else {
+                    if(kw == Keyword.VOID)
+                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
+                    else
+                        result = result.replaceAll("#Type", "<? " + kw.keyStr + " " + samTargetT.typeStr + ">");
+                }
+            }
+            else
+                result = result.replaceAll("#Type", "").replaceAll("#GenericDeclKind", "");
+
+            return result.replaceAll("#LBody", lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk));
+        }
+    }
+
+    enum SamKind {
+        GENERIC("interface SAM<T> { #R m(#ARG); }"),
+        NON_GENERIC("interface SAM { #R m(#ARG); }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(TypeKind parameterT, TypeKind returnT) {
+            return sam_str.replaceAll("#ARG", parameterT == TypeKind.VOID ? "" : parameterT.typeStr + " arg")
+                          .replaceAll("#R", returnT.typeStr);
+        }
+    }
+
+    enum TypeKind {
+        VOID("void", ""),
+        STRING("String", "\"hello\""),
+        INTEGER("Integer", "1"),
+        INT("int", "0"),
+        COMPARATOR("java.util.Comparator<String>", "(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"),
+        SAM("SAM2", "null"),
+        GENERIC("T", null);
+
+        String typeStr;
+        String valStr;
+
+        TypeKind(String typeStr, String valStr) {
+            this.typeStr = typeStr;
+            this.valStr = valStr;
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ParameterKind {
+        EXPLICIT("#TYPE"),
+        IMPLICIT("");
+
+        String paramTemplate;
+
+        ParameterKind(String paramTemplate) {
+             this.paramTemplate = paramTemplate;
+        }
+    }
+
+    enum Keyword {
+        SUPER("super"),
+        EXTENDS("extends"),
+        VOID("");
+
+        String keyStr;
+
+        Keyword(String keyStr) {
+            this.keyStr = keyStr;
+        }
+    }
+
+    enum LambdaBody {
+        RETURN_VOID("() -> #RET"),//no parameters, return type is one of the TypeKind
+        RETURN_ARG("(#PK arg) -> #RET");//has parameters, return type is one of the TypeKind
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk) {
+            String result = bodyStr.replaceAll("#PK", pk.paramTemplate);
+
+            if(result.contains("#TYPE")) {
+                if (parameterT == TypeKind.GENERIC && this != RETURN_VOID)
+                    result = result.replaceAll("#TYPE", samTargetT == null? "": samTargetT.typeStr);
+                else
+                    result = result.replaceAll("#TYPE", parameterT.typeStr);
+            }
+            if (this == RETURN_ARG && parameterT == returnT)
+                return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg"));
+            else {
+                if(returnT != TypeKind.GENERIC)
+                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", (returnT==TypeKind.VOID && lk==LambdaKind.EXPRESSION)? "{}" : returnT.valStr));
+                else
+                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", samTargetT.valStr));
+            }
+        }
+    }
+
+    enum GenericDeclKind {
+        NON_GENERIC(""),
+        GENERIC_NOBOUND("<T>"),
+        GENERIC_BOUND("<T extends #ExtendedType>");
+        String typeStr;
+
+        GenericDeclKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+
+        String getGenericDeclKind(TypeKind et) {
+            return typeStr.replaceAll("#ExtendedType", et==null? "":et.typeStr);
+        }
+    }
+
+    boolean checkTypeInference() {
+        if (parameterType == TypeKind.VOID) {
+            if (lambdaBodyType != LambdaBody.RETURN_VOID)
+                return false;
+        }
+        else if (lambdaBodyType != LambdaBody.RETURN_ARG)
+            return false;
+        if (  genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || genericDeclKind == GenericDeclKind.GENERIC_BOUND ) {
+            if ( parameterType == TypeKind.GENERIC && parameterKind == ParameterKind.IMPLICIT) //cyclic inference
+                return false;
+        }
+        return true;
+    }
+
+    String templateStr = "#C\n" +
+                         "interface SAM2 {\n" +
+                         "    SAM m();\n" +
+                         "}\n";
+    SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) {
+        public String toString() {
+            return template.replaceAll("#C", samKind.getSam(parameterType, returnType));
+        }
+    };
+
+    SourceFile clientSourceFile = new SourceFile("Client.java",
+                                                 "class Client { \n" +
+                                                 "    #Context\n" +
+                                                 "}") {
+        public String toString() {
+            return template.replaceAll("#Context", context.getContext(samKind, samTargetType, keyword, parameterType, returnType, lambdaKind, parameterKind, genericDeclKind, lambdaBodyType));
+        }
+    };
+
+    void test() throws Exception {
+        System.out.println("kk:");
+        StringBuilder sb = new StringBuilder("SamKind:");
+        sb.append(samKind).append(" SamTargetType:").append(samTargetType).append(" ParameterType:").append(parameterType)
+            .append(" ReturnType:").append(returnType).append(" Context:").append(context).append(" LambdaKind:").append(lambdaKind)
+            .append(" LambdaBodyType:").append(lambdaBodyType).append(" ParameterKind:").append(parameterKind).append(" Keyword:").append(keyword);
+        System.out.println(sb);
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkTypeInference()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile + "\n" + parameterType + " " + returnType);
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    SamKind samKind;
+    TypeKind samTargetType;
+    TypeKind parameterType;
+    TypeKind returnType;
+    Context context;
+    LambdaBody lambdaBodyType;
+    LambdaKind lambdaKind;
+    ParameterKind parameterKind;
+    Keyword keyword;
+    GenericDeclKind genericDeclKind;
+
+    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk, ParameterKind pk, Keyword kw, GenericDeclKind gdk) {
+        samKind = sk;
+        samTargetType = samTargetT;
+        parameterType = parameterT;
+        returnType = returnT;
+        context = c;
+        lambdaKind = lk;
+        parameterKind = pk;
+        keyword = kw;
+        lambdaBodyType = lb;
+        genericDeclKind = gdk;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (TypeKind returnT : TypeKind.values()) {
+                for (TypeKind parameterT : TypeKind.values()) {
+                    for(LambdaBody lb : LambdaBody.values()) {
+                        for (ParameterKind parameterK : ParameterKind.values()) {
+                            for(LambdaKind lambdaK : LambdaKind.values()) {
+                                for (SamKind sk : SamKind.values()) {
+                                    if (sk == SamKind.NON_GENERIC) {
+                                        if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC )
+                                            new TypeInferenceComboTest(sk, null, parameterT, returnT, lb, ct, lambdaK, parameterK, null, null).test();
+                                    }
+                                    else if (sk == SamKind.GENERIC) {
+                                        for (Keyword kw : Keyword.values()) {
+                                            for (TypeKind samTargetT : TypeKind.values()) {
+                                                if(samTargetT != TypeKind.VOID && samTargetT != TypeKind.INT && samTargetT != TypeKind.GENERIC
+                                                   && (parameterT == TypeKind.GENERIC || returnT == TypeKind.GENERIC)) {
+                                                    if(ct != Context.METHOD_CALL) {
+                                                        new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, null).test();
+                                                    }
+                                                    else {//Context.METHOD_CALL
+                                                        for (GenericDeclKind gdk : GenericDeclKind.values())
+                                                            new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, gdk).test();
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/TEST.properties	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,2 @@
+TestNG.dirs = tools/javac/lambdaShapes
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.javac;
+
+import org.openjdk.tests.shapegen.*;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.util.Pair;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.DataProvider;
+import static org.testng.Assert.*;
+
+public class FDTest {
+
+    public enum TestKind {
+        POSITIVE,
+        NEGATIVE;
+
+        Collection<Hierarchy> getHierarchy(HierarchyGenerator hg) {
+            return this == POSITIVE ?
+                    hg.getOK() : hg.getErr();
+        }
+    }
+
+    public static JavaCompiler comp;
+    public static StandardJavaFileManager fm;
+
+    @BeforeSuite
+    static void init() {
+        // create default shared JavaCompiler - reused across multiple
+        // compilations
+
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+    }
+
+    public static void main(String[] args) throws Exception {
+        init();
+
+        for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
+            runTest(fdtest.fst, fdtest.snd, comp, fm);
+        }
+    }
+
+    @Test(dataProvider = "fdCases")
+    public void testOneCase(TestKind tk, Hierarchy hs)
+            throws Exception {
+        FDTest.runTest(tk, hs, comp, fm);
+    }
+
+    @DataProvider(name = "fdCases")
+    public Object[][] caseGenerator() {
+        List<Pair<TestKind, Hierarchy>> cases = generateCases();
+        Object[][] fdCases = new Object[cases.size()][];
+        for (int i = 0; i < cases.size(); ++i) {
+            fdCases[i] = new Object[2];
+            fdCases[i][0] = cases.get(i).fst;
+            fdCases[i][1] = cases.get(i).snd;
+        }
+        return fdCases;
+    }
+
+    public static List<Pair<TestKind, Hierarchy>> generateCases() {
+        ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
+        HierarchyGenerator hg = new HierarchyGenerator();
+        for (TestKind tk : TestKind.values()) {
+            for (Hierarchy hs : tk.getHierarchy(hg)) {
+                list.add(new Pair<>(tk, hs));
+            }
+        }
+        return list;
+    }
+
+    public static void runTest(TestKind tk, Hierarchy hs,
+            JavaCompiler comp, StandardJavaFileManager fm) throws Exception {
+        new FDTest(tk, hs).run(comp, fm);
+    }
+
+    TestKind tk;
+    Hierarchy hs;
+    DefenderTestSource source;
+    DiagnosticChecker diagChecker;
+
+    public FDTest() {}
+
+    FDTest(TestKind tk, Hierarchy hs) {
+        this.tk = tk;
+        this.hs = hs;
+        this.source = new DefenderTestSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            fail("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected = tk == TestKind.NEGATIVE;
+        if (errorExpected != diagChecker.errorFound) {
+            fail("problem in source: \n" +
+                 "\nerror found = " + diagChecker.errorFound +
+                 "\nerror expected = " + errorExpected +
+                 "\n" + dumpHierarchy() +
+                 "\n" + source.getCharContent(true));
+        }
+    }
+
+    String dumpHierarchy() {
+        StringBuilder buf = new StringBuilder();
+        buf.append("root = " + hs.root + "\n");
+        for (ClassCase cc : hs.all) {
+            buf.append("  class name = " + cc.getName() + "\n");
+            buf.append("    class OK = " + cc.get_OK() + "\n");
+            buf.append("    prov = " + cc.get_mprov() + "\n");
+
+        }
+        return buf.toString();
+    }
+
+    class DefenderTestSource extends SimpleJavaFileObject {
+
+        String source;
+
+        public DefenderTestSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            StringBuilder buf = new StringBuilder();
+            List<ClassCase> defaultRef = new ArrayList<>();
+            for (ClassCase cc : hs.all) {
+                Hierarchy.genClassDef(buf, cc, null, defaultRef);
+            }
+            source = buf.toString();
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.io.*;
+
+public class AttributeInjector implements ClassFilePreprocessor {
+
+    private String attributeName;
+    private byte[] attributeData;
+
+    public AttributeInjector(String attributeName, byte[] attributeData) {
+        this.attributeName = attributeName;
+        this.attributeData = attributeData;
+    }
+
+    public byte[] preprocess(String name, byte[] cf) {
+        ClassFile classfile = new ClassFile(cf);
+
+        short cpIndex = (short)classfile.constant_pool.size();
+
+        ClassFile.CpUtf8 entry = new ClassFile.CpUtf8();
+        entry.bytes = new byte[attributeName.length()];
+        for (int i = 0; i < attributeName.length(); ++i) {
+            entry.bytes[i] = (byte)attributeName.charAt(i);
+        }
+
+        classfile.constant_pool.add(entry);
+
+        ClassFile.Attribute attr = new ClassFile.Attribute();
+        attr.attribute_name_index = cpIndex;
+        attr.info = attributeData;
+
+        classfile.attributes.add(attr);
+        return classfile.toByteArray();
+    }
+
+/*
+    public static void main(String argv[]) throws Exception {
+        File input = new File(argv[0]);
+        byte[] buffer = new byte[(int)input.length()];
+        new FileInputStream(input).read(buffer);
+
+        ClassFilePreprocessor cfp =
+            new AttributeInjector("RequiresBridges", new byte[0]);
+        byte[] cf = cfp.preprocess(argv[0], buffer);
+        new FileOutputStream(argv[0] + ".mod").write(cf);
+    }
+*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,454 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.io.*;
+import java.util.*;
+
+class CfInputStream extends ByteArrayInputStream {
+    private int ct;
+    public CfInputStream(byte[] input) {
+        super(input);
+    }
+
+    byte u1() { return (byte)read(); }
+    short u2() {
+        int b0 = read() << 8;
+        int b1 = read();
+        return (short)(b0 | b1);
+    }
+    int u4() {
+        int b0 = read() << 24;
+        int b1 = read() << 16;
+        int b2 = read() << 8;
+        int b3 = read();
+        return b0 | b1 | b2 | b3;
+    }
+    byte[] array(int count) {
+        byte[] ret = new byte[count];
+        read(ret, 0, count);
+        return ret;
+    }
+};
+
+class CfOutputStream extends ByteArrayOutputStream {
+    void u1(byte b) { write((int)b); }
+    void u2(short s) {
+        write((s >> 8) & 0xff);
+        write(s & 0xff);
+    }
+    void u4(int i) {
+        write((i >> 24) & 0xff);
+        write((i >> 16) & 0xff);
+        write((i >> 8) & 0xff);
+        write(i & 0xff);
+    }
+    void array(byte[] a) {
+        write(a, 0, a.length);
+    }
+
+    public byte[] toByteArray() { return super.toByteArray(); }
+};
+
+// A quick and dirty class file parser and representation
+public class ClassFile {
+
+    int magic;
+    short minor_version;
+    short major_version;
+    ArrayList<CpEntry> constant_pool;
+    short access_flags;
+    short this_class;
+    short super_class;
+    ArrayList<Interface> interfaces;
+    ArrayList<Field> fields;
+    ArrayList<Method> methods;
+    ArrayList<Attribute> attributes;
+
+    ClassFile(byte[] cf) {
+        CfInputStream in = new CfInputStream(cf);
+
+        magic = in.u4();
+        minor_version = in.u2();
+        major_version = in.u2();
+
+        short cpCount = in.u2();
+        constant_pool = new ArrayList<>();
+        constant_pool.add(new CpNull());
+        for (int i = 1; i < cpCount; ++i) {
+            constant_pool.add(CpEntry.newCpEntry(in));
+        }
+
+        access_flags = in.u2();
+        this_class = in.u2();
+        super_class = in.u2();
+
+        short ifaceCount = in.u2();
+        interfaces = new ArrayList<>();
+        for (int i = 0; i < ifaceCount; ++i) {
+            interfaces.add(new Interface(in));
+        }
+
+        short fieldCount = in.u2();
+        fields = new ArrayList<>();
+        for (int i = 0; i < fieldCount; ++i) {
+            fields.add(new Field(in));
+        }
+
+        short methodCount = in.u2();
+        methods = new ArrayList<>();
+        for (int i = 0; i < methodCount; ++i) {
+            methods.add(new Method(in));
+        }
+
+        short attributeCount = in.u2();
+        attributes = new ArrayList<>();
+        for (int i = 0; i < attributeCount; ++i) {
+            attributes.add(new Attribute(in));
+        }
+    }
+
+    byte[] toByteArray() {
+        CfOutputStream out = new CfOutputStream();
+
+        out.u4(magic);
+        out.u2(minor_version);
+        out.u2(major_version);
+
+        out.u2((short)(constant_pool.size()));
+        for (CpEntry cp : constant_pool) {
+            cp.write(out);
+        }
+
+        out.u2(access_flags);
+        out.u2(this_class);
+        out.u2(super_class);
+
+        out.u2((short)interfaces.size());
+        for (Interface iface : interfaces) {
+            iface.write(out);
+        }
+
+        out.u2((short)fields.size());
+        for (Field field : fields) {
+            field.write(out);
+        }
+
+        out.u2((short)methods.size());
+        for (Method method : methods) {
+            method.write(out);
+        }
+
+        out.u2((short)attributes.size());
+        for (Attribute attribute : attributes) {
+            attribute.write(out);
+        }
+
+        return out.toByteArray();
+    }
+
+    static abstract class CpEntry {
+        byte tag;
+
+        CpEntry(byte t) { tag = t; }
+        void write(CfOutputStream out) {
+            out.u1(tag);
+        }
+
+        static CpEntry newCpEntry(CfInputStream in) {
+            byte tag = in.u1();
+            switch (tag) {
+                case CpUtf8.TAG: return new CpUtf8(in);
+                case CpInteger.TAG: return new CpInteger(in);
+                case CpFloat.TAG: return new CpFloat(in);
+                case CpLong.TAG: return new CpLong(in);
+                case CpDouble.TAG: return new CpDouble(in);
+                case CpClass.TAG: return new CpClass(in);
+                case CpString.TAG: return new CpString(in);
+                case CpFieldRef.TAG: return new CpFieldRef(in);
+                case CpMethodRef.TAG: return new CpMethodRef(in);
+                case CpInterfaceMethodRef.TAG:
+                    return new CpInterfaceMethodRef(in);
+                case CpNameAndType.TAG: return new CpNameAndType(in);
+                case CpMethodHandle.TAG: return new CpMethodHandle(in);
+                case CpMethodType.TAG: return new CpMethodType(in);
+                case CpInvokeDynamic.TAG: return new CpInvokeDynamic(in);
+                default: throw new RuntimeException("Bad cp entry tag: " + tag);
+            }
+        }
+    }
+
+    static class CpNull extends CpEntry {
+        CpNull() { super((byte)0); }
+        CpNull(CfInputStream in) { super((byte)0); }
+        void write(CfOutputStream out) {}
+    }
+
+    static class CpUtf8 extends CpEntry {
+        static final byte TAG = 1;
+        byte[] bytes;
+
+        CpUtf8() { super(TAG); }
+        CpUtf8(CfInputStream in) {
+            this();
+            short length = in.u2();
+            bytes = in.array(length);
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2((short)bytes.length);
+            out.array(bytes);
+        }
+    }
+
+    static class CpU4Constant extends CpEntry {
+        byte[] bytes;
+
+        CpU4Constant(byte tag) { super(tag); }
+        CpU4Constant(byte tag, CfInputStream in) {
+            this(tag);
+            bytes = in.array(4);
+        }
+        void write(CfOutputStream out) { super.write(out); out.array(bytes); }
+    }
+    static class CpInteger extends CpU4Constant {
+        static final byte TAG = 3;
+        CpInteger() { super(TAG); }
+        CpInteger(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpFloat extends CpU4Constant {
+        static final byte TAG = 4;
+        CpFloat() { super(TAG); }
+        CpFloat(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpU8Constant extends CpEntry {
+        byte[] bytes;
+
+        CpU8Constant(byte tag) { super(tag); }
+        CpU8Constant(byte tag, CfInputStream in) {
+            this(tag);
+            bytes = in.array(8);
+        }
+        void write(CfOutputStream out) { super.write(out); out.array(bytes); }
+    }
+    static class CpLong extends CpU8Constant {
+        static final byte TAG = 5;
+        CpLong() { super(TAG); }
+        CpLong(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpDouble extends CpU8Constant {
+        static final byte TAG = 6;
+        CpDouble() { super(TAG); }
+        CpDouble(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpClass extends CpEntry {
+        static final byte TAG = 7;
+        short name_index;
+
+        CpClass() { super(TAG); }
+        CpClass(CfInputStream in) { super(TAG); name_index = in.u2(); }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(name_index);
+        }
+    }
+
+    static class CpString extends CpEntry {
+        static final byte TAG = 8;
+        short string_index;
+
+        CpString() { super(TAG); }
+        CpString(CfInputStream in) { super(TAG); string_index = in.u2(); }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(string_index);
+        }
+    }
+
+    static class CpRef extends CpEntry {
+        short class_index;
+        short name_and_type_index;
+
+        CpRef(byte tag) { super(tag); }
+        CpRef(byte tag, CfInputStream in) {
+            this(tag);
+            class_index = in.u2();
+            name_and_type_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(class_index);
+            out.u2(name_and_type_index);
+        }
+    }
+    static class CpFieldRef extends CpRef {
+        static final byte TAG = 9;
+        CpFieldRef() { super(TAG); }
+        CpFieldRef(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpMethodRef extends CpRef {
+        static final byte TAG = 10;
+        CpMethodRef() { super(TAG); }
+        CpMethodRef(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpInterfaceMethodRef extends CpRef {
+        static final byte TAG = 11;
+        CpInterfaceMethodRef() { super(TAG); }
+        CpInterfaceMethodRef(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpNameAndType extends CpEntry {
+        static final byte TAG = 12;
+        short name_index;
+        short descriptor_index;
+
+        CpNameAndType() { super(TAG); }
+        CpNameAndType(CfInputStream in) {
+            this();
+            name_index = in.u2();
+            descriptor_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(name_index);
+            out.u2(descriptor_index);
+        }
+    }
+
+    static class CpMethodHandle extends CpEntry {
+        static final byte TAG = 15;
+        byte reference_kind;
+        short reference_index;
+
+        CpMethodHandle() { super(TAG); }
+        CpMethodHandle(CfInputStream in) {
+            this();
+            reference_kind = in.u1();
+            reference_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u1(reference_kind);
+            out.u2(reference_index);
+        }
+    }
+
+    static class CpMethodType extends CpEntry {
+        static final byte TAG = 16;
+        short descriptor_index;
+
+        CpMethodType() { super(TAG); }
+        CpMethodType(CfInputStream in) {
+            this();
+            descriptor_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(descriptor_index);
+        }
+    }
+
+    static class CpInvokeDynamic extends CpEntry {
+        static final byte TAG = 18;
+        short bootstrap_index;
+        short name_and_type_index;
+
+        CpInvokeDynamic() { super(TAG); }
+        CpInvokeDynamic(CfInputStream in) {
+            this();
+            bootstrap_index = in.u2();
+            name_and_type_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(bootstrap_index);
+            out.u2(name_and_type_index);
+        }
+    }
+
+    static class Interface {
+        short index;
+
+        Interface() {}
+        Interface(CfInputStream in) { index = in.u2(); }
+        void write(CfOutputStream out) { out.u2(index); }
+    }
+
+    static class FieldOrMethod {
+        short access_flags;
+        short name_index;
+        short descriptor_index;
+        ArrayList<Attribute> attributes;
+
+        FieldOrMethod() { attributes = new ArrayList<>(); }
+        FieldOrMethod(CfInputStream in) {
+            access_flags = in.u2();
+            name_index = in.u2();
+            descriptor_index = in.u2();
+
+            short attrCount = in.u2();
+            attributes = new ArrayList<>();
+            for (int i = 0; i < attrCount; ++i) {
+                attributes.add(new Attribute(in));
+            }
+        }
+        void write(CfOutputStream out) {
+            out.u2(access_flags);
+            out.u2(name_index);
+            out.u2(descriptor_index);
+            out.u2((short)attributes.size());
+            for (Attribute attribute : attributes) { attribute.write(out); }
+        }
+    }
+
+    static class Field extends FieldOrMethod {
+        Field() {}
+        Field(CfInputStream in) { super(in); }
+    }
+    static class Method extends FieldOrMethod {
+        Method() {}
+        Method(CfInputStream in) { super(in); }
+    }
+
+    static class Attribute {
+        short attribute_name_index;
+        byte[] info;
+
+        Attribute() { info = new byte[0]; }
+        Attribute(CfInputStream in) {
+            attribute_name_index = in.u2();
+            int length = in.u4();
+            info = in.array(length);
+        }
+        void write(CfOutputStream out) {
+            out.u2(attribute_name_index);
+            out.u4(info.length);
+            out.array(info);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+public interface ClassFilePreprocessor {
+    public byte[] preprocess(String name, byte[] classfile);
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.io.*;
+import java.util.*;
+
+public class ClassToInterfaceConverter implements ClassFilePreprocessor {
+
+    private String whichClass;
+
+    public ClassToInterfaceConverter(String className) {
+        this.whichClass = className;
+    }
+
+    private boolean utf8Matches(ClassFile.CpEntry entry, String v) {
+        if (!(entry instanceof ClassFile.CpUtf8)) {
+            return false;
+        }
+        ClassFile.CpUtf8 utf8 = (ClassFile.CpUtf8)entry;
+        if (v.length() != utf8.bytes.length) {
+            return false;
+        }
+        for (int i = 0; i < v.length(); ++i) {
+            if (v.charAt(i) != utf8.bytes[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void convertToInterface(ClassFile cf) {
+        cf.access_flags = 0x0601; // ACC_INTERFACE | ACC_ABSTRACT | ACC_PUBLIC
+        ArrayList<ClassFile.Method> new_methods = new ArrayList<>();
+        // Find <init> method and delete it
+        for (int i = 0; i < cf.methods.size(); ++i) {
+            ClassFile.Method method = cf.methods.get(i);
+            ClassFile.CpEntry name = cf.constant_pool.get(method.name_index);
+            if (!utf8Matches(name, "<init>")) {
+                new_methods.add(method);
+            }
+        }
+        cf.methods = new_methods;
+    }
+
+    public byte[] preprocess(String classname, byte[] bytes) {
+        ClassFile cf = new ClassFile(bytes);
+
+        ClassFile.CpEntry entry = cf.constant_pool.get(cf.this_class);
+        ClassFile.CpEntry name = cf.constant_pool.get(
+            ((ClassFile.CpClass)entry).name_index);
+        if (utf8Matches(name, whichClass)) {
+            convertToInterface(cf);
+            return cf.toByteArray();
+        } else {
+            return bytes; // unmodified
+        }
+    }
+
+/*
+    public static void main(String argv[]) throws Exception {
+        File input = new File(argv[0]);
+        byte[] buffer = new byte[(int)input.length()];
+        new FileInputStream(input).read(buffer);
+
+        ClassFilePreprocessor cfp = new ClassToInterfaceConverter("Hello");
+        byte[] cf = cfp.preprocess(argv[0], buffer);
+        new FileOutputStream(argv[0] + ".mod").write(cf);
+    }
+*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.ConcurrentHashMap;
+import java.io.*;
+import java.net.URI;
+import javax.tools.*;
+
+import com.sun.source.util.JavacTask;
+
+import static org.openjdk.tests.separate.SourceModel.Type;
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.Extends;
+import static org.openjdk.tests.separate.SourceModel.SourceProcessor;
+
+public class Compiler {
+
+    public enum Flags {
+        VERBOSE, // Prints out files as they are compiled
+        USECACHE // Keeps results around for reuse.  Only use this is
+                 // you're sure that each compilation name maps to the
+                 // same source code
+    };
+
+    private static final AtomicInteger counter = new AtomicInteger();
+    private static final String targetDir = "gen-separate";
+    private static final File root = new File(targetDir);
+    private static ConcurrentHashMap<String,File> cache =
+            new ConcurrentHashMap<>();
+
+    Set<Flags> flags;
+
+    private JavaCompiler systemJavaCompiler;
+    private StandardJavaFileManager fm;
+    private List<File> tempDirs;
+    private List<ClassFilePreprocessor> postprocessors;
+
+    private static class SourceFile extends SimpleJavaFileObject {
+        private final String content;
+
+        public SourceFile(String name, String content) {
+            super(URI.create("myfo:/" + name + ".java"), Kind.SOURCE);
+            this.content = content;
+        }
+
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public String toString() { return this.content; }
+    }
+
+    public Compiler(Flags ... flags) {
+        setFlags(flags);
+        this.tempDirs = new ArrayList<>();
+        this.postprocessors = new ArrayList<>();
+        this.systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
+        this.fm = systemJavaCompiler.getStandardFileManager(null, null, null);
+    }
+
+    public void setFlags(Flags ... flags) {
+        this.flags = new HashSet<Flags>(Arrays.asList(flags));
+    }
+
+    public void addPostprocessor(ClassFilePreprocessor cfp) {
+        this.postprocessors.add(cfp);
+    }
+
+    /**
+     * Compile hierarchies starting with each of the 'types' and return
+     * a ClassLoader that can be used to load the compiled classes.
+     */
+    public ClassLoader compile(Type ... types) {
+        ClassFilePreprocessor[] cfps = this.postprocessors.toArray(
+            new ClassFilePreprocessor[0]);
+
+        DirectedClassLoader dcl = new DirectedClassLoader(cfps);
+
+        for (Type t : types) {
+            for (Map.Entry<String,File> each : compileHierarchy(t).entrySet()) {
+                dcl.setLocationFor(each.getKey(), each.getValue());
+            }
+        }
+        return dcl;
+    }
+
+    /**
+     * Compiles and loads a hierarchy, starting at 'type'
+     */
+    public java.lang.Class<?> compileAndLoad(Type type)
+            throws ClassNotFoundException {
+
+        ClassLoader loader = compile(type);
+        return java.lang.Class.forName(type.getName(), false, loader);
+    }
+
+    /**
+     * Compiles a hierarchy, starting at 'type' and return a mapping of the
+     * name to the location where the classfile for that type resides.
+     */
+    private Map<String,File> compileHierarchy(Type type) {
+        HashMap<String,File> outputDirs = new HashMap<>();
+
+        File outDir = compileOne(type);
+        outputDirs.put(type.getName(), outDir);
+
+        Class superClass = type.getSuperclass();
+        if (superClass != null) {
+            for( Map.Entry<String,File> each : compileHierarchy(superClass).entrySet()) {
+                outputDirs.put(each.getKey(), each.getValue());
+            }
+        }
+        for (Extends ext : type.getSupertypes()) {
+            Type iface = ext.getType();
+            for( Map.Entry<String,File> each : compileHierarchy(iface).entrySet()) {
+                outputDirs.put(each.getKey(), each.getValue());
+            }
+        }
+
+        return outputDirs;
+    }
+
+    private File compileOne(Type type) {
+        if (this.flags.contains(Flags.USECACHE)) {
+            File dir = cache.get(type.getName());
+            if (dir != null) {
+                return dir;
+            }
+        }
+        List<JavaFileObject> files = new ArrayList<>();
+        SourceProcessor accum =
+            (name, src) -> { files.add(new SourceFile(name, src)); };
+
+        for (Type dep : type.typeDependencies()) {
+            dep.generateAsDependency(accum, type.methodDependencies());
+        }
+
+        type.generate(accum);
+
+        JavacTask ct = (JavacTask)this.systemJavaCompiler.getTask(
+            null, this.fm, null, null, null, files);
+        File destDir = null;
+        do {
+            int value = counter.incrementAndGet();
+            destDir = new File(root, Integer.toString(value));
+        } while (destDir.exists());
+
+        if (this.flags.contains(Flags.VERBOSE)) {
+            System.out.println("Compilation unit for " + type.getName() +
+                " : compiled into " + destDir);
+            for (JavaFileObject jfo : files) {
+                System.out.println(jfo.toString());
+            }
+        }
+
+        try {
+            destDir.mkdirs();
+            this.fm.setLocation(
+                StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+        } catch (IOException e) {
+            throw new RuntimeException(
+                "IOException encountered during compilation");
+        }
+        Boolean result = ct.call();
+        if (result == Boolean.FALSE) {
+            throw new RuntimeException(
+                "Compilation failure in " + type.getName() + " unit");
+        }
+        if (this.flags.contains(Flags.USECACHE)) {
+            File existing = cache.putIfAbsent(type.getName(), destDir);
+            if (existing != null) {
+                deleteDir(destDir);
+                return existing;
+            }
+        } else {
+        this.tempDirs.add(destDir);
+        }
+        return destDir;
+    }
+
+    private static void deleteDir(File dir) {
+        for (File f : dir.listFiles()) {
+            f.delete();
+        };
+        dir.delete();
+    }
+
+    public void cleanup() {
+        if (!this.flags.contains(Flags.USECACHE)) {
+            for (File d : tempDirs) {
+                deleteDir(d);
+            };
+            tempDirs = new ArrayList<>();
+        }
+    }
+
+    // Removes all of the elements in the cache and deletes the associated
+    // output directories.  This may not actually empty the cache if there
+    // are concurrent users of it.
+    public static void purgeCache() {
+        for (Map.Entry<String,File> entry : cache.entrySet()) {
+            cache.remove(entry.getKey());
+            deleteDir(entry.getValue());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.util.HashMap;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+class DirectedClassLoader extends ClassLoader {
+
+    private HashMap<String,File> loadLocations;
+    private File defaultLocation;
+    private ClassFilePreprocessor[] preprocessors;
+
+    public DirectedClassLoader(
+            HashMap<String,File> locations, File fallback,
+            ClassFilePreprocessor ... preprocessors) {
+        loadLocations = new HashMap<>(locations);
+        defaultLocation = fallback;
+        this.preprocessors = preprocessors;
+    }
+
+    public DirectedClassLoader(
+            File fallback, ClassFilePreprocessor ... preprocessors) {
+        loadLocations = new HashMap<>();
+        defaultLocation = fallback;
+        this.preprocessors = preprocessors;
+    }
+
+    public DirectedClassLoader(ClassFilePreprocessor ... preprocessors) {
+        this((File)null, preprocessors);
+    }
+
+    public void setDefaultLocation(File dir) { this.defaultLocation = dir; }
+    public void setLocationFor(String name, File dir) {
+        loadLocations.put(name, dir);
+    }
+
+    @Override
+    protected Class<?> findClass(String name) {
+        String path = name.replace(".", File.separator) + ".class";
+
+        File location = loadLocations.get(name);
+        if (location == null || !(new File(location, path)).exists()) {
+            File def = new File(defaultLocation, path);
+            if (def.exists()) {
+                return defineFrom(name, new File(location, path));
+            }
+        } else {
+            return defineFrom(name, new File(location, path));
+        }
+        return null;
+    }
+
+    private Class<?> defineFrom(String name, File file) {
+        FileInputStream fis = null;
+        try {
+            try {
+                fis = new FileInputStream(file);
+                byte[] bytes = new byte[fis.available()];
+                int read = fis.read(bytes);
+                if (read != bytes.length) {
+                    return null;
+                }
+                if (preprocessors != null) {
+                    for (ClassFilePreprocessor cfp : preprocessors) {
+                        bytes = cfp.preprocess(name, bytes);
+                    }
+                 }
+                return defineClass(name, bytes, 0, bytes.length);
+            } finally {
+                fis.close();
+            }
+        } catch (IOException e) {}
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,582 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import java.util.*;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+public class SourceModel {
+
+    public static final String stdMethodName = "m";
+
+    public static interface SourceProcessor {
+        // Called with a generated source file
+        void process(String name, String content);
+    }
+
+    public static abstract class Element {
+
+        protected abstract void generate(PrintWriter pw);
+
+        public String toString() {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            return sw.toString();
+        }
+    };
+
+    public static class AccessFlag extends Element {
+        private String flag;
+
+        public AccessFlag(String name) { flag = name; }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(flag);
+        }
+
+        public String toString() { return flag; }
+
+        public static final AccessFlag PUBLIC = new AccessFlag("public");
+        public static final AccessFlag PRIVATE = new AccessFlag("private");
+        public static final AccessFlag PROTECTED = new AccessFlag("protected");
+        public static final AccessFlag STATIC = new AccessFlag("static");
+        public static final AccessFlag FINAL = new AccessFlag("final");
+        public static final AccessFlag SYNCHRONIZED = new AccessFlag("synchronized");
+        public static final AccessFlag VOLATILE = new AccessFlag("volatile");
+        public static final AccessFlag NATIVE = new AccessFlag("native");
+        public static final AccessFlag ABSTRACT = new AccessFlag("abstract");
+        public static final AccessFlag STRICTFP = new AccessFlag("strictfp");
+        public static final AccessFlag DEFAULT = new AccessFlag("default");
+    }
+
+    public static class TypeParameter extends Element {
+        private String parameter;
+
+        public TypeParameter(String str) {
+            this.parameter = str;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(parameter);
+        }
+    }
+
+    public static class TypeArgument extends Element {
+        private String argument;
+
+        public TypeArgument(String str) {
+            this.argument = str;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(argument);
+        }
+    }
+
+    public static class MethodParameter extends Element {
+        private String type;
+        private String name;
+
+        public MethodParameter(String type, String name) {
+            this.type = type;
+            this.name = name;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.printf("%s %s", this.type, this.name);
+        }
+
+        public String toString() { return type + " " + name; }
+    }
+
+    public static abstract class Type extends Element {
+        private String name;
+        private List<AccessFlag> accessFlags;
+        private List<TypeParameter> parameters;
+        private List<Extends> supertypes;
+        private List<Method> methods;
+
+        // methods from superclasses that are required for compilation
+        // (and thus will be present in stubs)
+        private Set<Method> methodDependencies;
+        private List<Type> typeDependencies;
+
+        protected Type(String name,
+                List<AccessFlag> flags, List<TypeParameter> params,
+                List<Extends> ifaces, List<Method> methods) {
+            this.name = name;
+            this.accessFlags = flags == null ? new ArrayList<>() : flags;
+            this.parameters = params == null ? new ArrayList<>() : params;
+            this.supertypes = ifaces == null ? new ArrayList<>() : ifaces;
+            this.methods = methods == null ? new ArrayList<>() : methods;
+            this.methodDependencies = new HashSet<>();
+            this.typeDependencies = new ArrayList<>();
+        }
+
+        public String getName() { return this.name; }
+        public List<AccessFlag> getAccessFlags() { return this.accessFlags; }
+        public List<TypeParameter> getParameters() { return this.parameters; }
+        public List<Extends> getSupertypes() { return this.supertypes; }
+        public List<Method> getMethods() { return this.methods; }
+        public Set<Method> methodDependencies() {
+            return this.methodDependencies;
+        }
+
+        public Class getSuperclass() { return null; }
+        protected abstract void setSuperClass(Extends supertype);
+
+        public void addSuperType(Extends sup) {
+            assert sup.getType() instanceof Interface : "Must be an interface";
+            this.supertypes.add(sup);
+        }
+        public void addSuperType(Interface iface) {
+            this.supertypes.add(new Extends(iface));
+        }
+
+        public void addMethod(Method m) {
+            this.methods.add(m);
+        }
+
+        public void addAccessFlag(AccessFlag f) {
+            this.accessFlags.add(f);
+        }
+
+        // Convenience method for creation.  Parameters are interpreted
+        // according to their type.  Class (or Extends with a Class type) is
+        // considered a superclass (only one allowed).  TypeParameters are
+        // generic parameter names.  Interface (or Extends with an Interface
+        // type) is an implemented supertype.  Methods are methods (duh!).
+        protected void addComponent(Element p) {
+            if (p instanceof Class) {
+                setSuperClass(new Extends((Class)p));
+            } else if (p instanceof Extends) {
+                Extends ext = (Extends)p;
+                if (ext.supertype instanceof Class) {
+                    setSuperClass(ext);
+                } else if (ext.supertype instanceof Interface) {
+                    addSuperType(ext);
+                } else {
+                    assert false : "What is this thing?";
+                }
+            } else if (p instanceof Interface) {
+                addSuperType((Interface)p);
+            } else if (p instanceof TypeParameter) {
+                this.parameters.add((TypeParameter)p);
+            } else if (p instanceof Method) {
+                addMethod((Method)p);
+            } else if (p instanceof AccessFlag) {
+                addAccessFlag((AccessFlag)p);
+            } else {
+                assert false : "What is this thing?";
+            }
+        }
+
+        // Find and return the first method that has name 'name'
+        public Method findMethod(String name) {
+            for (Method m : methods) {
+                if (m.name.equals(name)) {
+                    return m;
+                }
+            }
+            return null;
+        }
+
+        public void addCompilationDependency(Type t) {
+            typeDependencies.add(t);
+        }
+
+        public void addCompilationDependency(Method m) {
+            methodDependencies.add(m);
+        }
+
+        // Convenience method for creating an Extends object using this
+        // class and specified type arguments.
+        public Extends with(String ... args) {
+            return new Extends(this, args);
+        }
+
+        public abstract void generate(SourceProcessor sp);
+        public abstract void generateAsDependency(
+            SourceProcessor sp, Set<Method> neededMethods);
+
+        protected void generateName(PrintWriter pw) {
+            pw.print(this.name);
+            toJoinedString(this.parameters, ",", "<", ">", "");
+            pw.print(toJoinedString(this.parameters, ",", "<", ">", ""));
+            pw.print(" ");
+        }
+
+        protected void generateBody(PrintWriter pw, String superSpec) {
+            pw.print(toJoinedString(this.supertypes, ",", superSpec + " ", " ", ""));
+            pw.println("{ ");
+            pw.print(toJoinedString(this.methods, "\n    ", "\n    ", "\n", ""));
+            pw.println("}");
+        }
+
+        protected void generateAccessFlags(PrintWriter pw) {
+            pw.print(toJoinedString(this.accessFlags, " ", "", " "));
+        }
+
+        protected void generateBodyAsDependency(
+            PrintWriter pw, Set<Method> neededMethods) {
+            pw.println(" {");
+            for (Method m : this.methods) {
+                if (neededMethods.contains(m)) {
+                    pw.print("    ");
+                    m.generate(pw);
+                    pw.println();
+                }
+            }
+            pw.println("}");
+        }
+
+        public Collection<Type> typeDependencies() {
+            HashMap<String,Type> dependencies = new HashMap<>();
+            Type superclass = getSuperclass();
+            if (superclass != null) {
+                dependencies.put(superclass.getName(), superclass);
+            }
+            for (Extends e : getSupertypes())
+                dependencies.put(e.getType().getName(), e.getType());
+            // Do these last so that they override
+            for (Type t : this.typeDependencies)
+                dependencies.put(t.getName(), t);
+            return dependencies.values();
+        }
+    }
+
+    public static class Class extends Type {
+        private Extends superClass;
+
+        public Class(String name, List<AccessFlag> flags,
+                List<TypeParameter> params, Extends sprClass,
+                List<Extends> interfaces, List<Method> methods) {
+            super(name, flags, params, interfaces, methods);
+            this.superClass = sprClass;
+            addAccessFlag(AccessFlag.PUBLIC); // should remove this
+        }
+
+        public Class(String name, Element ... components) {
+            super(name, null, null, null, null);
+            this.superClass = null;
+
+            for (Element p : components) {
+                addComponent(p);
+            }
+            addAccessFlag(AccessFlag.PUBLIC); // should remove this
+        }
+
+        public boolean isAbstract() {
+            for (AccessFlag flag : getAccessFlags()) {
+                if (flag == AccessFlag.ABSTRACT) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public void setSuperClass(Extends ext) {
+            assert this.superClass == null : "Multiple superclasses defined";
+            assert ext.getType() instanceof Class : "Must be a class";
+            this.superClass = ext;
+        }
+
+        public void setSuperClass(Class c) {
+            setSuperClass(new Extends(c));
+        }
+
+        @Override
+        public Class getSuperclass() {
+            return superClass == null ? null : (Class)superClass.supertype;
+        }
+
+        public void generate(SourceProcessor processor) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            processor.process(getName(), sw.toString());
+        }
+
+        public void generate(PrintWriter pw) {
+            generateAccessFlags(pw);
+            pw.print("class ");
+            generateName(pw);
+            if (superClass != null) {
+                pw.print("extends ");
+                superClass.generate(pw);
+                pw.print(" ");
+            }
+            generateBody(pw, "implements");
+        }
+
+        public void generateAsDependency(
+                SourceProcessor processor, Set<Method> neededMethods) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generateAccessFlags(pw);
+            pw.print("class ");
+            generateName(pw);
+            pw.print(" ");
+            generateBodyAsDependency(pw, neededMethods);
+
+            processor.process(getName(), sw.toString());
+        }
+    }
+
+    public static class Interface extends Type {
+
+        public Interface(String name,
+                  List<AccessFlag> flags, List<TypeParameter> params,
+                  List<Extends> interfaces, List<Method> methods) {
+            super(name, flags, params, interfaces, methods);
+        }
+
+        public Interface(String name, Element ... components) {
+            super(name, null, null, null, null);
+            for (Element c : components) {
+                addComponent(c);
+            }
+        }
+
+        protected void setSuperClass(Extends ext) {
+            assert false : "Interfaces cannot have Class supertypes";
+        }
+
+        public void generate(SourceProcessor processor) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            processor.process(getName(), sw.toString());
+        }
+
+        public void generate(PrintWriter pw) {
+            generateAccessFlags(pw);
+            pw.print("interface ");
+            generateName(pw);
+            pw.print(" ");
+            generateBody(pw, "extends");
+        }
+
+        public void generateAsDependency(
+                SourceProcessor processor, Set<Method> neededMethods) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+
+            generateAccessFlags(pw);
+            pw.print("interface ");
+            generateName(pw);
+            pw.print(" ");
+            generateBodyAsDependency(pw, neededMethods);
+
+            processor.process(getName(), sw.toString());
+        }
+    }
+
+    /**
+     * Represents a type extension that might contain type arguments
+     */
+    public static class Extends extends Element {
+        private final Type supertype;
+        private final List<TypeArgument> arguments;
+
+        public Type getType() { return supertype; }
+        public List<TypeArgument> getArguments() {
+            return arguments;
+        }
+
+        public Extends(Type supertype, String ... args) {
+            assert supertype != null : "Null supertype";
+            this.supertype = supertype;
+            this.arguments = new ArrayList<>();
+            for (String arg : args) {
+                this.arguments.add(new TypeArgument(arg));
+            }
+        }
+
+        public void generate(PrintWriter pw) {
+            pw.print(supertype.getName());
+            pw.print(toJoinedString(getArguments(), ",", "<", ">", ""));
+        }
+    }
+
+    public static abstract class Method extends Element {
+        private String name;
+        private String returnType;
+        private List<AccessFlag> accessFlags;
+        private List<MethodParameter> parameters;
+        private boolean emitSuppressWarnings;
+
+        protected Method(String ret, String name, Element ... params) {
+            this.name = name;
+            this.returnType = ret;
+            this.accessFlags = new ArrayList<>();
+            this.parameters = new ArrayList<>();
+            this.emitSuppressWarnings = false;
+
+            for (Element e : params) {
+                if (e instanceof MethodParameter) {
+                    this.parameters.add((MethodParameter) e);
+                } else if (e instanceof AccessFlag) {
+                    this.accessFlags.add((AccessFlag) e);
+                }
+            }
+            assert accessFlags.size() + parameters.size() == params.length :
+                   "Non method parameters or access flags in constructor";
+        }
+
+        public String getName() { return this.name; }
+        public String getReturnType() { return this.returnType; }
+        public List<MethodParameter> getParameters() {
+            return this.parameters;
+        }
+        public List<AccessFlag> getAccessFlags() {
+            return this.accessFlags;
+        }
+        public Element[] getElements() {
+            ArrayList<Element> elements = new ArrayList<>();
+            elements.addAll(getParameters());
+            elements.addAll(getAccessFlags());
+            return elements.toArray(new Element[0]);
+        }
+
+        public void suppressWarnings() { this.emitSuppressWarnings = true; }
+
+        public void generateWarningSuppression(PrintWriter pw) {
+            if (this.emitSuppressWarnings) {
+                pw.printf("@SuppressWarnings(\"unchecked\")\n    ");
+            }
+        }
+
+        protected void generateDecl(PrintWriter pw) {
+            generateWarningSuppression(pw);
+            pw.print(toJoinedString(this.accessFlags, " ", "", " "));
+            pw.printf("%s %s(", returnType, name);
+            pw.print(toJoinedString(parameters, ","));
+            pw.print(")");
+        }
+    }
+
+    public static class AbstractMethod extends Method {
+        public AbstractMethod(
+                String ret, String name, Element ... params) {
+            super(ret, name, params);
+            this.getAccessFlags().add(AccessFlag.ABSTRACT);
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.print(";");
+        }
+
+        public static AbstractMethod std() {
+            return new AbstractMethod(
+                "int", SourceModel.stdMethodName, AccessFlag.PUBLIC);
+        }
+    }
+
+    public static class ConcreteMethod extends Method {
+        protected String body;
+
+        public ConcreteMethod(String ret, String name,
+                String body, Element ... params) {
+            super(ret, name, params);
+            this.body = body;
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.printf(" { %s }", this.body);
+        }
+
+        public static ConcreteMethod std(String value) {
+            return new ConcreteMethod(
+                "int", SourceModel.stdMethodName, "return " + value + ";",
+                AccessFlag.PUBLIC);
+        }
+    }
+
+    // When the default method flag gets moved into the traditional
+    // access flags location, we can remove this class completely and
+    // use a ConcreteMethod with an AccessFlag("default") in the constructor
+    public static class DefaultMethod extends Method {
+        protected String body;
+
+        public DefaultMethod(String ret, String name, String body,
+                Element ... params) {
+            super(ret, name, params);
+            this.body = body;
+            this.getAccessFlags().add(AccessFlag.DEFAULT);
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.printf(" { %s }", this.body);
+        }
+
+        public static DefaultMethod std(String value) {
+            return new DefaultMethod(
+                "int", SourceModel.stdMethodName, "return " + value + ";");
+        }
+    }
+
+    private static <T> String toJoinedString(List<T> list, String... p) {
+        StringBuilder sb = new StringBuilder();
+        String sep = "";
+        String init = "";
+        String end = "";
+        String empty = null;
+        switch (p.length) {
+            case 4:
+                empty = p[3];
+            /*fall-through*/
+            case 3:
+                end = p[2];
+            /*fall-through*/
+            case 2:
+                init = p[1];
+            /*fall-through*/
+            case 1:
+                sep = p[0];
+                break;
+        }
+        if (empty != null && list.isEmpty()) {
+            return empty;
+        } else {
+            sb.append(init);
+            for (T x : list) {
+                if (sb.length() != init.length()) {
+                    sb.append(sep);
+                }
+                sb.append(x.toString());
+            }
+            sb.append(end);
+            return sb.toString();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.separate;
+
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.testng.Assert.*;
+
+public class TestHarness {
+
+    /**
+     * Creates a per-thread persistent compiler object to allow as much
+     * sharing as possible, but still allows for parallel execution of tests.
+     */
+    protected ThreadLocal<Compiler> compilerLocal = new ThreadLocal<Compiler>(){
+         protected synchronized Compiler initialValue() {
+             return new Compiler();
+         }
+    };
+
+    protected ThreadLocal<Boolean> verboseLocal = new ThreadLocal<Boolean>() {
+         protected synchronized Boolean initialValue() {
+             return Boolean.FALSE;
+         }
+    };
+
+    protected boolean verbose;
+    protected boolean canUseCompilerCache;
+    public static final String stdMethodName = SourceModel.stdMethodName;
+
+    private TestHarness() {
+    }
+
+    protected TestHarness(boolean verbose, boolean canUseCompilerCache) {
+        this.verbose = verbose;
+        this.canUseCompilerCache = canUseCompilerCache;
+    }
+
+    public void setTestVerbose() {
+        verboseLocal.set(Boolean.TRUE);
+    }
+
+    @AfterMethod
+    public void reset() {
+        if (!this.verbose) {
+            verboseLocal.set(Boolean.FALSE);
+        }
+    }
+
+    public Compiler.Flags[] compilerFlags() {
+        HashSet<Compiler.Flags> flags = new HashSet<>();
+        if (verboseLocal.get() == Boolean.TRUE) {
+            flags.add(Compiler.Flags.VERBOSE);
+        }
+        if (this.canUseCompilerCache) {
+            flags.add(Compiler.Flags.USECACHE);
+        }
+        return flags.toArray(new Compiler.Flags[0]);
+    }
+
+    @AfterMethod
+    public void printError(ITestResult result) {
+        if (result.getStatus() == ITestResult.FAILURE) {
+            String clsName = result.getTestClass().getName();
+            clsName = clsName.substring(clsName.lastIndexOf(".") + 1);
+            System.out.println("Test " + clsName + "." +
+                               result.getName() + " FAILED");
+        }
+    }
+
+    private static final ConcreteMethod stdCM = ConcreteMethod.std("-1");
+    private static final AbstractMethod stdAM =
+            new AbstractMethod("int", stdMethodName);
+
+    /**
+     * Returns a class which has a static method with the same name as
+     * 'method', whose body creates an new instance of 'specimen' and invokes
+     * 'method' upon it via an invokevirtual instruction with 'args' as
+     * function call parameters.
+     *
+     * 'returns' is a dummy return value that need only match 'methods'
+     * return type (it is only used in the dummy class when compiling IV).
+     */
+    private Class invokeVirtualHarness(
+            Class specimen, ConcreteMethod method,
+            String returns, String ... args) {
+        Method cm = new ConcreteMethod(
+            method.getReturnType(), method.getName(),
+            "return " + returns + ";",  method.getElements());
+        Class stub = new Class(specimen.getName(), cm);
+
+        String params = toJoinedString(args, ", ");
+
+        ConcreteMethod sm = new ConcreteMethod(
+            method.getReturnType(), method.getName(),
+            String.format("return (new %s()).%s(%s);",
+                          specimen.getName(), method.getName(), params),
+            new AccessFlag("public"), new AccessFlag("static"));
+
+        Class iv = new Class("IV_" + specimen.getName(), sm);
+
+        iv.addCompilationDependency(stub);
+        iv.addCompilationDependency(cm);
+
+        return iv;
+    }
+
+    /**
+     * Returns a class which has a static method with the same name as
+     * 'method', whose body creates an new instance of 'specimen', casts it
+     * to 'iface' (including the type parameters)  and invokes
+     * 'method' upon it via an invokeinterface instruction with 'args' as
+     * function call parameters.
+     */
+    private Class invokeInterfaceHarness(Class specimen, Extends iface,
+            AbstractMethod method, String ... args) {
+        Interface istub = new Interface(
+            iface.getType().getName(), iface.getType().getAccessFlags(),
+            iface.getType().getParameters(),
+            null, Arrays.asList((Method)method));
+        Class cstub = new Class(specimen.getName());
+
+        String params = toJoinedString(args, ", ");
+
+        ConcreteMethod sm = new ConcreteMethod(
+            "int", SourceModel.stdMethodName,
+            String.format("return ((%s)(new %s())).%s(%s);", iface.toString(),
+                specimen.getName(), method.getName(), params),
+            new AccessFlag("public"), new AccessFlag("static"));
+        sm.suppressWarnings();
+
+        Class ii = new Class("II_" + specimen.getName() + "_" +
+            iface.getType().getName(), sm);
+        ii.addCompilationDependency(istub);
+        ii.addCompilationDependency(cstub);
+        ii.addCompilationDependency(method);
+        return ii;
+    }
+
+
+    /**
+     * Uses 'loader' to load class 'clzz', and calls the static method
+     * 'method'.  If the return value does not equal 'value' (or if an
+     * exception is thrown), then a test failure is indicated.
+     *
+     * If 'value' is null, then no equality check is performed -- the assertion
+     * fails only if an exception is thrown.
+     */
+    protected void assertStaticCallEquals(
+            ClassLoader loader, Class clzz, String method, Object value) {
+        java.lang.Class<?> cls = null;
+        try {
+            cls = java.lang.Class.forName(clzz.getName(), true, loader);
+        } catch (ClassNotFoundException e) {}
+        assertNotNull(cls);
+
+        java.lang.reflect.Method m = null;
+        try {
+            m = cls.getMethod(method);
+        } catch (NoSuchMethodException e) {}
+        assertNotNull(m);
+
+        try {
+            Object res = m.invoke(null);
+            assertNotNull(res);
+            if (value != null) {
+                assertEquals(res, value);
+            }
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            fail("Unexpected exception thrown: " + e.getCause());
+        }
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokevirtual,
+     * compiles and loads both the new class and 'target', and then invokes
+     * the method.  If the returned value does not match 'value' then a
+     * test failure is indicated.
+     */
+    public void assertInvokeVirtualEquals(
+            Object value, Class target, ConcreteMethod method,
+            String returns, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class iv = invokeVirtualHarness(target, method, returns, args);
+        ClassLoader loader = compiler.compile(iv, target);
+
+        assertStaticCallEquals(loader, iv, method.getName(), value);
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertInvokeVirtualEquals(int value, Class target) {
+        assertInvokeVirtualEquals(
+            new Integer(value), target, stdCM, "-1");
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokeinterface
+     * through 'iface', compiles and loads both it and 'target', and
+     * then invokes the method.  If the returned value does not match
+     * 'value' then a test failure is indicated.
+     */
+    public void assertInvokeInterfaceEquals(Object value, Class target,
+            Extends iface, AbstractMethod method, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class ii = invokeInterfaceHarness(target, iface, method, args);
+        ClassLoader loader = compiler.compile(ii, target);
+
+        assertStaticCallEquals(loader, ii, method.getName(), value);
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertInvokeInterfaceEquals(
+            int value, Class target, Interface iface) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        assertInvokeInterfaceEquals(
+            new Integer(value), target, new Extends(iface), stdAM);
+
+        compiler.cleanup();
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokevirtual,
+     * compiles and loads both the new class and 'target', and then invokes
+     * the method.  If an exception of type 'exceptionType' is not thrown,
+     * then a test failure is indicated.
+     */
+    public void assertThrows(java.lang.Class<?> exceptionType, Class target,
+            ConcreteMethod method, String returns, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class iv = invokeVirtualHarness(target, method, returns, args);
+        ClassLoader loader = compiler.compile(iv, target);
+
+        java.lang.Class<?> cls = null;
+        try {
+            cls = java.lang.Class.forName(iv.getName(), true, loader);
+        } catch (ClassNotFoundException e) {}
+        assertNotNull(cls);
+
+        java.lang.reflect.Method m = null;
+        try {
+            m = cls.getMethod(method.getName());
+        } catch (NoSuchMethodException e) {}
+        assertNotNull(m);
+
+        try {
+            m.invoke(null);
+            fail("Exception should have been thrown");
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            if (verboseLocal.get() == Boolean.TRUE) {
+                System.out.println(e.getCause());
+            }
+            assertEquals(e.getCause().getClass(), exceptionType);
+        }
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertThrows(java.lang.Class<?> exceptionType, Class target) {
+        assertThrows(exceptionType, target, stdCM, "-1");
+    }
+
+    private static <T> String toJoinedString(T[] a, String... p) {
+        return toJoinedString(Arrays.asList(a), p);
+    }
+
+    private static <T> String toJoinedString(List<T> list, String... p) {
+        StringBuilder sb = new StringBuilder();
+        String sep = "";
+        String init = "";
+        String end = "";
+        String empty = null;
+        switch (p.length) {
+            case 4:
+                empty = p[3];
+            /*fall-through*/
+            case 3:
+                end = p[2];
+            /*fall-through*/
+            case 2:
+                init = p[1];
+            /*fall-through*/
+            case 1:
+                sep = p[0];
+                break;
+        }
+        if (empty != null && list.isEmpty()) {
+            return empty;
+        } else {
+            sb.append(init);
+            for (T x : list) {
+                if (sb.length() != init.length()) {
+                    sb.append(sep);
+                }
+                sb.append(x.toString());
+            }
+            sb.append(end);
+            return sb.toString();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class ClassCase {
+
+    public enum Kind {
+        IVAC        (true,  "v"),
+        IPRESENT    (true,  "p"),
+        IDEFAULT    (true,  "d"),
+        CNONE       (false, "n"),
+        CABSTRACT   (false, "a"),
+        CCONCRETE   (false, "c");
+
+        private final String prefix;
+        public final boolean isInterface;
+
+        Kind(boolean isInterface, String prefix) {
+            this.isInterface = isInterface;
+            this.prefix = prefix;
+        }
+
+        public String getPrefix() { return prefix; }
+    }
+
+    public final Kind kind;
+    private final ClassCase superclass;
+    private final List<ClassCase> supertypes;
+
+    private String name;
+    private boolean _OK;
+    private boolean _HasClassMethod;
+    private Set<ClassCase> _mprov;
+    private boolean _IsConcrete;
+    private boolean _HasDefault;
+    private ClassCase _mres;
+    private ClassCase _mdefend;
+
+    private Set<RuleGroup> executed = new HashSet<RuleGroup>();
+
+    public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
+        this.kind = kind;
+        this.superclass = superclass;
+
+        // Set supertypes from superclass (if any) and interfaces
+        List<ClassCase> lc;
+        if (superclass == null) {
+            lc = interfaces;
+        } else {
+            lc = new ArrayList<>();
+            lc.add(superclass);
+            lc.addAll(interfaces);
+        }
+        this.supertypes = lc;
+    }
+
+    public final boolean isInterface() { return kind.isInterface; }
+    public final boolean isClass() { return !kind.isInterface; }
+
+    public Set<ClassCase> get_mprov() {
+        exec(RuleGroup.PROVENENCE);
+        return _mprov;
+    }
+
+    public void set_mprov(ClassCase cc) {
+        Set<ClassCase> s = new HashSet<>();
+        s.add(cc);
+        _mprov = s;
+    }
+
+    public void set_mprov(Set<ClassCase> s) {
+        _mprov = s;
+    }
+
+    public ClassCase get_mres() {
+        exec(RuleGroup.RESOLUTION);
+        return _mres;
+    }
+
+    public void set_mres(ClassCase cc) {
+        _mres = cc;
+    }
+
+    public ClassCase get_mdefend() {
+        exec(RuleGroup.DEFENDER);
+        return _mdefend;
+    }
+
+    public void set_mdefend(ClassCase cc) {
+        _mdefend = cc;
+    }
+
+    public boolean get_HasClassMethod() {
+        exec(RuleGroup.PROVENENCE);
+        return _HasClassMethod;
+    }
+
+    public void set_HasClassMethod(boolean bool) {
+        _HasClassMethod = bool;
+    }
+
+    public boolean get_HasDefault() {
+        exec(RuleGroup.MARKER);
+        return _HasDefault;
+    }
+
+    public void set_HasDefault(boolean bool) {
+        _HasDefault = bool;
+    }
+
+    public boolean get_IsConcrete() {
+        exec(RuleGroup.MARKER);
+        return _IsConcrete;
+    }
+
+    public void set_IsConcrete(boolean bool) {
+        _IsConcrete = bool;
+    }
+
+    public boolean get_OK() {
+        exec(RuleGroup.CHECKING);
+        return _OK;
+    }
+
+    public void set_OK(boolean bool) {
+        _OK = bool;
+    }
+
+    public boolean isMethodDefined() {
+        for (ClassCase cc : supertypes) {
+            if (cc.isMethodDefined()) {
+                return true;
+            }
+        }
+        switch (kind) {
+            case CCONCRETE:
+            case CABSTRACT:
+            case IPRESENT:
+            case IDEFAULT:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    public boolean isAbstract() {
+        return isMethodDefined() && (get_mres()==null);
+    }
+
+    public boolean hasSuperclass() {
+        return superclass != null;
+    }
+
+    public ClassCase getSuperclass() {
+        return superclass;
+    }
+
+    public List<ClassCase> getSupertypes() {
+        return supertypes;
+    }
+
+    public List<ClassCase> getInterfaces() {
+        if (superclass != null) {
+            if (supertypes.get(0) != superclass) {
+                throw new AssertionError("superclass missing from supertypes");
+            }
+            return supertypes.subList(1, supertypes.size());
+        } else {
+            return supertypes;
+        }
+    }
+
+    public boolean isSubtypeOf(ClassCase cc) {
+        // S-Refl
+        if (cc.equals(this)) {
+            return true;
+        }
+
+        // S-Def
+        for (ClassCase sp : getSupertypes()) {
+            if (cc.equals(sp)) {
+                return true;
+            }
+        }
+
+        // _S-Trans
+        for (ClassCase sp : getSupertypes()) {
+            if (sp.isSubtypeOf(cc)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public void init(Map<String, Integer> namingContext) {
+        if (name != null) {
+            return; // Already inited
+        }
+
+        for (ClassCase sup : supertypes) {
+            sup.init(namingContext);
+        }
+
+        // Build name
+        StringBuilder sb = new StringBuilder();
+        if (!supertypes.isEmpty()) {
+            sb.append(isInterface() ? "I" : "C");
+            for (ClassCase cc : supertypes) {
+                sb.append(cc.getName());
+            }
+            sb.append(kind.isInterface ? "i" : "c");
+        }
+        sb.append(kind.prefix);
+        String pname = sb.toString();
+        Integer icnt = namingContext.get(pname);
+        int cnt = icnt == null ? 0 : icnt;
+        ++cnt;
+        namingContext.put(pname, cnt);
+        if (cnt > 1) {
+            sb.append(cnt);
+        }
+        this.name = sb.toString();
+    }
+
+    public boolean isa(Kind... kinds) {
+        for (Kind k : kinds) {
+            if (kind == k) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void exec(RuleGroup rg ) {
+        if (!executed.contains(rg)) {
+            rg.exec(this);
+            executed.add(rg);
+        }
+    }
+
+    public void collectClasses(Set<ClassCase> seen) {
+        seen.add(this);
+        for (ClassCase cc : supertypes) {
+            cc.collectClasses(seen);
+        }
+    }
+
+    public String getID() {
+        if (name == null) {
+            throw new Error("Access to uninitialized ClassCase");
+        } else {
+            return name;
+        }
+    }
+
+    public final String getName() {
+        if (name == null) {
+            return "ClassCase uninited@" + hashCode();
+        } else {
+            return name;
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
+    }
+
+    @Override
+    public int hashCode() {
+        return getID().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class Hierarchy {
+
+    public final ClassCase root;
+    public final Set<ClassCase> all;
+
+    public Hierarchy(ClassCase root) {
+        this.root = root;
+        root.init(new HashMap<String,Integer>());
+        Set<ClassCase> allClasses = new HashSet<>();
+        root.collectClasses(allClasses);
+        this.all = allClasses;
+    }
+
+    public boolean anyDefaults() {
+        for (ClassCase cc : all) {
+            if (cc.kind == IDEFAULT) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean get_OK() {
+        return root.get_OK();
+    }
+
+    public String testName() {
+        return root + "Test";
+    }
+
+    private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
+            if (!interfaces.isEmpty()) {
+                buf.append(" ");
+                buf.append(prefix);
+                buf.append(" ");
+                buf.append(interfaces.get(0));
+                for (int i = 1; i < interfaces.size(); ++i) {
+                    buf.append(", " + interfaces.get(i));
+                }
+            }
+    }
+
+    public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
+        if (cc.isInterface()) {
+            buf.append("interface ");
+            buf.append(cc.getName() + " ");
+            genInterfaceList(buf, "extends", cc.getInterfaces());
+            buf.append(" {\n");
+
+            switch (cc.kind) {
+                case IDEFAULT:
+                    buf.append("    default String m() { return \"\"; }\n");
+                    defaultRef.add(cc);
+                    break;
+                case IPRESENT:
+                    buf.append("    String m();\n");
+                    break;
+                case IVAC:
+                    break;
+                default:
+                    throw new AssertionError("Unexpected kind");
+            }
+            buf.append("}\n\n");
+        } else {
+            buf.append((cc.isAbstract()? "abstract " : ""));
+            buf.append(" class " + cc.getName());
+            if (cc.getSuperclass() != null) {
+                buf.append(" extends " + cc.getSuperclass());
+            }
+
+            genInterfaceList(buf, "implements", cc.getInterfaces());
+            buf.append(" {\n");
+
+            switch (cc.kind) {
+                case CCONCRETE:
+                    buf.append("   public String m() { return \"\"; }\n");
+                    break;
+                case CABSTRACT:
+                    buf.append("   public abstract String m();\n");
+                    break;
+                case CNONE:
+                    break;
+                default:
+                    throw new AssertionError("Unexpected kind");
+            }
+            buf.append("}\n\n");
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
+    }
+
+    @Override
+    public int hashCode() {
+        return root.getID().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return root.getName();
+    }
+
+    private static String classNames[] = {
+        "C", "D", "E", "F", "G", "H", "S", "T", "U", "V"
+    };
+
+    private static String interfaceNames[] = {
+        "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R"
+    };
+
+    private static int CLASS_INDEX = 0;
+    private static int INTERFACE_INDEX = 1;
+    private static int NUM_INDICIES = 2;
+
+    public List<String> getDescription() {
+        Map<ClassCase,String> nameMap = new HashMap<>();
+        assignNames(root, new int[NUM_INDICIES], nameMap);
+
+        ArrayList<String> res = new ArrayList<>();
+        if (root.getSupertypes().size() == 0) {
+           res.add(nameMap.get(root) + root.kind.getPrefix() + "()");
+        } else {
+            genCaseDescription(root, res, new HashSet<ClassCase>(), nameMap);
+        }
+        return res;
+    }
+
+    private static void assignNames(
+            ClassCase cc, int indices[], Map<ClassCase,String> names) {
+        String name = names.get(cc);
+        if (name == null) {
+            if (cc.isInterface()) {
+                names.put(cc, interfaceNames[indices[INTERFACE_INDEX]++]);
+            } else {
+                names.put(cc, classNames[indices[CLASS_INDEX]++]);
+            }
+            for (int i = 0; i < cc.getSupertypes().size(); ++i) {
+                assignNames(cc.getSupertypes().get(i), indices, names);
+            }
+        }
+    }
+
+    private static void genCaseDescription(
+            ClassCase cc, List<String> res, Set<ClassCase> alreadyDone,
+            Map<ClassCase,String> nameMap) {
+        if (!alreadyDone.contains(cc)) {
+            if (cc.getSupertypes().size() > 0) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(nameMap.get(cc));
+                sb.append(cc.kind.getPrefix());
+                sb.append("(");
+                for (int i = 0; i < cc.getSupertypes().size(); ++i) {
+                    ClassCase supertype = cc.getSupertypes().get(i);
+                    if (i != 0) {
+                        sb.append(",");
+                    }
+                    genCaseDescription(supertype, res, alreadyDone, nameMap);
+                    sb.append(nameMap.get(supertype));
+                    sb.append(supertype.kind.getPrefix());
+                }
+                sb.append(")");
+                res.add(sb.toString());
+            }
+        }
+        alreadyDone.add(cc);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import org.openjdk.tests.shapegen.ClassCase.Kind;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+import static java.lang.Math.pow;
+
+/**
+ *
+ * @author Robert Field
+ */
+public final class HierarchyGenerator {
+
+    private int okcnt = 0;
+    private int errcnt = 0;
+    private Set<Hierarchy> uniqueOK = new HashSet<>();
+    private Set<Hierarchy> uniqueErr = new HashSet<>();
+
+    /**
+     * @param args the command line arguments
+     */
+    public HierarchyGenerator() {
+        organize("exhaustive interface", iExhaustive(2));
+        organize("exhaustive class", cExhaustive());
+        organize("shapes interface", iShapes());
+        organize("shapes class/interface", ciShapes());
+
+        System.out.printf("\nExpect OK:    %d -- unique %d",   okcnt,  uniqueOK.size());
+        System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size());
+    }
+
+    public Collection<Hierarchy> getOK() {
+        return uniqueOK;
+    }
+
+    public Collection<Hierarchy> getErr() {
+        return uniqueErr;
+    }
+
+    private void organize(String tname, List<Hierarchy> totest) {
+        System.out.printf("\nGenerating %s....\n", tname);
+        int nodefault = 0;
+        List<Hierarchy> ok = new ArrayList<>();
+        List<Hierarchy> err = new ArrayList<>();
+        for (Hierarchy cc : totest) {
+            if (cc.anyDefaults()) {
+                //System.out.printf("  %s\n", cc);
+                if (cc.get_OK()) {
+                    ok.add(cc);
+                } else {
+                    err.add(cc);
+                }
+            } else {
+                ++nodefault;
+            }
+        }
+
+        errcnt += err.size();
+        okcnt += ok.size();
+        uniqueErr.addAll(err);
+        uniqueOK.addAll(ok);
+
+        System.out.printf("  %5d No default\n  %5d Error\n  %5d OK\n  %5d Total\n",
+                nodefault, err.size(), ok.size(), totest.size());
+    }
+
+    public List<Hierarchy> iExhaustive(int idepth) {
+        List<ClassCase> current = new ArrayList<>();
+        for (int i = 0; i < idepth; ++i) {
+            current = ilayer(current);
+        }
+        return wrapInClassAndHierarchy(current);
+    }
+
+    private List<ClassCase> ilayer(List<ClassCase> srcLayer) {
+        List<ClassCase> lay = new ArrayList<>();
+        for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) {
+            List<ClassCase> itfs = new ArrayList<>();
+            for (int b = srcLayer.size() - 1; b >= 0; --b) {
+                if ((i & (1<<b)) != 0) {
+                    itfs.add(srcLayer.get(b));
+                }
+            }
+            lay.add(new ClassCase(IVAC, null, itfs));
+            lay.add(new ClassCase(IPRESENT, null, itfs));
+            lay.add(new ClassCase(IDEFAULT, null, itfs));
+            lay.add(new ClassCase(IDEFAULT, null, itfs));
+        }
+        return lay;
+    }
+
+    public List<Hierarchy> cExhaustive() {
+        final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null};
+        final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE};
+        List<Hierarchy> totest = new ArrayList<>();
+        for (int i1 = 0; i1 < iKinds.length; ++i1) {
+            for (int i2 = 0; i2 < iKinds.length; ++i2) {
+                for (int i3 = 0; i3 < iKinds.length; ++i3) {
+                    for (int c1 = 0; c1 < cKinds.length; ++c1) {
+                        for (int c2 = 0; c2 < cKinds.length; ++c2) {
+                            for (int c3 = 0; c3 < cKinds.length; ++c3) {
+                                totest.add( new Hierarchy(
+                                        new ClassCase(cKinds[c1],
+                                            new ClassCase(cKinds[c2],
+                                                new ClassCase(cKinds[c3],
+                                                    null,
+                                                    iList(iKinds[i1])
+                                                ),
+                                                iList(iKinds[i2])
+                                            ),
+                                            iList(iKinds[i3])
+                                        )));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return totest;
+    }
+
+    public static final List<ClassCase> EMPTY_LIST = new ArrayList<>();
+
+    private List<ClassCase> iList(Kind kind) {
+        if (kind == null) {
+            return EMPTY_LIST;
+        } else {
+            List<ClassCase> itfs = new ArrayList<>();
+            itfs.add(new ClassCase(kind, null, EMPTY_LIST));
+            return itfs;
+        }
+    }
+
+    public List<Hierarchy> ciShapes() {
+        return wrapInHierarchy(TTShape.allCases(true));
+    }
+
+    public List<Hierarchy> iShapes() {
+        return wrapInClassAndHierarchy(TTShape.allCases(false));
+    }
+
+    public List<Hierarchy> wrapInClassAndHierarchy(List<ClassCase> ihs) {
+        List<Hierarchy> totest = new ArrayList<>();
+        for (ClassCase cc : ihs) {
+            List<ClassCase> interfaces = new ArrayList<>();
+            interfaces.add(cc);
+            totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces)));
+        }
+        return totest;
+    }
+
+    public List<Hierarchy> wrapInHierarchy(List<ClassCase> ihs) {
+        List<Hierarchy> totest = new ArrayList<>();
+        for (ClassCase cc : ihs) {
+            totest.add(new Hierarchy(cc));
+        }
+        return totest;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+/**
+ *
+ * @author Robert Field
+ */
+public abstract class Rule {
+
+    public final String name;
+
+    public Rule(String name) {
+        this.name = name;
+    }
+
+    abstract boolean guard(ClassCase cc);
+
+    abstract void eval(ClassCase cc);
+
+    @Override
+    public String toString() {
+        return name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class RuleGroup {
+
+    final String name;
+    private final Rule[] rules;
+
+    public RuleGroup(String name, Rule[] rules) {
+        this.name = name;
+        this.rules = rules;
+    }
+
+    public boolean exec(ClassCase cc) {
+        boolean found = false;
+        for (Rule rule : rules) {
+            if (rule.guard(cc)) {
+                if (found) {
+                    throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc);
+                } else {
+                    rule.eval(cc);
+                    found = true;
+                }
+            }
+        }
+        return found;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] {
+      new Rule("P-CDeclare") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(CCONCRETE, CABSTRACT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc);
+              cc.set_HasClassMethod(true);
+          }
+      },
+
+      new Rule("P-IDeclare") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IDEFAULT, IPRESENT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc);
+          }
+      },
+
+      new Rule("P-IntfInh") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
+          }
+
+          void eval(ClassCase cc) {
+              Set<ClassCase> _S = new HashSet<>();
+              for (ClassCase t : cc.getSupertypes()) {
+                  _S.addAll(t.get_mprov());
+              }
+              Set<ClassCase> tops = new HashSet<>();
+              for (ClassCase _W : _S) {
+                  for (ClassCase _V : _S) {
+                      if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) {
+                          tops.add(_W);
+                      }
+                  }
+              }
+              cc.set_mprov(tops);
+          }
+      },
+
+      new Rule("P-ClassInh") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc.getSuperclass());
+              cc.set_HasClassMethod(true);
+          }
+      },
+
+    });
+
+    public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] {
+      new Rule("M-Default") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IDEFAULT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_HasDefault(true);
+          }
+      },
+
+      new Rule("M-Conc") {
+          boolean guard(ClassCase cc) {
+            return cc.isa(CCONCRETE);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_IsConcrete(true);
+          }
+      },
+
+    });
+
+    public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] {
+      new Rule("R-Resolve") {
+          boolean guard(ClassCase cc) {
+              if (!(cc.isClass() && cc.get_mprov().size() == 1)) {
+                  return false;
+              }
+              ClassCase _V = cc.get_mprov().iterator().next();
+              return _V.get_IsConcrete() || _V.get_HasDefault();
+          }
+
+          void eval(ClassCase cc) {
+              ClassCase _V = cc.get_mprov().iterator().next();
+              cc.set_mres(_V);
+          }
+      },
+
+    });
+
+    public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] {
+      new Rule("D-Defend") {
+          boolean guard(ClassCase cc) {
+              ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null;
+              boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper);
+              return cc.isa(CNONE) && !eq;
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mdefend(cc.get_mres());
+          }
+      },
+
+    });
+
+    public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] {
+      new Rule("C-Check") {
+          boolean guard(ClassCase cc) {
+              for (ClassCase t : cc.getSupertypes()) {
+                  if (! t.get_OK()) {
+                      return false;
+                  }
+              }
+              int defenderCount = 0;
+              int provCount = 0;
+              for (ClassCase prov : cc.get_mprov()) {
+                  if (prov.get_HasDefault()) {
+                      defenderCount++;
+                  }
+                  provCount++;
+              }
+              return provCount <= 1 || defenderCount == 0;
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_OK(true);
+          }
+      },
+
+    });
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import org.openjdk.tests.shapegen.ClassCase.Kind;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ * Type Template Node
+ *
+ * @author Robert Field
+ */
+public class TTNode {
+
+    final List<TTNode> supertypes;
+    final boolean canBeClass;
+
+    private int currentKindIndex;
+    private Kind[] kinds;
+
+    public TTNode(List<TTNode> subtypes, boolean canBeClass) {
+        this.supertypes = subtypes;
+        this.canBeClass = canBeClass;
+    }
+
+    public void start(boolean includeClasses) {
+        kinds =
+             supertypes.isEmpty()?
+                (new Kind[]{IDEFAULT, IPRESENT})
+             :  ((includeClasses && canBeClass)?
+                  new Kind[]{CNONE, IVAC, IDEFAULT, IPRESENT}
+                : new Kind[]{IVAC, IDEFAULT, IPRESENT});
+        currentKindIndex = 0;
+
+        for (TTNode sub : supertypes) {
+            sub.start(includeClasses);
+        }
+    }
+
+    public boolean next() {
+        ++currentKindIndex;
+        if (currentKindIndex >= kinds.length) {
+            currentKindIndex = 0;
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    public void collectAllSubtypes(Set<TTNode> subs) {
+        subs.add(this);
+        for (TTNode n : supertypes) {
+            n.collectAllSubtypes(subs);
+        }
+    }
+
+    private Kind getKind() {
+        return kinds[currentKindIndex];
+    }
+
+    boolean isInterface() {
+        return getKind().isInterface;
+    }
+
+    boolean isClass() {
+        return !isInterface();
+    }
+
+    boolean hasDefault() {
+        return getKind() == IDEFAULT;
+    }
+
+    public boolean isValid() {
+        for (TTNode n : supertypes) {
+            if (!n.isValid() || (isInterface() && n.isClass())) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public ClassCase genCase() {
+        ClassCase subclass;
+        List<TTNode> ttintfs;
+        if (isClass() && !supertypes.isEmpty() && supertypes.get(0).isClass()) {
+            subclass = supertypes.get(0).genCase();
+            ttintfs = supertypes.subList(1, supertypes.size());
+        } else {
+            subclass = null;
+            ttintfs = supertypes;
+        }
+        List<ClassCase> intfs = new ArrayList<>();
+        for (TTNode node : ttintfs) {
+            intfs.add(node.genCase());
+        }
+        return new ClassCase(getKind(), subclass, intfs);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.StringReader;
+
+import static java.lang.Character.isLetter;
+import static java.lang.Character.isUpperCase;
+import static java.lang.Character.isWhitespace;
+
+/**
+ * Parse a type template definition string
+ *
+ *   input     :: classDef
+ *   classDef  :: letter [ ( classDef* ) ]
+ *
+ * @author Robert Field
+ */
+public class TTParser extends StringReader {
+
+    private Map<Character, TTNode> letterMap = new HashMap<>();
+    private char ch;
+
+    private final String def;
+
+    public TTParser(String s) {
+        super(s);
+        this.def = s;
+    }
+
+    private void advance() throws IOException {
+        do {
+            ch = (char)read();
+        } while (isWhitespace(ch));
+    }
+
+    public TTNode parse() {
+        try {
+            advance();
+            return classDef();
+        } catch (IOException t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private TTNode classDef() throws IOException {
+        if (!isLetter(ch)) {
+            if (ch == (char)-1) {
+                throw new IOException("Unexpected end of type template in " + def);
+            } else {
+                throw new IOException("Unexpected character in type template: " + (Character)ch + " in " + def);
+            }
+        }
+        char nodeCh = ch;
+        TTNode node = letterMap.get(nodeCh);
+        boolean canBeClass = isUpperCase(nodeCh);
+        advance();
+        if (node == null) {
+            List<TTNode> subtypes = new ArrayList<>();
+            if (ch == '(') {
+                advance();
+                while (ch != ')') {
+                    subtypes.add(classDef());
+                }
+                advance();
+            }
+            node = new TTNode(subtypes, canBeClass);
+            letterMap.put(nodeCh, node);
+        }
+        return node;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class TTShape {
+
+    private final TTNode root;
+    private final TTNode[] nodes;
+
+    TTShape(TTNode root) {
+        this.root = root;
+        Set<TTNode> subs = new HashSet<>();
+        root.collectAllSubtypes(subs);
+        nodes = subs.toArray(new TTNode[subs.size()]);
+    }
+
+    private List<ClassCase> toCases(boolean includeClasses) {
+        List<ClassCase> ccs = new ArrayList<>();
+        root.start(includeClasses);
+        int i;
+        outer:
+        while (true) {
+            if (root.isValid()) {
+                ClassCase cc = root.genCase();
+                //System.out.println(cc);
+                ccs.add(cc);
+            }
+
+            i = 0;
+            do {
+                if (i >= nodes.length) {
+                    break outer;
+                }
+            } while(!nodes[i++].next());
+        }
+        return ccs;
+    }
+
+   public static List<ClassCase> allCases(boolean includeClasses) {
+        List<ClassCase> ccs = new ArrayList<>();
+        for (TTShape shape : SHAPES) {
+            ccs.addAll(shape.toCases(includeClasses));
+        }
+        return ccs;
+    }
+
+    public static TTShape parse(String s) {
+        return new TTShape(new TTParser(s).parse());
+    }
+
+    public static final TTShape[] SHAPES = new TTShape[] {
+        parse("a"),
+        parse("a(b)"),
+        parse("A(bb)"),
+        parse("A(B(d)c(d))"),
+        parse("A(b(c))"),
+        parse("A(B(cd)d)"),
+        parse("A(B(c)c)"),
+        parse("A(B(Ce)d(e))"),
+        parse("A(B(C)d(e))"),
+        parse("A(Bc(d))"),
+        parse("A(B(d)dc)"),
+        parse("A(B(dc)dc)"),
+        parse("A(B(c(d))d)"),
+        parse("A(B(C(d))d)"),
+        parse("A(B(C(e)d(e))e)"),
+        parse("A(B(c(d))c)"),
+        parse("A(B(dc(d))c)"),
+        parse("A(B(C(d))d)"),
+    };
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,826 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.vm;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.io.File;
+import java.io.IOException;
+
+import org.testng.annotations.Test;
+import org.openjdk.tests.separate.*;
+import org.openjdk.tests.separate.Compiler;
+
+import static org.testng.Assert.*;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.openjdk.tests.separate.SourceModel.Class;
+
+@Test(groups = "vm")
+public class DefaultMethodsTest extends TestHarness {
+    public DefaultMethodsTest() {
+        super(false, false);
+    }
+
+    /**
+     * class C { public int m() { return 22; } }
+     *
+     * TEST: C c = new C(); c.m() == 22
+     */
+    public void testHarnessInvokeVirtual() {
+        Class C = new Class("C", ConcreteMethod.std("22"));
+        assertInvokeVirtualEquals(22, C);
+    }
+
+    /**
+     * interface I { int m(); }
+     * class C implements I { public int m() { return 33; } }
+     *
+     * TEST: I i = new C(); i.m() == 33;
+     */
+    public void testHarnessInvokeInterface() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Class C = new Class("C", I, ConcreteMethod.std("33"));
+        assertInvokeInterfaceEquals(33, C, I);
+    }
+
+    /**
+     * class C {}
+     *
+     * TEST: C c = new C(); c.m() throws NoSuchMethod
+     */
+    public void testHarnessThrows() {
+        Class C = new Class("C");
+        assertThrows(NoSuchMethodError.class, C);
+    }
+
+    /**
+     * interface I { int m() default { return 44; } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: I i = new C(); i.m() == 44;
+     */
+    public void testBasicDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Class C = new Class("C", I);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 44; } }
+     * interface J extends I {}
+     * interface K extends J {}
+     * class C implements K {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: I i = new C(); i.m() == 44;
+     */
+    public void testFarDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", J);
+        Class C = new Class("C", K);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, K);
+    }
+
+    /**
+     * interface I { int m(); }
+     * interface J extends I { default int m() { return 44; } }
+     * interface K extends J {}
+     * class C implements K {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: K k = new C(); k.m() == 44;
+     */
+    public void testOverrideAbstract() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Interface J = new Interface("J", I, DefaultMethod.std("44"));
+        Interface K = new Interface("K", J);
+        Class C = new Class("C", K);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, K);
+    }
+
+    /**
+     * interface I { int m() default { return 44; } }
+     * class C implements I { public int m() { return 55; } }
+     *
+     * TEST: C c = new C(); c.m() == 55;
+     * TEST: I i = new C(); i.m() == 55;
+     */
+    public void testExisting() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Class C = new Class("C", I, ConcreteMethod.std("55"));
+
+        assertInvokeVirtualEquals(55, C);
+        assertInvokeInterfaceEquals(55, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testInherited() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class C { public int m() { return 11; } }
+     * class D extends C implements I {}
+     *
+     * TEST: D d = new D(); d.m() == 11;
+     * TEST: I i = new D(); i.m() == 11;
+     */
+    public void testExistingInherited() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class C = new Class("C", ConcreteMethod.std("11"));
+        Class D = new Class("D", C, I);
+
+        assertInvokeVirtualEquals(11, D);
+        assertInvokeInterfaceEquals(11, D, I);
+    }
+
+    /**
+     * interface I { default int m() { return 44; } }
+     * class C implements I { public int m() { return 11; } }
+     * class D extends C { public int m() { return 22; } }
+     *
+     * TEST: D d = new D(); d.m() == 22;
+     * TEST: I i = new D(); i.m() == 22;
+     */
+    void testExistingInheritedOverride() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class C = new Class("C", I, ConcreteMethod.std("11"));
+        Class D = new Class("D", C, ConcreteMethod.std("22"));
+
+        assertInvokeVirtualEquals(22, D);
+        assertInvokeInterfaceEquals(22, D, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J { defaultint m() { return 88; } }
+     * class C implements I { public int m() { return 11; } }
+     * class D extends C { public int m() { return 22; } }
+     * class E extends D implements J {}
+     *
+     * TEST: E e = new E(); e.m() == 22;
+     * TEST: J j = new E(); j.m() == 22;
+     */
+    public void testExistingInheritedPlusDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, ConcreteMethod.std("11"));
+        Class D = new Class("D", C, ConcreteMethod.std("22"));
+        Class E = new Class("E", D, J);
+
+        assertInvokeVirtualEquals(22, E);
+        assertInvokeInterfaceEquals(22, E, J);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B { public int m() { return 77; } }
+     *
+     * TEST: C c = new C(); c.m() == 77;
+     * TEST: I i = new C(); i.m() == 77;
+     */
+    public void testInheritedWithConcrete() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B, ConcreteMethod.std("77"));
+
+        assertInvokeVirtualEquals(77, C);
+        assertInvokeInterfaceEquals(77, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B implements I { public int m() { return 66; } }
+     *
+     * TEST: C c = new C(); c.m() == 66;
+     * TEST: I i = new C(); i.m() == 66;
+     */
+    public void testInheritedWithConcreteAndImpl() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B, I, ConcreteMethod.std("66"));
+
+        assertInvokeVirtualEquals(66, C);
+        assertInvokeInterfaceEquals(66, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J { default int m() { return 88; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testConflict() {
+        // debugTest();
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { int m(); }
+     * interface J { default int m() { return 88; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testAmbiguousReabstract() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { }
+     * interface K extends I { }
+     * class C implements J, K {}
+     *
+     * TEST: C c = new C(); c.m() == 99
+     * TEST: J j = new C(); j.m() == 99
+     * TEST: K k = new C(); k.m() == 99
+     * TEST: I i = new C(); i.m() == 99
+     */
+    public void testDiamond() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", I);
+        Class C = new Class("C", J, K);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, K);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { }
+     * interface K extends I { }
+     * interface L extends I { }
+     * interface M extends I { }
+     * class C implements I, J, K, L, M {}
+     *
+     * TEST: C c = new C(); c.m() == 99
+     * TEST: J j = new C(); j.m() == 99
+     * TEST: K k = new C(); k.m() == 99
+     * TEST: I i = new C(); i.m() == 99
+     * TEST: L l = new C(); l.m() == 99
+     * TEST: M m = new C(); m.m() == 99
+     */
+    public void testExpandedDiamond() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", I);
+        Interface L = new Interface("L", I);
+        Interface M = new Interface("M", L);
+        Class C = new Class("C", I, J, K, L, M);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, K);
+        assertInvokeInterfaceEquals(99, C, I);
+        assertInvokeInterfaceEquals(99, C, L);
+        assertInvokeInterfaceEquals(99, C, M);
+    }
+
+    /**
+     * interface I { int m() default { return 99; } }
+     * interface J extends I { int m(); }
+     * class C implements J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testReabstract() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I, AbstractMethod.std());
+        Class C = new Class("C", J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 88; } }
+     * interface J extends I { default int m() { return 99; } }
+     * class C implements J {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: J j = new C(); j.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testShadow() {
+        Interface I = new Interface("I", DefaultMethod.std("88"));
+        Interface J = new Interface("J", I, DefaultMethod.std("99"));
+        Class C = new Class("C", J);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 88; } }
+     * interface J extends I { default int m() { return 99; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: J j = new C(); j.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testDisqualified() {
+        Interface I = new Interface("I", DefaultMethod.std("88"));
+        Interface J = new Interface("J", I, DefaultMethod.std("99"));
+        Class C = new Class("C", I, J);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I<T> { default int m(T t) { return 99; } }
+     * Class C implements I<String> { public int m() { return 88; } }
+     *
+     * TEST: C c = new C(); c.m() == 88;
+     * TEST: I i = new C(); i.m() == 88;
+     */
+    public void testSelfFill() {
+        // This test ensures that a concrete method overrides a default method
+        // that matches at the language-level, but has a different method
+        // signature due to erasure.
+
+        // debugTest();
+
+        DefaultMethod dm = new DefaultMethod(
+            "int", "m", "return 99;", new MethodParameter("T", "t"));
+        ConcreteMethod cm = new ConcreteMethod(
+            "int", "m", "return 88;", AccessFlag.PUBLIC,
+            new MethodParameter("String", "s"));
+
+        Interface I = new Interface("I", new TypeParameter("T"), dm);
+        Class C = new Class("C", I.with("String"), cm);
+
+        AbstractMethod pm = new AbstractMethod(
+            "int", "m", new MethodParameter("T", "t"));
+
+        assertInvokeVirtualEquals(new Integer(88), C, cm, "-1", "\"string\"");
+        assertInvokeInterfaceEquals(
+            new Integer(88), C, I.with("String"), pm, "\"string\"");
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class C implements I {}
+     *
+     * TEST: C.class.getMethod("m").invoke(new C()) == 99
+     */
+    public void testReflectCall() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class C = new Class("C", I);
+
+        Compiler.Flags[] flags = this.verbose ?
+            new Compiler.Flags[] { Compiler.Flags.VERBOSE } :
+            new Compiler.Flags[] {};
+        Compiler compiler = new Compiler(flags);
+        java.lang.Class<?> cls = null;
+        try {
+            cls = compiler.compileAndLoad(C);
+        } catch (ClassNotFoundException e) {
+            fail("Could not load class");
+        }
+
+        java.lang.reflect.Method method = null;
+        try {
+            method = cls.getMethod(stdMethodName);
+        } catch (NoSuchMethodException e) {
+            fail("Could not find method in class");
+        }
+        assertNotNull(method);
+
+        Object c = null;
+        try {
+            c = cls.newInstance();
+        } catch (InstantiationException | IllegalAccessException e) {
+            fail("Could not create instance of class");
+        }
+        assertNotNull(c);
+
+        Integer res = null;
+        try {
+            res = (Integer)method.invoke(c);
+        } catch (IllegalAccessException |
+                 java.lang.reflect.InvocationTargetException e) {
+            fail("Could not invoke default instance method");
+        }
+        assertNotNull(res);
+
+        assertEquals(res.intValue(), 99);
+
+        compiler.cleanup();
+    }
+
+    /**
+     * interface I<T,V,W> { default int m(T t, V v, W w) { return 99; } }
+     * interface J<T,V> extends I<String,T,V> { int m(T t, V v, String w); } }
+     * interface K<T> extends J<String,T> { int m(T t, String v, String w); } }
+     * class C implements K<String> {
+     *     public int m(String t, String v, String w) { return 88; }
+     * }
+     *
+     * TEST: I<String,String,String> i = new C(); i.m("A","B","C") == 88;
+     * TEST: J<String,String> j = new C(); j.m("A","B","C") == 88;
+     * TEST: K<String> k = new C(); k.m("A","B","C") == 88;
+     */
+    public void testBridges() {
+        DefaultMethod dm = new DefaultMethod("int", stdMethodName, "return 99;",
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("W", "w"));
+
+        AbstractMethod pm0 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("W", "w"));
+
+        AbstractMethod pm1 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("String", "w"));
+
+        AbstractMethod pm2 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("String", "v"),
+            new MethodParameter("String", "w"));
+
+        ConcreteMethod cm = new ConcreteMethod("int",stdMethodName,"return 88;",
+            AccessFlag.PUBLIC,
+            new MethodParameter("String", "t"),
+            new MethodParameter("String", "v"),
+            new MethodParameter("String", "w"));
+
+        Interface I = new Interface("I", new TypeParameter("T"),
+            new TypeParameter("V"), new TypeParameter("W"), dm);
+        Interface J = new Interface("J",
+            new TypeParameter("T"), new TypeParameter("V"),
+            I.with("String", "T", "V"), pm1);
+        Interface K = new Interface("K", new TypeParameter("T"),
+            J.with("String", "T"), pm2);
+        Class C = new Class("C", K.with("String"), cm);
+
+        String[] args = new String[] { "\"A\"", "\"B\"", "\"C\"" };
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            I.with("String", "String", "String"), pm0, args);
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            J.with("String", "String"), pm1, args);
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            K.with("String"), pm2, args);
+    }
+
+    /**
+     * interface J { default int m() { return 88; } }
+     * interface I extends J { default int m() { return J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() == 88;
+     * TEST: I i = new C(); i.m() == 88;
+     */
+    public void testSuperBasic() {
+        // debugTest();
+
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Interface I = new Interface("I", J, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        I.addCompilationDependency(J.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertInvokeVirtualEquals(88, C);
+        assertInvokeInterfaceEquals(88, C, I);
+    }
+
+    /**
+     * interface K { int m() default { return 99; } }
+     * interface L { int m() default { return 101; } }
+     * interface J extends K, L {}
+     * interface I extends J, K { int m() default { J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for K k = new C(); k.m() throws AME
+     */
+    public void testSuperConflict() {
+        // debugTest();
+
+        Interface K = new Interface("K", DefaultMethod.std("99"));
+        Interface L = new Interface("L", DefaultMethod.std("101"));
+        Interface J = new Interface("J", K, L);
+        Interface I = new Interface("I", J, K, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        Interface Jstub = new Interface("J", DefaultMethod.std("-1"));
+        I.addCompilationDependency(Jstub);
+        I.addCompilationDependency(Jstub.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { default int m() { return 55; } }
+     * class C implements I, J { public int m() { return I.super.m(); } }
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for J j = new C(); j.m() throws AME
+     */
+    public void testSuperDisqual() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I, DefaultMethod.std("55"));
+        Class C = new Class("C", I, J,
+            new ConcreteMethod("int", stdMethodName, "return I.super.m();",
+                AccessFlag.PUBLIC));
+        C.addCompilationDependency(I.findMethod(stdMethodName));
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface J { int m(); }
+     * interface I extends J { default int m() { return J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for I i = new C(); i.m() throws AME
+     */
+    public void testSuperNull() {
+        Interface J = new Interface("J", AbstractMethod.std());
+        Interface I = new Interface("I", J, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        Interface Jstub = new Interface("J", DefaultMethod.std("99"));
+        I.addCompilationDependency(Jstub);
+        I.addCompilationDependency(Jstub.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface J<T> { default int m(T t) { return 88; } }
+     * interface I extends J<String> {
+     *     int m(String s) default { return J.super.m(); }
+     * }
+     * class C implements I {}
+     *
+     * TEST: I i = new C(); i.m("") == 88;
+     */
+    public void testSuperGeneric() {
+        Interface J = new Interface("J", new TypeParameter("T"),
+            new DefaultMethod("int", stdMethodName, "return 88;",
+                new MethodParameter("T", "t")));
+        Interface I = new Interface("I", J.with("String"),
+            new DefaultMethod("int", stdMethodName, "return J.super.m(s);",
+                new MethodParameter("String", "s")));
+        I.addCompilationDependency(J.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        AbstractMethod pm = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("String", "s"));
+
+        assertInvokeInterfaceEquals(
+            new Integer(88), C, new Extends(I), pm, "\"\"");
+    }
+
+    /**
+     * interface I<T> { int m(T t) default { return 44; } }
+     * interface J extends I<String> { int m(String s) default { return 55; } }
+     * class C implements I<String>, J {
+     *     public int m(String s) { return I.super.m(s); }
+     * }
+     *
+     * TEST: C c = new C(); c.m("string") throws AME
+     */
+    public void testSuperGenericDisqual() {
+        MethodParameter t = new MethodParameter("T", "t");
+        MethodParameter s = new MethodParameter("String", "s");
+
+        Interface I = new Interface("I", new TypeParameter("T"),
+            new DefaultMethod("int", stdMethodName, "return 44;", t));
+        Interface J = new Interface("J", I.with("String"),
+            new DefaultMethod("int", stdMethodName, "return 55;", s));
+        Class C = new Class("C", I.with("String"), J,
+            new ConcreteMethod("int", stdMethodName,
+                "return I.super.m(s);", AccessFlag.PUBLIC, s));
+        C.addCompilationDependency(I.findMethod(stdMethodName));
+
+        assertThrows(AbstractMethodError.class, C,
+            new ConcreteMethod(
+                "int", stdMethodName, "return -1;", AccessFlag.PUBLIC, s),
+            "-1", "\"string\"");
+    }
+
+    /**
+     * interface I { default Integer m() { return new Integer(88); } }
+     * class C { Number m() { return new Integer(99); } }
+     * class D extends C implements I {}
+     * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
+     * TEST: S s = new S(); s.foo() == new Integer(99)
+     */
+    public void testCovarBridge() {
+        Interface I = new Interface("I", new DefaultMethod(
+            "Integer", "m", "return new Integer(88);"));
+        Class C = new Class("C", new ConcreteMethod(
+            "Number", "m", "return new Integer(99);", AccessFlag.PUBLIC));
+        Class D = new Class("D", I, C);
+
+        ConcreteMethod DstubMethod = new ConcreteMethod(
+            "Integer", "m", "return null;", AccessFlag.PUBLIC);
+        Class Dstub = new Class("D", DstubMethod);
+
+        ConcreteMethod toCall = new ConcreteMethod(
+            "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC);
+        Class S = new Class("S", D, toCall);
+        S.addCompilationDependency(Dstub);
+        S.addCompilationDependency(DstubMethod);
+
+        assertInvokeVirtualEquals(new Integer(99), S, toCall, "null");
+    }
+
+    /**
+     * interface I { default Integer m() { return new Integer(88); } }
+     * class C { int m() { return 99; } }
+     * class D extends C implements I {}
+     * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
+     * TEST: S s = new S(); s.foo() == new Integer(88)
+     */
+    public void testNoCovarNoBridge() {
+        Interface I = new Interface("I", new DefaultMethod(
+            "Integer", "m", "return new Integer(88);"));
+        Class C = new Class("C", new ConcreteMethod(
+            "int", "m", "return 99;", AccessFlag.PUBLIC));
+        Class D = new Class("D", I, C);
+
+        ConcreteMethod DstubMethod = new ConcreteMethod(
+            "Integer", "m", "return null;", AccessFlag.PUBLIC);
+        Class Dstub = new Class("D", DstubMethod);
+
+        ConcreteMethod toCall = new ConcreteMethod(
+            "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC);
+        Class S = new Class("S", D, toCall);
+        S.addCompilationDependency(Dstub);
+        S.addCompilationDependency(DstubMethod);
+
+        assertInvokeVirtualEquals(new Integer(88), S, toCall, "null");
+    }
+
+    /**
+     * interface J { int m(); }
+     * interface I extends J { default int m() { return 99; } }
+     * class B implements J {}
+     * class C extends B implements I {}
+     * TEST: C c = new C(); c.m() == 99
+     *
+     * The point of this test is that B does not get default method analysis,
+     * and C does not generate any new miranda methods in the vtable.
+     * It verifies that default method analysis occurs when mirandas have been
+     * inherited and the supertypes don't have any overpass methods.
+     */
+    public void testNoNewMiranda() {
+        Interface J = new Interface("J", AbstractMethod.std());
+        Interface I = new Interface("I", J, DefaultMethod.std("99"));
+        Class B = new Class("B", J);
+        Class C = new Class("C", B, I);
+        assertInvokeVirtualEquals(99, C);
+    }
+
+    /**
+     * interface I<T,V,W> { int m(T t, V v, W w); }
+     * interface J<T,V> implements I<T,V,String> { int m(T t, V v, String w); }
+     * interface K<T> implements J<T,String> {
+     *     int m(T t, String v, String w); { return 99; } }
+     * class C implements K<String> {
+     *     public int m(Object t, Object v, String w) { return 77; }
+     * }
+     * TEST C = new C(); ((I)c).m(Object,Object,Object) == 99
+     * TEST C = new C(); ((J)c).m(Object,Object,String) == 77
+     * TEST C = new C(); ((K)c).m(Object,String,String) == 99
+     *
+     * Test that a erased-signature-matching method does not implement
+     * non-language-level matching methods
+     */
+    public void testNonConcreteFill() {
+        AbstractMethod ipm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("V", "s"),
+            new MethodParameter("W", "w"));
+        Interface I = new Interface("I",
+            new TypeParameter("T"),
+            new TypeParameter("V"),
+            new TypeParameter("W"), ipm);
+
+        AbstractMethod jpm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("V", "s"),
+            new MethodParameter("String", "w"));
+        Interface J = new Interface("J",
+            new TypeParameter("T"),
+            new TypeParameter("V"),
+            I.with("T", "V", "String"), jpm);
+
+        AbstractMethod kpm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("String", "s"),
+            new MethodParameter("String", "w"));
+        Interface K = new Interface("K",
+            new TypeParameter("T"),
+            J.with("T", "String"),
+            new DefaultMethod("int", "m", "return 99;",
+                new MethodParameter("T", "t"),
+                new MethodParameter("String", "v"),
+                new MethodParameter("String", "w")));
+
+        Class C = new Class("C",
+            K.with("String"),
+            new ConcreteMethod("int", "m", "return 77;",
+                AccessFlag.PUBLIC,
+                new MethodParameter("Object", "t"),
+                new MethodParameter("Object", "v"),
+                new MethodParameter("String", "w")));
+
+        String a = "\"\"";
+        assertInvokeInterfaceEquals(99, C,
+            K.with("String"), kpm, a, a, a);
+        assertInvokeInterfaceEquals(77, C,
+            J.with("String", "String"), jpm, a, a, a);
+        assertInvokeInterfaceEquals(99, C,
+            I.with("String", "String", "String"), ipm, a, a, a);
+    }
+
+    public void testStrictfpDefault() {
+        try {
+            java.lang.Class.forName("org.openjdk.tests.vm.StrictfpDefault");
+        } catch (Exception e) {
+            fail("Could not load class", e);
+        }
+    }
+
+    public void testSynchronizedDefault() {
+        try {
+            java.lang.Class.forName("org.openjdk.tests.vm.SynchronizedDefault");
+        } catch (Exception e) {
+            fail("Could not load class", e);
+        }
+    }
+}
+
+interface StrictfpDefault {
+    default strictfp void m() {}
+}
+
+interface SynchronizedDefault {
+    default synchronized void m() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.vm;
+
+import java.util.*;
+
+import org.testng.ITestResult;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+
+import org.openjdk.tests.separate.*;
+import org.openjdk.tests.separate.Compiler;
+
+import org.openjdk.tests.shapegen.Hierarchy;
+import org.openjdk.tests.shapegen.HierarchyGenerator;
+import org.openjdk.tests.shapegen.ClassCase;
+
+import static org.testng.Assert.*;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.Method;
+import static org.openjdk.tests.separate.SourceModel.Type;
+
+public class FDSeparateCompilationTest extends TestHarness {
+
+    private static String EMPTY = "\"\"";
+
+    public FDSeparateCompilationTest() {
+        super(false, true);
+    }
+
+    @DataProvider(name = "allShapes", parallel = true)
+    public Object[][] hierarchyGenerator() {
+        ArrayList<Object[]> allCases = new ArrayList<>();
+
+        HierarchyGenerator hg = new HierarchyGenerator();
+        for (Object x : hg.getOK()) {
+            allCases.add(new Object[]{x});
+        }
+        for (Object x : hg.getErr()) {
+            allCases.add(new Object[]{x});
+        }
+        return allCases.toArray(new Object[0][]);
+    }
+
+    // The expected value obtained when invoking the method from the specified
+    // class.  If returns null, then an AbstractMethodError is expected.
+    private static String getExpectedResult(ClassCase cc) {
+        Set<ClassCase> provs = cc.get_mprov();
+        if (cc.get_mres() != null) {
+            return cc.get_mres().getName();
+        } else if (provs != null && provs.size() == 1) {
+            ClassCase cand = provs.iterator().next();
+            switch (cand.kind) {
+                case CCONCRETE:
+                case IDEFAULT:
+                    return cand.getName();
+                case CNONE:
+                case IVAC:
+                    return getExpectedResult(cand);
+            }
+        }
+        return null;
+    }
+
+    private static final ConcreteMethod canonicalMethod = new ConcreteMethod(
+            "String", "m", "returns " + EMPTY + ";", AccessFlag.PUBLIC);
+
+    @Test(groups = "vm", dataProvider = "allShapes")
+    public void separateCompilationTest(Hierarchy hs) {
+        ClassCase cc = hs.root;
+        Type type = sourceTypeFrom(hs.root);
+
+        Class specimen = null;
+        if (type instanceof Class) {
+            Class ctype = (Class)type;
+            if (ctype.isAbstract()) {
+                specimen = new Class("Test" + ctype.getName(), ctype);
+            } else {
+                specimen = ctype;
+            }
+        } else {
+            specimen = new Class("Test" + type.getName(), (Interface)type);
+        }
+
+        String value = getExpectedResult(cc);
+        if (value != null) {
+            assertInvokeVirtualEquals(value, specimen, canonicalMethod, EMPTY);
+        } else {
+            assertThrows(AbstractMethodError.class, specimen,
+                canonicalMethod, EMPTY);
+        }
+    }
+
+    @AfterMethod
+    public void printCaseError(ITestResult result) {
+        if (result.getStatus() == ITestResult.FAILURE) {
+            Hierarchy hs = (Hierarchy)result.getParameters()[0];
+            System.out.println("Separate compilation case " + hs);
+            printCaseDetails(hs);
+        }
+    }
+
+    @AfterSuite
+    public void cleanupCompilerCache() {
+        Compiler.purgeCache();
+    }
+
+    private void printCaseDetails(Hierarchy hs) {
+        String exp = getExpectedResult(hs.root);
+        for (String s : hs.getDescription()) {
+             System.out.println("    " + s);
+        }
+        if (exp != null) {
+            System.out.println("    Expected \"" + exp + "\"");
+        } else {
+            System.out.println("    Expected AbstractMethodError");
+        }
+    }
+
+    private Type sourceTypeFrom(ClassCase cc) {
+        Type type = null;
+
+        if (cc.isInterface()) {
+            Interface iface = new Interface(cc.getName());
+            for (ClassCase scc : cc.getInterfaces()) {
+                Interface supertype = (Interface)sourceTypeFrom(scc);
+                iface.addSuperType(supertype);
+            }
+            type = iface;
+        } else {
+            Class cls = new Class(cc.getName());
+            if (cc.hasSuperclass()) {
+                Class superc = (Class)sourceTypeFrom(cc.getSuperclass());
+                cls.setSuperClass(superc);
+            }
+            for (ClassCase scc : cc.getInterfaces()) {
+                Interface supertype = (Interface)sourceTypeFrom(scc);
+                cls.addSuperType(supertype);
+            }
+            if (cc.isAbstract()) {
+                cls.getAccessFlags().add(AccessFlag.ABSTRACT);
+            }
+            type = cls;
+        }
+        Method method = methodFrom(cc);
+        if (method != null) {
+            type.addMethod(method);
+        }
+        return type;
+    }
+
+    private Method methodFrom(ClassCase cc) {
+        switch (cc.kind) {
+            case IVAC:
+            case CNONE: return null;
+            case IPRESENT:
+            case CABSTRACT:
+                return new AbstractMethod("String", "m", AccessFlag.PUBLIC);
+            case IDEFAULT:
+                return new DefaultMethod(
+                    "String", "m", "return \"" + cc.getName() + "\";");
+            case CCONCRETE:
+                return new ConcreteMethod(
+                    "String", "m", "return \"" + cc.getName() + "\";",
+                    AccessFlag.PUBLIC);
+            default:
+                fail("Unknown method type in class");
+                return null;
+        }
+    }
+}
--- a/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7150368
+ * @bug 7150368 8003412
  * @summary javac should include basic ability to generate native headers
  */
 
@@ -125,7 +125,7 @@
     }
 
     @Test
-    void annoTest(RunKind rk, GenKind gk) throws Exception {
+    void oldAnnoTest(RunKind rk, GenKind gk) throws Exception {
         List<File> files = new ArrayList<File>();
         files.add(createFile("p/C.java",
                 "@javax.tools.annotation.GenerateNativeHeader class C { }"));
@@ -136,10 +136,33 @@
     }
 
     @Test
+    void annoTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { @java.lang.annotation.Native public static final int i = 1907; }"));
+
+        Set<String> expect = createSet("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    @Test
+    void oldAnnoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }"));
+
+        Set<String> expect = createSet("C_Inner.h");
+        if (gk == GenKind.FULL) expect.add("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    @Test
     void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
         List<File> files = new ArrayList<File>();
         files.add(createFile("p/C.java",
-                "class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }"));
+                "class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }"));
 
         Set<String> expect = createSet("C_Inner.h");
         if (gk == GenKind.FULL) expect.add("C.h");
--- a/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7150368
+ * @bug 7150368 8003412
  * @summary javac should include basic ability to generate native headers
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.annotation.Native;
+
+public class TestClass4 {
+    @Native
+    public static final byte b = 1;
+
+    @Native
+    public static final short s = 2;
+
+    @Native
+    public static final int i = 3;
+
+    @Native
+    public static final long l = 4;
+
+    @Native
+    public static final float f = 5.0f;
+
+    @Native
+    public static final double d = 6.0;
+
+    @Native
+    public static final Object o = null;
+
+    @Native
+    public static final String t = "8";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.annotation.Native;
+
+public class TestClass5 {
+    @Native
+    public static final int tc5 = 1;
+
+    public class Inner1 {
+        @Native
+        public static final int tc5i1 = 2;
+
+        public class Inner1A {
+            @Native
+            public static final int tc5i1i1a = 3;
+        }
+
+        public class Inner1B {
+            @Native
+            public static final int tc5i1i1b = 4;
+        }
+    }
+
+    public class Inner2 {
+        @Native
+        public static final int tc521 = 5;
+
+        public class Inner2A {
+            @Native
+            public static final int tc5i2i2a = 6;
+        }
+
+        public class Inner2B {
+            @Native
+            public static final int tc5i2i2b = 7;
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/plugin/showtype/Identifiers.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,7 @@
+/* /nodynamiccopyright */
+
+public class Identifiers {
+    public double E = Math.E;
+    public double PI = Math.PI;
+    public double PIE = PI + E;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/plugin/showtype/Identifiers.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,21 @@
+Identifiers.java:3: Note: type is ()void
+public class Identifiers {
+       ^
+Identifiers.java:4: Note: type is double
+    public double E = Math.E;
+                          ^
+Identifiers.java:4: Note: type is java.lang.Math
+    public double E = Math.E;
+                      ^
+Identifiers.java:5: Note: type is double
+    public double PI = Math.PI;
+                           ^
+Identifiers.java:5: Note: type is java.lang.Math
+    public double PI = Math.PI;
+                       ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                        ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                             ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/plugin/showtype/Identifiers_PI.out	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,6 @@
+Identifiers.java:5: Note: type is double
+    public double PI = Math.PI;
+                           ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                        ^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/plugin/showtype/ShowTypePlugin.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Plugin;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import java.util.regex.Pattern;
+import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic.Kind;
+
+public class ShowTypePlugin implements Plugin {
+
+    public String getName() {
+        return "showtype";
+    }
+
+    public void call(JavacTask task, String... args) {
+        Pattern pattern = null;
+        if (args.length == 1)
+            pattern = Pattern.compile(args[0]);
+        task.addTaskListener(new PostAnalyzeTaskListener(task, pattern));
+    }
+
+    private static class PostAnalyzeTaskListener implements TaskListener {
+        private final ShowTypeTreeVisitor visitor;
+
+        PostAnalyzeTaskListener(JavacTask task, Pattern pattern) {
+            visitor = new ShowTypeTreeVisitor(task, pattern);
+        }
+
+        @Override
+        public void started(TaskEvent taskEvent) { }
+
+        @Override
+        public void finished(TaskEvent taskEvent) {
+            if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) {
+                CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit();
+                visitor.scan(compilationUnit, null);
+            }
+        }
+    }
+
+    private static class ShowTypeTreeVisitor extends TreePathScanner<Void, Void> {
+        private final Trees trees;
+        private final Pattern pattern;
+        private CompilationUnitTree currCompUnit;
+
+        ShowTypeTreeVisitor(JavacTask task, Pattern pattern) {
+            trees = Trees.instance(task);
+            this.pattern = pattern;
+        }
+
+        @Override
+        public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+            currCompUnit = tree;
+            return super.visitCompilationUnit(tree, ignore);
+        }
+
+        @Override
+        public Void visitIdentifier(IdentifierTree tree, Void ignore) {
+            show(tree, tree.getName());
+            return super.visitIdentifier(tree, ignore);
+        }
+
+        @Override
+        public Void visitMemberSelect(MemberSelectTree tree, Void ignore) {
+            show(tree, tree.getIdentifier());
+            return super.visitMemberSelect(tree, ignore);
+        }
+
+        void show(Tree tree, CharSequence name) {
+            if (pattern == null || pattern.matcher(name).matches()) {
+                TypeMirror type = trees.getTypeMirror(getCurrentPath());
+                trees.printMessage(Kind.NOTE, "type is " + type, tree, currCompUnit);
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/plugin/showtype/Test.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,171 @@
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ *  @test
+ *  @bug 8001098
+ *  @summary Provide a simple light-weight "plug-in" mechanism for javac
+ */
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    final File testSrc;
+    final File pluginSrc;
+    final File pluginClasses ;
+    final File pluginJar;
+    final List<String> ref1;
+    final List<String> ref2;
+    final JavaCompiler compiler;
+    final StandardJavaFileManager fm;
+
+    Test() throws Exception {
+        testSrc = new File(System.getProperty("test.src"));
+        pluginSrc = new File(testSrc, "ShowTypePlugin.java");
+        pluginClasses = new File("plugin");
+        pluginJar = new File("plugin.jar");
+        ref1 = readFile(testSrc, "Identifiers.out");
+        ref2 = readFile(testSrc, "Identifiers_PI.out");
+        compiler = ToolProvider.getSystemJavaCompiler();
+        fm = compiler.getStandardFileManager(null, null, null);
+    }
+
+    void run() throws Exception {
+        // compile the plugin explicitly, to a non-standard directory
+        // so that we don't find it on the wrong path by accident
+        pluginClasses.mkdirs();
+        compile("-d", pluginClasses.getPath(), pluginSrc.getPath());
+        writeFile(new File(pluginClasses, "META-INF/services/com.sun.source.util.Plugin"),
+                "ShowTypePlugin\n");
+        jar("cf", pluginJar.getPath(), "-C", pluginClasses.getPath(), ".");
+
+        testCommandLine("-Xplugin:showtype", ref1);
+        testCommandLine("-Xplugin:showtype PI", ref2);
+        testAPI("-Xplugin:showtype", ref1);
+        testAPI("-Xplugin:showtype PI", ref2);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void testAPI(String opt, List<String> ref) throws Exception {
+        File identifiers = new File(testSrc, "Identifiers.java");
+        fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, Arrays.asList(pluginJar));
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+        List<String> options = Arrays.asList(opt);
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(identifiers);
+
+        System.err.println("test api: " + options + " " + files);
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        boolean ok = compiler.getTask(pw, fm, null, options, null, files).call();
+        String out = sw.toString();
+        System.err.println(out);
+        if (!ok)
+            error("testCommandLine: compilation failed");
+        checkOutput(out, ref);
+    }
+
+    void testCommandLine(String opt, List<String> ref) {
+        File identifiers = new File(testSrc, "Identifiers.java");
+        String[] args = {
+            "-d", ".",
+            "-processorpath", pluginJar.getPath(),
+            opt,
+            identifiers.getPath() };
+
+        System.err.println("test command line: " + Arrays.asList(args));
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        String out = sw.toString();
+        System.err.println(out);
+        if (rc != 0)
+            error("testCommandLine: compilation failed");
+        checkOutput(out, ref);
+    }
+
+    private void checkOutput(String out, List<String> ref) {
+        List<String> lines = Arrays.asList(out
+                .replaceAll(".*?([A-Za-z.]+:[0-9]+: .*)", "$1") // remove file directory
+                .split("[\r\n]+"));                             // allow for newline formats
+        if (!lines.equals(ref)) {
+            error("unexpected output");
+        }
+    }
+
+    private void compile(String... args) throws Exception {
+        System.err.println("compile: " + Arrays.asList(args));
+        int rc = com.sun.tools.javac.Main.compile(args);
+        if (rc != 0)
+            throw new Exception("compiled failed, rc=" + rc);
+    }
+
+    private void jar(String... args) throws Exception {
+        System.err.println("jar: " + Arrays.asList(args));
+        boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar").run(args);
+        if (!ok)
+            throw new Exception("jar failed");
+    }
+
+    private List<String> readFile(File dir, String name) throws IOException {
+        return Files.readAllLines(new File(dir, name).toPath(), Charset.defaultCharset());
+    }
+
+    private void writeFile(File f, String body) throws IOException {
+        f.getParentFile().mkdirs();
+        try (FileWriter out = new FileWriter(f)) {
+            out.write(body);
+        }
+    }
+
+    private void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out	Wed Jul 05 18:30:46 2017 +0200
@@ -10,7 +10,6 @@
 BasicTest.java:52:31: compiler.err.expected: ';'
 BasicTest.java:52:37: compiler.err.expected: token.identifier
 BasicTest.java:53:30: compiler.err.expected: token.identifier
-BasicTest.java:53:32: compiler.err.lambda.not.supported.in.source: 1.8
 BasicTest.java:53:31: compiler.err.expected: ->
 BasicTest.java:56:23: compiler.err.expected: token.identifier
 BasicTest.java:56:24: compiler.err.expected2: '(', '['
@@ -59,4 +58,4 @@
 BasicTest.java:74:25: compiler.err.illegal.start.of.type
 BasicTest.java:74:33: compiler.err.expected: ';'
 BasicTest.java:77:2: compiler.err.premature.eof
-61 errors
+60 errors
--- a/langtools/test/tools/javadoc/CheckResourceKeys.java	Wed Jul 05 18:30:37 2017 +0200
+++ b/langtools/test/tools/javadoc/CheckResourceKeys.java	Wed Jul 05 18:30:46 2017 +0200
@@ -167,6 +167,13 @@
                 results.add("doclet." + s.toLowerCase());
         }
 
+        // special handling for code strings synthesized in
+        // com.sun.tools.javadoc.Messager
+        results.add("javadoc.error.msg");
+        results.add("javadoc.note.msg");
+        results.add("javadoc.note.pos.msg");
+        results.add("javadoc.warning.msg");
+
         return results;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/APITest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+
+/*
+ * Superclass with utility methods for API tests.
+ */
+class APITest {
+    protected APITest() { }
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /** Invoke all methods annotated with @Test. */
+    protected void run() throws Exception {
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                testCount++;
+                testName = m.getName();
+                System.err.println("test: " + testName);
+                try {
+                    m.invoke(this, new Object[] { });
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                System.err.println();
+            }
+        }
+
+        if (testCount == 0)
+            error("no tests found");
+
+        StringBuilder summary = new StringBuilder();
+        if (testCount != 1)
+            summary.append(testCount).append(" tests");
+        if (errorCount > 0) {
+            if (summary.length() > 0) summary.append(", ");
+            summary.append(errorCount).append(" errors");
+        }
+        System.err.println(summary);
+        if (errorCount > 0)
+            throw new Exception(errorCount + " errors found");
+    }
+
+    /**
+     * Create a directory in which to store generated doc files.
+     * Avoid using the default (current) directory, so that we can
+     * be sure that javadoc is writing in the intended location,
+     * not a default location.
+     */
+    protected File getOutDir() {
+        File dir = new File(testName);
+        dir.mkdirs();
+        return dir;
+    }
+
+    /**
+     * Create a directory in which to store generated doc files.
+     * Avoid using the default (current) directory, so that we can
+     * be sure that javadoc is writing in the intended location,
+     * not a default location.
+     */
+    protected File getOutDir(String path) {
+        File dir = new File(testName, path);
+        dir.mkdirs();
+        return dir;
+    }
+
+    protected JavaFileObject createSimpleJavaFileObject() {
+        return createSimpleJavaFileObject("pkg/C", "package pkg; public class C { }");
+    }
+
+    protected JavaFileObject createSimpleJavaFileObject(final String binaryName, final String content) {
+        return new SimpleJavaFileObject(
+                URI.create("myfo:///" + binaryName + ".java"), JavaFileObject.Kind.SOURCE) {
+            @Override
+            public CharSequence getCharContent(boolean ignoreEncoding) {
+                return content;
+            }
+        };
+    }
+
+    protected void checkFiles(File dir, Set<String> expectFiles) {
+        Set<File> files = new HashSet<File>();
+        listFiles(dir, files);
+        Set<String> foundFiles = new HashSet<String>();
+        URI dirURI = dir.toURI();
+        for (File f: files)
+            foundFiles.add(dirURI.relativize(f.toURI()).getPath());
+        checkFiles(foundFiles, expectFiles, dir);
+    }
+
+    protected void checkFiles(Path dir, Set<String> expectFiles) throws IOException {
+        Set<Path> files = new HashSet<Path>();
+        listFiles(dir, files);
+        Set<String> foundFiles = new HashSet<String>();
+        for (Path f: files) {
+            foundFiles.add(dir.relativize(f).toString().replace(f.getFileSystem().getSeparator(), "/"));
+        }
+        checkFiles(foundFiles, expectFiles, dir);
+    }
+
+    private void checkFiles(Set<String> foundFiles, Set<String> expectFiles, Object where) {
+        if (!foundFiles.equals(expectFiles)) {
+            Set<String> missing = new TreeSet<String>(expectFiles);
+            missing.removeAll(foundFiles);
+            if (!missing.isEmpty())
+                error("the following files were not found in " + where + ": " + missing);
+            Set<String> unexpected = new TreeSet<String>(foundFiles);
+            unexpected.removeAll(expectFiles);
+            if (!unexpected.isEmpty())
+                error("the following unexpected files were found in " + where + ": " + unexpected);
+        }
+    }
+
+    protected void listFiles(File dir, Set<File> files) {
+        for (File f: dir.listFiles()) {
+            if (f.isDirectory())
+                listFiles(f, files);
+            else if (f.isFile())
+                files.add(f);
+        }
+    }
+
+    private void listFiles(Path dir, Set<Path> files) throws IOException {
+        for (Path f: Files.newDirectoryStream(dir)) {
+            if (Files.isDirectory(f))
+                listFiles(f, files);
+            else if (Files.isRegularFile(f))
+                files.add(f);
+        }
+    }
+
+    protected void error(String msg) {
+        System.err.println("Error: " + msg);
+        errorCount++;
+    }
+
+    protected int testCount;
+    protected int errorCount;
+
+    protected String testName;
+
+    /**
+     * Standard files generated by processing a documented class pkg.C.
+     */
+    protected static Set<String> standardExpectFiles = new HashSet<String>(Arrays.asList(
+        "allclasses-frame.html",
+        "allclasses-noframe.html",
+        "constant-values.html",
+        "deprecated-list.html",
+        "help-doc.html",
+        "index-all.html",
+        "index.html",
+        "overview-tree.html",
+        "package-list",
+        "pkg/C.html",
+        "pkg/package-frame.html",
+        "pkg/package-summary.html",
+        "pkg/package-tree.html",
+        "resources/background.gif",
+        "resources/tab.gif",
+        "resources/activetitlebar_end.gif",
+        "resources/activetitlebar.gif",
+        "resources/titlebar_end.gif",
+        "resources/titlebar.gif",
+        "script.js",
+        "stylesheet.css"
+    ));
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/DocletPathTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main DocletPathTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for locating a doclet via the file manager's DOCLET_PATH.
+ */
+public class DocletPathTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new DocletPathTest().run();
+    }
+
+    /**
+     * Verify that an alternate doclet can be specified, and located via
+     * the file manager's DOCLET_PATH.
+     */
+    @Test
+    public void testDocletPath() throws Exception {
+        JavaFileObject docletSrc =
+                createSimpleJavaFileObject("DocletOnDocletPath", docletSrcText);
+        File docletDir = getOutDir("classes");
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
+        cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(docletDir));
+        Iterable<? extends JavaFileObject> cfiles = Arrays.asList(docletSrc);
+        if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+            throw new Exception("cannot compile doclet");
+
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir("api");
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        fm.setLocation(DocumentationTool.Location.DOCLET_PATH, Arrays.asList(docletDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-doclet", "DocletOnDocletPath");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+        boolean ok = t.call();
+        String out = sw.toString();
+        System.err.println(">>" + out + "<<");
+        if (ok) {
+            if (out.contains(TEST_STRING)) {
+                System.err.println("doclet executed as expected");
+            } else {
+                error("test string not found in doclet output");
+            }
+        } else {
+            error("task failed");
+        }
+    }
+
+    private static final String TEST_STRING = "DocletOnDocletPath found and running";
+
+    private static final String docletSrcText =
+        "import com.sun.javadoc.*;\n" +
+        "public class DocletOnDocletPath {\n" +
+        "    public static boolean start(RootDoc doc) {\n" +
+        "        doc.printNotice(\"" + TEST_STRING + "\");\n" +
+        "        return true;\n" +
+        "    }\n" +
+        "    public static int optionLength(String option) { return 0; }\n" +
+        "    public static boolean validOptions(String options[][],\n" +
+        "            DocErrorReporter reporter) { return true; }\n" +
+        "    public static LanguageVersion languageVersion() {\n" +
+        "        return LanguageVersion.JAVA_1_1;\n" +
+        "    }\n" +
+        "}\n";
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetSourceVersionsTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetSourceVersionsTest
+ */
+
+import java.util.EnumSet;
+import java.util.Set;
+import javax.lang.model.SourceVersion;
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getSourceVersions method.
+ */
+public class GetSourceVersionsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetSourceVersionsTest().run();
+    }
+
+    /**
+     * Verify getSourceVersions.
+     */
+    @Test
+    public void testRun() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        Set<SourceVersion> found = tool.getSourceVersions();
+        Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
+        if (!expect.equals(found)) {
+            System.err.println("expect: " + expect);
+            System.err.println(" found: " + expect);
+            error("unexpected versions");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_DiagListenerTest
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  diagnosticListener  parameter.
+ */
+public class GetTask_DiagListenerTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_DiagListenerTest().run();
+    }
+
+    /**
+     * Verify that a diagnostic listener can be specified.
+     * Note that messages from the tool and doclet are imperfectly modeled
+     * because the DocErrorReporter API works in terms of localized strings
+     * and file:line positions. Therefore, messages reported via DocErrorReporter
+     * and simply wrapped and passed through.
+     */
+    @Test
+    public void testDiagListener() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", "package pkg; public error { }");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        DocumentationTask t = tool.getTask(null, fm, dc, null, null, files);
+        if (t.call()) {
+            throw new Exception("task succeeded unexpectedly");
+        } else {
+            List<String> diagCodes = new ArrayList<String>();
+            for (Diagnostic d: dc.getDiagnostics()) {
+                System.err.println(d);
+                diagCodes.add(d.getCode());
+            }
+            List<String> expect = Arrays.asList(
+                    "javadoc.note.msg",         // Loading source file
+                    "compiler.err.expected3",   // class, interface, or enum expected
+                    "javadoc.note.msg");        // 1 error
+            if (!diagCodes.equals(expect))
+                throw new Exception("unexpected diagnostics occurred");
+            System.err.println("diagnostics received as expected");
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_DocletClassTest
+ */
+
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.LanguageVersion;
+import com.sun.javadoc.RootDoc;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Random;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  docletClass  parameter.
+ */
+public class GetTask_DocletClassTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_DocletClassTest().run();
+    }
+
+    /**
+     * Verify that an alternate doclet can be specified.
+     *
+     * There is no standard interface or superclass for a doclet;
+     * the only requirement is that it provides static methods that
+     * can be invoked via reflection. So, for now, the doclet is
+     * specified as a class.
+     * Because we cannot create and use a unique instance of the class,
+     * we verify that the doclet has been called by having it record
+     * (in a static field!) the comment from the last time it was invoked,
+     * which is randomly generated each time the test is run.
+     */
+    @Test
+    public void testDoclet() throws Exception {
+        Random r = new Random();
+        int key = r.nextInt();
+        JavaFileObject srcFile = createSimpleJavaFileObject(
+                "pkg/C",
+                "package pkg; /** " + key + "*/ public class C { }");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            if (TestDoclet.lastCaller.equals(String.valueOf(key)))
+                System.err.println("found expected key: " + key);
+            else
+                error("Expected key not found");
+            checkFiles(outDir, Collections.<String>emptySet());
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    public static class TestDoclet {
+        static String lastCaller;
+        public static boolean start(RootDoc root) {
+            lastCaller = root.classNamed("pkg.C").commentText().trim();
+            return true;
+        }
+
+        public static int optionLength(String option) {
+            return 0;  // default is option unknown
+        }
+
+        public static boolean validOptions(String options[][],
+                DocErrorReporter reporter) {
+            return true;  // default is options are valid
+        }
+
+        public static LanguageVersion languageVersion() {
+            return LanguageVersion.JAVA_1_1;
+        }
+    }
+
+    /**
+     * Verify that exceptions from a doclet are thrown as expected.
+     */
+    @Test
+    public void testBadDoclet() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
+        try {
+            t.call();
+            error("call completed without exception");
+        } catch (RuntimeException e) {
+            Throwable c = e.getCause();
+            if (c.getClass() == UnexpectedError.class)
+                System.err.println("exception caught as expected: " + c);
+            else
+                throw e;
+        }
+    }
+
+    public static class UnexpectedError extends Error { }
+
+    public static class BadDoclet {
+        public static boolean start(RootDoc root) {
+            throw new UnexpectedError();
+        }
+
+        public static int optionLength(String option) {
+            return 0;  // default is option unknown
+        }
+
+        public static boolean validOptions(String options[][],
+                DocErrorReporter reporter) {
+            return true;  // default is options are valid
+        }
+
+        public static LanguageVersion languageVersion() {
+            return LanguageVersion.JAVA_1_1;
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_FileManagerTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+import javax.tools.ToolProvider;
+
+import com.sun.tools.javac.nio.JavacPathFileManager;
+import com.sun.tools.javac.nio.PathFileManager;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * Tests for DocumentationTool.getTask  fileManager  parameter.
+ */
+public class GetTask_FileManagerTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_FileManagerTest().run();
+    }
+
+    /**
+     * Verify that an alternate file manager can be specified:
+     * in this case, a PathFileManager.
+     */
+    @Test
+    public void testFileManager() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
+        Path outDir = getOutDir().toPath();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify that exceptions from a bad file manager are thrown as expected.
+     */
+    @Test
+    public void testBadFileManager() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
+            @Override
+            public Iterable<JavaFileObject> list(Location location,
+                    String packageName,
+                    Set<Kind> kinds,
+                    boolean recurse)
+                    throws IOException {
+                throw new UnexpectedError();
+            }
+        };
+        Path outDir = getOutDir().toPath();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        try {
+            t.call();
+            error("call completed without exception");
+        } catch (RuntimeException e) {
+            Throwable c = e.getCause();
+            if (c.getClass() == UnexpectedError.class)
+                System.err.println("exception caught as expected: " + c);
+            else
+                throw e;
+        }
+    }
+
+    public static class UnexpectedError extends Error { }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_FileObjectsTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  fileObjects  parameter.
+ */
+public class GetTask_FileObjectsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_FileObjectsTest().run();
+    }
+
+    /**
+     * Verify that expected output files are written via the file manager,
+     * for a source file read from the file system with StandardJavaFileManager.
+     */
+    @Test
+    public void testStandardFileObject() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.java");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify that expected output files are written via the file manager,
+     * for an in-memory file object.
+     */
+    @Test
+    public void testMemoryFileObject() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify bad file object is handled correctly.
+     */
+    @Test
+    public void testBadFileObject() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.class");  // unacceptable file kind
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (IllegalArgumentException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+    /**
+     * Verify null is handled correctly.
+     */
+    @Test
+    public void testNull() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList((JavaFileObject) null);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_OptionsTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  options  parameter.
+ */
+public class GetTask_OptionsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_OptionsTest().run();
+    }
+
+    /**
+     * Verify that expected output files are written for given options.
+     */
+    @Test
+    public void testNoIndex() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-noindex");
+        DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
+            expectFiles.remove("index-all.html");
+            checkFiles(outDir, expectFiles);
+        } else {
+            error("task failed");
+        }
+    }
+
+    /**
+     * Verify null is handled correctly.
+     */
+    @Test
+    public void testNull() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<String> options = Arrays.asList((String) null);
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_WriterTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  writer  parameter.
+ */
+public class GetTask_WriterTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_WriterTest().run();
+    }
+
+    /**
+     * Verify that a writer can be provided.
+     */
+    @Test
+    public void testWriter() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+            String out = sw.toString();
+            System.err.println(">>" + out + "<<");
+            for (String f: standardExpectFiles) {
+                String f1 = f.replace('/', File.separatorChar);
+                if (f1.endsWith(".html") && !out.contains(f1))
+                    throw new Exception("expected string not found: " + f1);
+            }
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/IsSupportedOptionTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main IsSupportedOptionTest
+ */
+
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.usSupportedOption method.
+ */
+public class IsSupportedOptionTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new IsSupportedOptionTest().run();
+    }
+
+    /**
+     * Verify that isSupportedOption method can be invoked.
+     */
+    @Test
+    public void test() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        check(tool, "-sourcepath", 1);
+        check(tool, "-verbose", 0);
+        check(tool, "-ZZZ", -1);
+
+        try {
+            check(tool, null, -1);
+            error("null was accepted without exception");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    private void check(DocumentationTool tool, String option, int numArgs) {
+        System.err.println("check " + option);
+        int n = tool.isSupportedOption(option);
+        if (n != numArgs)
+            error("unexpected result for option: " + option + ": " + n);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main JavadocTaskImplTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.Messager;
+import com.sun.tools.javadoc.api.JavadocTaskImpl;
+
+/**
+ *  Misc tests for JavacTaskImpl.
+ */
+public class JavadocTaskImplTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new JavadocTaskImplTest().run();
+    }
+
+    @Test
+    public void testRawCall() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+
+        @SuppressWarnings("rawtypes")
+        Callable t = tool.getTask(null, fm, null, null, null, files);
+
+        if (t.call() == Boolean.TRUE) {
+            System.err.println("task succeeded");
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    @Test
+    public void testDirectAccess1() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Context c = new Context();
+        Messager.preRegister(c, "javadoc");
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        DocumentationTask t = new JavadocTaskImpl(c, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    @Test
+    public void testDirectAccess2() throws Exception {
+        JavaFileObject srcFile = null; // error, provokes NPE
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Context c = new Context();
+        Messager.preRegister(c, "javadoc");
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        try {
+            DocumentationTask t = new JavadocTaskImpl(c, null, null, files);;
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/RunTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main RunTest
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.run method.
+ */
+public class RunTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new RunTest().run();
+    }
+
+    /**
+     * Verify that run method can be invoked.
+     */
+    @Test
+    public void testRun() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.java");
+        File outDir = getOutDir();
+        String[] args = { "-d", outDir.getPath(), srcFile.getPath() };
+
+        ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        int rc = tool.run(null, stdout, stderr, args);
+        System.err.println("stdout >>" + stdout.toString() + "<<");
+        System.err.println("stderr >>" + stderr.toString() + "<<");
+
+        if (rc == 0) {
+            System.err.println("call succeeded");
+            checkFiles(outDir, standardExpectFiles);
+            String out = stdout.toString();
+            for (String f: standardExpectFiles) {
+                String f1 = f.replace('/', File.separatorChar);
+                if (f1.endsWith(".html") && !out.contains(f1))
+                    error("expected string not found: " + f1);
+            }
+        } else {
+            error("call failed");
+        }
+    }
+
+    /**
+     * Verify that run method can be invoked.
+     */
+    @Test
+    public void testRun2() throws Exception {
+        File outDir = getOutDir();
+        String badfile = "badfile.java";
+        String[] args = { "-d", outDir.getPath(), badfile };
+
+        ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        int rc = tool.run(null, stdout, stderr, args);
+        System.err.println("stdout >>" + stdout.toString() + "<<");
+        System.err.println("stderr >>" + stderr.toString() + "<<");
+
+        if (rc == 0) {
+            error("call succeeded unexpectedly");
+        } else {
+            String err = stderr.toString();
+            if (err.contains(badfile))
+                System.err.println("call failed as expected");
+            else
+                error("expected diagnostic not found");
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/TagletPathTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main TagletPathTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for locating a doclet via the file manager's DOCLET_PATH.
+ */
+public class TagletPathTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new TagletPathTest().run();
+    }
+
+    /**
+     * Verify that a taglet can be specified, and located via
+     * the file manager's TAGLET_PATH.
+     */
+    @Test
+    public void testTagletPath() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File tagletSrcFile = new File(testSrc, "taglets/UnderlineTaglet.java");
+        File tagletDir = getOutDir("classes");
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
+        cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tagletDir));
+        Iterable<? extends JavaFileObject> cfiles = cfm.getJavaFileObjects(tagletSrcFile);
+        if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+            throw new Exception("cannot compile taglet");
+
+        JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", testSrcText);
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir("api");
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        fm.setLocation(DocumentationTool.Location.TAGLET_PATH, Arrays.asList(tagletDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-taglet", "UnderlineTaglet");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+        boolean ok = t.call();
+        String out = sw.toString();
+        System.err.println(">>" + out + "<<");
+        if (ok) {
+            File f = new File(outDir, "pkg/C.html");
+            List<String> doc = Files.readAllLines(f.toPath(), Charset.defaultCharset());
+            for (String line: doc) {
+                if (line.contains("<u>" + TEST_STRING + "</u>")) {
+                    System.err.println("taglet executed as expected");
+                    return;
+                }
+            }
+            error("expected text not found in output " + f);
+        } else {
+            error("task failed");
+        }
+    }
+
+    static final String TEST_STRING = "xyzzy";
+    static final String testSrcText =
+            "package pkg;\n" +
+            "/** {@underline " + TEST_STRING + "} */\n" +
+            "public class C { }";
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main Task_reuseTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Locale;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for reusing a documentation task.
+ */
+public class Task_reuseTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new Task_reuseTest().run();
+    }
+
+    /**
+     * Verify that call can only be called once.
+     */
+    @Test
+    public void testReuse() throws Exception {
+        DocumentationTask t = getAndRunTask();
+        try {
+            t.call();
+            error("task was reused without exception");
+        } catch (IllegalStateException e) {
+            System.err.println("caught exception " + e);
+        }
+    }
+
+    /**
+     * Verify that cannot update task after call
+     */
+    @Test
+    public void testUpdateSetLocale() throws Exception {
+        DocumentationTask t = getAndRunTask();
+        try {
+            t.setLocale(Locale.getDefault());
+            error("task was reused without exception");
+        } catch (IllegalStateException e) {
+            System.err.println("caught exception " + e);
+        }
+    }
+
+    private DocumentationTask getAndRunTask() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            return t;
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/pkg/C.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg;
+
+public class C { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java	Wed Jul 05 18:30:46 2017 +0200
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * -Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ * -Redistribution in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in
+ *  the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ * Neither the name of Oracle nor the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES  SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that Software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+/**
+ * A sample Inline Taglet representing {@underline ...}. This tag can
+ * be used in any kind of {@link com.sun.javadoc.Doc}.
+ * The text is underlined.  For example,
+ * "@underline UNDERLINE ME" would be shown as: <u>UNDERLINE ME</u>.
+ *
+ * @author Jamie Ho
+ * @since 1.4
+ */
+
+public class UnderlineTaglet implements Taglet {
+
+    private static final String NAME = "underline";
+
+    /**
+     * Return the name of this custom tag.
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * @return true since this tag can be used in a field
+     *         doc comment
+     */
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a constructor
+     *         doc comment
+     */
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a method
+     *         doc comment
+     */
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in an overview
+     *         doc comment
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a package
+     *         doc comment
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * @return true since this
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Will return true since this is an inline tag.
+     * @return true since this is an inline tag.
+     */
+
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap  the map to register this tag to.
+     */
+    public static void register(Map tagletMap) {
+       UnderlineTaglet tag = new UnderlineTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Given the <code>Tag</code> representation of this custom
+     * tag, return its string representation.
+     * @param tag he <code>Tag</code> representation of this custom tag.
+     */
+    public String toString(Tag tag) {
+        return "<u>" + tag.text() + "</u>";
+    }
+
+    /**
+     * This method should not be called since arrays of inline tags do not
+     * exist.  Method {@link #tostring(Tag)} should be used to convert this
+     * inline tag to a string.
+     * @param tags the array of <code>Tag</code>s representing of this custom tag.
+     */
+    public String toString(Tag[] tags) {
+        return null;
+    }
+}
+