2

I am Trying to use records preview-feature with cannonical constructors in Eclipse .

public class Example {
    public static void main(String[] args) {
        record Range() {
            Range {
            }
        }
        new Range();
    }
}

However, at run time a verify error is caused.

Exception in thread "main" java.lang.VerifyError: Constructor must call super() or this() before return Exception Details: Location: Example$1Range.(II)V @36: return Reason: Error exists in the bytecode Bytecode: 0000000: 1b1c a400 22bb 000b 5912 0d05 bd00 0f59 0000010: 031b b800 1153 5904 1cb8 0011 53b8 0017 0000020: b700 1dbf b1 Stackmap Table: same_frame(@36)

at Example.main(Example.java:10)

This happens both in eclipse 2020-06 with JDK 14 and eclipse 2020-19 with JDK 15.0.1 and eclipse 15 support.

There is no problem running it from the command line with bin\java and no error is thrown then.

Is this working for anyone else on their eclipse? Are there any workarounds?

Naman
  • 27,789
  • 26
  • 218
  • 353
Gonen I
  • 5,576
  • 1
  • 29
  • 60

0 Answers0