RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]
Mandy Chung
mchung at openjdk.org
Fri Jun 2 17:19:07 UTC 2023
On Fri, 2 Jun 2023 02:37:13 GMT, Chen Liang <liach at openjdk.org> wrote:
> I think we only need to initialize Parent without initializing Child in this case.
The bytecode behavior to access the field via `lookup.findStaticVarHandle(Child.class, "value", int[].class)` is `Child.value;`. The class or interface that declared the resolved field is initialized per JVMS `getStatic` and `putStatic`. So I think `Parent` is initialized but not `Child`. @PaulSandoz can confirm.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13821#issuecomment-1574063904
More information about the core-libs-dev
mailing list