-
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
NullPointer Exception in the AnnotationBinding #2895
NullPointer Exception in the AnnotationBinding #2895
Conversation
ee9c71d
to
b3f8bf1
Compare
@@ -612,7 +615,7 @@ protected JavaElement getUnresolvedJavaElement() { | |||
return null; | |||
} | |||
if (!(this.resolver instanceof DefaultBindingResolver)) return null; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this change.
To add some context to my last review comment, here are couple of experiments I want you to try:
We should try and exclude the null annotation to the array if possible. |
Well, maybe this finding will help us to prevent the |
Well, I do know why we do that and assumed that's the expected way. In fact, almost copied you on this issue, but didn't bother you. Anyway, since we are here, let me say what's going on. When there's a type in the same CU with the same name (com) as the first qualifier of the type in question (com.Missing), the first call to findTypeOrpackage returns non empty and from there on (and since we don't have any other package/type with that name), we keep the scope as that type and return null. Do you think we should still create a missing type binding? |
Can you show me the location of that return null? Is it inside |
Sorry, this fell between cracks. What happens is, we return a SourceTypeBinding from Scope.getTypeOrPackage(char[], int, boolean). This is called from getPackage, line number 3173. Since it's not null, it escapes the null check in next line and then we hit this few lines below: We are looking for a qualified name "com.Missing". But getTypeOrPackage() call only gets one segment. So, it is oblivious to the fact that com.Missing is actually from a package "test", which is not part of the qualified name. So, ideally, getTypeOrPackage() should have returned null instead of STB. |
@subyssurendran666 Read the comment on the Scope#getPackage() method:
This is what is happening now. But looks like the clients of the getPackage() are not really prepared to receive a null. |
OK, after having spent quite a bit of time, I am more of less convinced that this is by design. The compiler is unaffected. Only the DOM is, which we can mitigate by the null-check. I will go ahead with the original patch from Suby. @subyssurendran666 can you please resolve the conflicts and update the PR? |
b3f8bf1
to
b15d113
Compare
a6f4685
to
16f1b8c
Compare
What it does
#2402
How to test
Author checklist