如何抑制有关弃用api的javac警告

如何抑制有关弃用api的javac警告

本文介绍了如何抑制有关弃用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.

根据,-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警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:55