eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[TWR] ECJ generated code fails to close resources used in try
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
This program when compiled with javac prints
```
Resource is closed
finally
```
whilke with ECJ 4.30 and on master/HEAD just prints `finally`
On 4.25, ECJ crashes with symptoms similar to https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3258
```
public class X implements AutoCloseable {
public void close() throws Exception {
System.out.println("Resource is closed");
}
public static void foo(String[] args) {
for (String arg : args) {
try (X x = new X()) {
if (args.length == 1) {
System.out.println("Broken!");
break;
} else {
throw new Exception("Checking if resource is closed");
}
} finally {
System.out.println("finally");
break;
}
}
}
public static void main(String[] args) {
foo(new String[] { "Hello", "World" });
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.