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

javac fails to produce an error on @Override annotations for 1.5 source

XMLWordPrintable

    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

      javac 1.6.0_20


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]

      A DESCRIPTION OF THE PROBLEM :
      Java 6 allows @Override annotations on initial implementations of methods from interfaces, as well as declaration of super functions in derived interfaces, while Java 5 will generate a compiler error. However, when specifying the source level as 1.5 on the compiler command line, Java 6 does NOT produce an error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create Test.java file that defines an interface and another interface which extends it, declares the same method and specifies the @Override annotation on the derived interface.

      execute command 'javac -source 1.5 Test.java'



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the same error you would get from a java 5 compiler:

      Test.java:7: method does not override a method from its superclass
                                                              @Override public void foo();
      ACTUAL -
      no output on stdout or stderr. Class compiled successfully.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Test {
        public interface A { public void foo(); }
        public interface B extends A { @Override public void foo(); }
      }

      ---------- END SOURCE ----------

            sadayapalam Srikanth Adayapalam (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: