<div dir="ltr"><div dir="ltr">On Thu, Feb 2, 2023 at 2:16 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

  
  <div>
    <font size="4"><font face="monospace">This can be amended to:<br>
        <br>
        An explicit constructor invocation statement introduces an
        _pre-initialization context_, which limits the use of constructs
        that refer to the current object.  Notably, the keywords `this`
        and `super` are prohibited in a pre-initialization context, as
        are unqualified references to instance variables and instance
        methods of lexically enclosing declarations.</font></font></div></blockquote><div><br></div><div>That might not work. For example, this source is legal (as it should be) and yet the 'this' keyword appears within the super() call:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">$ cat Outer.java <br>public class Outer {<br><br>    public int x;<br><br>    public Outer(int x) {<br>        this.x = x;<br>    }<br><br>    public class Inner extends Outer {<br>        public Inner() {<br>            super(Outer.this.x + 10);<br>        }<br>    }<br><br>    public static void main(String[] args) {<br>        System.out.println(new Outer(10).new Inner().x);<br>    }<br>}<br>$ java -cp classes Outer<br>20<br></span></div><div><br></div><div>What about something like this?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>An explicit constructor invocation statement introduces a <i>pre-initialization context</i>, which includes the prologue of the constructor and the explicit constructor invocation statement, and which prohibits the use of constructs that refer explicitly or implicitly to the current object. These include <span style="font-family:monospace">this</span> or <span style="font-family:monospace">super</span> referring to the current object, unqualified references to instance variables or instance methods of the current object, method references referring to instance methods of the current object, and instantiations of inner classes of the current object's class for which the current object is the enclosing instance (§8.1.3).</div></blockquote></div><div><br></div><div>-Archie</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>