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

sciwhiz12 duke at openjdk.org
Thu Apr 18 18:38:58 UTC 2024


On Sat, 23 Dec 2023 00:15:42 GMT, ExE Boss <duke at openjdk.org> wrote:

>> 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
>
> test/langtools/tools/javac/lambda/CompilerCrashLambdaPlusLocalClass.java line 43:
> 
>> 41:         consume(() -> {
>> 42:             class LambdaLocalClass extends LocalClass {}
>> 43:             new LocalClass();
> 
> Shouldn’t this construct a `LambdaLocalClass` instance instead?
> Suggestion:
> 
>             new LambdaLocalClass();

Constructing an instance of either `LocalClass` or `LambdaLocalClass` class triggers the issue, as described in the original issue report. (I was the one who wrote the issue report.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17151#discussion_r1435792707


More information about the compiler-dev mailing list