问题描述
当我使用 JDK 1.7.0 在 OS X 上编译 Spring JDBC 源代码时,我收到此警告:
When I compile the Spring JDBC source on OS X with JDK 1.7.0, I get this warning:
warning: CachedRowSetImpl is internal proprietary API and may be removed in a future release
如何在编译期间抑制警告消息?
How do I suppress the warning message during a compile?
我已经知道并使用了 Java 的 @SuppressWarning 注释.我正在寻找它的具体用途来抑制我所描述的警告.
I already know and use Java's @SuppressWarning annotations. I'm looking for the specific use of this to suppress the warning I've described.
我的问题是,在这行代码中:
My question specifically is, in this line of code:
@SuppressWarnings("valuegoeshere")
valuegoeshere"应该替换成什么?
what should "valuegoeshere" be replaced with?
人们,我知道最好避免导致警告的代码.通常这就是我的方法.但是,我正在此处编译我不想重写的第三方代码.我只是想添加正确的注释来抑制警告,这样我实际上可以做些什么的警告就不会被埋没.
People, I know that it is best to avoid the code that leads to the warning. And usually that would be my approach. However I'm compiling third-party code here which I don't want to rewrite. I just want to add the correct annotation to suppress the warning, so that warnings I can actually do something about don't get buried.
推荐答案
这个特别警告 无法抑制.至少不是正式的.
This particular warning cannot be suppressed. At least not officially.
关于专有 API 的警告意味着您不应该使用导致警告的 API.太阳不支持此类 API 和警告将不会被抑制.
如果你特别确定,你可以使用高度未公开的javac -XDignore.symbol.file
标志,它将针对 Sun 的内部 rt.jar
而不是面向公众的符号文件 ct.sym
编译您的程序.rt.jar
不会产生此警告.
If you're particularly determined, you can use the highly undocumented javac -XDignore.symbol.file
flag which will compile your program against Sun's internal rt.jar
rather than the public-facing symbol file ct.sym
. rt.jar
doesn't produce this warning.
这篇关于禁止 javac 警告“...是内部专有 API,可能会在未来版本中删除";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!