Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
###@###.### 2004-03-04 J2SE Version (please include all output from java -version flag): java version "1.5.0-beta2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b40) Java HotSpot(TM) Client VM (build 1.5.0-beta2-b40, mixed mode) Does this problem occur on J2SE 1.3.x or 1.4.x? Yes / No (pick one) N/A Operating System Configuration Information (be specific): Windows 2000 Professional SP2 Bug Description: Using @Override on a method from an implemented interface causes compilation to fail. This seems a shame, as it would be particularly useful when overriding the method with a different return type in an interface or abstract class - useful because a mistake made in doing so might not cause a compiler error yet still may not be what the programmer had intended. Steps to Reproduce (be specific): Compile Food.java (below) using -source 1.5. Note that removing the @Override annotations allows compilation to succeed. Test program: Food.java public interface Food { Food getInstance(); } interface Cheese extends Food { @Override Cheese getInstance(); // compilation error } class Biscuit implements Food { @Override public Food getInstance() { return new Biscuit(); } // compilation error } abstract class Fruit implements Food { @Override public abstract Fruit getInstance(); // compilation error } class Apple extends Fruit { @Override public Apple getInstance() { return new Apple(); } // ok } Elided java.net submission since compiler fixes are not accepted for specification issues.
|