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

Archie Cobbs archie.cobbs at gmail.com
Sun Jul 14 20:14:11 UTC 2024


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>
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);
> >          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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20240714/bcf717e4/attachment-0001.htm>


More information about the amber-spec-experts mailing list