Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325291

Summary: [otmodel] NPE in SourceRefElement.getAnnotations() at hover for callout binding
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTDTAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.7   
Target Milestone: 0.7.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix with one test none

Description Stephan Herrmann CLA 2010-09-14 16:13:52 EDT
The following NPE happend while hovering over a callout binding
(of CompletionAdaptor.CreateMethodMappingCompletionProposal.MyJavaLinkedModeProposal)

java.lang.NullPointerException
at org.eclipse.jdt.internal.core.SourceRefElement.getAnnotations(SourceRefElement.java:115)
at org.eclipse.objectteams.otdt.internal.core.MethodMapping.getAnnotations(MethodMapping.java:763)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getAnnotations(JavadocHover.java:957)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.addAnnotations(JavadocHover.java:937)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:604)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:555)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:547)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:141)
at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:82)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:166)
Comment 1 Stephan Herrmann CLA 2010-09-17 19:20:38 EDT
Created attachment 179156 [details]
Fix with one test

Fixed by these steps:

* include annotations in transformations by SourceElementNotifier and
  CompilationUnitStructureRequestor

* don't let MethodMapping.getAnnotation(s) delegate to the IMethod - 
  meanwhile MethodMappings are JavaElements and support getElementInfo()
  directly.

BTW: we might want to reconsider class MethodMappingInfo, which essentially
duplicates ISourceElementRequestor.MappingInfo and subclasses.
However, such changes would need to respect ClassFileInfo which currently
uses MethodMappingInfo for creating method mappings from bytecode attributes.
Comment 2 Stephan Herrmann CLA 2010-09-17 19:22:22 EDT
Fix has been committed as r823 / r824.
Comment 3 Stephan Herrmann CLA 2010-09-23 17:30:56 EDT
Verified using I201009211735
Comment 4 Stephan Herrmann CLA 2010-09-23 18:27:18 EDT
.