ezContract: Using Marker Library and Bytecode Instrumentation to Support Design by Contract in Java

Several approaches have been proposed to support Design by Contract in Java. In this paper, through the use of markers which are predefined dummy methods and attributes, a new approach to annotate contracts is presented. The annotated programs can be directly compiled by standard Java compilers. A bytecode instrumentor is developed to manipulate the bytecode to inject contract evaluation instructions and make the contracts executable at runtime. The marker approach avoids two primary problems found in the existing practices: source compatibility that depends on language extension and symbolic barrier that leaves contracts and their targets unrelated. It also facilitates streamlined integration with IDEs and improves readability as well as writability of the contract- annotated programs.