Information Technology Reference
In-Depth Information
Answering these questions was central in overcoming the limitations of earlier ver-
sion of the C ON G U tool. The chosen strategy consists in renaming to m Original each
method m that refines some operation (each method whose external calls we wish to in-
tercept), and placing in its lieu a method m with the exact same interface but dispatching
the call to a corresponding method in a property-monitoring class. Moreover, all calls
to m from within the class and inner classes are replaced by calls to m Original and all
calls to m in each superclasses are replaced also to calls by calls to m Original that are
also added to the superclasses. Although constructors are not methods, they can be for
the most part treated as such. Hence, the approach towards the interception of construc-
tor calls is identical to that employed for methods, with the safeguard that constructors
require initialisation calls, which are removed from the renamed method and inserted
in the replacement method.
More concretely, if m is a method of a class C that refines some operation, then the
bytecode instrumentation process involves the following steps:
1. Within C , rename method m to m Original ;
2. Still within C , replace invocations to m by invocations to m Original ;
3. In C 's superclasses, replace invocations to m by invocations to m Original and
generate a method m , with the signature of the original, which just forwards the
call to m Original ;
4. Generate a replacement for method m , with signature of the original, that calls the
respective method in the property-monitoring class:
congu.properties.CPMonitoring.m( this , ...);
5. Rename and generate a replacement for method equals ;if equals is not overrid-
den in C , first create a such method that delegates into the superclass;
6. Rename and generate a replacement for method clone ;if C does not implement
interface Cloneable or does not override method clone by making it public, a
clone_Original method is generated that simply returns this . This method is
for the exclusive use of the monitoring process.
Implementation of this bytecode-instrumentation approach resorts to the ASM Java
bytecode engineering library [6]. ASM is a lightweight and efficient, offering a very
simple, well-documented API, full support for Java 6 and an interesting open-source
license which allows for convenient packaging within the C ON G U 2 tool itself.
4.3
Generation of Property-Monitoring Classes
The checking of object properties described in subsection 3.2 is performed in classes
generated by the tool, which we call property-monitoring classes (or PM-classes, for
short). For each Java type C under monitoring, there is a corresponding PM-class,
named by appending the suffix PMonitoring to the name of C . In the instrumented
bytecode, the intercepted client method calls are dispatched to methods in the respective
PM-class.
Each method under monitoring has a counterpart in its respective PM-class, in the
form of a static method with the same name, the same return type, the same argument
 
Search WWH ::




Custom Search