Community
Participate
Working Groups
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)
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 ?
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.
Any news on this? Without further input, no action is planned.
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
Created attachment 131006 [details] Proposed fix + regression test
Verified for 3.5M7 using I20090428-0100.
Created attachment 135143 [details] Proposed fix + regression test for 3.4 maintenance