| By Nada daVeiga | Article Rating: |
|
| May 28, 2007 06:15 PM EDT | Reads: |
11,757 |
Running Flow Analysis
To better understand the
types of defects that flow analysis can expose, consider how it can be
applied to two sample Java classes. For our purposes, flow analysis
will be done with the BugDetective technology featured in Parasoft
Jtest.
One sample class involves a class instance field that can be null (Listing 1 - TestFields class) and the second one involves the same class with a local variable that can be null (Listing 2 - TestLocal class). Both classes call a LocalHelper class. The goal is to demonstrate how flow analysis handles (1) intra-procedural calls, and (2) inter-procedural calls (a) within one class and (b) that cross class boundaries.
Both of the examples (see below) contain instance field and local variable variations of the same defects. The methods named "falsePositive" contain false positives and the methods named "truePositive" contain true positives.
To do the flow analysis, I selected the two sample classes in my IDE (Eclipse) then ran a "BugDetective" Test Configuration. This flow analysis flagged the following defects in the two files (see Table 1).
All false positives are marked in blue and all true positives are marked in red. X indicates that a flow analysis violation wasn't reported in the method and indicates that a flow analysis violation was reported in that method.
Taking a closer look at the results, notice that no false positives were flagged in these examples. Also notice that Jtest's flow analysis found the defects in the truePositive3 method to be false positives even though other technologies may report them as true errors.
Consider the following code from the TestFields class:
Object x; //NPE origin
TestFields(Object x) {
this.x = x;
}
int truePositive3(boolean b) {
Object y = null;
if (x != null)
y = new Object();
if (y != null)
return x.hashCode() + y.hashCode();
else
return x.hashCode(); //NPE
}
The instance variable x is initially initialized to null, but it gets reassigned to the value of argument x in the constructor call.
This violation wasn't flagged during flow analysis because when simulating execution paths through the code, the flow analysis technology saw a potential violation point on the path (the line marked with //NPE) but it didn't see a path from the violation origin statement (the line marked with //NPE origin) to that line without going through a constructor. This wasn't reported as a violation because the flow analysis didn't find a line where x is initialized to null. The code didn't find a path in the source code that contains the following sequence of steps:
TestFields tf = new TestFields();
tf.truePositive3(true|false);
Nor did it find a path such as this:
TestFields tf = new TestFields(null);
tf.truePositive3(true|false);
However, assume that the following method is added to the TestFields class:
void callerTruePositive3() {
TestFields tf = new TestFields(null);
tf.truePositive3(true);
}
Flow analysis now flags this violation since it sees the violation origin and violation point, as well as a code path that leads from one to the other.
Conclusion
Flow analysis helps software
development teams find critical runtime bugs without executing code.
Since it tries to check whether potential problems could actually be
triggered by real application paths, it reports an extremely high ratio
of true positives to false positives. This means that you'll be alerted
to problems that are likely to occur at runtime - but you won't need to
waste time reviewing an overwhelming number of false positives. This is
especially helpful if you need a fast way to zero in on critical
defects in a large code base.
When flow analysis is applied as part of a comprehensive regression test suite, it helps development teams to:
• Increase team development productivity
by identifying and addressing defects from the earliest phases of the
development cycle - when fixing them requires minimal effort and rework.
• Achieve more with existing development resources by automatically vetting known coding issues so developers and QA can spend more time on tasks that require human intelligence.
• Build on the code base with confidence
by efficiently constructing, continuously executing, and maintaining a
comprehensive regression test suite that detects whether updates break
existing functionality.
• Decrease time to market
by building an efficient, consistent, and controlled team workflow for
applying best practices that reduce testing time, testing effort, and
the number of defects that reach QA.
• Reduce support costs
by automatically performing negative testing on a broad range of
potential user paths to uncover problems that might otherwise surface
only in "real-world" usage.
• Quickly expose problems in complex, difficult-to-test systems by automatically exposing many critical bugs in software for SOA and Java EE without involving staging systems.
Published May 28, 2007 Reads 11,757
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Nada daVeiga
Nada daVeiga is the Product Manager of Java Solutions at Parasoft, where she has been a senior member of Professional Services team for two years. Nada's background includes development of service-oriented architecture for integration of rich media applications such as Artesia Teams, IBM Content Manager, Stellent Content Server and Virage Video Logger. Nada developed J2EE enterprise applications and specialized in content transport frameworks using XML, JMS, SOAP, and JWSDP technologies. As a presales engineer, Nada worked with clients such as Cisco, Fidelity, HBO and Time Warner. Nada holds a bachelors degree in computer science from the University of California, Los Angeles (UCLA).
![]() |
blink4blog : kuala lumpur : malaysia 05/23/07 12:13:15 PM EDT | |||
Trackback Added: Flow Analysis: Static Analysis on Steroids; Flow Analysis: Static Analysis on Steroids - Building a robust regression suite is the best way to identify poorly implemented requirements, and performing negative testing is the best way to identify confused user errors. However, finding missing requirements is difficult because it's not clear what you're looking for. Flow analysis, which basically analyzes paths through the code without execut... |
||||
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?



































