<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I can open a bug for that Max.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 9, 2024 at 12:40 PM Max Rydahl Andersen <<a href="mailto:manderse@redhat.com">manderse@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div><div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">Hi,</p>
<p dir="auto">I noticed that Java 23 <code style="margin:0px;padding:0px 0.25em;border-radius:3px;background-color:rgb(247,247,247)">javac -Xlint:dangling-doc-comments test.java</code><br>
where <code style="margin:0px;padding:0px 0.25em;border-radius:3px;background-color:rgb(247,247,247)">test.java</code> is:</p>
<pre style="margin-left:15px;margin-right:15px;padding:5px;background-color:rgb(247,247,247);border-radius:5px;overflow-x:auto;max-width:90vw;color:black"><code style="margin:0px;border-radius:3px;background-color:rgb(247,247,247);padding:0px"><span style="color:slategray">///usr/bin/env jbang "$0" "$@" ; exit $?</span>
<span style="color:slategray">/**
* test
*/</span>
<span style="color:rgb(0,119,170)">public</span> <span style="color:rgb(0,119,170)">class</span> test <span style="color:rgb(153,153,153)">{</span>
<span style="color:rgb(0,119,170)">public</span> <span style="color:rgb(0,119,170)">static</span> <span style="color:rgb(0,119,170)">void</span> <span style="color:rgb(221,74,104)">main</span><span style="color:rgb(153,153,153)">(</span><span style="color:rgb(221,74,104)">String</span><span style="color:rgb(153,153,153)">[</span><span style="color:rgb(153,153,153)">]</span> args<span style="color:rgb(153,153,153)">)</span> <span style="color:rgb(153,153,153)">{</span>
<span style="color:rgb(221,74,104)">System</span><span style="color:rgb(153,153,153)">.</span>out<span style="color:rgb(153,153,153)">.</span><span style="color:rgb(221,74,104)">println</span><span style="color:rgb(153,153,153)">(</span><span style="color:rgb(102,153,0)">"Javadoc should not complain about the 1st line"</span><span style="color:rgb(153,153,153)">)</span><span style="color:rgb(153,153,153)">;</span>
<span style="color:rgb(153,153,153)">}</span>
<span style="color:rgb(153,153,153)">}</span>
</code></pre>
<p dir="auto">Now result in:</p>
<pre style="margin-left:15px;margin-right:15px;padding:5px;background-color:rgb(247,247,247);border-radius:5px;overflow-x:auto;max-width:90vw"><code style="margin:0px;border-radius:3px;background-color:rgb(247,247,247);padding:0px">test.java:1: warning: [dangling-doc-comments] documentation comment is not attached to any declaration
///usr/bin/env jbang "$0" "$@" ; exit $?
^
1 warning
</code></pre>
<p dir="auto">which is unfortunate given that this top-line construct is a common thing in unix based shells to use for<br>
enabling scripts to run.</p>
<p dir="auto">In this case I'm using jbang, but it is also common for others - kotlin script, go script, scala and others use it; been valid for longer than Java existed.</p>
<p dir="auto">Thus, it is unfortunate that this is flagged by the linter which IDE's are enabling and you end up with bug reports<br>
for something that is not actually a bug.</p>
<p dir="auto">My suggestion is that the linter would not complain if the line is the very first line in the file, and there is no space.</p>
<p dir="auto">i.e. it should let this pass:</p>
<pre style="margin-left:15px;margin-right:15px;padding:5px;background-color:rgb(247,247,247);border-radius:5px;overflow-x:auto;max-width:90vw"><code style="margin:0px;border-radius:3px;background-color:rgb(247,247,247);padding:0px">///usr/bin/env jbang "$0" "$@" ; exit $?
public class test
</code></pre>
<p dir="auto">but complain about</p>
<pre style="margin-left:15px;margin-right:15px;padding:5px;background-color:rgb(247,247,247);border-radius:5px;overflow-x:auto;max-width:90vw"><code style="margin:0px;border-radius:3px;background-color:rgb(247,247,247);padding:0px">/// An actual comment
public class test
</code></pre>
<p dir="auto">and</p>
<pre style="margin-left:15px;margin-right:15px;padding:5px;background-color:rgb(247,247,247);border-radius:5px;overflow-x:auto;max-width:90vw"><code style="margin:0px;border-radius:3px;background-color:rgb(247,247,247);padding:0px">package org.acme;
/// An actual comment
/**
* test
*/
public class test
</code></pre>
<p dir="auto">I'm happy to look into a PR for it but wanted to start with getting it recognized as bug/issue first.</p>
<p dir="auto">Could someone with the right powers open a bug for it?</p>
<p dir="auto">Thank you,<br>
/max<br>
<a href="https://xam.dk/about" style="color:rgb(57,131,196)" target="_blank">https://xam.dk/about</a></p>
</div>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him<br></div></div>