1

I was wondering why some methods and classes are marked @Deprecated when they work perfectly fine. What are the technical reasons for why one shouldn't use methods marked @Deprecated?

Why should I use something else when they work fine?

If there's no better alternative or no alternative at all (which is the case for some methods and classes), and I use them what are some common performance issues with @Deprecated methods and/or classes?

If I use a Deprecated method will it stop working over time (even if I don't change by JDK)?

Coder
  • 1,175
  • 1
  • 12
  • 32
  • 2
    Typically a method or class is deprecated for a number of reasons, sometimes because a better method or class has been created to replace it. This can happen for lots of reasons, performance, security, (bad) design choices - While unlikely in the core APIs, it's also possible for the API developers to remove those APIs in future releases – MadProgrammer Oct 02 '17 at 05:57
  • 1
    There is no universal "technical reason". You need to read the comments to understand why the method has been deprecated .. and research whether it is likely to be removed. Also note that different API designers have different approaches to deprecation and removal. It is worth bearing this in mind when choosing an API. – Stephen C Oct 02 '17 at 05:59

1 Answers1

9

There are three good reasons to deprecate an API, according to Java documentation:

  • It is insecure, buggy, or highly inefficient
  • It is going away in a future release
  • It encourages bad coding practices

I would expect a comment in the Javadoc to explain which of the three is applicable for the deprecated concerned, and without knowing which API you're referring to, I cannot get more specific than that.

Joe C
  • 15,324
  • 8
  • 38
  • 50
  • Cool, thanks for explaining it. If there's a chance that it may go away in a future release of Java, I guess I'll have to program my program a different way – Coder Oct 02 '17 at 05:59