Chapter

ECOOP 2004 – Object-Oriented Programming

Volume 3086 of the series Lecture Notes in Computer Science pp 491-515

Object Invariants in Dynamic Contexts

  • K. Rustan M. LeinoAffiliated withMicrosoft Research
  • , Peter MüllerAffiliated withETH Zurich

* Final gross prices may vary according to local VAT.

Get Access

Abstract

Object invariants describe the consistency of object-oriented data structures and are central to reasoning about the correctness of object-oriented software. Yet, reasoning about object invariants in the presence of object references, methods, and subclassing is difficult. This paper describes a methodology for specifying and verifying object-oriented programs, using object invariants to specify the consistency of data and using ownership to organize objects into contexts. The novelty is that contexts can be dynamic: there is no bound on the number of objects in a context and objects can be transferred between contexts. The invariant of an object is allowed to depend on the fields of the object, on the fields of all objects in transitively-owned contexts, and on fields of objects reachable via given sequences of fields. With these invariants, one can describe a large variety of properties, including properties of cyclic data structures. Object invariants can be declared in or near the classes whose fields they depend on, not necessarily in the class of an owning object. The methodology is designed to allow modular reasoning, even in the presence of subclasses, and is proved sound.