抑制javac警告“......是内部专有API,可能会在将来的版本中删除” [英] Suppress javac warning "...is internal proprietary API and may be removed in a future release"

查看:923
本文介绍了抑制javac警告“......是内部专有API,可能会在将来的版本中删除”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用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的警告意味着你不应该使用引发警告的
。 Sun不支持
这样的API并且警告不会被禁止。

The warning about proprietary API means that you should not use the API which causes the warning. Sun does not support such API and the warning will not be suppressible.

如果你特别坚定,你可以使用高度未记录的 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,可能会在将来的版本中删除”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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