RFR: 8360884: Better scoped values

Andrew Haley aph at openjdk.org
Fri Jun 27 15:37:07 UTC 2025


On Fri, 27 Jun 2025 15:12:57 GMT, Chen Liang <liach at openjdk.org> wrote:

> I looked at the existing code: the reason ScopedValue creation requires getProperty in Cache is that `generateKey` uses `Cache.primarySlot(x)` and `Cache.secondarySlot(x)`. Why did you choose to factor out `getProperty` into a new class instead of adding `primaryIndex` and `secondaryIndex` to the root `ScopedValue` to avoid early initialization of `Cache`?

Mmm, you mean set things up so that `newInstance()` does not use `class Cache` at all? That would certainly have been possible, but it seems a bit artificial, and perhaps rather fragile. It's more explicit to put the things that need late initialization into a separate lazy holder class. But I'm not rigid about that, if people strongly object.

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

PR Comment: https://git.openjdk.org/jdk/pull/26019#issuecomment-3013478608


More information about the core-libs-dev mailing list