和其他已弃用的 Date 方法。所有这些方法在 JDK 1.1 中都已-6ren">
gpt4 book ai didi

java - 标记为 "deprecated"的 API 方法何时真正消失?

转载 作者:IT老高 更新时间:2023-10-28 21:21:27 26 4
gpt4 key购买 nike

我正在审查我的一位同事刚刚所做的更改,他添加了一堆对 Date.toMonth()Date.toYear() 的调用code> 和其他已弃用的 Date 方法。所有这些方法在 JDK 1.1 中都已弃用,但他坚持认为可以使用它们,因为它们还没有消失(我们正在使用 JDK 1.5),我说它们现在可能会消失,他应该使用日历方法。

Sun/Oracle 是否真的说过这些东西会消失,还是 @deprecated 只是意味着你失去了风格点?

最佳答案

关于 API,...没有指定它们将很快被删除。

Incompatibilities in J2SE 5.0 (since 1.4.2) :

源兼容性

[...]
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.

即使在其 How and When To Deprecate APIs 中,也没有提及关于实际删除已弃用 API 的政策...


10年后更新,新JDK9+ Enhanced Deprecation明确折旧政策。
请参阅 Jens Bannmannanswer 了解更多详情。
Vojtěch Růžičkacriticisms 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.

关于java - 标记为 "deprecated"的 API 方法何时真正消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/314540/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com