FindBugs 1.3.5: great new stuff
FindBugs 1.3.5 has been released yesterday. FindBugs is a static analysis tool that automatically finds common bugs in compiled Java code. It's open source, easy to set up and usually reports "real" potential issues in code. Most people I know who first see FindBugs in action love it: free extra feedback just after creating the code, without any extra effort from the developer (no tests, manual reviews), and these are sometimes real nasty bugs.
FindBugs 1.3.5 adds some great new stuff into the mix. First of the all, the FindBugs Eclipse plug-in has got some updates to make it behave better in a large codebase. Previously, working on lots of code meant disabling the automatic features or else face endless waiting. In 1.3.5, the plug-in can only re-check the changed files in automatic mode, giving instant feedback without having the risk of long waiting periods. This is fantastic, as we can now finally enable the automatic mode in my current project, instead of the manual check that usually was run only after the FindBugs analysis on the build server reported extra bugs.
Additionally, FindBugs adds some extra support for JSR-305: Annotations for Software Defect Detection. Basically, these annotations allow you to add extra information about the behavior of your code, like @NonNull if no null value is allowed. Tools like FindBugs can use these annotations to perform extra checks. Consider the following simple example:
It's also great for documentation purpose as they provide readable and concrete info, and FindBugs can also find discrepancies between the annotations and the behavior of the actual code. In this case, FindBugs detects that either the annotation is incorrectly specifying that sayHello should not return null, or that the code itself is incorrect:
Please note that FindBugs does not need annotations for most of its checks, see the docs and this FindBugs presentation for more information. The JSR 305 annotations are just an extra addition that allow you to manually add extra information for static analysis tools to do their work. In Java 7, annotations like these will be even more powerful and flexible, allowing even more bugs to be found early and without effort. Prepare your code for the future and start using them!