Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 135143 Details for
Bug 270367
[DOM] NullPointerException in ParenthesizedExpression.resolveTypeBinding()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test for 3.4 maintenance
patch_270367_34x.txt (text/plain), 3.86 KB, created by
Olivier Thomann
on 2009-05-11 10:23:49 EDT
(
hide
)
Description:
Proposed fix + regression test for 3.4 maintenance
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2009-05-11 10:23:49 EDT
Size:
3.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.268.2.2 >diff -u -r1.268.2.2 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 3 Sep 2008 11:54:37 -0000 1.268.2.2 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 11 May 2009 14:24:22 -0000 >@@ -46,7 +46,7 @@ > } > > static { >-// TESTS_NUMBERS = new int[] { 239 }; >+// TESTS_NUMBERS = new int[] { 323 }; > // TESTS_RANGE = new int[] { 308, -1 }; > // TESTS_NAMES = new String[] {"test0204"}; > } >@@ -10229,4 +10229,48 @@ > IMemberValuePairBinding pairBinding = memberValuePairBindings[0]; > assertNull("Got a value", pairBinding.getValue()); > } >+ >+ public void test0323() throws JavaModelException { >+ String contents = "package test0323;\n" >+ + "public class X {\n" >+ + " public void someMethod() {\n" >+ + " int i = /*start*/(new Integer(getId())).intValue()/*end*/;\n" >+ + " }\n" >+ + " public String getId() {\n" >+ + " return null;\n" >+ + " }\n" >+ + "}"; >+ this.workingCopy = getWorkingCopy("/Converter15/src/test0323/X.java", contents, true/*resolve*/ >+ ); >+ MethodInvocation methodCall = (MethodInvocation) buildAST(contents, workingCopy, false, true, true); >+ ParenthesizedExpression intValueReceiver = (ParenthesizedExpression) methodCall.getExpression(); >+ ParenthesizedExpression newParenthesizedExpression = (ParenthesizedExpression) ASTNode.copySubtree( >+ intValueReceiver.getAST(), intValueReceiver); >+ replaceNodeInParent(methodCall, newParenthesizedExpression); >+ ClassInstanceCreation constructorCall = (ClassInstanceCreation) newParenthesizedExpression.getExpression(); >+ constructorCall.resolveTypeBinding(); // This should not throw a NPE >+ IMethodBinding constructorBinding = constructorCall.resolveConstructorBinding(); >+ assertNull("Not null constructor binding", constructorBinding); >+ constructorCall = (ClassInstanceCreation) intValueReceiver.getExpression(); >+ constructorCall.resolveTypeBinding(); // This should not throw a NPE >+ constructorBinding = constructorCall.resolveConstructorBinding(); >+ assertNotNull("Null constructor binding", constructorBinding); >+ } >+ >+ // Utility method to replace "node" by "replacement" >+ private static void replaceNodeInParent(Expression node, Expression replacement) { >+ StructuralPropertyDescriptor loc = node.getLocationInParent(); >+ if (loc.isChildProperty()) { >+ node.getParent().setStructuralProperty(loc, replacement); >+ } >+ else { >+ List l = (List) node.getParent().getStructuralProperty(loc); >+ for (int i = 0; i < l.size(); i++) { >+ if (node.equals(l.get(i))) { >+ l.set(i, replacement); >+ break; >+ } >+ } >+ } >+ } > } >\ No newline at end of file >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v >retrieving revision 1.164 >diff -u -r1.164 DefaultBindingResolver.java >--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 27 May 2008 22:24:51 -0000 1.164 >+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 11 May 2009 14:24:23 -0000 >@@ -662,7 +662,7 @@ > if (typeBinding != null) { > return typeBinding; > } >- } else { >+ } else if (astNode instanceof AllocationExpression) { > // should be an AllocationExpression > AllocationExpression allocationExpression = (AllocationExpression) astNode; > return this.getTypeBinding(allocationExpression.resolvedType);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 270367
:
131006
| 135143