Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Find the Java Bugs That Pose a Threat with FindBugs

FindBugs enables you to isolate and correct dangerous Java bugs. Its unique features separate it from the many static analysis tools in the Java world. Find out what makes FindBugs so special.


advertisement
indBugs is an open-source static analysis tool designed to find bugs in your Java code. Unlike many other static analysis tools, however, FindBugs concentrates almost exclusively on isolating potentially dangerous coding errors that could break your application. This powerful tool can find subtle yet dangerous bugs that other static analysis tools will not detect.

FindBugs works by searching compiled Java bytecode for what it calls "bug patterns." Simply put, a bug pattern is a coding practice that often leads to bugs. Bug patterns are based on the observation that people tend to reproduce the same errors, both individually and collectively. Humans are creatures of habit, and habits tend to persist—even harmful ones. Inexperienced developers often make the same mistakes that more experienced developers were making when they were newbies. So, unless a conscious effort is made to identify and correct a poor programming habit, it will raise its head again and again. In particular, trickier parts of the Java language APIs can lead to common mistakes.

FindBugs comes with over 300 bug patterns (336 in FindBugs 1.3.4), organized in different bug categories, such as "Malicious Code," "Bad Practice," and "Performance." Each bug also has a priority rating (high, medium, and low). You can use this rating system to prioritize your bug-correction activities. The FindBugs team recommends treating both high- and medium-priority issues seriously.



In addition to isolating the most dangerous of these poor coding habits and mistakes, FindBugs also explains in great detail what is wrong with the code. This feature makes FindBugs not only an effective bug detector but also an excellent learning tool: it can help hone a team's programming skills and help individual developers avoid similar mistakes in the future.

Coding standards are generally recognized as a good thing, and any tool that helps you enforce your organization's own coding conventions is certainly worthwhile. While many coding best practices focus on making your code more readable and easier to maintain, FindBugs has a very different focus: finding nasty bugs and subtle errors that will crash your application, often at the worst possible time.

This article briefly introduces FindBugs, showing in particular how to use it in Eclipse, and then demonstrates its features with a few examples.

What You Need
Java 5
Lots of memory (at least 512MB are recommended)



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap