Bug 217287

Summary: [dom]IVariableBinding#getJavaElement() return null for variable inside an initializer
Product: [Eclipse Project] JDT Reporter: David Audel <david_audel>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.3   
Target Milestone: 3.5 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix and regression test none

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