Can FindBugs be used to indicate code that uses a method that has been blacklisted?

We are trying to port our very large code base from Guava 11 to Guava 14 and would like to catch using remote or obsolete APIs. Can FindBugs do this check? If so, how?

+6
source share
3 answers

One solution would be to simply use the Oracle Java javac for this.

Remote methods in the API will lead to compiler errors if they are used, so they can be found by compiling the code.

Deprecated methods can be found using the javac -deprecation . More on -deprecation here: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html

+4
source

You can also use PMD Sourceforge for this task. There are rules to find outdated methods

+1
source

One aspect that I consider javac will not cover if you cannot modify third-party code to add @Deprecated annotations. If you just want to avoid a method that was not marked as deprecated, you can use this plugin that I wrote for FindBugs:

https://github.com/Grundlefleck/FindBugs4Deprecating3rdParty

There is very little documentation, so you may need to study yourself a little. This avoids settings and classes in the properties file. I use it to refuse org.junit.Assert.assertThat .

+1
source

All Articles