skip to main content
10.1145/3479394.3479414acmotherconferencesArticle/Chapter ViewAbstractPublication PagesppdpConference Proceedingsconference-collections
research-article

Papaya: Global Typestate Analysis of Aliased Objects

Authors Info & Claims
Published:07 October 2021Publication History

ABSTRACT

Typestates are state machines used in object-oriented programming to specify and verify correct order of method calls on an object. To avoid inconsistent object states, typestates enforce linear typing, which eliminates—or at best limits—aliasing. However, aliasing is an important feature in programming, and the state-of-the-art on typestates is too restrictive if we want typestates to be adopted in real-world software systems.

In this paper, we present a type system for an object-oriented language with typestate annotations, which allows for unrestricted aliasing, and as opposed to previous approaches it does not require linearity constraints. The typestate analysis is global and tracks objects throughout the entire program graph, which ensures that well-typed programs conform and complete the declared protocols. We implement our framework in the Scala programming language and illustrate our approach using a running example that shows the interplay between typestates and aliases.

References

  1. Jonathan Aldrich, Joshua Sunshine, Darpan Saini, and Zachary Sparks. 2009. Typestate-oriented programming. (2009), 1015–1022. https://doi.org/10.1145/1639950.1640073Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Kevin Bierhoff and Jonathan Aldrich. 2007. Modular typestate checking of aliased objects. ACM SIGPLAN Notices 42, 10 (2007), 301–319. https://doi.org/10.1145/1297105.1297050Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Mario Bravetti, Adrian Francalanza, Iaroslav Golovanov, Hans Hüttel, Mathias S Jakobsen, Mikkel K Kettunen, and António Ravara. 2020. Behavioural Types for Memory and Method Safety in a Core Object-Oriented Language. In Programming Languages and Systems, Bruno C d. S Oliveira (Ed.). Springer International Publishing, Cham, 105–124.Google ScholarGoogle Scholar
  4. Luís Caires and João C. Seco. 2013. The type discipline of behavioral separation. ACM SIGPLAN Notices 48, 1 (2013), 275–286. https://doi.org/10.1145/2480359.2429103Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Silvia Crafa and Luca Padovani. 2017. The chemical approach to typestate-oriented programming. ACM Transactions on Programming Languages and Systems 39, 3 (2017), 917–934. https://doi.org/10.1145/3064849Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Ornela Dardha, Simon J. Gay, Dimitrios Kouzapas, Roly Perera, A. Laura Voinea, and Florian Weber. 2017. Mungo and StMungo: tools for typechecking protocols in Java. In Behavioural Types: from Theory to Tools, Simon Gay and Antonio Ravara (Eds.). River Publishers, 309–328. http://eprints.gla.ac.uk/146891/Google ScholarGoogle Scholar
  7. Robert DeLine and Manuel Fahndrich. 2001. Enforcing high-level protocols in low-level software. In Proc. of PLDI pages(2001), 59–69.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Robert DeLine and Manuel Fähndrich. 2004. The Fugue protocol checker: Is your software Baroque?Technical Report January. Microsoft Research. http://research.microsoft.com/apps/pubs/default.aspx?id=67458%5Cnhttp://research.microsoft.com/en-us/projects/fugue/Google ScholarGoogle Scholar
  9. Robert Deline and Manuel Fähndrich. 2004. Typestates for Objects. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) 3086 (2004), 465–490. https://doi.org/10.1007/978-3-540-24851-4_21Google ScholarGoogle ScholarCross RefCross Ref
  10. Mariangiola Dezani-Ciancaglini, Dimitris Mostrous, Nobuko Yoshida, and Sophia Drossopoulou. 2006. Session types for object-oriented languages. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) 4067 LNCS (2006), 328–352. https://doi.org/10.1007/11785477_20Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Manuel Fähndrich and Robert DeLine. 2002. Adoption and Focus: Practical Linear Types for Imperative Programming. In Proceedings of the 2002 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Berlin, Germany, June 17-19, 2002, Jens Knoop and Laurie J. Hendren (Eds.). ACM, 13–24. https://doi.org/10.1145/512529.512532Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Stephen J. Fink, Eran Yahav, Nurit Dor, G. Ramalingam, and Emmanuel Geay. 2008. Effective typestate verification in the presence of aliasing. ACM Trans. Softw. Eng. Methodol. 17, 2 (2008), 9:1–9:34. https://doi.org/10.1145/1348250.1348255Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Simon J. Gay, Nils Gesbert, António Ravara, and Vasco T. Vasconcelos. 2015. Modular session types for objects. Logical Methods in Computer Science 11, 4 (2015), 1–76. https://doi.org/10.2168/LMCS-11(4:12)2015Google ScholarGoogle ScholarCross RefCross Ref
  14. Simon J. Gay, Vasco Thudichum Vasconcelos, António Ravara, Nils Gesbert, and Alexandre Z. Caldeira. 2010. Modular session types for distributed object-oriented programming. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, Madrid, Spain, January 17-23, 2010, Manuel V. Hermenegildo and Jens Palsberg (Eds.). ACM, 299–312. https://doi.org/10.1145/1706299.1706335Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Iaroslav Golovanov, Hans Hüttel, Mathias Steen Jakobsen, and Mikkel Klinke Kettunen. 2021. Behavioural Separation with Parallel Usages. In Proceedings of the 23rd ACM SIGPLAN International Workshop on Formal Techniques for Java-Like Programs (Virtual, Denmark) (FTfJP 2021). Association for Computing Machinery, New York, NY, USA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Kohei Honda. 1993. Types for Dyadic Interaction. In CONCUR ’93, 4th International Conference on Concurrency Theory, Hildesheim, Germany, August 23-26, 1993, Proceedings(Lecture Notes in Computer Science, Vol. 715), Eike Best(Ed.). Springer, 509–523. https://doi.org/10.1007/3-540-57208-2_35Google ScholarGoogle Scholar
  17. Kohei Honda, Vasco T. Vasconcelos, and Makoto Kubo. 1998. Language primitives and type discipline for structured communication-based programming. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) 1381 (1998), 122–138. https://doi.org/10.1007/bfb0053567Google ScholarGoogle Scholar
  18. Kohei Honda, Nobuko Yoshida, and Marco Carbone. 2008. Multiparty asynchronous session types. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, San Francisco, California, USA, January 7-12, 2008, George C. Necula and Philip Wadler (Eds.). ACM, 273–284. https://doi.org/10.1145/1328438.1328472Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Mathias Jakobsen, Alice Ravier, and Ornela Dardha. 2021. Papaya: Global Typestate Analysis of Aliased Objects Extended Version. CoRR abs/2107.13101(2021). arxiv:2107.13101https://arxiv.org/abs/2107.13101Google ScholarGoogle Scholar
  20. Mathias Steen Jakobsen, Mikkel Klinke Kettunen, and Iaroslav Golovanov. 2020. Behavioural Separation with Parallel Usages for a Core Object-Oriented Language.Google ScholarGoogle Scholar
  21. Dimitrios Kouzapas, Ornela Dardha, Roly Perera, and Simon J. Gay. 2016. Typechecking protocols with Mungo and StMungo. In Proceedings of the 18th International Symposium on Principles and Practice of Declarative Programming, Edinburgh, United Kingdom, September 5-7, 2016, James Cheney and Germán Vidal (Eds.). ACM, 146–159. https://doi.org/10.1145/2967973.2968595Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Dimitrios Kouzapas, Ornela Dardha, Roly Perera, and Simon J. Gay. 2018. Typechecking protocols with Mungo and StMungo: A session type toolchain for Java. Science of Computer Programming 155 (2018), 52–75. https://doi.org/10.1016/j.scico.2017.10.006Google ScholarGoogle ScholarCross RefCross Ref
  23. Microsoft. 2020. Common Language Runtime (CLR) overview -.NET. https://docs.microsoft.com/en-us/dotnet/standard/clrGoogle ScholarGoogle Scholar
  24. Filipe Militão, Jonathan Aldrich, and Luís Caires. 2010. Aliasing control with view-based typestate. In Proceedings of the 12th Workshop on Formal Techniques for Java-Like Programs, FTFJP 2010, Maribor, Slovenia, June 22, 2010. ACM, 7:1–7:7. https://doi.org/10.1145/1924520.1924527Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. João Mota. 2021. Coping with the reality: adding crucial features to a typestate-oriented language.Google ScholarGoogle Scholar
  26. João Mota, Marco Giunti, and António Ravara. 2021. Java Typestate Checker. In Coordination Models and Languages - 23rd IFIP WG 6.1 International Conference, COORDINATION 2021, Held as Part of the 16th International Federated Conference on Distributed Computing Techniques, DisCoTec 2021, Valletta, Malta, June 14-18, 2021, Proceedings(Lecture Notes in Computer Science, Vol. 12717), Ferruccio Damiani and Ornela Dardha (Eds.). Springer, 121–133. https://doi.org/10.1007/978-3-030-78142-2_8Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Mungo project. 2021. Mungo. http://www.dcs.gla.ac.uk/research/mungo/Google ScholarGoogle Scholar
  28. Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors, Lukas Rytz, Michel Schinz, Erik Stenman, and Matthias Zenger. 2021. Scala Language Specification. https://scala-lang.org/files/archive/spec/2.13/Google ScholarGoogle Scholar
  29. Luca Padovani. 2018. Deadlock-Free Typestate-Oriented Programming. Art Sci. Eng. Program. 2, 3 (2018), 15. https://doi.org/10.22152/programming-journal.org/2018/2/15Google ScholarGoogle ScholarCross RefCross Ref
  30. Alice Ravier. 2021. Scala-Mungo. https://github.com/Aliceravier/Scala-MungoGoogle ScholarGoogle Scholar
  31. Alceste Scalas, Ornela Dardha, Raymond Hu, and Nobuko Yoshida. 2017. A linear decomposition of multiparty sessions for safe distributed programming. Leibniz International Proceedings in Informatics, LIPIcs 74, March(2017), 241–2431. https://doi.org/10.4230/LIPIcs.ECOOP.2017.24Google ScholarGoogle Scholar
  32. Alceste Scalas and Nobuko Yoshida. 2016. Lightweight Session Programming in Scala. In Proceedings of the 30th European Conference on Object-Oriented Programming, ECOOP(LIPIcs, Vol. 56). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 21:1–21:28. https://doi.org/10.4230/LIPIcs.ECOOP.2016.21Google ScholarGoogle Scholar
  33. Robert E. Strom and Shaula Yemini. 1986. Typestate: A Programming Language Concept for Enhancing Software Reliability., 157–171 pages. https://doi.org/10.1109/TSE.1986.6312929Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Joshua Sunshine, Karl Naden, Sven Stork, Jonathan Aldrich, and Eric Tanter. 2011. First-class state change in plaid. ACM SIGPLAN Notices 46, 10 (2011), 713–732. https://doi.org/10.1145/2076021.2048122Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Vasco T. Vasconcelos. 2011. Sessions, from Types to Programming Languages. Bull. EATCS 103(2011), 53–73. http://eatcs.org/beatcs/index.php/beatcs/article/view/136Google ScholarGoogle Scholar
  36. Vasco T. Vasconcelos, Simon J. Gay, António Ravara, Nils Gesbert, and Alexandre Z. Caldiera. 2009. Dynamic interfaces. In 2009 International Workshop on Foundations of Object-Oriented Languages (FOOL’09).Google ScholarGoogle Scholar
  37. A. Laura Voinea, Ornela Dardha, and Simon J. Gay. 2020. Typechecking Java Protocols with [St]Mungo. In Proceedings of the International Conference on Formal Techniques for Distributed Objects, Components, and Systems - 40th IFIP WG 6.1, FORTE(Lecture Notes in Computer Science, Vol. 12136). Springer, 208–224. https://doi.org/10.1007/978-3-030-50086-3_12Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Papaya: Global Typestate Analysis of Aliased Objects
          Index terms have been assigned to the content through auto-classification.

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in
          • Published in

            cover image ACM Other conferences
            PPDP '21: Proceedings of the 23rd International Symposium on Principles and Practice of Declarative Programming
            September 2021
            277 pages
            ISBN:9781450386890
            DOI:10.1145/3479394

            Copyright © 2021 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 7 October 2021

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article
            • Research
            • Refereed limited

            Acceptance Rates

            Overall Acceptance Rate230of486submissions,47%

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader

          HTML Format

          View this article in HTML Format .

          View HTML Format