-
Notifications
You must be signed in to change notification settings - Fork 130
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
ECJ hangs when pattern matching code is used in a nested conditional expression. #1485
Comments
Here is an edit to the org.eclipse.jdt.internal.compiler.ast.Statement.addPatternVariables(LocalVariableBinding[] current, LocalVariableBinding[] add) method, which finally helped to deal with the hang in org.eclipse.jdt.core 3.32.0 lib when analyzing the IntelliJ IDEA source code using PVS-Studio (edits are only in beta for now):
|
I'll propose an alternate fix. The core issue is that we should be maintaining pattern variables in a
That the debug print routine prints Changing this is a sizeable refactoring. I will explore maintaining setness while using array instead. |
The comment in
but that is not quite so. We don't set the same The reason I don't like the Arrays.equals() approach is because the order of elements may differ while as a set they may be equal - if that were possible the problem would resurface. |
As I understand, the comment you referred to was added before Pattern Matching was extended in Java, so this limitation is most likely no longer relevant. I used Arrays.equals to cut out the simplest cases (in my simple examples, Arrays.equals was enough in most cases). In order not to create a HashSet for each case, wasting memory. In more complex situations (for example, in the case of different orders of array elements), I just used HashSet in the else branch. This is exactly what happened when analyzing the code of the |
FWIW, According to git blame, the comment
Do I understand that you maintain a fork where you made such a change ?? This is exactly what happened when analyzing the code of the Interesting, thanks. |
|
Sorry, this didn't get answered in time. Do you still have the question open ? If so I can request @jarthana or @mpalat to help clarify how to do what you want to do. Thanks.
|
No thanks. We managed to assemble the necessary version (3.32.0) with our modification from our branch. |
Hello.
I'm from PVS-Studio LLC. We develop a static analyzer for Java code that uses the Spoon library (we use the 10.3.0 version). Spoon uses your org.eclipse.jdt.core 3.32.0 library.
Reproduction of hang
When such code is evaluated via Spoon (a compliance level equal to 17 is used):
the org.eclipse.jdt.internal.compiler.ast.Statement class hangs on a method:
The method on which the hang occurs
The code in the latest version of the org.eclispe.jdt.core library is the same as here.
StackTrace hangs
Here is a StackTrace of the hang:
Possible edit
I think you could edit the code of the method that is up the call stack in such a way. It would help avoid the hang on the code above:
The hang occurs due to the fact that the current parameter and the add parameter contain a reference to the same array when the last statement is called in the org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression.collectPatternVariablesToScope method.
Additional questions
I would also like to know: how do I build org.eclipse.jdt.core 3.32.0? I would like to edit the org.eclipse.jdt.core source code for the 3.32.0 version and build the library, so we can use it in our Spoon branch on Github .
I checked out to the fe90c2cce150ba4fcadeee10f32bcab0a7f29969 commit (the 4.26 release version is specified in its message). However, when trying to build the library, the plugins from the org.eclipse.tycho group version 4.0.0-SNAPSHOT are not in the repository - https://repo.eclipse.org/content/repositories/eclipse/
I need this specific version because we use Spoon 10.3.0, and this version of Spoon uses org.eclipse.jdt.core 3.32.0.
The text was updated successfully, but these errors were encountered: