Bug 228651 - [dom] NPE in MemberValuePairBinding.isDefault()
Summary: [dom] NPE in MemberValuePairBinding.isDefault()
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 229615 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-04-24 07:32 EDT by David Audel CLA
Modified: 2008-05-02 11:43 EDT (History)
5 users (show)

See Also:


Attachments
Proposed fix (4.44 KB, patch)
2008-04-29 21:04 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (17.13 KB, patch)
2008-04-30 12:37 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2008-04-24 07:32:31 EDT
build I20080422-0800

1) create A.java
// ABC doesn't exists
@ABC (name1="")
public class A {
	
}
2) open the ASTView
3) open the MemberValuePair named 'name1' in the ASTView
4) click on member value pair binding
An NPE occurs

java.lang.NullPointerException
	at org.eclipse.jdt.core.dom.MemberValuePairBinding.isDefault(MemberValuePairBinding.java:150)
	at org.eclipse.jdt.astview.views.Binding.getChildren(Binding.java:234)
	at org.eclipse.jdt.astview.views.ASTViewContentProvider.getChildren(ASTViewContentProvider.java:95)
	at org.eclipse.jdt.astview.views.ASTViewContentProvider.hasChildren(ASTViewContentProvider.java:227)
	at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2076)
	at org.eclipse.jface.viewers.TreeViewer.isExpandable(TreeViewer.java:576)
Comment 1 Olivier Thomann CLA 2008-04-29 21:04:16 EDT
Created attachment 98094 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2008-04-29 21:05:35 EDT
Jérôme, Frédéric,

I would release this fix. It prevents the NPE when calling the isDefault() method on a member value pair binding located inside a recovered annotation binding.

Comment 3 Jerome Lanneluc CLA 2008-04-30 02:51:33 EDT
+1 to fix for 3.4M7
Comment 4 Olivier Thomann CLA 2008-04-30 11:13:01 EDT
In this case we should not return any MemberValuePairBinding for name1 since it cannot be resolved and we don't have binding recovery fully functional in this case.
So I would return null when requesting the resolveMemberValuePairBinding() on the corresponding pair.
Also the corresponding annotation which is recovered should return an empty list of pairs.

Jérôme, do you prefer this solution ?
Comment 5 Jerome Lanneluc CLA 2008-04-30 11:45:14 EDT
(In reply to comment #4)
> In this case we should not return any MemberValuePairBinding for name1 since it
> cannot be resolved and we don't have binding recovery fully functional in this
> case.
> So I would return null when requesting the resolveMemberValuePairBinding() on
> the corresponding pair.
> Also the corresponding annotation which is recovered should return an empty
> list of pairs.
> 
> Jérôme, do you prefer this solution ?
> 
That sounds good to me
Comment 6 Olivier Thomann CLA 2008-04-30 12:37:06 EDT
Created attachment 98215 [details]
Proposed fix

This patch:
- makes sure that the annotation binding is returned only if the binding recovery is on when the annotation binding itself cannot be resolved.
- makes sure that only "resolvable" member values pairs are returned from an annotation binding. In case the annotation binding is recovered, no pairs are returned.

When the binding recovery will be functional inside member values pairs, this can be revisited.

This doesn't seem to cause any problem with the existing specifications of IAnnotationBinding methods.
Comment 7 Olivier Thomann CLA 2008-04-30 12:40:38 EDT
*** Bug 229615 has been marked as a duplicate of this bug. ***
Comment 8 Jerome Lanneluc CLA 2008-05-02 04:57:52 EDT
It looks like the patch was released with v_858. Shouldn't it be resolved now?
Comment 9 Olivier Thomann CLA 2008-05-02 08:29:47 EDT
Yes, released for 3.4M7.
Comment 10 Kent Johnson CLA 2008-05-02 11:43:39 EDT
Verified for 3.4M7 using I20080502-1000