Bug 270367 - [DOM] NullPointerException in ParenthesizedExpression.resolveTypeBinding()
Summary: [DOM] NullPointerException in ParenthesizedExpression.resolveTypeBinding()
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-28 23:46 EDT by Tomas Pollak CLA
Modified: 2009-05-11 10:23 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix + regression test (9.63 KB, patch)
2009-04-06 11:20 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test for 3.4 maintenance (3.86 KB, patch)
2009-05-11 10:23 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 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