Draft Spec for Second Preview of Flexible Constructor Bodies (JEP 482)
Stephan Herrmann
stephan.herrmann at berlin.de
Tue Jun 11 16:17:32 UTC 2024
Am 11.06.24 um 16:05 schrieb Maurizio Cimadamore:
> 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?
I'm sorry, I didn't look at the specific complications. This particular one is
wrongly accepted also by ecj. IOW there is some confusion indeed regarding how
far the "staticness" propagates into nested structures.
Stephan
More information about the amber-spec-experts
mailing list