This work describes the design and implementation of runtime verification of OCL (Object Constraint Language) constraints in java programs. Therefore, the OCL compiler developed by Frank Finger [FF00] was extended into a java source code instrumentation tool.
Many different approaches for increasing software quality have been developed in the past. Few of them have experienced wide spread usage in industry. One of them is Structural Programming, another one is the Object Oriented Paradigm. And there is just another one, which convinces through its simpleness: Check Statements (or assertions in C++).
Suppose a method for removing all objects from a collection:
{
// some complex handling of
// hash tables or trees ...
}
{
// some complex handling of
// hash tables or trees ...
assert(size()==0)
}
Unfortunately, there is no assert statement in Java. A similar functionality could be achieved using exceptions, but there would be no possibility to globally disable assertions.
Furthermore, assertions are just a special case of a much more powerful concept: Design by Contract (DbC). A good introduction is given in [TP98]. In DbC the example assertion above is transformed into a postcondition of the method:
@postcondition: size()==0
*/
void clear()
{
// some complex handling of
// hash tables or trees ...
}
This work aims to extend the OCL compiler developed by Frank Finger with a java source code instrumentation tool. [FF00] section 3.6 already provides a list of requirements for such a tool. Additional attention is paid to java programs, where no UML class diagrams are available. The tool should be implemented to a sufficient extent. This includes maintance of the existing OCL compiler. For the java code provided by the industrial partner, net-linx AG, a small set of typical OCL constraints will be developed and experimented with.
Chapter lists work related to this paper, particularly software aiming for similar functionality. Chapters
and
present the design and implementation of the two major extensions of the OCL compiler developed in this paper: the java source code instrumentation and the completed model information for OCL. Chapter
reports experiences made using the tool on an industrial strength project. Chapter
summarizes the results of this work, while chapter
points out directions for future work.
Appendix lists all modifications of the OCL compiler made during this work. Appendix
contains a short manual of the software together with an illustrative example. Finally, some very detailed descriptions have been shifted into appendix
to keep the main text clear.
This work comes with a CD, containing a current snapshot of the developed software, an electronic version of this paper and software and literature referred to in this work, where available.