This weekend, I came across FindBugs, an interesting application that analyzes Java programs for potential bugs. It was created by William Pugh at the University of Maryland, who is a four-time JavaOne Rock Star. Google, for example, has used his tool for finding problems in their Java code.
FindBugs made plenty of suggestions for some code I’ve been working on, and some of them looked like things that I should fix. I found one thing in particular of interest. I’ve been using the following pattern for the lazy instantiation of singletons: