RFR: 8291065: Creating a VarHandle for a static field triggers class initialization
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri May 5 13:15:19 UTC 2023
On Fri, 5 May 2023 13:08:33 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Also, perhaps @PaulSandoz knows more history on this one (I believe this code predates FFM).
>
> Eh? I am not sure what you mean here. This is the essence of the patch, where the "TODO" above is fixed: lookup.findStaticVarHandle now creates lazy varhandle if the defining class of the field is not initialized.
>
> The fixing of IndirectVarHandle.isAccessModeSupported is a side effect, because the override of `getMethodHandle` in `IndirectVarHandle` appears to me as a no-op; turns out it exists due to NPE in isAccessModeSupported, which IMO should be fixed as it's a public API.
> This seems unrelated to the issue this PR is really about (if I understand correctly). Would it make sense to address this as part of another PR?
Actually I realize I was confused as I came to this PR looking at this: https://bugs.openjdk.org/browse/JDK-8307508
And not realizing that this PR is about initialization (and, as a side-fix, it also addresses the access mode issue). I will leave to you whether to split or not.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1186077002
More information about the core-libs-dev
mailing list