Bug 217287 - [dom]IVariableBinding#getJavaElement() return null for variable inside an initializer
Summary: [dom]IVariableBinding#getJavaElement() return null for variable inside an ini...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-31 11:18 EST by David Audel CLA
Modified: 2008-08-06 13:55 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix and regression test (8.96 KB, patch)
2008-05-22 10:47 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2008-01-31 11:18:09 EST
build Build id: I20080122-1600

public class X {
  {
    int i;
    i = 0;
  }
	
  void foo() {
    int j;
    j = 0;
  }
}

IVariableBinding#getJavaElement() return a java element for j but 'null' for i.

The problem is in VariableBinding#getUnresolvedJavaElement(). This method return null if the parent of the variable is not a method.
Comment 1 Olivier Thomann CLA 2008-02-01 10:33:06 EST
This seems to be done on purpose.
Comment 2 Jerome Lanneluc CLA 2008-05-22 10:47:32 EDT
Created attachment 101518 [details]
Proposed fix and regression test
Comment 3 Jerome Lanneluc CLA 2008-06-24 05:05:23 EDT
Fix and test released for 3.5M1
Comment 4 Olivier Thomann CLA 2008-08-06 13:55:30 EDT
Verified for 3.5M1 using I20080805-1307