Databases Reference
In-Depth Information
An example of state machine usage comes from class Scribe from the pack-
age org : eclipse : jdt : internal : formatter in Eclipse responsible for pretty-
printing Java source code. Method exitAlignment is supposed to match
an earlier enterAlignment call to preserve consistency. Typically, method
redoAlignment that tries to resolve an exception caused by the current
enterAlignment would be placed in a catch block and executed optionally,
only if an exception is raised. The regular expression
o : enterAlignmento : redoAlignment ? o : exitAlignment
summarizes how methods of this class are supposed to be called on an object
o of type Scribe . In our dynamic experiments, the pattern matched 885 times
with only 17 dynamic violations that correspond to 9 static violations, which
makes this an excellent usage pattern.
Another interesting state machine below is found based on mining jEdit.
Methods beginCompoundEdit and endCompoundEdit are used to group editing
operations on a text buffer together so that undo or redo actions can be later
applied to them at once.
o : beginCompoundEdit ()
( o : insert (:::) j o : remove (:::)) +
o : endCompoundEdit ()
A dynamic study of this pattern reveals that (1) methods beginCompoundEdit
and endCompoundEdit are perfectly matched in all cases; (2) 86% of calls to
insert / remove are within a compound edit; (3) there are three cases of several
h begin , endCompoundEdit i pairs that have no insert or remove operations
between them. Since a compound edit is established for a reason, this shows
that our regular expression most likely does not fully describe the life-cycle
of a Buffer object. Indeed, a detailed study of the code reveals some other
methods that may be used within a compound edit. Subsequently adding these
methods to the pattern and re-instrumenting the jEdit led to a new pattern
that fully describes the Buffer object's life-cycle.
Precisely following the order in which methods must be invoked is com-
mon for C interfaces [14], as represented by functions that manipulate files and
sockets. While such dependency on call order is less common in Java, it still oc-
curs in programs that have low-level access to OS data structures. For instance,
methods PmMemCreateMC , PmMemFlush , and PmMemStop , PmMemReleaseMC de-
clared in org : eclipse : swt : OS in Eclipse expose low-level memory context
management routines in Java through the use of JNI wrappers. These meth-
ods are supposed to be called in an order described by the regular expression
below:
OS : PmMemCreateMC
( OS : PmMemStartOS : PmMemFlushOS : PmMemStop )?
OS : PmMemReleaseMC
The first and last lines are mandatory when using this pattern, while the mid-
 
Search WWH ::




Custom Search