eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
164 stars 130 forks source link

[23] VerifyError during conversion between T extends Short and short #2937

Closed jarthana closed 1 month ago

jarthana commented 1 month ago

Here's the affected testcase, which is a slightly modified version from #2936 :

record Record<T extends Short>(T t) {}
public class X {
    public static <T extends Short> short foo(Record<T> s) {
        return switch (s) {
            case Record(short s1) -> s1;
            default -> 0;
        };
    }
    public static void main(String[] args) {}
}

Running this with the latest from BETA_JAVA23 crashes with the following:

Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Inconsistent stackmap frames at branch target 62
Exception Details:
  Location:
    X.foo(LRecord;)S @52: goto
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @52
    flags: { }
    locals: { 'Record', 'Record', integer }
    stack: { }
  Stackmap Frame:
    bci: @62
    flags: { }
    locals: { 'Record', 'Record', integer }
    stack: { 'java/lang/Short' }
stephan-herrmann commented 1 month ago

Resolved by #2958