known translation issues related to JEP 482

Archie Cobbs archie.cobbs at gmail.com
Thu Jun 20 16:43:46 UTC 2024


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?

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://github.com/openjdk/jdk/compare/master...archiecobbs:jdk:javac-pre-capture-fixes?expand=1>
branch (already includes your lambda refactoring).

-Archie

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


More information about the amber-dev mailing list