Bug 96698

Summary: org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement produce ClassCastException
Product: [Eclipse Project] JDT Reporter: Matthieu Helleboid <mhelleboid>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Matthieu Helleboid CLA 2005-05-25 16:26:55 EDT
If you call getJavaElement() on a VariableDeclarationFragment which is part of a    
VariableDeclarationExpression you'll get a ClassCastException.    
 
In org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement 
"VariableDeclarationStatement statement = (VariableDeclarationStatement)  
localVar.getParent();" is a useless and a bad cast because localVar.getParent() could be a 
VariableDeclarationExpression. 
   
For example in "For(int i=0;..."   
"int i=0" is a VariableDeclarationExpression   
"i=0" is a VariableDeclarationFragment   
If you do "i=0".resolveBinding().getJavaElement(), you'll get a ClassCastException.
Comment 1 Olivier Thomann CLA 2005-05-26 00:23:18 EDT
Fixed and released in HEAD.
Regression tests added in
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0608/609
Comment 2 Frederic Fusier CLA 2005-05-27 08:29:09 EDT
Verified for 3.1 RC1 with build I20050527-0010.