Safely creating correct subclasses without seeing superclass code

Citation
C. Ruby et Gt. Leavens, Safely creating correct subclasses without seeing superclass code, ACM SIGPL N, 35(10), 2000, pp. 208-228
Citations number
33
Categorie Soggetti
Computer Science & Engineering
Journal title
ACM SIGPLAN NOTICES
ISSN journal
15232867 → ACNP
Volume
35
Issue
10
Year of publication
2000
Pages
208 - 228
Database
ISI
SICI code
1523-2867(200010)35:10<208:SCCSWS>2.0.ZU;2-8
Abstract
A major problem for object-oriented frameworks and class libraries is how t o provide enough information about a superclass, so programmers can safely create new subclasses without giving away the superclass's code. Code inher ited from the superclass can call down to methods of the subclass, which ma y cause nontermination or unexpected behavior. We describe a reasoning tech nique that allows programmers, who have no access to the code of the superc lass, to determine both how to safely override the superclass's methods and when it is safe to call them. The technique consists of a set of rules and some new forms of specification. Part of the specification would be genera ted automatically by a tool, a prototype of which is planned for the formal specification language JML. We give an example to show the kinds of proble ms caused by method overrides and how our technique can be used to avoid th em. We also argue why the technique is sound and give guidelines for librar y providers and programmers that greatly simplify reasoning about how to av oid problems caused by method overrides.