http://pmd.sourceforge.net/
PMD scans Java source code and looks for potential problems like:
- Empty try/catch/finally/switch blocks
- Unused local variables, parameters and private methods
- Empty if/while statements
- Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
- Classes with high Cyclomatic Complexity measurements
http://www-900.ibm.com/developerworks/cn/java/j-pmd/index.shtml
http://www.onjava.com/pub/a/onjava/2003/02/12/static_analysis.html