Supporting Design by Contract in Java

Martin Lackner and Andreas Krall and Franz Puntigam

Decision Management Systems
Wallnerstr. 2
A-1010 Wien, Austria

Institut für Computersprachen
Technische Universität Wien
Argentinierstraße 8
A-1040 Wien, Austria

Abstract

Design by Contract is a valuable design method for trusted software components. Eiffel shows how to provide appropriate language support for it. However, no such concepts currently exist in Java. Full integration of them into Java may help to improve and guarantee the quality of Java classes. We briefly compare several approaches to extend Java in this way and present our model and a compiler that translates extended Java code into JVM byte code. Our Java extension integrates preconditions, postconditions, and invariants as in Eiffel while respecting the characteristics of Java. The evaluation shows that Design by Contract can be added effciently to Java while keeping compatibility.