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

Incorrect/inconsistent specification and implementation for Elements.getDocComment

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 22
    • 20, 21, 22
    • core-libs
    • None

      The specification for Elements.getDocConnent does not match the implementation.

      There are (at least) 3 issues:

      1. The description of which leading characters are removed from each of the lines in the body of the comment is incorrect. Leading whitespace and asterisks are only removed if there is at least one asterisk. No characters are removed if there are no asterisks on the line. (That is as it should be, and would be an incompatible change if changed.)

      Spec text: For lines of the comment starting after the initial "/**", leading white space characters are discarded as are any consecutive "*" characters appearing after the white space or starting the line. The processed lines are then concatenated together (including line terminators) and returned.


      2. The description does not cover the removal of any initial whitespace and newline after the initial `/**`.

      Spec text: The leading "/**" ... [is] removed.

      3. The description does not cover the removal of the trailing whitespace before the final `*/`.

      Spec text: The ... trailing "*/" [is] removed.

      A small demo program is attached that can be used to show the contents of comments. The program takes one or more filenames as arguments, and shows the contents of comments found in those files. Whitespace is made visible by replacing space and newline characters with distinctive visible glyphs. The program can be run with the Java source launcher. The program can be run on itself, showing any comments found in itself.

      As written, the output from the program is as follows:

      # file play/showComments/src/ShowComments.java ShowComments
          ●ShowComments●class.▲

            darcy Joe Darcy
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: