On Wed, 7 Jan 2026 13:17:22 GMT, Maurizio Cimadamore <[email protected]> wrote:
> [This PR](https://git.openjdk.org/jdk/pull/22553) introduced a new diagnostic > info line to allow warning keys to be associated with a lint category. For > instance: > > > # lint: identity > compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class=\ > attempt to synchronize on an instance of a value-based class > > > Is parsed at build time, and result in the following field to be added to the > `CompilerProperties` class: > > > /** > * "attempt.to.synchronize.on.instance.of.value.based.class" > */ > public static final LintWarning > AttemptToSynchronizeOnInstanceOfValueBasedClass = new > LintWarning(EnumSet.noneOf(DiagnosticFlag.class), > LintCategory.get("identity").get(), "compiler", > "attempt.to.synchronize.on.instance.of.value.based.class"); > > > Note that the lint category undergoes a dynamic lookup: > > > LintCategory.get("identity").get() > > > This means that if there's a typo in the compiler.properties file, the lookup > will fail and the JDK build will fail in a very obscure way (see JBS for > reference). To avoid this problem, this PR removes the dynamic lookup from > the generated file -- that is, the code in `CompilerProperties` will be: > > > /** > * "attempt.to.synchronize.on.instance.of.value.based.class" > */ > public static final LintWarning > AttemptToSynchronizeOnInstanceOfValueBasedClass = new > LintWarning(EnumSet.noneOf(DiagnosticFlag.class), LintCategory.IDENTITY, > "compiler", "attempt.to.synchronize.on.instance.of.value.based.class"); > > > That is, the lint category string in `compiler.properties` is turned into a > field name, first by capitalizing all the chars, then by replacing `-` with > `_`. This ensures that if a lint category is mispelled in > `compiler.prooprties`, the resulting generated code will fail to compile. > > The small price we have to pay for this is that we need to make sure that the > naming of the lint category enum fields are consistent -- to this end the > lint field `RAW` had to be renamed to `RAWTYPES`. But that was the only > exception to the unwritten rule. I have also added a comment to capture this > rule. Looks good to me, thanks! ------------- Marked as reviewed by jlahoda (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/29090#pullrequestreview-3634945680
