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

@Override of static shouldn't be accepted (compiler shouldissue an error/warning)

    Details

    • Subcomponent:
    • Resolved In Build:
      b75
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      I think that the @Override annotation should issue a compiler error/warning if it is applied to a static method.

      The following code compiles without any warnings:
      class Example {
          public static void example() {
              
          }
      }

      class Test extends Example {
          @Override
          public static void example() {

          }
      }

      Static methods can't be overridden, only hidden. I think that the code above might give a programmer a false indication that the method is indeed overridden and not just hidden.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Paste the code above in a source file, and compile with JDK 1.5.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect to get at least a warning from the compiler.
      ACTUAL -
      Nothing. I compiles fine without any warnings.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Example {
          public static void example() {
              
          }
      }

      class Test extends Example {
          @Override
          public static void example() {

          }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              ahe Peter Ahe
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: