RFR: 8354071: Add LintCategory property indicating whether @SuppressWarnings is supported

Archie Cobbs acobbs at openjdk.org
Tue Apr 8 20:57:32 UTC 2025


This is split off as a sub-task of [JDK-8224228](https://bugs.openjdk.org/browse/JDK-8224228), which seeks to add `@SuppressWarnings` support for lexical features.

Lint warnings that are subject to suppression via `@SuppressWarnings` must be deferred until attribution, because until then we can't determine whether they are suppressed or not.

Whether a lint warning is subject to suppression via `@SuppressWarnings` is a function of the associated `LintCategory`, not the warning itself. For example `LintCategory.OPTIONS` is not, so an occurrence of `@SuppressWarnings("options")` is meaningless and would be ignored.

This information is needed in the upcoming refactoring. We can facilitate that very simply by adding a boolean property to the `LintCategory` enum.

In addition, this permits a small optimization to be added to `Lint.suppressionsFrom()`.

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

Commit messages:
 - Add field LintCategory.annotationSuppression.

Changes: https://git.openjdk.org/jdk/pull/24529/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24529&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8354071
  Stats: 35 lines in 1 file changed: 25 ins; 0 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/24529.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24529/head:pull/24529

PR: https://git.openjdk.org/jdk/pull/24529


More information about the compiler-dev mailing list