|Authors||L. Briand, J. W. Dzidek and Y. Labiche|
|Title||Using Aspect-Oriented Programming to Instrument OCL Contracts in Java|
|Publication Type||Technical reports|
|Year of Publication||2004|
Analysis and design by contract allows the definitions of a formal agreement between a class and its clients, expressing each party's rights and obligations. Contracts written in the Object-Constraint Language (OCL) are known to be a useful technique to specify the precondition and postcondition of operations and class invariants in a UML context, making the definition of object-oriented analysis or design elements more precise. In this report, we introduce the ocl2j approach to automatically instrument OCL constraints in Java programs using aspect-oriented programming (AOP). One of the many possible applications of checking contract assertions at run time is to help testing and debugging. The approach strives for automatic, efficient generation of contract code and a nonintrusive instrumentation technique. It is assessed on a case study and initial results show that the approach is viable. We conclude by discussing strategies to optimize instrumentation so as to further decrease overhead.