如何抑制有关已弃用 api 的 javac 警告? [英] How can I suppress javac warnings about deprecated api?

查看:31
本文介绍了如何抑制有关已弃用 api 的 javac 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译时,javac 输出:

When I compile, javac outputs:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.`

我希望取消此警告.尝试 -Xlint:none 似乎没有帮助.

I wish to suppress this warning. Trying -Xlint:none does not seem to help.

推荐答案

根据我在文档中的说法,您无法在命令行上执行此操作.

From what I can tell in the docs, you can't do it on the command-line.

根据javac 文档,-Xlint:none 仅禁用Java 语言规范未强制要求"的警告.语言规范似乎对您使用已弃用 API 的警告进行了管理.

According to the javac documentation, -Xlint:none only disables warnings "not mandated by the Java Language Specification". It appears that warning you of the use of deprecated APIs is managed by the language spec.

您最好的选择是修复已弃用的 API 的使用.但是,一个选项是将 @SuppressWarnings("deprecation") 注释添加到使用已弃用 API 的类或方法中.

Your best option would be to fix the use of deprecated APIs. However, an option would be to add the @SuppressWarnings("deprecation") annotation to the classes or methods that are using the deprecated APIs.

这篇关于如何抑制有关已弃用 api 的 javac 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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