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

javac -Xlint should ignore /// on first line of source file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 23
    • tools
    • None
    • 23
    • b25

      A common idiom in shell-based operating systems is to add a line like the following as the initial line of a program to make it behave as a shell script:

      {code}
      ///usr/bin/env java "$0" "$@" ; exit $?

      /** other doc */
      public class Foo { // ...
      {code}

      Since JDK-8298405 was merged, {{///}} is now presumably recognized as the start of a markdown doc comment. This means that when {{-Xlint:dangling-doc-comments}} is given to {{javac}}, a warning is presented:

      {code}
      scratch_5.java:1: warning: [dangling-doc-comments] documentation comment is not attached to any declaration
      ///usr/bin/env java "$0" "$@" ; exit $?
      ^
      1 warning
      {code}

      A warning should not be given for comments starting with {{///}} on the first non-whitespace line of the program.

      The example source here is:

      {code:java}
      ///usr/bin/env java "$0" "$@" ; exit $?

      /**
       * Foo
       */
      public class scratch_5 {
          public static void main(String[] args) {
              System.out.println("Hello world!");
          }
      }
      {code}

            prappo Pavel Rappo
            dmlloyd David Lloyd
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: