Draft Spec for Second Preview of Flexible Constructor Bodies (JEP 482)

Stephan Herrmann stephan.herrmann at berlin.de
Sun Jul 14 20:25:07 UTC 2024


This answers my other post
   "Field assignment in early construction context - details"
right? :)

Am 14.07.24 um 22:14 schrieb Archie Cobbs:
> I think you are correct in that the spec needs further clarification on those 
> two points.
> 
> I can at least confirm that what the compiler currently implements is in fact 
> the intended behavior:
> 
>   * Access to superclass instance fields by any means in an early construction
>     context is not allowed
>   * The rules for "foo", "this.foo", and "C.this.foo" (for the same "foo") in an
>     early construction context should be the same
> 
> -Archie
> 
> 
> On Sun, Jul 14, 2024 at 2:50 PM Stephan Herrmann <stephan.herrmann at berlin.de 
> <mailto:stephan.herrmann at berlin.de>> wrote:
> 
>     This part doesn't look fully resolved to me:
> 
>     Am 28.05.24 um 19:20 schrieb Stephan Herrmann:
>      > [...] > In §8.8.7.1 it says:
>      >      "References to instance variables of class C are disallowed ..."
>      > which seems to disqualify the following code:
>      >
>      > public class C {
>      >      String name;
>      >      C(C other) {
>      >          System.out.println(other.name <http://other.name>);
>      >          super();
>      >      }
>      > }
>      >
>      > I assume this paragraph in italics is not normative, right? Later
>     paragraphs are
>      > clear that this applies to single name references and this references,
>     but still
>      > the above sentence seems misleading. The same applies for the next two
>     sentences
>      > (regarding other.foo(), or new other.Inner()).
>      > [...]
> 
> 
>     While the detailed rules in 15.12.3 look good, the explanation in 8.8.7.1 still
>     lacks precision. If that explanation is not meant to be precise, maybe it
>     should
>     indicate this :)
> 
>     The same problem also exists in the summary in 6.5.7.1 (which is not italics -
>     explanatory):
> 
>     "The rules (15.12.3) also prohibit a reference to an instance method occurring
>     in any one of the following:
>     ...
>     3. an early construction context (8.8.7.1) of a class where the instance method
>     is a member."
> 
> 
>     Interestingly, 6.5.7.1 is more precise regarding qualified this expressions
>     than
>     what §15.8.4 says about it (see my previous post).
> 
>     thanks,
>     Stephan
> 
> 
> 
> -- 
> Archie L. Cobbs



More information about the amber-spec-experts mailing list