RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v8]

Chen Liang liach at openjdk.org
Sun Jun 4 21:19:06 UTC 2023


On Sun, 4 Jun 2023 16:12:46 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Improve subsequent VH call performance, thanks exeboss
>
> src/java.base/share/classes/java/lang/invoke/LazyInitializingVarHandle.java line 125:
> 
>> 123:                 cache[i] = callTarget;
>> 124:             }
>> 125:         }
> 
> Unlike calling `Unsafe::ensureClassInitialized(…)` (which performs its own synchronisation) or writing `true` to `this.initialized` (which is a benign race), updating the lambda forms this way is probably not quite correct to do under a race and probably needs some synchronisation.

The form update is a benign race. The array update might need some fences, but I'm not sure, as the read MH should be complete when the updated value is already observed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1217150854


More information about the core-libs-dev mailing list