RFR: 8359493: Refactor how aggregated mandatory warnings are handled in the compiler [v4]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jul 3 10:17:42 UTC 2025


On Tue, 1 Jul 2025 16:03:33 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> The compiler's handling of the aggregation of mandatory warnings into "notes" at the end of compilation can be refactored to simplify the code.
>> 
>> The `JCDiagnostic` class supports flags that alter how warnings are handled, e.g., `MANDATORY`, `NON_DEFERRABLE`, etc. So instead of having to log aggregated mandatory warnings through a separate channel (the `MandatoryWarningHandler`), these warnings could instead be logged just like any other warning, but with an `AGGREGATED` flag added. The actual aggregation can then be handled "behind the scenes" by the logging subsystem.
>> 
>> This will also make it easier to implement `@SuppressAnnotations` support for parser/tokenizer warnings which require aggregated mandatory warning notes such as warnings for preview features.
>
> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
> 
>  - Merge branch 'master' into MandatoryWarningCleanup
>  - Move (most) SOURCE_LEVEL flags into compiler.properties.
>  - Add DiagnosticFlag support to compiler.properties and put AGGREGATE there.
>  - Apply some review suggestions.
>  - Refactor MandatoryWarningHandler to just be an aggregator.

I like capturing flags in the diagnostic key -- it seems to go in the direction of trying to make the diagnostic subsystem more robust and "statically self-described" -- a direction we've kept pushing for quite some time now. I have some (minor) quibbles re. use of nulls.

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

PR Review: https://git.openjdk.org/jdk/pull/25810#pullrequestreview-2982595048


More information about the compiler-dev mailing list