Forward references in initializers

Brian Goetz brian.goetz at oracle.com
Mon Nov 11 12:54:12 UTC 2024


I will reiterate my point that I think changing these rules is something that is more amenable to a strict class, then to a subset of the fields being strict. I continue to think that we are missing an abstraction here.

Sent from my iPad

On Nov 11, 2024, at 7:06 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:



I agree with this conclusion.

The main point here is that whether strict fields are initialized before/after a super call is a very low-level detail that we'd like most developers to happily ignore. But if the distinction surfaces up at the level of DA/DU and field assignment, this is no longer strictly true, and it is possible that some developers might be puzzled as a result, and have to dig much deeper than they'd comfortable with to find exactly why that is the case. Preserving the illusion that all fields are created equal seems kind of nice, even though it is still an illusion.

Maurizio


On 08/11/2024 19:59, Dan Smith wrote:

Conclusion: I think I'm happy with a DA/DU analysis that treats
initializers as if they run in left-to-right order, before the start of
the constructor. It's not really true, but it detects the errors we need
 to detect with less complexity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-experts/attachments/20241111/e2e18192/attachment.htm>


More information about the valhalla-spec-experts mailing list