RFR: 8224228: No way to locally suppress lint warnings in parser/tokenizer or preview features [v14]

Archie Cobbs acobbs at openjdk.org
Fri Feb 28 22:59:15 UTC 2025


On Fri, 28 Feb 2025 22:09:55 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> > I originally was handling things "as they come", based on the assumption that reports always occur prior to the completion of their containing declaration, but that's not true (`dangling-doc-comment` violates it).
> 
> Just one question: looking at your code, it seems that `saveDanglingDocComments` is always called _before_ `endDecl`. So I'm not sure how to read your comment.

Well I may just be confused. I saw that problem at the same time I was fighting with `VirtualParser`, so the "backwards" reports may have actually just been bogus duplicates.

In any case, it's a moot point now because the issue is no longer relevant in linear time refactoring (just pushed as 12d8c730c1f0051c52bd0d5362597ab0971867c7).

> One of the two warnings actually gets suppressed -- suggesting that the warning -- after all - is being attributed to the method parameter (which seems odd, given that method parameters cannot have javadoc comments).

I think the behavior of that example is correct. It doesn't matter if you put a Javadoc comment in front of something that doesn't support Javadoc comments - that just makes it definitely dangling, as opposed to maybe dangling!

The other thing playing into this example is that the lexical extent of variable declarations is defined to include any annotations on the declaration. Therefore the offending dangling Javadoc comment is contained by it, and therefore the suppression specified by the annotation applies. Therefore, the warning is suppressed.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23237#issuecomment-2691682549


More information about the compiler-dev mailing list