RFR: 8347958: Minor compiler cleanups relating to MandatoryWarningHandler [v2]
Archie Cobbs
acobbs at openjdk.org
Wed Feb 5 16:21:38 UTC 2025
On Wed, 5 Feb 2025 11:02:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> 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?)
>
> (of course the part that removes the sunapi handler is ok and orthogonal)
> Now the handler starts off empty, and the first report determines the kind. But the same kind is then used for all deferred logging...
You are correct - which is why the Javadoc comment "Instances assume all warnings will be in the same LintCategory" was added.
So in summary, I replaced what was previously an assertion of an invariant with a new API requirement of that invariant (which, currently, is satisfied). Admittedly it was a close call - the benefit being the elimination of an instance field and constructor parameter.
But keeping the assertion is a more conservative approach so I'll do that instead. Updated in 87e44347f65.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23167#discussion_r1943267113
More information about the compiler-dev
mailing list