Skip to content

fix: issue 4358 prevent infinite cycles with static imports #4359

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

Merged
merged 1 commit into from
Apr 2, 2024
Merged

fix: issue 4358 prevent infinite cycles with static imports #4359

merged 1 commit into from
Apr 2, 2024

Conversation

kdunee
Copy link
Contributor

@kdunee kdunee commented Mar 31, 2024

Fixes #4358 (infinite loop when import static is used between an ancestor and parent class).

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.860%. Comparing base (eed85f0) to head (afc5c75).
Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##            master     #4359       +/-   ##
=============================================
+ Coverage   51.853%   51.860%   +0.007%     
=============================================
  Files          497       497               
  Lines        28326     28326               
  Branches      4916      4916               
=============================================
+ Hits         14688     14690        +2     
+ Misses       11597     11595        -2     
  Partials      2041      2041               
Flag Coverage Δ
AlsoSlowTests 51.860% <ø> (+0.007%) ⬆️
javaparser-core 51.860% <ø> (+0.007%) ⬆️
javaparser-symbol-solver 51.860% <ø> (+0.007%) ⬆️
jdk-10 51.856% <ø> (?)
jdk-11 51.856% <ø> (?)
jdk-12 51.856% <ø> (?)
jdk-13 51.856% <ø> (?)
jdk-14 51.856% <ø> (?)
jdk-15 51.856% <ø> (+0.007%) ⬆️
jdk-16 51.856% <ø> (?)
jdk-17 51.856% <ø> (?)
jdk-18 51.849% <ø> (ø)
jdk-8 51.855% <ø> (+0.007%) ⬆️
jdk-9 51.856% <ø> (+0.007%) ⬆️
macos-latest 51.853% <ø> (ø)
ubuntu-latest 51.853% <ø> (?)
windows-latest 51.839% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cab0b39...afc5c75. Read the comment docs.

.setSymbolResolver(new JavaSymbolSolver(cts));
StaticJavaParser.setConfiguration(pc);
CompilationUnit cu = StaticJavaParser.parse(issueResourcesPath.resolve("foo/A.java"));
cu.findAll(MethodCallExpr.class).forEach(MethodCallExpr::resolve);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we check the result because there's only one method call?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll accept this solution because it doesn't break the existing tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlerbsc The result is irrelevant, the test verifies that StackOverflowError isn't thrown during resolve. I considered adding a comment explaining it or explicitly using assertDoesNotThrow to make it more clear.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that the method is not correctly solved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is correctly solved 😉. I could add the assertions to make it clear that:

  • The method is correctly solved.
  • StackOverflowError isn't thrown.

Should I do that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking that the method is correctly resolved is sufficient. If we want to find the context, we can refer to the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.
Thanks for reviewing the change. I'll let you know when I implement the assertion, can't do it right now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as it's done, I'll validate the PR. Thank you for your contribution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlerbsc Done. I also rebased my change onto current master.

@jlerbsc jlerbsc merged commit ae51121 into javaparser:master Apr 2, 2024
@jlerbsc jlerbsc added this to the next release milestone Apr 2, 2024
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Fixed A PR that offers a fix or correction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StackOverflowError with import static in circular dependencies
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy