RFR: 8344159: Add lint warnings for unnecessary warning suppression
Pavel Rappo
prappo at openjdk.org
Tue Sep 23 21:04:59 UTC 2025
On Sat, 10 May 2025 20:20:32 GMT, Archie Cobbs <acobbs at openjdk.org> 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
Hi Archie. I've just seen this PR. It looks nice.
While I've read the CSR, I haven't read any compiler-dev thread(s). At least not carefully. I also haven't seen the diff.
IIUC, this annotation can be applied to itself: `@SupressWarnings("suppression")`. Has the scope of `@SupressWarnings` always included the annotation itself, or it's something that you had to tweak in this PR?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25167#issuecomment-3325540024
More information about the serviceability-dev
mailing list