RFR: 8354071: Add LintCategory property indicating whether @SuppressWarnings is supported
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Apr 9 08:34:31 UTC 2025
On Tue, 8 Apr 2025 20:52:09 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
> 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()`.
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java line 377:
> 375: * This category is not supported by {@code @SuppressWarnings}.
> 376: */
> 377: TEXT_BLOCKS("text-blocks", false),
For this I'm a bit unsure -- the warning here is not unsuppressible by design, but, rather because of a deficiency in how suppression works. So seeing a "bug" reified in a flag here seems odd. At the very least this one seems different from the others -- where effectively there's no place to even put the `SuppressWarning` ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24529#discussion_r2034787042
More information about the compiler-dev
mailing list