| By S G Ganesh | Article Rating: |
|
| May 16, 2008 11:45 AM EDT | Reads: |
12,167 |
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,167
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.
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- Hot Event in Santa Clara Becomes Cool with the iPhone
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects
































