JVMS changes for JEP 401
Dan Smith
daniel.smith at oracle.com
Tue Feb 6 20:05:15 UTC 2024
> On Feb 6, 2024, at 11:17 AM, liangchenblue at gmail.com wrote:
>
> On a side note, does VM spec require all strict fields to be already assigned via putfield (i.e. no missing assignment, even ones with default zero values) before a super constructor call?
No. The JVM doesn't care how many assignments you make to a field; you just can't make assignments outside of an authorized context. (For final instance fields, "authorized context" = "<init> method of the same class"; for strict-final instance fields, "authorized context" = "<init> method of the same class, before a this/super call".)
> (This doesn't affect the correctness of strict fields, as unassigned fields will just have default zero values published)
Right.
We did explore applying these same concepts to null-restricted, non-implicitly-constructible fields, and in that case, it can be important for the JVM to prove that a field is written *at least once*, because there is no default value. But mandatory writes are not a capability we need for now.
More information about the valhalla-spec-experts
mailing list