eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Flexible constructors] Incorrect diagnostic: The final field x may already have been assigned
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
I am not claiming snippets like below are _realistic_, but it does reveal _real_ problem in flow analysis for flexible constructors:
The following program is rejected by 4.40, 4.41 M2 and master/HEAD with 2 errors of the form `The final field x may already have been assigned` while javac compiles them correctly. See that there are no other assignments to `x` and `z` in the program, so these messages are plain wrong:
```
public final class X {
final int x; // 1
final int y; // 2
final int z; // 4
{
x = 10;
z = y;
}
X() {
int xx = 123; // 8
if (true)
throw new RuntimeException();
super();
}
X(int a) {
this.y = 10;
if (true)
throw new RuntimeException();
super();
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.