RFR: 8378607: GlyphLayout cache can prevent Fonts from being GC'd

Phil Race prr at openjdk.org
Sat Feb 28 23:01:29 UTC 2026


On Fri, 27 Feb 2026 13:11:10 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:

> I'm not sure about the thread safety of `cacheRef`. Is there a reason that it's not declared final and initialized immediately in the declaration? It's inside of `SDCache`, so it wouldn't be initialized unless needed anyway (nested static class lazy init).

It can't be final. Because if it is cleared it will need to be re-created.
If 2 threads happen to create the CacheRef and one is dropped it should not matter.
My understanding is that reference assignments are atomic so that should be OK too.
All pre-existing anyway.

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

PR Comment: https://git.openjdk.org/jdk/pull/29904#issuecomment-3978352359


More information about the client-libs-dev mailing list