Both NetBeans IDE and Eclipse JDT projects have significant Java code analysis / generation logic. I donβt know what their dependencies are (i.e. you can use them as stand-alone libraries), but, besides this, I would look at these two pretty well: it is unlikely that there will be a library for analyzing java code with more intensive development and more updated .
Update:
PMD may be of interest, as well as:
PMD scans the Java source code and looks for potential problems like:
* Possible bugs - empty try/catch/finally/switch statements * Dead code - unused local variables, parameters and private methods * Suboptimal code - wasteful String/StringBuffer usage * Overcomplicated expressions - unnecessary if statements, for loops that could be while loops * Duplicate code - copied/pasted code means copied/pasted bugs
In addition, this blog article discusses various static code analysis tools.
Tomislav nakic-alfirevic
source share