New JEP: Strict Field Initialization in the JVM
Dan Smith
daniel.smith at oracle.com
Wed Mar 5 02:01:54 UTC 2025
As we've worked through the details of strictly-initialized fields, it has made sense to spin the feature off into its own JVM-only preview feature JEP:
https://openjdk.org/jeps/8350458
The Value Classes and Objects JEP will depend on Strict Field Initialization in the JVM.
The JEP covers all uses of ACC_STRICT: final and non-final, static and non-static. We've worked to unify these under a cohesive model, where all strict field initialization happens within a *larval initialization state*. Static field initialization rules are enforced dynamically, while instance field initialization rules are enforced by verification.
A few months ago, the EG discussed the idea that, if we require all fields to be set in a basic block immediately before the 'super()' call, the verifier could enforce the initialization requirements without any changes to StackMapTable. We seriously considered that idea, but concluded that it was worthwhile to enhance StackMapTable to be able to express intermediate initialization states. So this JEP includes the 'assert_unset_fields' entry we discussed previously.
This is a draft, feedback is welcome!
More information about the valhalla-spec-experts
mailing list