-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
Added null check to handle anonymous classes to TypeFactory #3553
Conversation
Just some extra context for Spoon folks (CC @monperrus @tdurieux): we're prioritizing better Spoon-powered Java code intelligence at Sourcegraph and @Strum355 is working through our issues in lsif-java, so you'll probably see a couple of PRs like this one to Spoon :-) We're submitting best-effort patches, do let us know if they can be improved. Appreciate your reviews! |
Thanks a lot for the fix and the context explanation. How is that possible that |
I will get further context on the state inside |
Additional step-by-step debugger states Of note is in CtTypeImpl, setResult is never called, resulting in null being returned. |
hard to understand with the screenshot. just for debugging, you can create a PR with a failing test case that uses the full lsif-java stack and gson. We may not merge the test case in master but we will for sure use it to debug and fix the problem. |
If there is no way to understand this more deeply, while this is indeed a correct fix, we can proceed. If yes, I would propose to add a fat comment explaining the problem and this workaround and we can merge. |
I will try get a working test case PR open today/tomorrow if possible. If I cannot get it to reproduce in a test case, we can proceed with your suggestion |
Looking at the bug, thanks the failure reproduction test case works perfectly. It happens for anonymous classes, because Java's Class.getSimpleName "Returns an empty string if the underlying class is anonymous."
|
#3567 is a proper fix with a minimal test case. |
When indexing https://github.com/google/gson with https://github.com/sourcegraph/lsif-java, anonymous class declarations (of the form
com.google.gson.<xyz>.SomeClass$1
), the following line would cause a NullPointerException https://github.com/INRIA/spoon/blob/master/src/main/java/spoon/reflect/factory/TypeFactory.java#L568Was unsuccessful in reproducing at a smaller scale than google/gson. This PR may be just a symptom patch for a larger issue that Im not aware of where to find.
Debugger state view
Stack trace