FindBugs,
http://findbugs.sourceforge.net/
发现代码中潜在bug的工具,有eclipse的插件,安装后右键单击java project name,点击Find Bugs,切换到FindBugs得perspective可以看到结果,速度还比较快,比之前用过的一个(虽然已经记不得名字了)快一些~具体的效果还是要逐个分析。
Bug categories:
- Correctness bug
- Probable bug - an apparent coding mistake
resulting in code that was probably not what the
developer intended. We strive for a low false positive rate.
- Bad Practice
-
Violations of recommended and essential
coding practice. Examples include hash code and equals
problems, cloneable idiom, dropped exceptions,
serializable problems, and misuse of finalize.
We strive to make this analysis accurate,
although some groups may
not care about some of the bad practices.
- Dodgy
-
Code that is confusing, anomalous, or
written in a way that leads itself to errors.
Examples include dead local stores, switch fall through,
unconfirmed casts, and redundant null check of value
known to be null.
More false positives accepted.
In previous versions of FindBugs, this category was known as Style.
Multithreaded correctness
Incorrect lazy initialization and update of static field
Calls Thread.sleep() with a lock held: better to use wait(lock)
Synchronization on interned String could deadlock: 最好不用字符串,以免重复
Performance
invokes inefficient new String() constructor
concatenates strings using + in a loop: better to use append StringBuffer
inner class usage