-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suspect code generation for "try-with-resource" functionality #934
Comments
Thanks @SwathiKalahastri for raising this |
The segment
in ECJ generated code look suspect. JLS 20 gives this translation scheme: 14.20.3.1 ... The meaning of a basic try-with-resources statement of the form:
is given by by the following translation to a local variable declaration and a try-catchfinally
There is no provision for the comparison and jump in this scheme. I wonder if draft JLS7 wording somehow suggested this. |
PR here: #1033 |
This seem to cause a massive amount of regressions in our internal (Advantest) tests. The code that uses "try with resources" (or wrapped into such try block) now fails in many cases reporting
in places where we never call We don't see the problem with I will try to create a standalone reproducer. |
Turns out, it is trivial:
Executed with ecj from master it throws
With commit 2bac9e4 reverted, it prints what is expected to print:
@srikanth-sankaran : this must be fixed or 2bac9e4 reverted before M3 which is this Thursday. |
Thanks for the reduced test case. I will get on this right away. |
Related issues: - redhat-developer/vscode-java#3138 - eclipse-jdt/eclipse.jdt.core#934 Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
Related issues: - redhat-developer/vscode-java#3138 - eclipse-jdt/eclipse.jdt.core#934 Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
@srikanth-sankaran : anything here to do, or why this issue is still opened? |
The original problem reported by SwathiKalahastri is still there on master. My attempted solution was reverted due to a regression and I haven't had an opportunity to revisit yet. |
Ah, I remember now, I've removed 4.29 milestone now. |
Generated java class and its output is different using eclipse with traditional Java
As per specification, In Throwable.addSuppressed() method, if exception is this throwable; a throwable cannot suppress itself in such scenario it should throw java.lang.IllegalArgumentException but the result is varies with using eclipse compiler.
https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#addSuppressed-java.lang.Throwable-
Output using regular java (with java 7 version & above)
Output from eclipse
The bytecode of class generated by eclipse vs regular javac
Using eclipse compiler
Using Traditional java compiler
I am not sure it might be the reason, I could see generated “Exception table” in java class with eclipse compiler is different from java class generated by the traditional java compiler.
The text was updated successfully, but these errors were encountered: