Similar to other static code analysis tools (e.g. PMD), it has a number of categories of various code issues, ranging from dodgy practices and bad form, to downright errors (null pointer deferences, anyone?). I wholeheartedly recommend running it on your code on a regular basis, and want to present below one example recently of where it helped me.
See anything wrong with the following?
new Thread( new Runnable(){public void run() {// long running code in a separate thread... or is it?}}).run();
This defect was sprinkled in various places throughout our 650+ class codebase. FindBugs quickly found the issue, providing the following helpful advice:
M M Ru] Invokes run on a thread (did you mean to start it instead?) [RU_INVOKE_RUN]This method explicitly invokes
run()
on an object. In general, classes implement theRunnable
interface because they are going to have theirrun()
method invoked in a new thread, in which caseThread.start()
is the right method to call.
Think of FindBugs as your fine-toothed comb; it instantly spotted a number of places in our application where we thought we were dumping long-running processes into separate threads, but in actualality were simply running them in the same.