Bug 270367

Summary: [DOM] NullPointerException in ParenthesizedExpression.resolveTypeBinding()
Product: [Eclipse Project] JDT Reporter: Tomas Pollak <tomas_pollak>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_audel, Olivier_Thomann
Version: 3.4.2   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression test
none
Proposed fix + regression test for 3.4 maintenance none

Description Tomas Pollak CLA 2009-03-28 23:46:51 EDT
Build ID: M20080911-1700

Steps To Reproduce:
1.The input file for the ASTParser contains a parentesized expression like the following: (new Integer(getId())), where getId returns a String.
2.Create an ASTParser and parse the input file.
3.Use a visitor, and when visiting the parentesized expression call resolveTypeBinding. It throws a NPE.


More information:
A possible solution would be to include a null check in line 665 of DefaultBindingResolver (where the comment says: // should be an AllocationExpression)

This is the stack trace:
java.lang.NullPointerException
	at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveExpressionType(DefaultBindingResolver.java:668)
	at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveExpressionType(DefaultBindingResolver.java:717)
	at org.eclipse.jdt.core.dom.Expression.resolveTypeBinding(Expression.java:108)
	at com.mycompany.myproject.impl.ast.visitor.MethodInvocationParametersHelper$IsPotentialDeclarationPredicate.evaluate(MethodInvocationParametersHelper.java:126)
Comment 1 Olivier Thomann CLA 2009-03-31 11:33:07 EDT
I cannot reproduce the failure.
I tried on 3.4.2 and 3.5 integration builds.

Could you please provide a more complete test case that reproduces the problem?
Are you using statement recovery ?
Comment 2 Olivier Thomann CLA 2009-03-31 11:36:18 EDT
The NPE would mean that the new Integer(getId()) is not seen as an allocation expression. I would be null.
I don't see how this can happen.
Comment 3 Olivier Thomann CLA 2009-04-02 13:28:12 EDT
Any news on this?
Without further input, no action is planned.
Comment 4 Olivier Thomann CLA 2009-04-06 11:19:47 EDT
Ok, got a test case.
Nodes created after the unit has been resolved are not expected to have bindings.

Released for 3.5M7.
Regression test added in:
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0324
Comment 5 Olivier Thomann CLA 2009-04-06 11:20:55 EDT
Created attachment 131006 [details]
Proposed fix + regression test
Comment 6 David Audel CLA 2009-04-29 11:18:26 EDT
Verified for 3.5M7 using I20090428-0100.
Comment 7 Olivier Thomann CLA 2009-05-11 10:23:49 EDT
Created attachment 135143 [details]
Proposed fix + regression test for 3.4 maintenance