JDK-6954234 : JDK 1.6 @Override: Implementation different from Specification
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2010-05-20
  • Updated: 2012-03-20
  • Resolved: 2010-07-08
Related Reports
Relates :  
Relates :  
Relates :  
Description
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.

Comments
EVALUATION The implementation of @Override currently implemented in javac in JDK 6 is the intended one for that release (even though the documentation does not say so): http://blogs.sun.com/ahe/entry/override_snafu The JDK 6 implemention is more useful and more consistent than the JDK 5 semantics. Closing as will not fix.
08-07-2010