RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v4]
Mandy Chung
mchung at openjdk.org
Fri Jun 2 02:12:30 UTC 2023
On Fri, 2 Jun 2023 01:19:26 GMT, Chen Liang <liach at openjdk.org> wrote:
> In addition, should we initialize the ref class or the declaring class only? I don't think we need to initialize the ref class when declaring class initialization should be sufficient, but that is a change in behavior.
Declaring class will be initialized [1].
refc should be equals to the declaring class because the static field to be looked up can only be found in the declaring class. There should be no behavioral change.
[1] https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#findStaticVarHandle(java.lang.Class,java.lang.String,java.lang.Class)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13821#issuecomment-1573031355
More information about the core-libs-dev
mailing list