On Sun, 19 Apr 2026 03:27:37 GMT, Archie Cobbs <[email protected]> wrote:

>> This PR adds a new compiler warning for `@SuppressWarnings` annotations that 
>> don't actually suppress any warnings.
>> 
>> Summary of code changes:
>> 
>> * Add new warning and associated lint category `"suppression"`
>> * Update `LintMapper` to keep track of which `@SuppressWarnings` 
>> suppressions have been validated ¹
>> * Update `Log.warning()` so it validates any current suppression of the 
>> warning's lint category in effect.
>> * Add a new `validate` parameter to `Lint.isEnabled()` and 
>> `Lint.isSuppressed()` that specifies whether to also validate any current 
>> suppression.
>> * Add `Lint.isActive()` to check whether a category is enabled _or_ 
>> suppression of the category is being tracked - in other words, whether the 
>> warning calculation needs to be performed. Used for non-trivial warning 
>> calculations.
>> * Add `-Xlint:-suppression` flags to `*.gmk` build files so the build 
>> doesn't break
>> 
>> ¹ The suppression of a lint category is "validated" as soon as it suppresses 
>> some warning in that category
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Archie Cobbs has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 143 commits:
> 
>  - Merge branch 'master' into JDK-8344159 to fix conflicts.
>  - Merge branch 'master' into JDK-8344159.
>  - Merge branch 'master' into JDK-8344159 to fix conflicts.
>  - Merge branch 'master' into JDK-8344159 to fix conflicts.
>  - Update copyrights to 2026.
>  - Merge branch 'master' into JDK-8344159
>  - Merge branch 'master' into JDK-8344159
>  - Merge branch 'master' into JDK-8344159
>  - Suppress new unnecessary suppresion warnings created by recent commits.
>  - Merge branch 'master' into JDK-8344159
>  - ... and 133 more: https://git.openjdk.org/jdk/compare/d71f070c...86889534

I still share the concerns with Jon and Maurizio on the mailing list, that this 
may interfere with other Java Language compiler implementations. I think we 
might get a different flag than -Xlint to enable this to alleviate that issue? 
Not sure.

Anyways we definitely need a unit test to ensure this is not emitting warnings 
for values not recognized by javac. But that said, if we are not recognizing 
these values, some users might not want those suppressions too (assuming, say, 
they aren't using any IDE). So I still think this check may be better done by a 
third party or so instead of a part of javac.

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java line 370:

> 368:          * Warn about recognized {@code @SuppressWarnings} lint 
> categories that don't actually suppress any warnings.
> 369:          */
> 370:         SUPPRESSION("suppression"),

Why should we recognize this as a value in `SuppressWarnings`? I think this 
increases complexity and provides little value.

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

PR Review: https://git.openjdk.org/jdk/pull/25167#pullrequestreview-4136497575
PR Review Comment: https://git.openjdk.org/jdk/pull/25167#discussion_r3107451507

Reply via email to