| By S G Ganesh | Article Rating: |
|
| May 16, 2008 11:45 AM EDT | Reads: |
12,116 |
Alternatively, we can consider using non-blocking locks when we attempt to acquire multiple locks. The tryLock method in the java.util.concurrent.locks.Lock interface provides this ability. It’s also recommended to release locks quickly and not hold the locks for a long time; so, it’s not recommended to use sleep/wait methods after acquiring a lock; consider using the wait/notify mechanism instead to avoid deadlocks because of holding a lock for a long time waiting for a condition to occur.
The QJ-Pro tool checks for problems like conformance to coding standards, coding best practices, misuse of features, and APIs. It gives lots of violations by default, so you’d have to spend some time selecting the list of rules you want to run for your project. It works on Java source files and is easy-to-use in its standalone GUI version (shown in Figure 5). You can use its plug-ins with popular IDEs like Eclipse, JBuilder, and JDeveloper or use it as an Ant job. You can get QJ-Pro from http://qjpro.sourceforge.net/.
Other Tools
In addition to the four tools covered here – Jlint, FindBugs,
PMD, and QJ-Pro – there are many other FOSS tools available. For example,
CheckStyle checks for adherence to coding standards such as Sun’s. You can get
it from http://checkstyle.sourceforge.net/. JCSC (Java Coding Style Checker)
checks for coding style adherence and for common bugs. You can get it at http://jcsc.sourceforge.net/.
There are many more useful tools like Classycle, Condenser, DoctorJ, and
JarAnalyzer. More information and links on Java tools is provided in the
Resource section.
Conclusion
We discussed four specific static analysis tools that
can be used to detect not-so-common defects in code. They are free,
easy-to-integrate with IDEs, and easy-to-use. It’s highly recommended to use
such tools to improve the quality of the software by detecting and fixing bugs
early in the software life cycle.
Resources
- If you’re interested in a list of the available Java FOSS static analysis tools, see http://java-source.net/open-source/code-analyzers.
- “A Comparison of Bug Finding Tools for Java” by Nick Rutar, Christian B. Almazan, and Jeffrey S. Foster from the University of Maryland provides a detailed technical comparison of Bandera, ESC/Java, FindBugs, JLint and PMD tools. See http://www.cs.umd.edu/~jfoster/papers/issre04.pdf.
- If you’re using Eclipse, it’s very convenient to use Java tools as plug-ins. Here's the list of available plug-ins for Java.
- The book Java Puzzlers: Traps, Pitfalls, and Corner Cases by Joshua Bloch and Neal Gafter covers many interesting bugs that can occur in code. Check the link http://www.javapuzzlers.com/.
References
1. Here the word “uncommon” means the kind of defects we
talk about are not defects due to usual programming problems like null-pointer
access or incorrect casts. The defects we are going to cover are little unusual
in that they don’t generally occur in programs, at least, they don’t occur everyday when we program.
2. To err is human: it is only that novices make more mistakes, but experts know common pitfalls, so they write code with fewer defects.
Published May 16, 2008 Reads 12,116
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By S G Ganesh
S G Ganesh is a research engineer in Siemens (Corporate Technology), Bangalore. Prior to Siemens, he worked in Hewlett-Packard for around five years. His area of interest is programming languages and compilers. His latest book is "60 Tips on Object Oriented Programming" (ISBN-13 978-0-07-065670-3) published by Tata McGraw-Hill, New Delhi.
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX




































