Community
Participate
Working Groups
Eclipse shows errors on method calls to setText and getText in inner class DefaultLookupField. I have added the code for class LookupTextField and EnabledTextField. These errors only happen when the inner class extends a class that extends another class. This is the same error message as bug 32342 which has been marked as resolved in 2.1 RC1 public class Enclosing { public void setText(Object text) { } public String getText() { return ""; } class DefaultLookupTextField extends LookupTextField { DefaultLookupTextField(int columns, boolean edit) { super(columns, edit); } public void setValue(Object value) { if (value != null) { setText(value.toString()); } else { setText(null); } } public Object getValue() { return getText(); } } } public abstract class LookupTextField extends EnabledTextField { public LookupTextField(int columns, boolean edit) { } public abstract void setValue(Object value); public abstract Object getValue(); } import javax.swing.JTextField;; public class EnabledTextField extends JTextField { /** * Sets the text of the textfield * @param text sets the text fo the textfield */ public void setText(String text) { } }
Bug 32342 was indeed a bug, but this behavior is intended in 1.3 compliant mode. javac 1.3.1 will also report problems: Enclosing.java:16: setText(java.lang.String) is inherited from EnabledTextField and hides method in outer class Enclosing. An explicit 'this' qualifier must be used to select the desired instance. setText(value.toString()); ^ Enclosing.java:18: setText(java.lang.String) is inherited from EnabledTextField and hides method in outer class Enclosing. An explicit 'this' qualifier must be used to select the desired instance. setText(null); ^ Enclosing.java:23: getText() is inherited from javax.swing.text.JTextComponent and hides method in o uter class Enclosing. An explicit 'this' qualifier must be used to select the desired instance. return getText(); ^ 4 errors If you switch our compliance setting to 1.4, then the problem will go away since in 1.4 mode, the inherited implementation is always privileged. Preferences>Java>Compiler>Compliance and Classfiles>Compiler Compliance Level>1.4