eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[flexible-constructors] java.lang.VerifyError: Constructor must call super() or this() before return

Open
#5,396 0 comments 0 reactions 1 assignee Claimed by @srikanth-sankaran View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

From https://github.com/eclipse-jdt/eclipse.jdt.core/pull/5383#issuecomment-5608408274:

We don't handle the program from the comment above (shared below) correctly:

- On 4.40 GA and 4.41 M2 and on master/HEAD the generated class crashed with:

```
Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Constructor must call super() or this() before return
Exception Details:
Location:
X.()V @14: return
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb00 0a59 b700 0cbf 2a12 0eb5 0010 b1
Stackmap Table:
same_frame(@8)
```

Test case:

```
public class X {
String s = "good";
X() {
if (true) throw new RuntimeException();
super();
}
X (int i) {
System.out.println(s);
}
public static void main(String[] args) {
new X(1);
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.