| By S G Ganesh | Article Rating: |
|
| May 16, 2008 11:45 AM EDT | Reads: |
12,150 |
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,150
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.
- IBM Puts Systems Chief on Leave of Absence
- Amazon Web Services Database in the Cloud
- SpringSource Moving to Spring 3.0
- Virtualization Expo Call for Papers Deadline December 15
- Move Over BI, Here Comes PI - Performance Intelligence
- Using Ext JS, Servlets, JSON, MySQL and Tomcat on Fedora
- Qt DevDays 2009 - Munich
- Developing APIs for the Cloud
- Canonical Offers Free Cloudware
- New-Generation Virtualization Technologies with Ultra Low-Cost Endpoints
- The Planet Executive to Speak at Cloud Computing Conference
- Trusting the Cloud
- Oracle-Sun: IBM Reportedly Behind Delay
- The Case for Single-Purpose Services
- IBM Puts Systems Chief on Leave of Absence
- Cloud BI & Amazon VPC
- Cloud-Oriented Switch Start-up Valued at $230M
- The Curious Case of Build Release Management eBook
- Amazon Web Services Database in the Cloud
- Tips for Efficient PaaS Application Design
- Reporting Solutions Using Crystal Reports for Eclipse
- SpringSource Moving to Spring 3.0
- Virtualization Expo Call for Papers Deadline December 15
- Un-Clouding Federal Security Compliance
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- Creating Web Applications with the Eclipse Web Tools Project
- Eclipse Special: Remote Debugging Tomcat & JBoss Apps with Eclipse
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- How to Bring Eclipse 3.1, J2SE 5.0, and Tomcat 5.0 Together
- SYS-CON Webcast: Eclipse IDE for Students, Useful Eclipse Tips & Tricks
- Eclipse: The Story of Web Tools Platform 0.7
- "Eclipse 3.0 is a Great Leap Forward," Says JDJ's Dudney
- Developing an Eclipse BIRT Report Item Extension
- The Top 250 Players in the Cloud Computing Ecosystem




























