API方法何时标记为“已弃用”其实要走了? [英] When are API methods marked "deprecated" actually going to go away?

查看:416
本文介绍了API方法何时标记为“已弃用”其实要走了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在检查一个刚刚做过的同事的代码,他添加了一些对Date.toMonth(),Date.toYear()和其他不推荐使用的Date方法的调用。所有这些方法在JDK 1.1中已被弃用,但他坚持认为可以使用它们,因为它们还没有消失(我们使用的是JDK 1.5),我现在说他们可能会走了,他应该使用日历方法。有没有太太真的说这些东西要走了,还是@deprecated只是意味着你失去了风格点?

解决方案

关于API,...没有指定他们很快就会被删除。



J2SE 5.0中不兼容(自1.4.2起)



源兼容性


[...]

一般来说,除了下面进一步列出的任何不兼容之外,策略如下:



不推荐使用的API是只支持向后兼容性的接口。除非使用-nowarn命令行选项,否则javac编译器将在其中一个使用时生成警告消息。建议对程序进行修改,以消除使用不推荐使用的API,虽然目前没有计划删除这样的API - 除了JVMDI和JVMPI - 完全来自系统。


即使在如何以及何时弃用API ,关于实际删除已删除的API ...


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 actually said when these things are going away, or does "@deprecated" just mean you lose style points?

解决方案

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

这篇关于API方法何时标记为“已弃用”其实要走了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆