Lazy Behavioral Subtyping
2008, Springer eBooks
Abstract
Late binding allows flexible code reuse but complicates formal reasoning significantly, as a method call's receiver class is not statically known. This is especially true when programs are incrementally developed by extending class hierarchies. This report develops a novel method to reason about late bound method calls. In contrast to traditional behavioral subtyping, reverification is avoided without restricting method overriding to fully behavior-preserving redefinition. The approach ensures that when analyzing the methods of a class, it suffices to consider that class and its superclasses. Thus, the full class hierarchy is not needed, and incremental reasoning is supported. We formalize this approach as a calculus which lazily imposes context-dependent subtyping constraints on method definitions. The calculus ensures that all method specifications required by late bound calls remain satisfied when new classes extend a class hierarchy. The calculus does not depend on a specific program logic, but the examples in the report use a Hoare-style proof system. We show soundness of the analysis method.
References (27)
- M. Abadi and K. R. M. Leino. A logic of object-oriented programs. In N. Dershowitz, editor, Verification: Theory and Practice, Essays Dedicated to Zohar Manna, volume 2772 of LNCS, pages 11-41. Springer, 2003.
- P. America. Designing an object-oriented programming language with behavioural sub- typing. In J. W. de Bakker, W.-P. de Roever, and G. Rozenberg, editors, Foundations of Object-Oriented Languages, pages 60-90. Springer, 1991.
- K. R. Apt. Ten years of Hoare's logic: A survey -Part I. ACM Transactions on Program- ming Languages and Systems, 3(4):431-483, Oct. 1981.
- K. R. Apt and E.-R. Olderog. Verification of Sequential and Concurrent Systems. Texts and Monographs in Computer Science. Springer, 1991.
- M. Barnett, K. R. M. Leino, and W. Schulte. The Spec# programming system: An overview. In G. Barthe, L. Burdy, M. Huisman, J.-L. Lanet, and T. Muntean, editors, Intl. Workshop on Construction and Analysis of Safe, Secure, and Interoperable Smart Devices (CASSIS'04), volume 3362 of LNCS, pages 49-69. Springer, 2005.
- B. Beckert, R. Hähnle, and P. H. Schmitt, editors. Verification of Object-Oriented Software. The KeY Approach, volume 4334 of LNAI. Springer, 2007.
- L. Burdy, Y. Cheon, D. R. Cok, M. Ernst, J. Kiniry, G. T. Leavens, K. R. M. Leino, , and E. Poll. An overview of JML tools and applications. In T. Arts and W. Fokkink, editors, Proceedings of FMICS '03, volume 80 of ENTCS. Elsevier Science Publishers, 2003.
- O.-J. Dahl, B. Myhrhaug, and K. Nygaard. (Simula 67) Common Base Language. Technical Report S-2, Norsk Regnesentral (Norwegian Computing Center), Oslo, Norway, May 1968.
- F. S. de Boer. A WP-calculus for OO. In W. Thomas, editor, Proceedings of Foundations of Software Science and Computation Structure, (FOSSACS'99), volume 1578 of LNCS, pages 135-149. Springer, 1999.
- F. S. de Boer, D. Clarke, and E. B. Johnsen. A complete guide to the future. In R. de Nicola, editor, Proc. 16th European Symposium on Programming (ESOP'07), volume 4421 of LNCS, pages 316-330. Springer-Verlag, Mar. 2007.
- E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, Mass., 1995.
- C. A. R. Hoare. An Axiomatic Basis of Computer Programming. Communications of the ACM, 12:576-580, 1969.
- C. A. R. Hoare. Procedures and parameters: An axiomatic approach. In E. Engeler, ed- itor, Symposium On Semantics of Algorithmic Languages, volume 188 of Lecture Notes in Mathematics, pages 102-116. Springer, 1971.
- M. Huisman. Java Program Verification in Higher-Order Logic with PVS and Isabelle. PhD thesis, University of Nijmegen, 2001.
- A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems, 23(3):396-450, 2001.
- B. Jacobs and E. Poll. A logic for the Java Modelling Language JML. In H. Hussmann, editor, Fundamental Approaches to Software Engineering, volume 2029 of LNCS, pages 284-299. Springer, 2001.
- E. B. Johnsen and O. Owe. An asynchronous communication model for distributed concur- rent objects. Software and Systems Modeling, 6(1):35-58, Mar. 2007.
- G. T. Leavens, K. R. M. Leino, and P. Müller. Specification and verification challenges for sequential object-oriented programs. Formal Aspects of Computing, 19(2):159-189, 2007.
- G. T. Leavens and D. A. Naumann. Behavioral subtyping, specification inheritance, and modular reasoning. Technical Report 06-20a, Department of Computer Science, Iowa State University, Ames, Iowa, 2006.
- B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Transactions on Programming Languages and Systems, 16(6):1811-1841, Nov. 1994.
- L. Mikhajlov and E. Sekerinski. A study of the fragile base class problem. In E. Jul, editor, 12th European Conference on Object-Oriented Programming (ECOOP), volume 1445 of LNCS, pages 355-382. Springer, 1998.
- D. v. Oheimb. Analysing Java in Isabelle/HOL: Formalization, Type Safety, and Hoare- Logics. PhD thesis, Technische Universität München, 2001.
- D. v. Oheimb and T. Nipkow. Hoare logic for NanoJava: Auxiliary variables, side effects, and virtual methods revisited. In L.-H. Eriksson and P. A. Lindsay, editors, Formal Methods Europe (FME 2002), volume 2391 of LNCS, pages 89-105. Springer, 2002.
- S. Owicki and D. Gries. An axiomatic proof technique for parallel programs I. Acta Inform- atica, 6(4):319-340, 1976.
- C. Pierik and F. S. de Boer. A proof outline logic for object-oriented programming. Theor- etical Computer Science, 343(3):413-442, 2005.
- A. Poetzsch-Heffter and P. Müller. A programming logic for sequential Java. In S. D. Swier- stra, editor, 8th European Symposium on Programming Languages and Systems (ESOP'99), volume 1576 of LNCS, pages 162-176. Springer, 1999.
- N. Soundarajan and S. Fridella. Inheritance: From code reuse to reasoning reuse. In P. Devanbu and J. Poulin, editors, Proc. Fifth International Conference on Software Reuse (ICSR5), pages 206-215. IEEE Computer Society Press, 1998.