It's clear that having @Override
annotation on overriding methods is a good practice. Is there an automatic way of finding all methods that miss the @Override
annotation in a project? A script, search technique in any IDE would help
Asked
Active
Viewed 2,282 times
6

Boris Pavlović
- 63,078
- 28
- 122
- 148
-
Take a look at this thread: http://stackoverflow.com/questions/224945/add-warning-for-missing-override-annotation-for-interface-implementation-in-ecli – Luciano Fiandesio Feb 11 '11 at 09:27
-
You could always write a tool to manually inspect the .class files. :-) – templatetypedef Feb 11 '11 at 09:27
3 Answers
6
Eclipse shows warnings if you are missing @Override
. You can go to:
Window > Preferences > Java > Compiler > Errors/Warnings > Annotations
You can choose to have warning or even error for "Missing @Override
annotation".

Bozho
- 588,226
- 146
- 1,060
- 1,140
5
In IntelliJ IDEA open Settings CtrlAltS in Inspections open Class Structure -> 'Missing @Override annotation'
For version 15.0.3 and newer: Editor > Inspections > Java > Inheritance Issues > Missing @ Override (via @skubski)

Boris Pavlović
- 63,078
- 28
- 122
- 148
-
1This now is under Editor > Inspections > Java > Inheritance Issues > Missing @ Override (Using IJ 15.0.3) – skubski Mar 03 '16 at 12:49
4
In Netbeans, right click the project, select Inspect and Transform, select "Add @Override Annotation" from the Single Inspection combo-box, hit Inspect, then Refactor.

kazmer
- 501
- 4
- 12