RFR: 8350118: Simplify the layout access VarHandle [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Feb 24 11:31:01 UTC 2025


On Fri, 21 Feb 2025 22:12:43 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/Utils.java line 120:
>> 
>>> 118:      * with a {@link ValueLayout#varHandle()} call is cached inside a stable field of the value layout implementation.
>>> 119:      * This optimizes common code idioms like {@code JAVA_INT.varHandle().getInt(...)}. A second layer of caching
>>> 120:      * is then provided by this method, so different value layouts with same effects can reuse var handle instances.
>> 
>> I believe this comment is now out of sync? (It talks about two levels of caching --- but there's only one now)
>
> The first level is right, it is the instance field AbstractValueLayout.handle. The static final CHM over there was not mentioned and is now removed

I've re-read this, and I see how `cached inside a stable field` doesn't really imply use of map or something else. So yes, this text is still ok.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23720#discussion_r1967464555


More information about the build-dev mailing list