RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]
Paul Sandoz
psandoz at openjdk.org
Wed Jun 28 19:22:05 UTC 2023
On Wed, 28 Jun 2023 00:08:35 GMT, Chen Liang <liach at openjdk.org> wrote:
>> The MH on VH case is worth considering; the indirect VH cases are already covered by `-Djava.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT=true`.
>
> Done; added a test case to test initialization on toMethodHandle use in latest push, passed locally.
Ok. I just realized you could also run using the system property `java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS` to disables the guards, and it will go through the MH invokers, achieving the same thing. Up to you if you want to keep the current test or use the system property.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1245661478
More information about the core-libs-dev
mailing list