javainterfaceannotations

What is a deprecated annotation target - implementation, interface or both?


I wonder, if I have to annotate a @Deprecated method at all their occurrences e.g: Interface, Base (Abstract Class) and all the Implementation Classes or is one annotation in the Interface sufficient?


Solution

  • Actually depends of how deprecated classes are used. Deprecate an interface (methods or attributes) is enough if you use good practices (instantiating the interface to use the implementation).

    Anyway,


    Resuming: if you want to deprecate a method implementation you must deprecate both, interface and implementation.

    SOURCES 1 2 3