RFR: 8350514: Refactor MandatoryWarningHandler to support dynamic verbosity
Archie Cobbs
acobbs at openjdk.org
Fri Apr 11 20:40:33 UTC 2025
On Fri, 21 Feb 2025 20:42:10 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
> This PR is a sub-task split off from [JDK-8224228](https://bugs.openjdk.org/browse/JDK-8224228), which seeks to add `@SuppressWarnings` support for lexical features.
>
> The `MandatoryWarningHandler` is used by the `preview`, `deprecation`, `removal`, and `unchecked` mandatory warnings. The constructor takes a boolean `verbose` flag which is documented to "Specify whether or not detailed messages about individual instances should be given, or whether an aggregate message should be generated at the end of the compilation."
>
> The problem is that this flag doesn't really make sense for warnings that are suppressible via `@SuppressWarnings`: for such warnings, what we actually want to do is trigger the aggregate message at the end of compilation if and only if there were any warnings that were not suppressed by `@SuppressWarnings` but _were_ suppressed because the corresponding lint category was not enabled, either because it wasn't enabled by default, or due to an explicit `-Xlint:-foo` flag.
>
> Currently, we get that same net result, because `preview` is not suppressible via `@SuppressWarnings`, and for the other three categories there is logic around the calls to `MandatoryWarningHandler.report()` to ensure the right thing happens.
>
> It would be simpler and more straightforward for the users of `MandatoryWarningHandler` to just pass along the currently applicable `Lint` instance and let `MandatoryWarningHandler` keep track of whether to generate the aggregate message at the end of the compilation.
Closing this PR. It's being made obsolete by #24584.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23730#issuecomment-2797967060
More information about the compiler-dev
mailing list