Contracts for Java
Robert Bruce Findler
Dept. of Computer Science, Rice University
October 17, 2000
2 a.m.
Fuller Labs 311
Abstract
Increasingly, programs are compositions of off-the-shelf, black-box components. Practically, however, composing components is difficult because the composer cannot ensure that the components will interoperate properly. To ensure correct compositions, components should come with not only type signatures but also with contracts that describe other aspects of their behavior.
One way to express contracts is to state pre- and post- conditions for methods of externally visible classes. These pre- and post-conditions should then be validated during evaluation or possibly even as a prerequisite for composition. Further, when a contract is violated, the run-time system should identify the faulty component.
Behavioral contracts in the form of assertions are well-understood in first- order procedural languages. Their addition to class and interface hierarchies in object-oriented languages, however, raises many new and interesting questions. One complicating factor is that components can exchange objects which may trigger nested call-backs. Another problem is that a single object may simultaneously have to satisfy the contracts in multiple interfaces.
This talk explains how to add contracts to Java and demonstrates how other approaches to adding contracts to Java may misapply blame for contract violations.
Host:
Professor Dave Brown
Maintained by webmaster@wpi.eduLast modified: Sep 27, 2006, 16:05 EDT
