RFR: 8350514: Refactor MandatoryWarningHandler to support dynamic verbosity
Archie Cobbs
acobbs at openjdk.org
Fri Feb 21 21:49:02 UTC 2025
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.
-------------
Commit messages:
- Refactor MandatoryWarningHandler to support dynamic verbosity.
Changes: https://git.openjdk.org/jdk/pull/23730/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23730&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8350514
Stats: 60 lines in 3 files changed: 14 ins; 25 del; 21 mod
Patch: https://git.openjdk.org/jdk/pull/23730.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23730/head:pull/23730
PR: https://git.openjdk.org/jdk/pull/23730
More information about the compiler-dev
mailing list