Databases Reference
In-Depth Information
dle line is optional. Unfortunately, this pattern only exhibits itself at runtime
on certain platforms, so we were unable to confirm it dynamically.
Another similar JNI wrapper found in Eclipse that can be expressed as a
state machine is responsible for region-based memory allocation and can be
described with the following regular expression:
(
OS
:
NewPtr
j
OS
:
NewPtrClear
)
OS
:
DisposePtr
Either one of functions
NewPtr
and
NewPtrClear
can be used to create a new
pointer; the latter function zeroes-out the memory region before returning.
Another commonly used pattern that can be captured with a state ma-
chine has to do with hierarchical allocation of resources. Objects request and
release system resources in a way that is perfectly nested. For instance, one of
the patterns we found in Eclipse suggests the following resource management
scheme on objects of type component:
o
:
createHandle
()
o
:
register
()
o
:
deregister
()
o
:
releaseHandle
()
The call to
createHandle
requests an operating system resource for a GUI
widget, such as a window or a button;
releaseHandle
frees this OS re-
source for subsequent use.
register
associates the current GUI object with
a
display
data structure, which is responsible for forwarding GUI events to
components as they arrive;
deregister
breaks this link.
7.5.2.3
More Complex Patterns
More complicated patterns, that are concerned with the behavior of more
than one object or patterns for which a finite state machine is not expressive
enough, are quite widespread in the code base we have considered as well.
Notice that approaches that use a restrictive model of a pattern, such as
matching function calls [15], would not be able to find these complex patterns.
Due to space restrictions, we only describe one complex pattern in detail
here, which is motivated by the code snippet in Figure 7.4. The lines rele-
vant to the pattern are highlighted in bold. Object
workspace
is a runtime
representation of an Eclipse workspace, a large complex object that has a spe-
cialized transaction scheme for when it needs to be modified. In particular,
one is supposed to start the transaction that requires workspace access with
a call to
beginOperation
and finish it with
endOperation
.
Calls to
beginUnprotected
() and
endUnprotected
() on a
WorkManager
object obtained from the
workspace
indicate \unlocked" operations on the
workspace: The first one releases the workspace lock that is held by de-
fault and the second one re-acquires it; the
WorkManager
is obtained for
a
workspace
by calling
workspace
:
getWorkManager
. Unlocking operations
should be precisely matched if no error occurs; in case an exception is raised,
Search WWH ::
Custom Search