RFR: 8305007: Within-lambda subclass of local class using method param causes compiler crash

Vicente Romero vromero at openjdk.org
Mon Dec 18 23:44:00 UTC 2023


javac is crashing while compiling code like:


public abstract class CompilerCrashLambdaPlusLocalClass {
    public abstract void consume(Runnable r);

    public void doThing(String parameter) {
        class LocalClass {
            @Override
            public String toString() {
                return parameter;
            }
        }
        consume(() -> {
            class LambdaLocalClass extends LocalClass {}
            new LocalClass();
        });
    }
}

the reason for the issue is that the mappings for captured variables created by LambdaToMethod are not copying the `adr`, local address, field of the original VarSymbol it is mapping. Later on during code generation an assertion was being triggered due to a variable with an `adr < 0` this patch fixes this issue.

Thanks,
Vicente

-------------

Commit messages:
 - keeping address of original VarSymbol
 - Merge branch 'master' into JDK-8305007
 - 8305007: Within-lambda subclass of local class using method param causes compiler crash

Changes: https://git.openjdk.org/jdk/pull/17151/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17151&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8305007
  Stats: 48 lines in 2 files changed: 48 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/17151.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17151/head:pull/17151

PR: https://git.openjdk.org/jdk/pull/17151


More information about the compiler-dev mailing list