Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5008260

@Override should be generalized from 'superclass' to 'supertype'

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      rc
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      ###@###.### 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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              abuckley Alex Buckley
              Reporter:
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: