8190552: Augment the Compiler API tree with APIs to represent HTML content
authorksrini
Thu, 30 Nov 2017 04:43:09 -0800
changeset 48028 9e022f580a9d
parent 48027 ddbcfca4d51d
child 48029 e9dab2492924
8190552: Augment the Compiler API tree with APIs to represent HTML content Reviewed-by: jjg, jlahoda
src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java
src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java
src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java
src/jdk.compiler/share/classes/com/sun/source/doctree/DocTypeTree.java
src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java
src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java
test/langtools/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java
test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java
test/langtools/tools/javac/doctree/DocCommentTester.java
test/langtools/tools/javac/doctree/SimpleDocTreeVisitorTest.java
test/langtools/tools/javac/doctree/dcapi/Anchor.java
test/langtools/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java
test/langtools/tools/javac/doctree/dcapi/OverviewTest.java
test/langtools/tools/javac/doctree/dcapi/overview0.html
test/langtools/tools/javac/doctree/dcapi/overview0.html.out
test/langtools/tools/javac/doctree/dcapi/overview1.html
test/langtools/tools/javac/doctree/dcapi/overview1.html.out
test/langtools/tools/javac/doctree/dcapi/overview2.html
test/langtools/tools/javac/doctree/dcapi/overview2.html.out
test/langtools/tools/javac/doctree/dcapi/overview3.html
test/langtools/tools/javac/doctree/dcapi/overview3.html.out
test/langtools/tools/javac/doctree/dcapi/overview4.html
test/langtools/tools/javac/doctree/dcapi/overview4.html.out
test/langtools/tools/javac/doctree/dcapi/overview5.html
test/langtools/tools/javac/doctree/dcapi/overview5.html.out
test/langtools/tools/javac/doctree/dcapi/overview6.html
test/langtools/tools/javac/doctree/dcapi/overview6.html.out
test/langtools/tools/javac/doctree/dcapi/overview7.html
test/langtools/tools/javac/doctree/dcapi/overview7.html.out
test/langtools/tools/javac/doctree/dcapi/package.html
test/langtools/tools/javac/doctree/dcapi/package.html.out
test/langtools/tools/javac/doctree/dcapi/pkg/package.html
test/langtools/tools/javac/doctree/dcapi/pkg/package.html.out
test/langtools/tools/javac/lib/DPrinter.java
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java	Thu Nov 30 04:43:09 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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.doctree;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -69,4 +70,39 @@
      * @return the block tags of a documentation comment
      */
     List<? extends DocTree> getBlockTags();
+
+    /**
+     * Returns a list of trees containing the content (if any) preceding
+     * the content of the documentation comment.
+     * When the {@code DocCommentTree} has been read from a documentation
+     * comment in a Java source file, the list will be empty.
+     * When the {@code DocCommentTree} has been read from an HTML file, this
+     * represents the content from the beginning of the file up to and
+     * including the {@code <body>} tag.
+     *
+     * @implSpec This implementation returns an empty list.
+     *
+     * @return the list of trees
+     * @since 10
+     */
+    default List<? extends DocTree> getPreamble() {
+        return Collections.emptyList();
+    }
+
+    /**
+     * Returns a list of trees containing the content (if any) following the
+     * content of the documentation comment.
+     * When the {@code DocCommentTree} has been read from a documentation
+     * comment in a Java source file, the list will be empty.
+     * When {@code DocCommentTree} has been read from an HTML file, this
+     * represents the content from the {@code </body>} tag to the end of file.
+     *
+     * @implSpec This implementation returns an empty list.
+     *
+     * @return the list of trees
+     * @since 10
+     */
+    default List<? extends DocTree> getPostamble() {
+        return Collections.emptyList();
+    }
 }
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java	Thu Nov 30 04:43:09 2017 -0800
@@ -78,6 +78,12 @@
         DOC_ROOT("docRoot"),
 
         /**
+         * Used for instances of {@link DocTypeTree}
+         * representing an HTML DocType declaration.
+         */
+        DOC_TYPE,
+
+        /**
          * Used for instances of {@link EndElementTree}
          * representing the end of an HTML element.
          */
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java	Thu Nov 30 04:43:09 2017 -0800
@@ -105,6 +105,21 @@
     R visitDocRoot(DocRootTree node, P p);
 
     /**
+     * Visits a DocTypeTree node.
+     *
+     * @implSpec Visits a {@code DocTypeTree} node
+     * by calling {@code visitOther(node, p)}.
+     *
+     * @param node the node being visited
+     * @param p    a parameter value
+     * @return a result value
+     * @since 10
+     */
+    default R visitDocType(DocTypeTree node, P p) {
+        return visitOther(node, p);
+    }
+
+    /**
      * Visits an EndElementTree node.
      * @param node the node being visited
      * @param p a parameter value
@@ -267,7 +282,9 @@
      * @return a result value
      * @since 10
      */
-    default R visitSummary(SummaryTree node, P p) { return visitOther(node, p);}
+    default R visitSummary(SummaryTree node, P p) {
+        return visitOther(node, p);
+    }
 
     /**
      * Visits a TextTree node.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTypeTree.java	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 a {@code doctype} declaration.
+ *
+ * <p>
+ * &lt;!doctype text&gt;
+ *
+ * @since 10
+ */
+public interface DocTypeTree extends DocTree {
+    /**
+     * Returns the text of the doctype declaration.
+     * @return text
+     */
+    String getText();
+}
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java	Thu Nov 30 04:43:09 2017 -0800
@@ -39,6 +39,7 @@
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocRootTree;
 import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTypeTree;
 import com.sun.source.doctree.EndElementTree;
 import com.sun.source.doctree.EntityTree;
 import com.sun.source.doctree.ErroneousTree;
@@ -121,6 +122,20 @@
      */
     DocCommentTree newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags);
 
+
+    /**
+     * Create a new {@code DocCommentTree} object, to represent the enitire doc comment.
+     * @param fullBody the entire body of the doc comment
+     * @param tags the block tags in the doc comment
+     * @param preamble the meta content of an html file including the body tag
+     * @param postamble the meta content of an html including the closing body tag
+     * @return a {@code DocCommentTree} object
+     * @since 10
+     */
+    DocCommentTree newDocCommentTree(List<? extends DocTree> fullBody,
+                                     List<? extends DocTree> tags,
+                                     List<? extends DocTree> preamble,
+                                     List<? extends DocTree> postamble);
     /**
      * Create a new {@code DocRootTree} object, to represent an {@code {@docroot} } tag.
      * @return a {@code DocRootTree} object
@@ -128,6 +143,14 @@
     DocRootTree newDocRootTree();
 
     /**
+     * Create a new {@code DocTypeTree}, to represent a {@code DOCTYPE} HTML declaration.
+     * @param text the content of the declaration
+     * @return a {@code CommentTree} object
+     * @since 10
+     */
+    DocTypeTree newDocTypeTree(String text);
+
+    /**
      * Create a new {@code EndElement} object, to represent the end of an HTML element.
      * @param name the name of the HTML element
      * @return an {@code EndElementTree} object
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java	Thu Nov 30 04:43:09 2017 -0800
@@ -206,6 +206,18 @@
      * @return the result of scanning
      */
     @Override
+    public R visitDocType(DocTypeTree node, P p) {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc} This implementation returns {@code null}.
+     *
+     * @param node  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of scanning
+     */
+    @Override
     public R visitEndElement(EndElementTree node, P p) {
         return null;
     }
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java	Thu Nov 30 04:43:09 2017 -0800
@@ -98,13 +98,12 @@
     /**
      * Returns the doc comment tree of the given file. The file must be
      * an HTML file, in which case the doc comment tree represents the
-     * contents of the &lt;body&gt; tag, and any enclosing tags are ignored.
+     * entire contents of the file.
      * Returns {@code null} if no doc comment was found.
      * Future releases may support additional file types.
      *
      * @param fileObject the content container
      * @return the doc comment tree
-     *
      * @since 9
      */
     public abstract DocCommentTree getDocCommentTree(FileObject fileObject);
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java	Thu Nov 30 04:43:09 2017 -0800
@@ -168,6 +168,19 @@
     }
 
     /**
+     * {@inheritDoc}
+     *
+     * @implSpec This implementation calls {@code defaultAction}.
+     *
+     * @param node {@inheritDoc}
+     * @param p {@inheritDoc}
+     * @return  the result of {@code defaultAction}
+     * @since 10
+     */
+    @Override
+    public R visitDocType(DocTypeTree node, P p) { return defaultAction(node, p); }
+
+    /**
      * {@inheritDoc} This implementation calls {@code defaultAction}.
      *
      * @param node {@inheritDoc}
@@ -175,9 +188,7 @@
      * @return  the result of {@code defaultAction}
      */
     @Override
-    public R visitEndElement(EndElementTree node, P p) {
-        return defaultAction(node, p);
-    }
+    public R visitEndElement(EndElementTree node, P p) { return defaultAction(node, p);}
 
     /**
      * {@inheritDoc} This implementation calls {@code defaultAction}.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu Nov 30 04:43:09 2017 -0800
@@ -28,9 +28,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.text.BreakIterator;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -59,6 +58,8 @@
 
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.EndElementTree;
+import com.sun.source.doctree.StartElementTree;
 import com.sun.source.tree.CatchTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Scope;
@@ -68,6 +69,7 @@
 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.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Scope.NamedImportScope;
@@ -1006,16 +1008,7 @@
             public String getText() {
                 try {
                     CharSequence rawDoc = fileObject.getCharContent(true);
-                    Pattern bodyPat =
-                            Pattern.compile("(?is).*?<body\\b[^>]*>(.*)</body\\b.*");
-                    Matcher m = bodyPat.matcher(rawDoc);
-                    if (m.matches()) {
-                        offset = m.end(1);
-                        return m.group(1);
-                    } else {
-                        // Assume doclint will do the right thing.
-                        return "";
-                    }
+                    return rawDoc.toString();
                 } catch (IOException ignore) {
                     // do nothing
                 }
@@ -1038,13 +1031,15 @@
             }
         };
 
-        return new DocCommentParser(parser, diagSource, comment).parse();
+        return new DocCommentParser(parser, diagSource, comment, true).parse();
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
     public DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement) {
         JavaFileObject jfo = asJavaFileObject(fileObject);
         DocCommentTree docCommentTree = getDocCommentTree(jfo);
+        if (docCommentTree == null)
+            return null;
         TreePath treePath = makeTreePath((PackageSymbol)packageElement, jfo, docCommentTree);
         return new DocTreePath(treePath, docCommentTree);
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Thu Nov 30 04:43:09 2017 -0800
@@ -36,10 +36,12 @@
 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.DCEndPosTree;
 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;
@@ -50,6 +52,7 @@
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Position;
+import com.sun.tools.javac.util.StringUtils;
 
 import static com.sun.tools.javac.util.LayoutCharacters.*;
 
@@ -68,11 +71,14 @@
         }
     }
 
+    private enum Phase {PREAMBLE, BODY, POSTAMBLE};
+
     final ParserFactory fac;
     final DiagnosticSource diagSource;
     final Comment comment;
     final DocTreeMaker m;
     final Names names;
+    final boolean isFileContent;
 
     BreakIterator sentenceBreaker;
 
@@ -93,17 +99,23 @@
 
     Map<Name, TagParser> tagParsers;
 
-    public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) {
+    public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource,
+                            Comment comment, boolean isFileContent) {
         this.fac = fac;
         this.diagSource = diagSource;
         this.comment = comment;
         names = fac.names;
+        this.isFileContent = isFileContent;
         m = fac.docTreeMaker;
         initTagParsers();
     }
 
+    public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) {
+        this(fac, diagSource, comment, false);
+    }
+
     public DocCommentParser(ParserFactory fac) {
-        this(fac, null, null);
+        this(fac, null, null, false);
     }
 
     public DCDocComment parse() {
@@ -115,13 +127,22 @@
         bp = -1;
         nextChar();
 
-        List<DCTree> body = blockContent();
+        List<DCTree> preamble = isFileContent ? blockContent(Phase.PREAMBLE) : List.nil();
+        List<DCTree> body = blockContent(Phase.BODY);
         List<DCTree> tags = blockTags();
-        int pos = !body.isEmpty()
-                ? body.head.pos
-                : !tags.isEmpty() ? tags.head.pos : Position.NOPOS;
+        List<DCTree> postamble = isFileContent ? blockContent(Phase.POSTAMBLE) : List.nil();
 
-        DCDocComment dc = m.at(pos).newDocCommentTree(comment, body, tags);
+        int pos = Position.NOPOS;
+        if (!preamble.isEmpty())
+            pos = preamble.head.pos;
+        else if (!body.isEmpty())
+            pos = body.head.pos;
+        else if (!tags.isEmpty())
+            pos = tags.head.pos;
+        else if (!postamble.isEmpty())
+            pos = postamble.head.pos;
+
+        DCDocComment dc = m.at(pos).newDocCommentTree(comment, body, tags, preamble, postamble);
         return dc;
     }
 
@@ -133,13 +154,17 @@
         }
     }
 
+    protected List<DCTree> blockContent() {
+        return blockContent(Phase.BODY);
+    }
+
     /**
      * 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() {
+    protected List<DCTree> blockContent(Phase phase) {
         ListBuffer<DCTree> trees = new ListBuffer<>();
         textStart = -1;
 
@@ -160,8 +185,36 @@
 
                 case '<':
                     newline = false;
+                    if (isFileContent) {
+                        switch (phase) {
+                            case PREAMBLE:
+                                if (peek("body")) {
+                                    trees.add(html());
+                                    if (textStart == -1) {
+                                        textStart = bp;
+                                        lastNonWhite = -1;
+                                    }
+                                    // mark this as the start, for processing purposes
+                                    newline = true;
+                                    break loop;
+                                }
+                                break;
+                            case BODY:
+                                if (peek("/body")) {
+                                    addPendingText(trees, lastNonWhite);
+                                    break loop;
+                                }
+                                break;
+                            default:
+                                // fallthrough
+                        }
+                    }
                     addPendingText(trees, bp - 1);
                     trees.add(html());
+
+                    if (phase == Phase.PREAMBLE || phase == Phase.POSTAMBLE) {
+                        break; // Ignore newlines after html tags, in the meta content
+                    }
                     if (textStart == -1) {
                         textStart = bp;
                         lastNonWhite = -1;
@@ -734,11 +787,37 @@
         }
     }
 
+    boolean peek(String s) {
+        final int savedpos = bp;
+        try {
+            if (ch == '<')
+                nextChar();
+
+            if (ch == '/') {
+                if (s.charAt(0) != ch) {
+                    return false;
+                } else {
+                    s = s.substring(1, s.length());
+                    nextChar();
+                }
+            }
+
+            if (isIdentifierStart(ch)) {
+                Name name = readIdentifier();
+                return StringUtils.toLowerCase(name.toString()).equals(s);
+            }
+            return false;
+        } finally {
+            bp = savedpos;
+            ch = buf[bp];
+        }
+    }
+
     /**
      * Read the start or end of an HTML tag, or an HTML comment
      * {@literal <identifier attrs> } or {@literal </identifier> }
      */
-    protected DCTree html() {
+    private DCTree html() {
         int p = bp;
         nextChar();
         if (isIdentifierStart(ch)) {
@@ -790,6 +869,19 @@
                         nextChar();
                     }
                 }
+            } else if (isIdentifierStart(ch) && peek("doctype")) {
+                readIdentifier();
+                nextChar();
+                skipWhitespace();
+                int d = bp;
+                while (bp < buflen) {
+                    if (ch == '>') {
+                        int mark = bp;
+                        nextChar();
+                        return m.at(d).newDocTypeTree(newString(d, mark));
+                    }
+                    nextChar();
+                }
             }
         }
 
@@ -1316,4 +1408,5 @@
             tagParsers.put(names.fromString(p.getTreeKind().tagName), p);
 
     }
+
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java	Thu Nov 30 04:43:09 2017 -0800
@@ -109,17 +109,23 @@
         public final List<DCTree> firstSentence;
         public final List<DCTree> body;
         public final List<DCTree> tags;
+        public final List<DCTree> preamble;
+        public final List<DCTree> postamble;
 
         public DCDocComment(Comment comment,
                             List<DCTree> fullBody,
                             List<DCTree> firstSentence,
                             List<DCTree> body,
-                            List<DCTree> tags) {
+                            List<DCTree> tags,
+                            List<DCTree> preamble,
+                            List<DCTree> postamble) {
             this.comment = comment;
             this.firstSentence = firstSentence;
             this.fullBody = fullBody;
             this.body = body;
             this.tags = tags;
+            this.preamble = preamble;
+            this.postamble = postamble;
         }
 
         @Override @DefinedBy(Api.COMPILER_TREE)
@@ -152,6 +158,15 @@
             return tags;
         }
 
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public List<? extends DocTree> getPreamble() {
+            return preamble;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public List<? extends DocTree> getPostamble() {
+            return postamble;
+        }
     }
 
     public static abstract class DCBlockTag extends DCTree implements BlockTagTree {
@@ -288,6 +303,29 @@
         }
     }
 
+    public static class DCDocType extends DCTree implements DocTypeTree {
+        public final String text;
+
+        DCDocType(String text) {
+            this.text = text;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public Kind getKind() {
+            return Kind.DOC_TYPE;
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDocType(this, d);
+        }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public String getText() {
+            return text;
+        }
+    }
+
     public static class DCEndElement extends DCTree implements EndElementTree {
         public final Name name;
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java	Thu Nov 30 04:43:09 2017 -0800
@@ -225,6 +225,16 @@
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
+    public Void visitDocType(DocTypeTree node, Void p) {
+        try {
+            print(node.getText());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public Void visitEndElement(EndElementTree node, Void p) {
         try {
             print("</");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java	Thu Nov 30 04:43:09 2017 -0800
@@ -28,6 +28,7 @@
 import java.text.BreakIterator;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.ListIterator;
@@ -37,6 +38,7 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.DocTree.Kind;
 import com.sun.source.doctree.EndElementTree;
@@ -59,6 +61,7 @@
 import com.sun.tools.javac.tree.DCTree.DCDeprecated;
 import com.sun.tools.javac.tree.DCTree.DCDocComment;
 import com.sun.tools.javac.tree.DCTree.DCDocRoot;
+import com.sun.tools.javac.tree.DCTree.DCDocType;
 import com.sun.tools.javac.tree.DCTree.DCEndElement;
 import com.sun.tools.javac.tree.DCTree.DCEntity;
 import com.sun.tools.javac.tree.DCTree.DCErroneous;
@@ -195,9 +198,23 @@
         return tree;
     }
 
-    public DCDocComment newDocCommentTree(Comment comment, List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
+    @Override @DefinedBy(Api.COMPILER_TREE)
+    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
         Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
-        DCDocComment tree = new DCDocComment(comment, cast(fullBody), pair.fst, pair.snd, cast(tags));
+        List<DCTree> preamble = Collections.emptyList();
+        List<DCTree> postamble = Collections.emptyList();
+
+        return newDocCommentTree(fullBody, tags, preamble, postamble);
+    }
+
+    public DCDocComment newDocCommentTree(Comment comment,
+                                          List<? extends DocTree> fullBody,
+                                          List<? extends DocTree> tags,
+                                          List<? extends DocTree> preamble,
+                                          List<? extends DocTree> postamble) {
+        Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
+        DCDocComment tree = new DCDocComment(comment, cast(fullBody), pair.fst, pair.snd,
+                cast(tags), cast(preamble), cast(postamble));
         tree.pos = pos;
         return tree;
     }
@@ -208,7 +225,10 @@
      * where the trees are being synthesized by a tool.
      */
     @Override @DefinedBy(Api.COMPILER_TREE)
-    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
+    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody,
+                                          List<? extends DocTree> tags,
+                                          List<? extends DocTree> preamble,
+                                          List<? extends DocTree> postamble) {
         ListBuffer<DCTree> lb = new ListBuffer<>();
         lb.addAll(cast(fullBody));
         List<DCTree> fBody = lb.toList();
@@ -236,7 +256,8 @@
             }
         };
         Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
-        DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
+        DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags),
+                                             cast(preamble), cast(postamble));
         return tree;
     }
 
@@ -248,6 +269,13 @@
     }
 
     @Override @DefinedBy(Api.COMPILER_TREE)
+    public DCDocType newDocTypeTree(String text) {
+        DCDocType tree = new DCDocType(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public DCEndElement newEndElementTree(Name name) {
         DCEndElement tree = new DCEndElement(name);
         tree.pos = pos;
--- a/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java	Thu Nov 30 04:43:09 2017 -0800
@@ -61,6 +61,7 @@
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
@@ -214,7 +215,9 @@
                 }
             }
 
-            DocCommentTree docCommentTree = parseDocComment(task, docComment);
+            Pair<DocCommentTree, Integer> parsed = parseDocComment(task, docComment);
+            DocCommentTree docCommentTree = parsed.fst;
+            int offset = parsed.snd;
             IOException[] exception = new IOException[1];
             Map<int[], String> replace = new TreeMap<>((span1, span2) -> span2[0] - span1[0]);
 
@@ -349,7 +352,10 @@
                     if (inherited == null) {
                         return null;
                     }
-                    DocCommentTree inheritedDocTree = parseDocComment(inheritedJavacTask, inherited);
+                    Pair<DocCommentTree, Integer> parsed =
+                            parseDocComment(inheritedJavacTask, inherited);
+                    DocCommentTree inheritedDocTree = parsed.fst;
+                    int offset = parsed.snd;
                     List<List<? extends DocTree>> inheritedText = new ArrayList<>();
                     DocTree parent = interestingParent.peek();
                     switch (parent.getKind()) {
@@ -391,7 +397,6 @@
                             break;
                     }
                     if (!inheritedText.isEmpty()) {
-                        long offset = trees.getSourcePositions().getStartPosition(null, inheritedDocTree, inheritedDocTree);
                         long start = Long.MAX_VALUE;
                         long end = Long.MIN_VALUE;
 
@@ -475,7 +480,6 @@
                 return docComment;
 
             StringBuilder replacedInheritDoc = new StringBuilder(docComment);
-            int offset = (int) trees.getSourcePositions().getStartPosition(null, docCommentTree, docCommentTree);
 
             for (Entry<int[], String> e : replace.entrySet()) {
                 replacedInheritDoc.delete(e.getKey()[0] - offset, e.getKey()[1] - offset + 1);
@@ -507,22 +511,28 @@
             }
 
          private DocTree parseBlockTag(JavacTask task, String blockTag) {
-            DocCommentTree dc = parseDocComment(task, blockTag);
+            DocCommentTree dc = parseDocComment(task, blockTag).fst;
 
             return dc.getBlockTags().get(0);
         }
 
-        private DocCommentTree parseDocComment(JavacTask task, String javadoc) {
+        private Pair<DocCommentTree, Integer> parseDocComment(JavacTask task, String javadoc) {
             DocTrees trees = DocTrees.instance(task);
             try {
-                return trees.getDocCommentTree(new SimpleJavaFileObject(new URI("mem://doc.html"), javax.tools.JavaFileObject.Kind.HTML) {
+                SimpleJavaFileObject fo =
+                        new SimpleJavaFileObject(new URI("mem://doc.html"), Kind.HTML) {
                     @Override @DefinedBy(Api.COMPILER)
-                    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    public CharSequence getCharContent(boolean ignoreEncodingErrors)
+                            throws IOException {
                         return "<body>" + javadoc + "</body>";
                     }
-                });
+                };
+                DocCommentTree tree = trees.getDocCommentTree(fo);
+                int offset = (int) trees.getSourcePositions().getStartPosition(null, tree, tree);
+                offset += "<body>".length() + 1;
+                return Pair.of(tree, offset);
             } catch (URISyntaxException ex) {
-                return null;
+                throw new IllegalStateException(ex);
             }
         }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Thu Nov 30 04:43:09 2017 -0800
@@ -3096,6 +3096,10 @@
         if (!configuration.isAllowScriptInComments()) {
             DocCommentTree dct = configuration.cmtUtils.parse(
                     URI.create("option://" + name.replace("-", "")), "<body>" + value + "</body>");
+
+            if (dct == null)
+                return;
+
             try {
                 javaScriptScanner.scan(dct, null, p -> {
                     throw new JavaScriptScanner.Fault();
--- a/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java	Thu Nov 30 04:43:09 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8131019
+ * @bug 8131019 8190552
  * @summary Test JavadocHelper
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
--- a/test/langtools/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java	Thu Nov 30 04:43:09 2017 -0800
@@ -44,7 +44,7 @@
                 "-sourcepath", testSrc,
                 "pkg1");
         checkExit(Exit.ERROR);
-        checkOutput(Output.OUT, true, "package.html:10: error: bad use of '>'");
+        checkOutput(Output.OUT, true, "package.html:5: error: bad use of '>'");
     }
 
     // Doclet must handle empty body in package.html, must
--- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java	Thu Nov 30 04:43:09 2017 -0800
@@ -102,7 +102,7 @@
                 "p2");
         checkExit(Exit.OK);
 
-        checkOutput(Output.OUT, true, "package.html:5: warning: invalid use of @summary");
+        checkOutput(Output.OUT, true, "package.html:3: warning: invalid use of @summary");
 
         checkOutput("index-all.html", true, "<div class=\"block\">foo bar</div>\n");
 
--- a/test/langtools/tools/javac/doctree/DocCommentTester.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/DocCommentTester.java	Thu Nov 30 04:43:09 2017 -0800
@@ -404,9 +404,18 @@
             public Void visitDocComment(DocCommentTree node, Void p) {
                 header(node);
                 indent(+1);
+                // Applicable only to html files, print iff non-empty
+                if (!node.getPreamble().isEmpty())
+                    print("preamble", node.getPreamble());
+
                 print("firstSentence", node.getFirstSentence());
                 print("body", node.getBody());
                 print("block tags", node.getBlockTags());
+
+                // Applicable only to html files, print iff non-empty
+                if (!node.getPostamble().isEmpty())
+                    print("postamble", node.getPostamble());
+
                 indent(-1);
                 indent();
                 out.println("]");
@@ -418,6 +427,11 @@
                 return null;
             }
 
+            public Void visitDocType(DocTypeTree node, Void p) {
+                header(node, compress(node.getText()));
+                return null;
+            }
+
             public Void visitEndElement(EndElementTree node, Void p) {
                 header(node, node.getName().toString());
                 return null;
--- a/test/langtools/tools/javac/doctree/SimpleDocTreeVisitorTest.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/SimpleDocTreeVisitorTest.java	Thu Nov 30 04:43:09 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTree.Kind;
 import com.sun.source.doctree.DocTreeVisitor;
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
@@ -84,7 +85,7 @@
             }
 
             for (DocTree.Kind k: DocTree.Kind.values()) {
-                if (!found.contains(k) && k != DocTree.Kind.OTHER)
+                if (!found.contains(k) && k != DocTree.Kind.OTHER && k != DocTree.Kind.DOC_TYPE)
                     error("not found: " + k);
             }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/Anchor.java	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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.
+ */
+
+/**
+ * Anchor test.
+ */
+public class Anchor {}
--- a/test/langtools/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java	Thu Nov 30 04:43:09 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug  8132096 8157611
+ * @bug  8132096 8157611 8190552
  * @summary test the APIs  in the DocTree interface
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.file
@@ -52,6 +52,7 @@
 import javax.lang.model.util.Elements;
 import javax.tools.FileObject;
 import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
 import javax.tools.StandardJavaFileManager;
 
 import com.sun.source.doctree.DocTree;
@@ -64,8 +65,8 @@
 
 public class DocCommentTreeApiTester {
 
-    private static final String MARKER_START = "<!-- EXPECT_START";
-    private static final String MARKER_END   = "EXPECT_END -->";
+    private static final String MARKER_START = "EXPECT_START";
+    private static final String MARKER_END   = "EXPECT_END";
 
     private static final String testSrc = System.getProperty("test.src", ".");
 
@@ -85,22 +86,26 @@
         DocCommentTreeApiTester test = new DocCommentTreeApiTester();
         try {
             // test getting a DocTree from an element
-            test.runElementAndBreakIteratorTests("OverviewTest.java", "OverviewTest test.");
+            test.runElementAndBreakIteratorTests("Anchor.java", "Anchor test.");
 
             // test relative paths in a class within a package
-            test.runRelativePathTest("pkg/Anchor.java", "package.html");
+            test.runRelativePathTest("pkg/Anchor.java", "package.html", true);
 
             // tests files relative path in an unnamed package
-            test.runRelativePathTest("OverviewTest.java", "overview0.html");
+            test.runRelativePathTest("Anchor.java", "overview0.html", true);
 
-            // tests doctreepath using package element and package.html
-            test.runDocTreePath("pkg/Anchor.java", "package.html");
+            // test doctree path and Doc
+            test.runDocTreePath("Anchor.java", "package.html");
 
             // test for correct parsing using valid and some invalid html tags
-            for (int i = 0; i < 7; i++) {
-                String hname = "overview" + i + ".html";
-                test.runFileObjectTest(hname);
-            }
+            test.runFileObjectTest("overview0.html");
+            test.runFileObjectTest("overview1.html");
+            test.runFileObjectTest("overview2.html");
+            test.runFileObjectTest("overview3.html");
+            test.runFileObjectTest("overview4.html");
+            test.runFileObjectTest("overview5.html");
+            test.runFileObjectTest("overview6.html");
+            test.runFileObjectTest("overview7.html");
 
         } finally {
             test.status();
@@ -166,7 +171,8 @@
      * @param fileName the relative html file
      * @throws java.lang.Exception ouch
      */
-    public void runRelativePathTest(String javaFileName, String fileName) throws Exception  {
+    public void runRelativePathTest(String javaFileName, String fileName,
+                                    boolean bodyOnly) throws Exception  {
         List<File> javaFiles = new ArrayList<>();
         javaFiles.add(new File(testSrc, javaFileName));
 
@@ -185,13 +191,17 @@
             Element klass = elements.iterator().next();
 
             DocCommentTree dcTree = trees.getDocCommentTree(klass, fileName);
+
+            if (dcTree == null)
+                throw new Error("invalid input: " + fileName);
+
             StringWriter sw = new StringWriter();
             printer.print(dcTree, sw);
             String found = sw.toString();
 
             FileObject htmlFo = fm.getFileForInput(javax.tools.StandardLocation.SOURCE_PATH,
                     t.getElements().getPackageOf(klass).getQualifiedName().toString(),
-                    fileName);
+                    fileName + ".out");
 
             String expected = getExpected(htmlFo.openReader(true));
             astcheck(fileName, expected, found);
@@ -209,6 +219,7 @@
 
         List<File> otherFiles = new ArrayList<>();
         otherFiles.add(new File(testSrc, htmlfileName));
+        otherFiles.add(new File(testSrc, htmlfileName + ".out"));
 
         try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
             Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(javaFiles);
@@ -218,10 +229,22 @@
             final DocTrees trees = DocTrees.instance(t);
 
             StringWriter sw = new StringWriter();
+            DocCommentTree dct = null;
+            String expected = null;
+            for (JavaFileObject jfo : others) {
+                switch (jfo.getKind()) {
+                    case HTML:
+                        dct = trees.getDocCommentTree(jfo);
+                        if (dct == null)
+                            throw new Exception("invalid input: " + jfo);
+                        break;
+                    default:
+                        expected = getExpected(jfo.openReader(true));
+                }
+            }
 
-            printer.print(trees.getDocCommentTree(others.iterator().next()), sw);
+            printer.print(dct, sw);
             String found = sw.toString();
-            String expected = getExpected(otherFiles.iterator().next().toPath());
             astcheck(otherFiles.toString(), expected, found);
         }
     }
@@ -237,6 +260,9 @@
         List<File> javaFiles = new ArrayList<>();
         javaFiles.add(new File(testSrc, javaFileName));
 
+        List<File> otherFiles = new ArrayList<>();
+        otherFiles.add(new File(testSrc, pkgFileName + ".out"));
+
         List<File> dirs = new ArrayList<>();
         dirs.add(new File(testSrc));
 
@@ -256,15 +282,23 @@
             FileObject htmlFo = fm.getFileForInput(javax.tools.StandardLocation.SOURCE_PATH,
                     t.getElements().getPackageOf(klass).getQualifiedName().toString(),
                     "package.html");
-            System.out.println();
             DocTreePath treePath = trees.getDocTreePath(htmlFo, pkg);
+
+            if (treePath == null) {
+                throw new Exception("invalid input: " + htmlFo);
+            }
+
             DocCommentTree dcTree = treePath.getDocComment();
+            if (dcTree == null)
+                throw new Exception("invalid input" + htmlFo);
 
             StringWriter sw = new StringWriter();
             printer.print(dcTree, sw);
             String found = sw.toString();
+            Iterable<? extends JavaFileObject> oos = fm.getJavaFileObjectsFromFiles(otherFiles);
+            JavaFileObject otherFo = oos.iterator().next();
+            String expected = getExpected(otherFo.openReader(true));
 
-            String expected = getExpected(htmlFo.openReader(true));
             astcheck(pkgFileName, expected, found);
         }
     }
@@ -300,10 +334,6 @@
         return getExpected(lines);
     }
 
-    String getExpected(Path p) throws IOException {
-        return getExpected(Files.readAllLines(p));
-    }
-
     String getExpected(List<String> lines) {
         boolean start = false;
         StringWriter sw = new StringWriter();
--- a/test/langtools/tools/javac/doctree/dcapi/OverviewTest.java	Thu Nov 30 07:54:28 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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.
- */
-
-/**
- * OverviewTest test.
- */
-public class OverviewTest {}
--- a/test/langtools/tools/javac/doctree/dcapi/overview0.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview0.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,48 +1,8 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, A_simple_well_fo...rmed_html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:36
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:41, overview0.html]
-    StartElement[START_ELEMENT, pos:55
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:60, .]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
 </HEAD>
 <BODY>
-A simple well formed html document <pre>overview0.html<pre>.
+A simple well formed html document <pre>overview0.html</pre>.
 </BODY>
-</HTML>
-
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview0.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,33 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 5
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:37
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:44, HEAD]
+    StartElement[START_ELEMENT, pos:52
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:59, A_simple_well_fo...rmed_html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:94
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:99, overview0.html]
+    EndElement[END_ELEMENT, pos:113, pre]
+    Text[TEXT, pos:119, .]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:121, BODY]
+    EndElement[END_ELEMENT, pos:129, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview1.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview1.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,47 +1,8 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, Html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:15
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:20, overview1.html]
-    StartElement[START_ELEMENT, pos:34
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:39, .|Missing_HTML.]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HEAD>
 </HEAD>
 <BODY>
-Html document <pre>overview1.html<pre>.
+Html document <pre>overview1.html</pre>.
 Missing HTML.
 </BODY>
-</HTML>
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview1.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,29 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 4
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:37, HEAD]
+    StartElement[START_ELEMENT, pos:45
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:52, Html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:66
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:71, overview1.html]
+    EndElement[END_ELEMENT, pos:85, pre]
+    Text[TEXT, pos:91, .|Missing_HTML.]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:107, BODY]
+    EndElement[END_ELEMENT, pos:115, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview2.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview2.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,47 +1,8 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, Html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:15
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:20, overview2.html]
-    StartElement[START_ELEMENT, pos:34
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:39, .|Missing_HEAD.]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HTML>
 </HEAD>
 <BODY>
-Html document <pre>overview2.html<pre>.
+Html document <pre>overview2.html</pre>.
 Missing HEAD.
 </BODY>
-</HTML>
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview2.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,29 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 4
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:37, HEAD]
+    StartElement[START_ELEMENT, pos:45
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:52, Html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:66
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:71, overview2.html]
+    EndElement[END_ELEMENT, pos:85, pre]
+    Text[TEXT, pos:91, .|Missing_HEAD.]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:107, BODY]
+    EndElement[END_ELEMENT, pos:115, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview3.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview3.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,47 +1,8 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, Html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:15
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:20, overview3.html]
-    StartElement[START_ELEMENT, pos:34
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:39, .|Missing_enclosing_HEAD.]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
 <BODY>
-Html document <pre>overview3.html<pre>.
+Html document <pre>overview3.html</pre>.
 Missing enclosing HEAD.
 </BODY>
-</HTML>
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview3.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,32 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 4
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:37
+      name:HEAD
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:44
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:51, Html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:65
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:70, overview3.html]
+    EndElement[END_ELEMENT, pos:84, pre]
+    Text[TEXT, pos:90, .|Missing_enclosing_HEAD.]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:116, BODY]
+    EndElement[END_ELEMENT, pos:124, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview4.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview4.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,44 +1,6 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
+<!-- /nodynamiccopyright/ -->
 
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, Html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:15
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:20, overview4.html]
-    StartElement[START_ELEMENT, pos:34
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:39, .|Only_BODY]
-  block tags: empty
-]
-EXPECT_END -->
 <BODY>
-Html document <pre>overview4.html<pre>.
+Html document <pre>overview4.html</pre>.
 Only BODY
-</BODY>
+</BODY>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview4.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,23 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 2
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:31
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:38, Html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:52
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:57, overview4.html]
+    EndElement[END_ELEMENT, pos:71, pre]
+    Text[TEXT, pos:77, .|Only_BODY]
+  block tags: empty
+  postamble: 1
+    EndElement[END_ELEMENT, pos:89, BODY]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview5.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview5.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,47 +1,8 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, Html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:15
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:20, overview5.html]
-    StartElement[START_ELEMENT, pos:34
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:39, .|Missing_enclosing_HTML]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
 </HEAD>
 <BODY>
-Html document <pre>overview5.html<pre>.
+Html document <pre>overview5.html</pre>.
 Missing enclosing HTML
-</BODY>
+</BODY>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview5.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,32 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 5
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:37
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:44, HEAD]
+    StartElement[START_ELEMENT, pos:52
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:59, Html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:73
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:78, overview5.html]
+    EndElement[END_ELEMENT, pos:92, pre]
+    Text[TEXT, pos:98, .|Missing_enclosing_HTML]
+  block tags: empty
+  postamble: 1
+    EndElement[END_ELEMENT, pos:123, BODY]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/overview6.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/overview6.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,40 +1,4 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, The_first_correct_body_pair.]
-  body: 4
-    EndElement[END_ELEMENT, pos:30, BODY]
-    Text[TEXT, pos:37, ||]
-    StartElement[START_ELEMENT, pos:39
-      name:BODY
-      attributes: empty
-    ]
-    Text[TEXT, pos:45, |Illegal_second_...body_pair,_the_first_body_should_not_be_ignored.]
-  block tags: empty
-]
-EXPECT_END -->
+<!-- /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
 </HEAD>
@@ -46,4 +10,3 @@
 Illegal second body pair, the first body should not be ignored.
 </BODY>
 </HTML>
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview6.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,32 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 5
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:37
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:44, HEAD]
+    StartElement[START_ELEMENT, pos:52
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:59, The_first_correct_body_pair.]
+  body: empty
+  block tags: empty
+  postamble: 5
+    EndElement[END_ELEMENT, pos:88, BODY]
+    StartElement[START_ELEMENT, pos:97
+      name:BODY
+      attributes: empty
+    ]
+    Text[TEXT, pos:104, Illegal_second_b...ody_pair,_the_first_body_should_not_be_ignored.|]
+    EndElement[END_ELEMENT, pos:168, BODY]
+    EndElement[END_ELEMENT, pos:176, HTML]
+]
+EXPECT_END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview7.html	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,6 @@
+<!-- /nodynamiccopyright/ -->
+<HTML>
+<HEAD>
+</HEAD>
+<BODY>@since 1.0</BODY>
+</HTML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/overview7.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,29 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 5
+    Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:30
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:37
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:44, HEAD]
+    StartElement[START_ELEMENT, pos:52
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Since[SINCE, pos:58
+      body: 1
+        Text[TEXT, pos:65, 1.0]
+    ]
+  postamble: 2
+    EndElement[END_ELEMENT, pos:68, BODY]
+    EndElement[END_ELEMENT, pos:76, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/package.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/package.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,47 +1,11 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<!-- /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
+    <TITLE>The Crafty Fox</TITLE>
 </HEAD>
 <BODY>
 A simple well formed html document <pre>package.html<pre>.
 </BODY>
-</HTML>
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, This_is_a_very_simple]
-  body: 4
-    StartElement[START_ELEMENT, pos:23
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:28, _well_formed_html_document_]
-    StartElement[START_ELEMENT, pos:55
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:60, _using_some_html_tags.]
-  block tags: empty
-]
-EXPECT_END -->
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/package.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,43 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:10
+  preamble: 9
+    DocType[DOC_TYPE, pos:10, HTML_PUBLIC_"-//...W3C//DTD_HTML_4.01//EN"|________"http://www.w3.org/TR/html4/strict.dtd"]
+    Comment[COMMENT, pos:99, <!--_/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:129
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:136
+      name:HEAD
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:147
+      name:TITLE
+      attributes: empty
+    ]
+    Text[TEXT, pos:154, The_Crafty_Fox]
+    EndElement[END_ELEMENT, pos:168, TITLE]
+    EndElement[END_ELEMENT, pos:177, HEAD]
+    StartElement[START_ELEMENT, pos:185
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:192, A_simple_well_fo...rmed_html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:227
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:232, package.html]
+    StartElement[START_ELEMENT, pos:244
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:249, .]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:251, BODY]
+    EndElement[END_ELEMENT, pos:259, HTML]
+]
+EXPECT_END
--- a/test/langtools/tools/javac/doctree/dcapi/pkg/package.html	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/doctree/dcapi/pkg/package.html	Thu Nov 30 04:43:09 2017 -0800
@@ -1,48 +1,9 @@
-<!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
- This code is free software; you can redistribute 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.
--->
-<!-- EXPECT_START
-DocComment[DOC_COMMENT, pos:1
-  firstSentence: 1
-    Text[TEXT, pos:1, A_simple_well_fo...rmed_html_document]
-  body: 4
-    StartElement[START_ELEMENT, pos:36
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:41, package.html]
-    StartElement[START_ELEMENT, pos:53
-      name:pre
-      attributes: empty
-    ]
-    Text[TEXT, pos:58, .|In_package_pkg.]
-  block tags: empty
-]
-EXPECT_END -->
+<!--  /nodynamiccopyright/ -->
 <HTML>
 <HEAD>
 </HEAD>
 <BODY>
-A simple well formed html document <pre>package.html<pre>.
+A simple well formed html document <pre>package.html</pre>.
 In package pkg.
 </BODY>
-</HTML>
+</HTML>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/doctree/dcapi/pkg/package.html.out	Thu Nov 30 04:43:09 2017 -0800
@@ -0,0 +1,33 @@
+EXPECT_START
+DocComment[DOC_COMMENT, pos:0
+  preamble: 5
+    Comment[COMMENT, pos:0, <!--__/nodynamiccopyright/_-->]
+    StartElement[START_ELEMENT, pos:31
+      name:HTML
+      attributes: empty
+    ]
+    StartElement[START_ELEMENT, pos:38
+      name:HEAD
+      attributes: empty
+    ]
+    EndElement[END_ELEMENT, pos:45, HEAD]
+    StartElement[START_ELEMENT, pos:53
+      name:BODY
+      attributes: empty
+    ]
+  firstSentence: 1
+    Text[TEXT, pos:60, A_simple_well_fo...rmed_html_document]
+  body: 4
+    StartElement[START_ELEMENT, pos:95
+      name:pre
+      attributes: empty
+    ]
+    Text[TEXT, pos:100, package.html]
+    EndElement[END_ELEMENT, pos:112, pre]
+    Text[TEXT, pos:118, .|In_package_pkg.]
+  block tags: empty
+  postamble: 2
+    EndElement[END_ELEMENT, pos:136, BODY]
+    EndElement[END_ELEMENT, pos:144, HTML]
+]
+EXPECT_END
\ No newline at end of file
--- a/test/langtools/tools/javac/lib/DPrinter.java	Thu Nov 30 07:54:28 2017 -0500
+++ b/test/langtools/tools/javac/lib/DPrinter.java	Thu Nov 30 04:43:09 2017 -0800
@@ -1028,6 +1028,12 @@
             return visitInlineTag(node, null);
         }
 
+        @Override
+        public Void visitDocType(DocTypeTree node, Void aVoid) {
+            printLimitedEscapedString("body", node.getText());
+            return visitTree(node, null);
+        }
+
         public Void visitEndElement(EndElementTree node, Void p) {
             printName("name", node.getName());
             return visitTree(node, null);