Comments (9)
Thanks @SwathiKalahastri for raising this
from eclipse.jdt.core.
The segment
49: aload_2
50: aload_3
51: if_acmpeq 59
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:
try ({VariableModifier} R Identifier = Expression ...)
Block
is given by by the following translation to a local variable declaration and a try-catchfinally
statement:
{
final {VariableModifierNoFinal} R Identifier = Expression;
Throwable #primaryExc = null;
try ResourceSpecification_tail
Block
catch (Throwable #t) {
#primaryExc = #t;
throw #t;
} finally {
if (Identifier != null) {
if (#primaryExc != null) {
try {
Identifier.close();
} catch (Throwable #suppressedExc) {
#primaryExc.addSuppressed(#suppressedExc);
}
} else {
Identifier.close();
}
}
}
}
There is no provision for the comparison and jump in this scheme. I wonder if draft JLS7 wording somehow suggested this.
from eclipse.jdt.core.
PR here: #1033
from eclipse.jdt.core.
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
java.lang.IllegalArgumentException: Self-suppression not permitted at java.base/java.lang.Throwable.addSuppressed(Throwable.java:1072) at
in places where we never call Throwable.addSuppressed()
.
We don't see the problem with I20230504-1800
and we see it with I20230511-1800
.
PR #1033 seem to be the best candidate.
I will try to create a standalone reproducer.
from eclipse.jdt.core.
I will try to create a standalone reproducer.
Turns out, it is trivial:
import java.io.Closeable;
import java.io.IOException;
public class X {
public static void main(String[] args) throws IOException {
try (DummyClosable closable = new DummyClosable()) {
throw new IOException("OMG!!!");
} catch (IOException e) {
throw e;
}
}
static class DummyClosable implements Closeable {
@Override
public void close() throws IOException {
System.out.println("Closed!");
}
}
}
Executed with ecj from master it throws IllegalArgumentException
:
Closed!
Exception in thread "main" java.lang.IllegalArgumentException: Self-suppression not permitted
at java.base/java.lang.Throwable.addSuppressed(Throwable.java:1072)
at X.main(X.java:8)
Caused by: java.io.IOException: OMG!!!
at X.main(X.java:7)
With commit 2bac9e4 reverted, it prints what is expected to print:
Closed!
Exception in thread "main" java.io.IOException: OMG!!!
at X.main(X.java:7)
@srikanth-sankaran : this must be fixed or 2bac9e4 reverted before M3 which is this Thursday.
from eclipse.jdt.core.
Thanks for the reduced test case. I will get on this right away.
from eclipse.jdt.core.
@srikanth-sankaran : anything here to do, or why this issue is still opened?
from eclipse.jdt.core.
@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.
from eclipse.jdt.core.
Ah, I remember now, I've removed 4.29 milestone now.
from eclipse.jdt.core.
Related Issues (20)
- [23] JSR 398
- Building with xml and errors with UTF-8
- Types solely referenced from Javadoc reported as unused imports
- [feat] Add support for polymorphic external null annotations
- Bug 575822 - FR: Add support for polymorphic external null annotations HOT 1
- BindingKeyResolver.consumeAnnotation() should expect null array elements
- [23] markdown javadoc should detect code regions HOT 5
- [Bug - Go To/Navigation Java Records] - Can not go to Class HOT 2
- [Bug - Go To/Navigation/References] - Does not work for Private Methods/Constructor HOT 1
- [Bug - Autocompletion] - Does not work with Record implements Interface
- win: 24 failing compiler.regression.TestAll since I20240805-1800 "being used by another process" HOT 1
- JEP 413 Javadoc External Code Snippets do not work for JARs HOT 1
- ephemeral memory allocation in JRTUtil.getJrtSystem() HOT 3
- ClassCastException with array as wildcard generic parameter
- NPE in TypeSystem.getArrayType
- [23] Code completion for module imports HOT 2
- [23] Parsing details for markdown comments
- [Bug] - No Autocompletion/Import for annotation elements
- NPE in AST: Cannot read the array length because "this.arguments" is null HOT 3
- [feat] Add `@LateNonNull` annotation to declare late initializaiton of non-null fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eclipse.jdt.core.