Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8048628

javadoc strips HTML incorrectly; causes invalid generated HTML files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • b156
    • Verified

        Following a changeset earlier this week, there are now no doclint errors being reported against 3 of the 15 JDK doc bundles:

        docs/jdk/api/javac/tree/index.html
        docs/jdk/api/javadoc/doclet/index.html
        docs/jdk/api/javadoc/taglet/index.html

        Therefore, it becomes interesting to run tidy on the files in these directories, to see if tidy reports any errors.

        If it reports errors, that would seem to indicate either problems in the javadoc tool, or in doclint for not reporting issues in user comments.

        So, I tried that, and found errors! 5 to be exact, but I think they are all derivatives of one basic error.

        The problem seems to be in the way javadoc is processing a user comment. But the comment appears to be legal.

        Here's the doc comment. It's on a nested enum in langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java

            /**
             * Lambda expressions come in two forms:
             * <ul compact>
             * <li> expression lambdas, whose body is an expression, and
             * <li> statement lambdas, whose body is a block
             * </ul>
             */
            @jdk.Exported
            public enum BodyKind {
                /** enum constant for expression lambdas */
                EXPRESSION,
                /** enum constant for statement lambdas */
                STATEMENT
            }

        The issue is that <ul> tag.

        The comment is being processed correctly for the doc page for the enum itself

        <div class="block">Lambda expressions come in two forms:
         <ul compact>
         <li> expression lambdas, whose body is an expression, and
         <li> statement lambdas, whose body is a block
         </ul></div>

        But look at it in the Nested Class summary for the enclosing page ... the <li> and the closing </ul> have been removed:

        <div class="block">Lambda expressions come in two forms:
         <ul compact>
          expression lambdas, whose body is an expression, and
          statement lambdas, whose body is a block
         </div>

        All 5 errors are effectively equivalent, so I assume the (incorrect) summary is being written into multiple pages.

        ---

        Problem appears to be in HtmlDocletWriter.removeNonInlineHtmlTags. The loop round about line 1772 is not allowing for the possibility of attributes, and so tags with attributes are (incorrectly) allowed through, meaning that "<ul compact>" is not filtered out, but its closing tag "</ul>" is.

              ksrini Kumar Srinivasan
              jjg Jonathan Gibbons
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: