eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
166 stars 131 forks source link

[23] VerifyError when instantiating a local class inside a flexible constructor #3115

Open jarthana opened 1 month ago

jarthana commented 1 month ago

Compiling and running the below class throws a verify error:

public class X {
    public static void main(String argv[]) {
        X test = new X();
    }
    X() {
        class InnerLocal {}
        java.util.function.IntSupplier foo = () -> {
            new InnerLocal() {}; // This is trouble
            return 0;
        };
        super();
    }
}

And the error is:

Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    X.<init>()V @1: invokedynamic
  Reason:
    Type uninitializedThis (current frame, stack[0]) is not assignable to 'X'
  Current Frame:
    bci: @1
    flags: { flagThisUninit }
    locals: { uninitializedThis }
    stack: { uninitializedThis }
  Bytecode:
    0000000: 2aba 0012 0000 4c2a b700 16b1     
srikanth-sankaran commented 1 month ago

@stephan-herrmann - Thanks for taking a look