可以使用FindBugs标记使用已列入黑名单的方法的代码吗? [英] Can FindBugs be used to flag code that uses a method that's been blacklisted?
问题描述
我们正试图将非常庞大的代码库从Guava 11迁移到Guava 14,并希望抓住使用已删除或已弃用的API的方法. FindBugs可以执行这种检查吗?如果可以,怎么办?
We're trying to move our very large codebase from Guava 11 to Guava 14 and would like to catch uses of removed or deprecated APIs. Can FindBugs perform such checking? If so, how?
推荐答案
一种解决方案是仅使用Oracle的Java编译器javac
来做到这一点.
One solution would be to just use Oracle's Java compiler javac
to do this.
如果使用了API中已删除的方法,则会导致编译器错误,因此应该可以通过编译代码找到这些错误.
Removed methods in the API would result in compiler errors if they are used so it should be possible to find these by compiling the code.
可以使用javac -deprecation
选项找到不推荐使用的方法.有关-deprecation
的更多信息,请点击此处:
http://docs.oracle.com/javase/6 /docs/technotes/tools/windows/javac.html
Deprecated methods can be found using the javac -deprecation
option. More on -deprecation
here:
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
这篇关于可以使用FindBugs标记使用已列入黑名单的方法的代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!