Draft Spec for Second Preview of Flexible Constructor Bodies (JEP 482)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Jun 11 14:05:03 UTC 2024
On 11/06/2024 13:37, Stephan Herrmann wrote:
> Am 10.06.24 um 19:10 schrieb Maurizio Cimadamore:
>> On 10/06/2024 17:32, Archie Cobbs wrote:
>>
>>> On Mon, Jun 10, 2024 at 4:24 AM Maurizio Cimadamore [...]
>>> Historically, the JLS used to treat this/super calls as a static
>>> context
>>> (8.8.7.1).
>>>
>>>
>>> That's what the JLS said, but of course that's not what the compiler
>>> ever implemented (JDK-8301649).
>>
>> Sure. What about ecj? What did that compiler implement? (This is more
>> a question for Stephan).
>
> A quick sample shows that flags insideConstructorCall and
> insideStaticContext differ only in what exact error message ecj gives.
> So, generally ecj does implement that rule. Relevant code sections go
> back to some time around 2003. I see no reason to consider that rule
> as a failure.
So, to be clear, the Eclipse compiler rejects stuff like the one we’ve
been discussing - e.g.
|class Outer int x; class Inner extends Foo { Inner() { super(new Bar()
{ { Outer.this.x++; } // allowed??? }); } } } |
Correct?
>
>
>> What I’m trying to say is that “because javac does it” is not always
>> a good reason for doing something.
>
> I couldn't agree more :)
>
>
> Am 10.06.24 um 11:24 schrieb Maurizio Cimadamore:
> > So, for this particular JEP, I think there's a choice in front of us:
> >
> > * do we keep JLS as is (and fix javac to do what the spec has always
> said the
> > behavior was) ?
> > * or, do we keep javac as is and then tweak the JLS to model what the
> > implemented behavior is?
>
> Which state of JLS are you referring to? Current stable version?
> Version as of JEP 447, latest draft for JEP 482? If stable version,
> how should early-construction context be integrated in your opinion?
I’m referring to JEP 482.
Maurizio
>
> regards,
> Stephan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20240611/5cc182b2/attachment-0001.htm>
More information about the amber-spec-experts
mailing list