Search code examples
javadate

When are API methods marked "deprecated" actually going to go away?


I'm code reviewing a change one of my co-workers just did, and he added a bunch of calls to Date.toMonth(), Date.toYear() and other deprecated Date methods. All these methods were deprecated in JDK 1.1, but he insists that it's ok to use them because they haven't gone away yet (we're using JDK 1.5) and I'm saying they might go away any day now and he should use Calendar methods.

Has Sun/Oracle actually said when these things are going away, or does @deprecated just mean you lose style points?


Solution

  • Regarding the APIs, ... it is not specified they will be removed anytime soon.

    Incompatibilities in J2SE 5.0 (since 1.4.2):

    Source Compatibility

    [...]
    In general, the policy is as follows, except for any incompatibilities listed further below:

    Deprecated APIs are interfaces that are supported only for backwards compatibility. The javac compiler generates a warning message whenever one of these is used, unless the -nowarn command-line option is used. It is recommended that programs be modified to eliminate the use of deprecated APIs, though there are no current plans to remove such APIs – with the exception of JVMDI and JVMPI – entirely from the system.

    Even in its How and When To Deprecate APIs, nothing is being said about a policy regarding actually removing the deprected APIs...


    Update 10 years later, the new JDK9+ Enhanced Deprecation clarifies the depreciation policy.
    See Jens Bannmann's answer for more details.
    This is also detailed in this blog post by Vojtěch Růžička, following criticisms on JEP 277.

    The convention for JDK is that once a JDK API is marked as forRemoval=true in a certain Java version, it will be removed in the directly following major Java release.
    That means - when something is marked as forRemoval=true in Java 9, it is supposed to be completely removed in Java 10.
    Keep that in mind when using API marked for removal.

    Note that this convention applies only to JDK itself and third-party libraries are free to choose any convention they see fit.