diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java index 94d91c5cb83..1150b43b854 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java @@ -269,7 +269,20 @@ public class Checker extends DocTreePathScanner { @Override @DefinedBy(Api.COMPILER_TREE) public Void visitDocComment(DocCommentTree tree, Void ignore) { - super.visitDocComment(tree, ignore); + scan(tree.getFirstSentence(), ignore); + scan(tree.getBody(), ignore); + checkTagStack(); + + for (DocTree blockTag : tree.getBlockTags()) { + tagStack.clear(); + scan(blockTag, ignore); + checkTagStack(); + } + + return null; + } + + private void checkTagStack() { for (TagStackItem tsi: tagStack) { warnIfEmpty(tsi, null); if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT @@ -278,7 +291,6 @@ public class Checker extends DocTreePathScanner { env.messages.error(HTML, t, "dc.tag.not.closed", t.getName()); } } - return null; } // @@ -548,6 +560,7 @@ public class Checker extends DocTreePathScanner { done = true; break; } else if (top.tag == null || top.tag.endKind != HtmlTag.EndKind.REQUIRED) { + warnIfEmpty(top, null); tagStack.pop(); } else { boolean found = false; diff --git a/test/langtools/tools/doclint/EmptyTagsTest.java b/test/langtools/tools/doclint/EmptyTagsTest.java new file mode 100644 index 00000000000..bec33195df5 --- /dev/null +++ b/test/langtools/tools/doclint/EmptyTagsTest.java @@ -0,0 +1,45 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8258957 + * @summary DocLint: check for HTML start element at end of body + * @modules jdk.javadoc/jdk.javadoc.internal.doclint + * @build DocLintTester + * @run main DocLintTester -Xmsgs:-html EmptyTagsTest.java + * @run main DocLintTester -Xmsgs:html -ref EmptyTagsTest.out EmptyTagsTest.java + */ + +/** . */ +public class EmptyTagsTest { + /** + * Comment.

+ */ + void simpleTrailing() { } + + /** + * Comment.

+ *

    + *
  • Item. + *
+ */ + void beforeBlock() { } + + /** + * Comment.

+ * @since 1.0 + */ + void beforeTag() { } + + /** + * Comment. + *

    + *
  • Item.

    + *

+ */ + void inBlock() { } + + /** + * Comment. + * @author J. Duke

+ */ + void inTag() { } +} diff --git a/test/langtools/tools/doclint/EmptyTagsTest.out b/test/langtools/tools/doclint/EmptyTagsTest.out new file mode 100644 index 00000000000..34ad9389fd7 --- /dev/null +++ b/test/langtools/tools/doclint/EmptyTagsTest.out @@ -0,0 +1,16 @@ +EmptyTagsTest.java:14: warning: empty

tag + * Comment.

+ ^ +EmptyTagsTest.java:19: warning: empty

tag + * Comment.

+ ^ +EmptyTagsTest.java:27: warning: empty

tag + * Comment.

+ ^ +EmptyTagsTest.java:35: warning: empty

tag + *

  • Item.

    + ^ +EmptyTagsTest.java:42: warning: empty

    tag + * @author J. Duke

    + ^ +5 warnings \ No newline at end of file diff --git a/test/langtools/tools/doclint/EndTagsTest.out b/test/langtools/tools/doclint/EndTagsTest.out index 3367a62b8c7..2455b197718 100644 --- a/test/langtools/tools/doclint/EndTagsTest.out +++ b/test/langtools/tools/doclint/EndTagsTest.out @@ -1,6 +1,9 @@ EndTagsTest.java:19: error: unexpected end tag: /** */ ^ +EndTagsTest.java:22: warning: empty

    tag + /**

    */ + ^ EndTagsTest.java:22: error: unexpected end tag: /**

    */ ^ @@ -23,3 +26,4 @@ EndTagsTest.java:37: error: unknown tag: invalid /** */ ^ 8 errors +1 warning \ No newline at end of file diff --git a/test/langtools/tools/doclint/HtmlTagsTest.out b/test/langtools/tools/doclint/HtmlTagsTest.out index 66d80e365e6..8117de21dc1 100644 --- a/test/langtools/tools/doclint/HtmlTagsTest.out +++ b/test/langtools/tools/doclint/HtmlTagsTest.out @@ -16,6 +16,9 @@ HtmlTagsTest.java:29: error: element not closed: html HtmlTagsTest.java:34: error: block element not allowed within inline element : p *

    ^ +HtmlTagsTest.java:34: warning: empty

    tag + *

    + ^ HtmlTagsTest.java:39: error: block element not allowed within @link: p * {@link java.lang.String

    } ^ @@ -41,4 +44,4 @@ HtmlTagsTest.java:65: error: tag not allowed here: *

      text
    • ...
    ^ 13 errors -1 warning +2 warnings