RFR: 8347958: Minor compiler cleanups relating to MandatoryWarningHandler [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Feb 5 11:05:16 UTC 2025


On Sat, 25 Jan 2025 23:01:38 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> After recent improvements to Lint-related classes, there are now a few minor cleanup opportunities relating to `MandatoryWarningHandler`.
>> 
>> 1. The new `LintWarning` class provides access to the associated `LintCategory`. This means that the `LintCategory` parameter being passed to the `MandatoryWarningHandler` constructor is no longer needed.
>> 1. The `prefix` string being passed to the `MandatoryWarningHandler` constructor can (in most cases) be inferred as well.
>> 1. The field `Check.sunApiHandler` (which has type `MandatoryWarningHandler`) is no longer used and can be removed.
>
> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
> 
>  - Merge branch 'master' into JDK-8347958 to fix conflict.
>  - Some cleanups relating to MandatoryWarningHandler.

src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java line 155:

> 153: 
> 154:         // Infer the log prefix from the lint category if not given explicitly
> 155:         if (prefix == null)

Honestly, I'm not sure if I would call this an improvement. The code used to be strict -- only one kind of warning allowed per handler. Now the handler starts off empty, and the first `report` determines the kind. But the same kind is then used for _all_ deferred logging... my feeling is that this would be better left alone (in the sense that I'm not sure the outcome of this PR is _objectively_ better than the code it replaces?)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23167#discussion_r1942665132


More information about the compiler-dev mailing list