Thanks, just double checking.
On Tue, Oct 27, 2026 at 7:59 PM Archie Cobbs <[email protected]> wrote:
> Hi David,
>
> I believe this behavior is intentional and correct according to the JLS.
>
> Javadoc comments are supposed to immediately precede a declaration in
> order to be recognized as such. In the first example, because the
> declaration includes an annotation, the official "starting point" of
> that declaration is the annotation. Since the comment does not immediately
> precede the annotation, it does not immediately precede the declaration as
> a whole, so it's not going to be recognized as a Javadoc comment, and you
> get the warning.
>
> It's essentially the same situation as if you had said something like this:
>
> public static void /** Main entry point. */ main(String[] args) { ... }
>
> -Archie
>
> On Tue, Oct 27, 2026 at 6:02 PM David Alayachew <[email protected]>
> wrote:
>
>> Hello @compiler-dev <[email protected]> and
>> @[email protected] <[email protected]>,
>>
>> Consider the following program.
>>
>> /** blah. */
>> public class abc
>> {
>>
>> @SuppressWarnings("unchecked")
>> /** Some comment. */
>> public void someMethod()
>> {
>>
>> }
>>
>> }
>>
>> If I compile the above with javac -Xlint:all abc.java, I get the
>> following compiler error.
>>
>> abc.java:6: warning: [dangling-doc-comments] documentation comment is not
>> attached to any declaration
>> /** Some comment. */
>> ^
>> 1 warning
>>
>> But if I make the following change, it compiles without error.
>>
>> /** blah. */
>> public class abc
>> {
>>
>> /** Some comment. */
>> @SuppressWarnings("unchecked")
>> public void someMethod()
>> {
>>
>> }
>>
>> }
>>
>> Is this intentional? I tried to look it up on bugs.java, but nothing
>> showed up on a cursory glance.
>>
>> Thank you for your time, attention, and consideration.
>> David Alayachew
>>
>
>
> --
> Archie L. Cobbs
>