Databases Reference
In-Depth Information
These collected code examples include necessary information for mining API
usage specifications. The search phase also includes additional techniques for
addressing the challenges faced while collecting code examples via code search
engine. The analyze phase analyzes collected code examples to extract relevant
SE data such as static method-call sequences.
The mine phase transforms extracted SE data into a format suitable for
applying a mining algorithm. For example, the mine phase replaces each dis-
tinct method call in method-call sequences with a unique symbol. Based on
requirements of the SE task, the mine phase either uses an existing off-the-
shelf mining algorithm such as frequent itemset mining [7] or produces a new
mining algorithm developed based on the requirements unique to the SE task.
The apply phase transforms results of mining algorithm into a format
required to achieve the SE task. For example, the apply phase replaces each
symbol in the results with its corresponding method call. The apply phase next
uses mining results for achieving the SE task. For example, the apply phase
detects defects in API client code by using a static-verification tool with mined
API specifications. Among these four phases, the search phase is independent
of target SE task, whereas the remaining phases are specific to the target SE
task. In this chapter, we use an SE task, described next, as an example task
for describing our life-cycle model. We next explain each phase in detail.
10.3 Example SE Task: Detecting Exception-Handling
Defects
Programming languages such as Java and C# provide exception-handling
constructs such as try-catch to handle exception conditions that arise during
program execution. Under these exception conditions, programs follow paths
different from normal execution paths; these additional paths are referred to
as exception paths. Applications developed based on these programming lan-
guages are expected to handle these exception conditions and take necessary
recovery actions. For example, when an application reuses resources such as
files or database connections, the application should release the resources after
the usage in all paths including exception paths. Failing to release the resources
can cause performance degradation, but can also lead to critical issues. For
example, consider the code example shown in Figure 10.3. In Statement 9, the
method call executeUpdate acquires a database lock before updating the con-
tents of the database. This lock can be released either by the commit method
call (Statement 10) or by the rollback method call (Statement 12). Consider
that the rollback method call is not invoked in Statement 12. In this sce-
nario, if SQLException is raised while updating the contents of the database,
the database lock is not released and any other process trying to acquire the
same lock hangs till the database releases the lock after timeout. We refer to
 
Search WWH ::




Custom Search