Abstract
Traits have been proposed as a more flexible mechanism than class inheritance for structuring code in object-oriented programming, to achieve fine-grained code reuse. A trait originally developed for one purpose can be adapted and reused in a completely different context. Formalizations of traits have been extensively studied, and implementations of traits have started to appear in programming languages. So far, work on formally establishing properties of trait-based programs has mostly concentrated on type systems. This paper presents the first deductive proof system for a trait-based object-oriented language. If a specification of a trait can be given a priori, covering all actual usage of that trait, our proof system is modular as each trait is analyzed only once. However, imposing such a restriction may in many cases unnecessarily limit traits as a mechanism for flexible code reuse. In order to reflect the flexible reuse potential of traits, our proof system additionally allows new specifications to be added to a trait in an incremental way which does not violate established proofs. We formalize and show the soundness of the proof system.
Similar content being viewed by others
References
Apt KR, de Boer FS, Olderog ER (2009) Verification of sequential and concurrent systems. Texts and Monographs in Computer Science, 3rd edn. Springer, Berlin
Apel S, Kästner C, Lengauer C (2013) Language-independent and automated software composition: the featureHouse experience. IEEE Trans Softw Eng 39(1): 63–79
Aldrich J (2005) Open modules: modular reasoning about advice. In: Black AP (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 3586 of lecture notes in computer science, pp 144–168. Springer, Berlin
Ancona D, Lagorio G, Zucca E (2003) Jam—designing a Java extension with mixins. Trans Program Lang Syst 25(5): 641–712
America P (1991) Designing an object-oriented programming language with behavioural subtyping. In: de Bakker JW, de Roever W-P, Rozenberg G (eds) Foundations of object-oriented languages, volume 489 of lecture notes in computer science, pp 60–90. Springer, Berlin
Apt KR (1981) Ten years of Hoare’s logic: a survey—Part I. Trans Program Lang Syst 3(4): 431–483
Bracha G, Cook W (1990) Mixin-based inheritance. In: Meyrowitz N, (ed) Proceedings of the conference on object-oriented programming: systems, languages, and applications / European conference on object-oriented programming, pp 303–311. ACM Press, New York
Burdy L, Cheon Y, Cok DR, Ernst MD, Kiniry JR, Leavens GT, Leino KRM, Poll E (2005) An overview of JML tools and applications. Int J Softw Tools Technol Transf 7(3): 212–232
Bettini L, Capecchi S, Damiani F (2012) On flexible dynamic trait repacement for Java-like languages. Sci Comput Program. Available online doi:10.1016/j.scico.2012.11.003
Bettini L, Damiani F, De Luca M, Geilmann K, Schäfer J (2010) A calculus for boxes and traits in a Java-like setting. In: Clarke D, Agha G (eds) Coordination models and languages, volume 6116 of lecture notes in computer science, pp 46–60. Springer, Berlin
Bono V, Damiani F, Giachino E (2007) Separating type, behavior, and state to achieve very fine-grained reuse. In: Proceedings of formal techniques for Java-like Programs (FTfJP)
Bono V, Damiani F, Giachino E (2008) On traits and types in a Java-like setting. In: Fifth IFIP international conference on theoretical computer science (TCS’08), volume 273 of international federation for information processing, pp 367–382. Springer, Berlin
Bettini L, Damiani F, Geilmann K, Schäfer J (2013) Combining traits with boxes and ownership types in a Java-like setting. Sci Comput Program 78(2): 218–247
Black A, Ducasse S, Nierstrasz O, Pollet D, Cassou D, Denker M (2009) Pharo by example. Square Bracket Associates
Bergel A, Ducasse S, Nierstrasz O, Wuyts R (2008) Stateful traits and their formalization. Comput Lang Syst Struct 34(2–3): 83–108
Bettini L, Damiani F, Schaefer I (2009) Implementing SPL using Traits. Technical report, Dipartimento di Informatica, Università di Torino. Available at http://www.di.unito.it/~damiani/papers/isplurat.pdf
Bettini L, Damiani F, Schaefer I (2010) Implementing software product lines using traits. In: Proceedings of the 2010 ACM symposium on applied computing (SAC’10), pp 2096–2102. ACM Press, New York
Bettini L, Damiani F, Schaefer I, Strocco F (2010) A prototypical Java-like language with records and traits. In: Proceedings of the 8th international conference on the principles and practice of programming in Java (PPPJ’10), pp 129–138. ACM Press, New York
Bettini L, Damiani F, Schaefer I, Strocco F (2013) TraitRecordJ: a programming language with traits and records. Sci Comput Program 78(5):521–541
Beckert B, Hähnle R, Schmitt PH (eds) (2007) Verification of object-oriented software: the key approach, volume 4334 of lecture notes in computer science. Springer, Berlin
Booch G, Rumbaugh JE, Jacobson I (1999) The unified modeling language user guide. Addison-Wesley, Reading
Bagherzadeh M, Rajan H, Leavens GT, Mooney SL (2011) Translucid contracts: expressive specification and modular verification for aspect-oriented interfaces. In: Borba P, Chiba S (eds) Proceedings of the 10th international conference on aspect-oriented software development (AOSD 2011), pp 141–152. ACM Press, New York
Batory D, Sarvela JN, Rauschmayer A (2004) Scaling step-wise refinement. IEEE Trans Softw Eng 30: 355–371
Back R-J, von Wright J (1998) Refinement calculus: a systematic introduction. Graduate texts in computer science. Springer, Berlin
de Boer FS (1999) A WP-calculus for OO. In: Thomas W (ed) Proceedings of foundations of software science and computation structure (FOSSACS’99), volume 1578 of lecture notes in computer science, pp 135–149. Springer, Berlin
Damiani F, Dovland J, Johnsen EB, Owe O, Schaefer I, Yu IC (2012) A transformational proof system for delta-oriented programming. In: de Almeida ES, Schwanninger C, Benavides D (eds) Proceedings of 16th international software product line conference (SPLC’12), vol 2, pp 53–60. ACM Press, New York
Damiani F, Dovland J, Johnsen EB, Schaefer I (2011) Verifying traits: a proof system for fine-grained reuse. In: Proceedings of formal techniques for Java-like programs (FTfJP), pp 8:1–8:6. ACM Press, New York
Dovland J, Johnsen EB, Owe O, Steffen M (2010) Lazy behavioral subtyping. J Logic Algebraic Program 79(7): 578–607
Dovland J, Johnsen EB, Owe O, Steffen M (2011) Incremental reasoning with lazy behavioral subtyping for multiple inheritance. Sci Comput Program 76(10): 915–941
Ducasse S, Nierstrasz O, Schärli N, Wuyts R, Black AP (2006) Traits: a mechanism for fine-grained reuse. Trans Program Lang Syst 28(2): 331–388
De Fraine B, Ernst E, Südholt M (2010) Essential AOP: the A calculus. In: D’Hondt T (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 6183 of lecture notes in computer science, pp 101–125. Springer, Berlin
Flatt M, Krishnamurthi S, Felleisen M (1998) Classes and mixins. In: Proceedings of principles of programming languages (POPL), pp 171–183. ACM Press, New York
Hatcliff J, Leavens GT, Leino KRM, Müller P, Parkinson MJ (2012) Behavioral interface specification languages. ACM Comput Surv 44(3): 16
Hoare CAR (1969) An axiomatic basis of computer programming. Commun ACM 12:576–580
Hoare CAR (1971) Procedures and parameters: An axiomatic approach. In: Engeler E (e) Symposium on semantics of algorithmic languages, volume 188 of lecture notes in mathematics, pp 102–116. Springer, Berlin
Hähnle R, Schaefer I (2012) A Liskov principle for delta-oriented programming. In: Margaria T, Steffen B (eds) Proceedings of 5th international symposium on leveraging applications of formal methods, verification and validation (ISoLA), volume 7609 of lecture notes in computer science, pp 32–46. Springer, Berlin
Igarashi A, Pierce BC, Wadler P (2001) Featherweight Java: a minimal core calculus for Java and GJ. Trans Program Lang Syst 23(3): 396–450
Johnsen EB, Owe O, Yu IC (2006) Creol: a type-safe object-oriented model for distributed concurrent systems. Theor Comput Sci 365(1–2): 23–66
Krishnamurthi S, Fisler K (2007) Foundations of incremental aspect model-checking. Trans Softw Eng Methodol 16(2)
Kiczales G, Lamping J, Mendhekar A, Maeda C, Lopes C, Loingtier J-M, Irwin J (1997) Aspect-oriented programming. In: Akşit M, Matsuoka S (eds) Proceedings of European conference on object-oriented programming (ECOOP), volume 1241 of lecture notes in computer science, pp 220–242. Springer, Berlin
Leavens GT, Naumann DA (2006) Behavioral subtyping, specification inheritance, and modular reasoning. Technical Report 06-20a, Department of Computer Science, Iowa State University, Ames
Luo C, Qin S (2008) Separation logic for multiple inheritance. Electronic Notes in Theoretical Computer Science. In: Proceedings of first international conference on foundations of informatics, computing and software (FICS), vol 212, pp 27–40
Liquori L, Spiwack A (2008) Extending FeatherTrait Java with interfaces. Theor Comput Sci 398(1–3): 243–260
Liquori L, Spiwack A (2008) FeatherTrait: a modest extension of Featherweight Java. Trans Program Lang Syst 30(2): 1–32
Lagorio G, Servetto M, Zucca E (2009) Flattening versus direct semantics for featherweight jigsaw. In: Proceedings of workshop on foundations of object-oriented languages (FOOL)
Liskov B, Wing JM (1994) A behavioral notion of subtyping. Trans Program Lang Syst 16(6): 1811–1841
Nordio M, Calcagno C, Müller P, Meyer B (2009) A sound and complete program logic for eiffel. In: Oriol M (ed) TOOLS-EUROPE 2009, volume 33 of lecture notes in business and information processing, pp 195–214
Nierstrasz O, Ducasse S, Schärli N (2006) Flattening traits. J Object Technol 5(4): 129–148
Owicki S, Gries D (1976) An axiomatic proof technique for parallel programs I. Acta Inf 6(4): 319–340
Odersky M, Spoon L, Venners B (2010) Programming in Scala, 2 edn. Artima Press, California
Parkinson MJ, Bierman GM (2008) Separation logic, abstraction and inheritance. In: Proceedings of principles of programming languages (POPL), pp 75–86. ACM Press, New York
Parkinson MJ, Bornat R, Calcagno C (2006) Variables as resource in Hoare logics. In: Proceedings of symposium on logic in computer science (LICS’06), pp 137–146. IEEE Computer Society Press, New York
Poetzsch-Heffter A, Müller P (1999) A programming logic for sequential Java. In: Swierstra SD (ed) 8th European symposium on programming languages and systems (ESOP’99), volume 1576 of lecture notes in computer science, pp 162–176. Springer, Berlin
Reppy JH, Turon A (2006) A foundation for trait-based metaprogramming. In: Proceedings of FOOL/WOOD
Reppy JH, Turon A (2007) Metaprogramming with traits. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 4609 of lecture notes in computer science, pp 373–398. Springer, Berlin
Steele Jr GL, Allen EE, Chase D, Flood CH, Luchangco V, Maessen J-W, Ryu S (2011) Fortress (Sun HPCS language). In: Padua DA (ed) Encyclopedia of parallel computing, pp 718–735. Springer, Berlin
Schaefer I, Bettini L, Bono V, Damiani F, Tanzarella N (2010) Delta-oriented programming of software product lines. In: Bosch J, Lee J (eds) Software product lines: going beyond (SPLC’10), volume 6287 of lecture notes in computer science, pp 77–91. Springer, Berlin
Schwerhoff M (2010) Verifying scala traits. Semester Report, Swiss Federal Institute of Technology Zurich (ETH)
Smith C, Drossopoulou S (2005) Chai: traits for Java-like languages. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 3586 of lecture notes in computer science, pp 453–478. Springer, Berlin
Schärli N, Ducasse S, Nierstrasz O, Black A (2003) Traits: composable units of behavior. In: Proceedings of European conference on object-oriented programming (ECOOP), volume 2743 of lecture notes in computer science, pp 248–274. Springer, Berlin
TraitRecordJ website (2011) http://traitrecordj.sourceforge.net/
Thüm T, Schaefer I, Apel S, Hentschel M (2012) Family-based deductive verification of software product lines. In: International conference on generative programming and component engineering (GPCE), pp 11–20. ACM Press, New York
Thüm T, Schaefer I, Kuhlemann M, Apel S (2011) Proof composition for deductive verification of software product lines. In: Proceedings of international workshop on variability-intensive systems testing, validation and verification, pp 270–277. IEEE Computer Society Press, New York
Van Limberghen M, Mens T (1996) Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Syst 3(1): 1–30
van Staden S, Calcagno C (2010) Reasoning about multiple related abstractions with MultiStar. In: Proceedings of object-oriented programming systems, languages and applications (OOPSLA), pp 504–519. ACM Press, New York
Wills A (1991) Capsules and types in fresco: program verification in smalltalk. In: America P (ed) Proceedings of European conference on object-oriented programming (ECOOP), volume 512 of lecture notes in computer science, pp 59–76. Springer, Berlin
Author information
Authors and Affiliations
Corresponding author
Additional information
B. Pierce
The authors of this paper are listed in alphabetical order. This work has been partially supported by the Deutsche Forschungsgemeinschaft (SCHA 1635/2-1), the Italian MIUR (PRIN 2008 DISCO), the German-Italian University Centre (Vigoni program), and the EU project FP7-231620 HATS: Highly Adaptable and Trustworthy Software using Formal Models (http://www.hats-project.eu).
Rights and permissions
About this article
Cite this article
Damiani, F., Dovland, J., Johnsen, E.B. et al. Verifying traits: an incremental proof system for fine-grained reuse. Form Asp Comp 26, 761–793 (2014). https://doi.org/10.1007/s00165-013-0278-3
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00165-013-0278-3