Community
Participate
Working Groups
Eclipse can't compile a class which javac is able to compile without errors when : - the same field is defined in a parent class and an inner class [1] - another inner class [2] extends the previous inner class [1] and uses the field A test case is easier than an explaination: the following class compiles with javac (tested on jdk1.5, windows): public class TestDuplicateField { public int simpleField; public TestDuplicateField() { simpleField = 1; } public class InnerOne { public int simpleField; public InnerOne() { simpleField = 1; } } public class InnerTwo extends InnerOne { public InnerTwo() { simpleField = 1; } } } Eclipse reports the following error: "The field simpleType is defined in an inherited type and an enclosing scope" Tested on Eclipse 3.1M6
Which compliance are you using ? I suspect you use 1.3 compliance, where the error is legite. Checked javac 1.3 which agrees with us: TestDuplicateField .java:14: simpleField is inherited from TestDuplicateField .InnerOne and hides variable in outer class TestDuplicateField . An explicit 'this' qualifier must be used to select the desired instance. simpleField = 1; ^ 1 error In compliance 1.4 and above, no error is reported. Only a warning (optional) is surfaced to flag the field override.
verified, I was using the default settings with 1.3 compliance. Sorry for the invalid report and thanks.
No problem, and thanks for checking.