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

CCE while performing Java Search #3516

Open
ssttaarr opened this issue Jan 5, 2025 · 4 comments
Open

CCE while performing Java Search #3516

ssttaarr opened this issue Jan 5, 2025 · 4 comments
Labels
bug Something isn't working null Issues related to null pointer analysis

Comments

@ssttaarr
Copy link

ssttaarr commented Jan 5, 2025

Getting an error while searching for occurrences of a type com.google.gson.Gson (Ctrl-Shift-G)

!ENTRY org.eclipse.core.jobs 4 2 2025-01-05 18:27:21.571
!MESSAGE An internal error occurred during: "Java Search".
!STACK 0
java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding (org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding and org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @27342d64)
        at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.initDefaultNullness(PackageBinding.java:330)
        at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getDefaultNullness(PackageBinding.java:338)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.scanTypeForNullDefaultAnnotation(BinaryTypeBinding.java:2227)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:467)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:1093)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.cacheBinaryType(LookupEnvironment.java:550)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.cacheBinaryType(LookupEnvironment.java:537)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.cacheBinaryType(MatchLocator.java:451)
        at org.eclipse.jdt.internal.core.search.matching.ClassFileMatchLocator.locateMatches(ClassFileMatchLocator.java:269)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1982)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1351)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1388)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1531)
        at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:143)
        at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:276)
        at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:620)
        at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:677)
        at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:178)
        at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:94)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Eclipse IDE Version: 2024-12 (4.34.0) Build id: 20241128-0757

@jukzi jukzi added bug Something isn't working null Issues related to null pointer analysis labels Jan 6, 2025
@jukzi
Copy link
Contributor

jukzi commented Jan 6, 2025

cc @stephan-herrmann because of [null] commits in stack trace

@stephan-herrmann
Copy link
Contributor

Some package seems to have a package-info.java or package-info.class which, however, has some unexpected problem. Most likely cause: the package has access restrictions.

We'll probably need a reproducing example to figure out how package-info could be a ProblemReferenceBinding.

The only thing specific to null analysis is: this analysis needs to evaluate annotations even in package-info.

jukzi added a commit to jukzi/eclipse.jdt.core that referenced this issue Jan 7, 2025
During internal errors it is not clear which file did contain the
problematic binary. For example:

eclipse-jdt#3516

Example output will be like: "java.lang.RuntimeException:
RuntimeException caching =P/libGh375.jar|TestGh375.class"
jukzi added a commit to jukzi/eclipse.jdt.core that referenced this issue Jan 8, 2025
During internal errors it is not clear which file did contain the
problematic binary. For example:

eclipse-jdt#3516

Example output will be like: "java.lang.RuntimeException:
RuntimeException loading =P/libGh375.jar|TestGh375.class"
@ssttaarr
Copy link
Author

ssttaarr commented Jan 9, 2025

We'll probably need a reproducing example to figure out how package-info could be a ProblemReferenceBinding.

Please take a look at https://github.com/ssttaarr/BTB
Import this maven project into Eclipse.
There's only one class with one private member of Gson type. If you place a cursor on that type and press Ctrl-Shift-G, then the error occurs.

jukzi added a commit that referenced this issue Jan 9, 2025
During internal errors it is not clear which file did contain the
problematic binary. For example:

#3516

Example output will be like: "java.lang.RuntimeException:
RuntimeException loading =P/libGh375.jar|TestGh375.class"
@stephan-herrmann
Copy link
Contributor

We'll probably need a reproducing example to figure out how package-info could be a ProblemReferenceBinding.

Please take a look at https://github.com/ssttaarr/BTB Import this maven project into Eclipse. There's only one class with one private member of Gson type. If you place a cursor on that type and press Ctrl-Shift-G, then the error occurs.

I still cannot reproduce. For me Ctrl+Shift+G finds 43 matches.

Looking at the stacktrace we can see that you have null annotation analysis enabled. This means we'd need the file .settings/org.eclipse.jdt.core.prefs to see how your project is configured. And while you're at it, it would be good to avoid maven (which raises more questions how exactly JDT will see the project), but simply put the gson jar file on the classpath (or module path?). If then you include the jar file in github, we can also rule out that you simply worked from a corrupt copy of the jar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working null Issues related to null pointer analysis
Projects
None yet
Development

No branches or pull requests

3 participants