hg: amber/amber: allow statements before this, super in a constructor
Brian Goetz
brian.goetz at oracle.com
Sun Jan 7 16:37:08 UTC 2018
Further detail: we can treat `this` as DU before the super call and DA
after. So the code before the super can't call instance methods (but
can call static methods), and can't access instance fields (though we
apply the same name resolution rules.)
On 1/7/2018 11:21 AM, Tagir Valeev wrote:
> This would be very helpful for IDE refactorings as well! Every time we
> need to extract a statement from an expression, being inside
> this/super is always annoying corner case. Even field initializer is
> better as we can move it first to the initializer section. Thanks!
>
> Tagir Valeev.
>
> 7 янв. 2018 г. 23:11 пользователь "Brian Goetz"
> <brian.goetz at oracle.com <mailto:brian.goetz at oracle.com>> написал:
>
> Yes, this is something people have wanted for a long time. There
> were a number of historical impediments to getting there, having
> to do with verification (verifying that the super <init> is called
> exactly once is one of the nastiest bits of the verifier.) A
> number of verifier issues were addressed over the years, that
> enabled us to eventually get here.
>
> And yes, this interacts nicely with records. I'll write up the
> details soon.
>
> On 1/7/2018 7:09 AM, Remi Forax wrote:
>
> Very cool,
> always wanted to do that in Java,
> i suppose it's a preparation for the 'default' call in
> constructor.
>
> Rémi
>
> ----- Mail original -----
>
> De: "Vicente Romero" <vicente.romero at oracle.com
> <mailto:vicente.romero at oracle.com>>
> À: "amber-dev" <amber-dev at openjdk.java.net
> <mailto:amber-dev at openjdk.java.net>>
> Envoyé: Dimanche 7 Janvier 2018 03:48:25
> Objet: hg: amber/amber: allow statements before this,
> super in a constructor
> Changeset: 35b9d7ffcd88
> Author: vromero
> Date: 2018-01-06 21:42 -0500
> URL:
> http://hg.openjdk.java.net/amber/amber/rev/35b9d7ffcd88
> <http://hg.openjdk.java.net/amber/amber/rev/35b9d7ffcd88>
>
> allow statements before this, super in a constructor
>
> !
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
> !
> src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> -
> test/langtools/tools/javac/diags/examples/CallMustBeFirst.java
> + test/langtools/tools/javac/diags/examples/OnlyOneSuper.java
>
>
More information about the amber-dev
mailing list