| By S G Ganesh | Article Rating: |
|
| May 16, 2008 11:45 AM EDT | Reads: |
12,146 |
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,146
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.
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF




























