eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Flexible constructors] VerifyError: Bad type on operand stack
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
On 4.40, 4.41 M2 and master/HEAD the following program compiled by ECJ fails to pass verification:
```
public class X {
String field = "initialized";
{ // Instance initializer block
System.out.println(field);
field = "modified";
}
// First constructor with unreachable super() call
X() {
if (true) throw new RuntimeException();
super(); // unreachable
}
// Second constructor that can reach the field initializer
X(int x) {
System.out.println(field); // uses the field
}
public static void main(String[] args) {
new X(1);
}
}
```
When run, we get:
```
Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
X.()V @18: getfield
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'X'
Current Frame:
bci: @18
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { 'java/io/PrintStream', uninitializedThis }
Bytecode:
0000000: bb00 0a59 b700 0cbf 2a12 0eb5 0010 b200
0000010: 122a b400 10b6 0018 2a12 1eb5 0010 b1
Stackmap Table:
same_frame(@8)
```
Contributor guide
Assessment
This issue has not been assessed yet.