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

Bug 316330

Summary: NPE hovering in JS editor - "Unexpected runtime error while computing a text hover"
Product: [WebTools] JSDT Reporter: Michael Rennie <Michael_Rennie>
Component: GeneralAssignee: Chris Jaun <cmjaun>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun, rmiller, tomasz.zarna
Version: 3.2Keywords: needinfo
Target Milestone: 3.2.1Flags: thatnitind: review+
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The script that produces the NPEs
none
patch - added null checks none

Description Michael Rennie CLA 2010-06-09 11:34:17 EDT
Created attachment 171542 [details]
The script that produces the NPEs

version: 1.2.0.v201006041342-7C78FGDF9JgLWLMLM4Vsye

while hovering around in the JS editor I was hit with this gem:

java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.resolve0(LocalDeclaration.java:234)
at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:129)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:733)
at org.eclipse.wst.jsdt.internal.core.Openable.codeSelect(Openable.java:167)
at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:318)
at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:312)
at org.eclipse.wst.jsdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:108)
at org.eclipse.wst.jsdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:99)
at org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:67)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:168)

I have no exact steps other than "try hovering in the attached script". I had opened the root script node from www.google.ca in an editor, and hovering would produce the given NPE constantly. I will attach the script.
Comment 1 Chris Jaun CLA 2010-06-09 13:52:47 EDT
That is a very unusual spot for a NPE.

My guess is this has something to do with your project set up. Please explain your set up.
Comment 2 Michael Rennie CLA 2010-06-10 14:25:18 EDT
(In reply to comment #1)

> My guess is this has something to do with your project set up. Please explain
> your set up.

My setup is very simple. Put the attached script is a normal (non-JavaScript) project and open it with the JSDT editor.
Comment 3 Chris Jaun CLA 2010-06-10 17:26:00 EDT
Created attachment 171674 [details]
patch - added null checks
Comment 4 Chris Jaun CLA 2010-06-10 17:26:50 EDT
This happens when not in a JS project because it cannot resolve the Array type leading to the NPE.

If we can't resolve the Array type we need to make sure ArrayBinding does not throw NPE's.
Comment 5 Nitin Dahyabhai CLA 2010-06-28 21:23:28 EDT
Approving, but should ArrayBinding#getInferredType() ever return null?
Comment 6 Chris Jaun CLA 2010-06-29 09:36:24 EDT
Patch checked in.

Not sure getInferredType should ever return null.

Probably not, but at least it won't throw a NPE for now.
Comment 7 Chris Jaun CLA 2010-06-29 17:39:50 EDT
*** Bug 304894 has been marked as a duplicate of this bug. ***