Bug 84562 - [DCR][1.5][options] Optional warning/error to avoid accidental overrides with JDK 5.0
Summary: [DCR][1.5][options] Optional warning/error to avoid accidental overrides with...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 86234
  Show dependency tree
 
Reported: 2005-02-07 08:02 EST by Jon Skeet CLA
Modified: 2005-03-31 09:26 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Skeet CLA 2005-02-07 08:02:35 EST
Now that Java has the @Override tag, it would be nice if the compiler could
enforce this, by giving a warning or error if a method overrides another without
the @Override tag being present. This should be available in the "JDK 5.0
options" part of the Errors/Warnings preferences.
Comment 1 Markus Keller CLA 2005-02-08 13:27:42 EST
+1. IMO, the @Override annotation doesn't make much sense if it is only optional.
Comment 2 Tobias Widmer CLA 2005-02-09 03:52:58 EST
+1. With the advent of covariance and generics, overriding rules have become 
more complex, and checking @Override annotations certainly helps against 
unwanted overriding of methods.
Comment 3 Philipe Mulet CLA 2005-02-22 04:27:33 EST
Good suggestion
Comment 4 Philipe Mulet CLA 2005-02-23 12:24:54 EST
Option added.
Enabled it through our some of our test suites, and adapted test results
accordingly.

Fixed
Comment 5 Philipe Mulet CLA 2005-02-23 12:26:06 EST
Added optional compiler diagnosis to flag method overriding a superclass method,
but missing proper @Override annotation. Corresponding problem ID is:
IProblem.MissingOverrideAnnotation

* COMPILER / Reporting Missing @Override Annotation
*    When enabled, the compiler will issue an error or a warning whenever
encountering a method
*    declaration which overrides a superclass method but has no @Override
annotation.
*     - option id:       
"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation"
*     - possible values:   { "error", "warning", "ignore" }
*     - default:           "warning"                               
Comment 6 Philipe Mulet CLA 2005-02-23 13:02:00 EST
Any opinion whether this warning should be on by default ?
Comment 7 Tobias Widmer CLA 2005-02-23 13:10:15 EST
IMO, only few people use annotations at all. Even most 5.0 JDK rarely use 
@Override. I suggest to set this to ignore as default, even if the option can 
be very useful.
Comment 8 Jon Skeet CLA 2005-02-23 14:09:33 EST
Agreed. Unless the team already has the convention of using @Override, it would
create a lot of warnings almost all of which are spurious. I'm in the happy
situation of starting a new project with no existing code, but most other people
aren't!
Comment 9 Philipe Mulet CLA 2005-02-23 16:33:43 EST
sold
Comment 10 David Audel CLA 2005-03-31 09:26:57 EST
Verified in I20050330-0500