Bug 96698 - org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement produce ClassCastException
Summary: org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement produce Cla...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-25 16:26 EDT by Matthieu Helleboid CLA
Modified: 2005-05-27 08:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.