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

Archie Cobbs acobbs at openjdk.org
Mon Jun 23 13:50:29 UTC 2025


On Mon, 23 Jun 2025 09:52:58 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Can we save `Source` as an instance variable? I'm mildly worried about using the `context` instance field (which is used for lazy init of lint) more generally. (In fact, I was even thinking if it would make sense to have a `Supplier<Lint>` field that we create at construction, so that we don't have to save the `context` field at all.

I guess I don't understand the issue - isn't this kind of usage the whole point of having a `Context` singleton?

We can certainly grab the reference to `Source` eagerly (which means sometimes we would be grabbing it unnecessarily - i.e., any time there are no preview warnings) but beyond that I'm not sure what additional changes would buy us.

Put another way: what are you trying to optimize for with that question? How would `Supplier<Lint>` be better than a `Context` (plus `Lint.instance()`) which is the more standard way to achieve the same thing?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25810#discussion_r2161684795


More information about the compiler-dev mailing list