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

Ill formatted Javadoc generated when first sentence contains <code> markup

    XMLWordPrintable

Details

    Description

      Take a test class like the following one:

      /**
       * Test.
       */
      public class Test {
              /**
               * <code>M . </code>.
               */
              public void m() {}

              /**
               * <code>Y</code>.
               */
              public void n() {}
      }

      Now run

      javadoc Test.java

      The resulting Test.html document is ill formatted starting from method m(). The subsequent methods n() (and all others, if available) will be badly formatted, the browser cannot recover from this error. See also attached screenshot

      The markup in Test.html looks like this:

      <div class="block"><code>M .</div>


      As can be seen, the closing </code> tag is lost. It took me a while to reproduce the exact problem. It's related to there being a whitespace between the period "." and the closing tag. E.g. the following example removes the whitespace:

      /**
       * Test.
       */
      public class Test {
              /**
               * <code>M .</code>.
               */
              public void m() {}

              /**
               * <code>Y</code>.
               */
              public void n() {}
      }

      And now, the generated markup is as expected:

      <div class="block"><code>M .</code>.</div>

      The real world Javadoc contained <code>BEGIN .. END</code> using the periods as ellipsis.

      I guess there are two problems:

      1. The resulting markup is ill-formed
      2. There is no warning about the Javadoc format being wrong, because the first period marks the end of the Javadoc method title.

      Attachments

        Activity

          People

            prappo Pavel Rappo
            leder Lukas Eder
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: