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

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jun 11 17:15:32 UTC 2024


Ok, I hve replied my own question. The change in behavior in ecj seems 
to be triggered by -source 22. If no -source option is passed, the 
program will NOT compile.

Maurizio

On 11/06/2024 18:10, Maurizio Cimadamore wrote:
>
> On 11/06/2024 17:17, Stephan Herrmann wrote:
>
>> 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. 
>
> Ok. I tried this example:
>
> |$ cat Foo.java class Test { interface Bar { } static class Foo { 
> Foo(Bar bar) { } } int x; class Inner extends Foo { Inner() { 
> super(new Bar() { { Test.this.x++; } // allowed??? }); } } } |
> |java -jar 
> org.eclipse.jdt.core.compiler.batch_3.38.0.v20240524-2033.jar Foo.java 
> ---------- 1. ERROR in /w/lt/jdk/dev/Foo.java (at line 11) { 
> Test.this.x++; } // allowed??? ^^^^^^^^^ No enclosing instance of the 
> type Test is accessible in scope ---------- 1 problem (1 error) |
>
> This seems to suggest that the “outside JLS” behavior is not supported 
> by ecj?
>
> Maurizio
>
>-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20240611/9c00a278/attachment.htm>


More information about the amber-spec-experts mailing list