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

JDK 1.6 @Override: Implementation different from Specification

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P2 P2
    • None
    • 6u10
    • tools
    • x86
    • windows_vista

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Specification: If a method is annotated with @Override but does not _override_ a _superclass_ method, compilers are required to generate an error message (see http://java.sun.com/javase/6/docs/api/java/lang/Override.html).

      Implementation: _Implementing_ an _interface_ method using @Override will compile fine and NOT generate an error message.

      Note: The specification was consistent to the implementation in JDK 1.5 but the implementation was changed in JDK 1.6 without changing the specification.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Use the @override annotation when implementing an interface methode. This will NOT generate an error message when compiling with JDK 1.6.

      2. Now look in the JDK Specification (see http://java.sun.com/javase/6/docs/api/java/lang/Override.html). It says there should have been a compiler error (as was the case in JDK 1.5), because you did not _overwrite_ a _superclass_ method, you just _implemented_ an _interface_ method.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There a two ways to fix the bug:
      1. Fix the specification of the @Override annotation in JDK 1.6.
      or
      2. Fix the implementation of the @Override annotation in JDK 1.6 and consider a new @Implement adding an http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399361

      REPRODUCIBILITY :
      This bug can be reproduced always.

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: