Eclipse indigo, java 1.6
public interface I {
String getName();
}
/* and in another file */
public enum E implements I {
E1() {
String getName() { return "foo"; }
};
}
In Eclipse, this worked! Other classes could invoke getName() on references of type I. The actual javac rejected it, claiming that there was no such thing as getName() in the enum. Is this just an Eclipse bug?
Note that what's wierd about this is the method definition inside the enumerator. It all works just fine in both Eclipse and Javac if I do the normal thing, and have the function defined at the bottom of the enum returning the value of a field.
getName()
in E1
should be public
-- is that what's causing you problems? Otherwise, you're trying to override a public method (all methods declared in interfaces are public) with a package-private method, which isn't allowed.
First I agree with @yshavit.
Otherwise it can be related with this one: Workaround for javac compilation order bug in maven
I think it's name order related. Try to rename your interface A, it may compile first and things should work.
Interfaces methods are public scoped. Increase the visibility level in your enum and it should compile successfully. As a side note, your code shows a compilation error in my version of Eclipse (Indigo running on Mac 0S X 10.7.2, JDK 1.6).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With