RFR: 8376477: Avoid loading empty Lock classes in Shutdown and ReferenceQueue

Aleksey Shipilev shade at openjdk.org
Tue Jan 27 17:26:35 UTC 2026


On Tue, 27 Jan 2026 10:01:34 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this PR which removes empty nested `Lock` classes in `java.lang.Shutdown` and `java.lang.ref.ReferenceQueue`. 
> 
> These are replaced with the more common "new Object()" idiom, which saves us loading these two nested classes.
> 
> Additionally, this PR marks the lock objects in `Shutdown` as `final`
> 
> This was initially discussed in https://mail.openjdk.org/pipermail/core-libs-dev/2026-January/157704.html.
> 
> Except the observability of the lock name class, this should be a strict refactoring. No tests updated, `noreg-cleanup`.

This looks fine in principle, and dealing with papercut issues like these does add up to improvements eventually.

There is an observability loss, though. I would have suspected it is marginal. But even GHA catches fire in `serviceability/sa/ClhsdbInspect` looking for now-missing named lock. So run more tests and see what else might be depending on it?

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

PR Review: https://git.openjdk.org/jdk/pull/29442#pullrequestreview-3712511229


More information about the core-libs-dev mailing list