RFR: 8356255: Add Stable Field Updaters to allow efficient lazy field evaluations

Chen Liang liach at openjdk.org
Tue May 6 11:48:14 UTC 2025


On Mon, 5 May 2025 13:41:22 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This sketch shows how "Stable Updaters" can be used to create stable computations of `@Stable` fields. Only one updater is needed per class, similar to `AtomicIntegerFieldUpdater`.

Changes requested by liach (Reviewer).

src/java.base/share/classes/java/lang/reflect/Method.java line 101:

> 99: 
> 100:     private static final ToIntFunction<Method> HASH_UPDATER =
> 101:             StableFieldUpdater.ofIntRaw(Method.class, Unsafe.getUnsafe().objectFieldOffset(Method.class, "hash"), new ToIntFunction<Method>() {

If we are using unsafe to get field offsets, why don't we just accept arguments to locate a MethodHandle (like those arguments to MhUtils)?

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

PR Review: https://git.openjdk.org/jdk/pull/25040#pullrequestreview-2815145097
PR Review Comment: https://git.openjdk.org/jdk/pull/25040#discussion_r2073631615


More information about the net-dev mailing list