Skip to content
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

[Bug] - Can not find references for static method #3147

Open
mamilic opened this issue Oct 23, 2024 · 7 comments
Open

[Bug] - Can not find references for static method #3147

mamilic opened this issue Oct 23, 2024 · 7 comments
Assignees

Comments

@mamilic
Copy link

mamilic commented Oct 23, 2024

Can not find references for static method.

Steps To Reproduce

  1. Download and open test.zip
  2. Go to DemoApplication
  3. Find references for public static Top of(One one), it will say no references found
    . However for method meta() in the same claas, DemoApplication, it will find references.

The error below happened on a project that I have no liberty of sharing. Hope it might be helpfull.

Details

Oct 23, 2024 4:48:26 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.lang.UnsupportedOperationException
java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException
at org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18.getPackage(IntersectionTypeBinding18.java:143)
at org.eclipse.jdt.internal.compiler.lookup.ArrayBinding.getPackage(ArrayBinding.java:259)
at org.eclipse.jdt.internal.compiler.lookup.TypeBinding.qualifiedPackageName(TypeBinding.java:1605)
at org.eclipse.jdt.internal.core.search.matching.PatternLocator.resolveLevelForType(PatternLocator.java:823)
at org.eclipse.jdt.internal.core.search.matching.PatternLocator.resolveLevelForType(PatternLocator.java:752)
at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchMethod(MethodLocator.java:371)
at org.eclipse.jdt.internal.core.search.matching.MethodLocator.resolveLevel(MethodLocator.java:787)
at org.eclipse.jdt.internal.core.search.matching.MethodLocator.resolveLevel(MethodLocator.java:718)
at org.eclipse.jdt.internal.core.search.matching.OrLocator.resolveLevel(OrLocator.java:340)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2805)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:2053)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1366)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1403)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1546)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:134)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:251)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:595)
at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:669)
at org.eclipse.jdt.ls.core.internal.handlers.ReferencesHandler.search(ReferencesHandler.java:184)
at org.eclipse.jdt.ls.core.internal.handlers.ReferencesHandler.findReferences(ReferencesHandler.java:87)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$10(JDTLanguageServer.java:712)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
... 7 more

@srikanth-sankaran
Copy link
Contributor

@mamilic - Thanks for your diligent efforts to report issues. To my knowledge most JDT committers aren't familiar with gradle or maven or such layers on top of Eclipse SDK -- Sometimes, people have expressed amazement at the lack of familiarity with maven, gradle etc - but that is how it is - we are resource constrained and a test project that shows the problem on a plain Eclipse SDK will see swifter response relatively speaking.

If I simply import the zip file, open DemoApplication.java and select Top.meta() and ask for references - I get a pop up informing me "The resource is not on the build path of a Java project" -

@srikanth-sankaran srikanth-sankaran added the help wanted Extra attention is needed label Oct 23, 2024
@srikanth-sankaran
Copy link
Contributor

Tagging as help wanted - perhaps some knowledgeable person can extract a plain SDK project and attach here.

@rgrunber
Copy link
Contributor

Does the stacktrace at redhat-developer/vscode-java#3827 (comment) help at all to narrow down what it might be ?

@stephan-herrmann
Copy link
Contributor

Does the stacktrace at redhat-developer/vscode-java#3827 (comment) help at all to narrow down what it might be ?

Yes, it tells us that the fix in https://bugs.eclipse.org/bugs/show_bug.cgi?id=485805 was incomplete: we detect intersection types at top level, but did not expect them as leaf component type of an array type.

@mpalat do you want to amend your fix from 8 years ago? :)

I briefly scanned the attached reproducer, and although it mentions a few annotations from spring, I believe it should be straight forward to reduce it further into a unit tests, as those annotations are probably irrelevant for us.

@mpalat
Copy link
Contributor

mpalat commented Nov 5, 2024

@mpalat do you want to amend your fix from 8 years ago? :)

Karmic law is inescapable, so why not? :)

@mpalat mpalat self-assigned this Nov 5, 2024
@mpalat mpalat removed the help wanted Extra attention is needed label Nov 5, 2024
@mpalat
Copy link
Contributor

mpalat commented Nov 5, 2024

Importing the gradle project was quite easy with the Eclipse Gradle plugin. However, I don't see this issue in Eclipse IDE. ie, I see the reference of of() shown in search. However, I then used VSCOde and I could see that the reference is not picked up. @rgrunber - since you would have the VSCode already setup, could you please let now parameter values in the concerned ST at line number 677 of SearchEngine - ie, the parameters of search() method - at least the value of the pattern. TIA.

@rgrunber
Copy link
Contributor

rgrunber commented Nov 5, 2024

All the parameters are set at :

https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/369805257a5c1abfc6a2d286b7fed755899904a0/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/ReferencesHandler.java#L178-L184

The elementToSearch is the ResolvedSourceMethod :

static Top of(One) {key=Lcom/example/demo/Top;.of(Lcom/example/demo/One;)Lcom/example/demo/Top;} [in Top [in Top.java [in com.example.demo [in src/main/java [in demo]]]]]

The pattern is an OrPattern :

MethodReferencePattern: com.example.demo.Top.of(One) --> Top, exact match, case sensitive, generic erasure match, fine grain: none
| MethodDeclarationPattern: com.example.demo.Top.of(One) --> Top, exact match, case sensitive, generic erasure match, fine grain: none

Let me know if you need more.

Update: Although, I will say, even setting includeDeclarations to false, allowing the pattern to be a MethodPattern of

MethodReferencePattern: com.example.demo.Top.of(One) --> Top, exact match, case sensitive, generic erasure match, fine grain: none

still fails the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants