JDK-8300786 - No longer require super() and this() to appear first in a constructor

Archie Cobbs archie.cobbs at gmail.com
Tue Feb 7 22:48:15 UTC 2023


On Tue, Feb 7, 2023 at 4:21 PM Brian Goetz <brian.goetz at oracle.com> wrote:

> I think the approach is right, the specific list of stuff might need to be
> reviewed more carefully (specifically, I've not thought through the
> connection with inner classes, which we've now opened the door to.)  Let's
> call it a placeholder and we'll make sure to review it more carefully after
> you've worked through the implementation and caught any obvious gaps?
>

Thanks - that sounds like a plan.

FWIW in the JEP I've raised the importance of fixing this bug in the spec
<https://bugs.openjdk.org/browse/JDK-8301649> (i.e., that constructor
invocation is not really a "static context" but truly something different -
what we're calling a "pre-initialization context") and made it one of the
"goals" of the JEP, because the gulf between the spec on one hand and the
compiler's current behavior (and what everyone has actually been doing for
the past decade) on the other hand is pretty glaring.

Regarding the prototype implementation
<https://github.com/archiecobbs/jdk/tree/SuperInit>, it's complete and
seems to be working. One nice surprise is that, because the compiler
already effectively implements this notion of "pre-initialization context"
within superclass constructors, the changes required are relatively
limited, in some cases, just ensuring the appropriate error message is
generated.

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20230207/3dd758f4/attachment.htm>


More information about the amber-spec-experts mailing list