RFR: 6983726: Reimplement MethodHandleProxies.asInterfaceInstance [v16]

Rémi Forax forax at openjdk.org
Mon May 8 14:12:37 UTC 2023


On Mon, 8 May 2023 10:46:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java line 342:
>> 
>>> 340: 
>>> 341:             // individual handle fields
>>> 342:             clb.withField(ORIGINAL_TARGET_NAME, CD_MethodHandle, ACC_PRIVATE | ACC_FINAL);
>> 
>> Would a @Stable field help here? E.g if the returned functional interface instance is stored in a `static final` field, it should enable better performance?
>
> (actually, not sure - as the class is saved in a class value cache, so probably adding stable won't make any difference).

The class is loaded as a hidden class, so all final fields are truly final (unlike classes but like records), so @Stable is not needed.

The class value cache only change performance if the cache was used in a hot path. And currently a class value cache is not considered as a cache by the JIT, i.e. the JIT does not know that if the key is a constant, the value is a constant.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13197#discussion_r1187495168


More information about the core-libs-dev mailing list