Java 中不推荐使用的项目是否会被删除

发布于 2024-12-16 14:11:40 字数 80 浏览 3 评论 0原文

我们知道 Java 中有几个已弃用的项目。

他们会被移除吗? 是否已从 Java 中删除了任何已弃用的项目?

We know that there are several deprecated items in Java.

Will they be removed?
Have any deprecated items ever been removed from Java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟雨凡馨 2024-12-23 14:11:40

它们会被删除吗?

不太可能,因为 java 一直致力于保持向后兼容性,但它有可能发生。我认为弃用是一个警告,表明该 API 要么不可靠,要么存在严重缺陷。
Thread 有其中几个)。

过去不推荐使用的项目是否已从 java 中删除?

AFAIC 未删除,但从未实现 Thread.destroy(),因为它与其他几个 Thread 方法本质上是不安全的。

Will they be removed?

Unlikely since java has always been about maintaining backward compability, but it can happen. I see deprecations as a warning that the API is either unreliable or somehow seriously flawed.
(Thread has several of these).

Has any of the deprecated items in the past has been removed from java?

AFAIC not removed but never implemented Thread.destroy(), as it was along with several other Thread methods inherently unsafe.

临风闻羌笛 2024-12-23 14:11:40

其他地方已提出此问题

坦率地说,Java 团队通常所做的就是弃用该方法并将其实现删除为建议的方法。不推荐使用的方法只是一个未实现的方法。

This question has been asked elsewhere.

Quite frankly, what the Java team usually do, is to deprecate the method and remove its implementation to the suggested method instead. The deprecated method is just an unimplemented method.

机场等船 2024-12-23 14:11:40

根据文档此处。

可以看到它说

不鼓励程序员使用带有 @Deprecated 注释的程序元素,通常是因为它很危险,或者因为存在更好的替代方案。

因此,已弃用的方法或类基本上是不鼓励使用的旧方法或类,因为有更新的更合乎逻辑的方法来执行该操作。

这些方法会被删除吗?

可能不会。它将继续像弃用之前一样工作,您只需处理讨厌的警告即可。为了保持未更新的旧程序仍然正确运行,几乎所有已弃用的类和方法都不会仅仅因为这个原因而被删除。

已弃用的 API 是仅支持向后兼容的接口。只要使用其中之一,javac 编译器就会生成警告消息,除非使用 -nowarn 命令行选项。建议修改程序以消除已弃用 API 的使用,但目前没有计划从系统中完全删除此类 API(JVMDI 和 JVMPI 除外)。

是否删除了任何已弃用的项目?

在 java.* 类中,没有。 javax.* 类中发生了一些更改,但在常规 java 中从未删除过时的方法或类。

According to the documentation here.

You can see that it says

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

So a deprecated method or class is basically a older method or class that is discouraged from being used as there are newer more logical ways to perform that action.

Will these methods ever be removed?

Probably not. It will continue to work as before the deprecation, you just have to deal with the pesky warning. In order to keep older programs still running correctly that aren't being updated, almost all deprecated classes and methods won't be removed solely for that reason.

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.

Have any deprecated items been removed?

In the java.* class, no. There have been a few changes in the javax.* class but in regular java there has never been a deprecated method or class removed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文