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}
SinceJDK-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}
{code}
///usr/bin/env java "$0" "$@" ; exit $?
/** other doc */
public class Foo { // ...
{code}
Since
{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}
- links to
-
Commit(master) openjdk/jdk/3eece6e9
-
Review(master) openjdk/jdk/21923