known translation issues related to JEP 482

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Jun 20 17:03:58 UTC 2024


On 20/06/2024 17:43, Archie Cobbs wrote:
> On Thu, Jun 20, 2024 at 10:16 AM Maurizio Cimadamore 
> <maurizio.cimadamore at oracle.com> wrote:
>
>     The crucial observation here is that there can be /multiple/ valid
>     enclosing instances, and the innermost one might not be available
>     due to early construction context, so we need to be able to skip
>     that, and jump to the next
>
> Hah, that's a new one for me... :)
>
> Just curious, your comment "the JLS text for member inner class 
> creation seems lacking" makes me wonder if this obscure corner already 
> existed (i.e., before "flexible constructors") with the anonymous 
> class equivalent:
> |class Outer2 {     Outer2() {     }     Outer2(Object obj) {     }   
>   class InnerSuperclass {         { System.out.println(Outer2.this); } 
>     }     static class InnerOuter extends Outer2 {         class 
> InnerInnerOuter extends Outer2 {             InnerInnerOuter() {       
>           super(new InnerSuperclass() { });             }         }   
>   }     public static void main(String[] args) {         new 
> InnerOuter().new InnerInnerOuter(); // prints 
> "Outer2$InnerOuter at 327471b5"     } } |
> That program doesn't compile now but by the same argument maybe it 
> should - or at least the same ambiguity already exists?
The issues are pre-existing, although, w/o JEP 482, the anon 
InnerSuperClass would be created in a static context, so it kind of 
follows that there's no enclosing instance available there.
>
>     I think that this fix, coupled with the translation fixes I shared
>     last week should implement JEP 482 “as intended”
>
> Awesome, thanks for tackling this! Fyi, I've merged this patch into my 
> javac-pre-capture-fixes 
> <https://urldefense.com/v3/__https://github.com/openjdk/jdk/compare/master...archiecobbs:jdk:javac-pre-capture-fixes?expand=1__;!!ACWV5N9M2RV99hQ!LNS_Z7ARnFzONoErnZklxoEZgNNqB6Z94YH73CC6lr9bNGs2ity2KjdM20yZjTgLM7aJTjO6MNMN0sLbdJaN4ojJJcfNUQ$> 
> branch (already includes your lambda refactoring).

Let me know if that fixes all the issue we're seeing (it would be great 
if we could collect all test cases in some github repo, so that we can 
add to them easily).

Maurizio

>
> -Archie
>
> -- 
> Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240620/aefd010c/attachment-0001.htm>


More information about the amber-dev mailing list