Skip to main content

Behavioural Types for Memory and Method Safety in a Core Object-Oriented Language

  • Conference paper
  • First Online:
Programming Languages and Systems (APLAS 2020)

Abstract

We present a type-based analysis ensuring memory safety and object protocol completion in the Java-like language Mungo. Objects are annotated with usages, typestates-like specifications of the admissible sequences of method calls. The analysis entwines usage checking, controlling the order in which methods are called, with a static check determining whether references may contain null values. It prevents null pointer dereferencing in a typestate-aware manner and memory leaks and ensures that the intended usage protocol of every object is respected and completed. The type system admits an algorithm that infers the most general usage with respect to a simulation preorder. The type system is implemented in the form of a type checker and a usage inference tool.

Work partially supported by the EU H2020 RISE programme under the Marie Skłodowska-Curie grant agreement No. 778233 (BehAPI), the UK EPSRC grant EP/K034413/1 (ABCD), and by NOVA LINCS (UIDB/04516/2020) via FCT.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    We use \(\uplus \) to denote disjoint union.

References

  1. https://github.com/MungoTypesystem/Mungo-Typechecker/ExamplePrograms/

  2. Aldrich, J.: The Plaid programming language (2010)

    Google Scholar 

  3. Ancona, D., et al.: Behavioral types in programming languages. Found. Trends Program. Lang. 3(2–3), 95–230 (2016)

    Article  Google Scholar 

  4. Bravetti, M., Carbone, M., Zavattaro, G.: Undecidability of asynchronous session subtyping. Inf. Comput. 256, 300–320 (2017)

    Article  MathSciNet  Google Scholar 

  5. Bravetti, M., Carbone, M., Zavattaro, G.: On the boundary between decidability and undecidability of asynchronous session subtyping. Theoret. Comput. Sci. 722, 19–51 (2018)

    Article  MathSciNet  Google Scholar 

  6. Bravetti, M., Zavattaro, G.: Process calculi as a tool for studying coordination, contracts and session types. J. Logical Algebraic Methods Program. 112, 100527 (2020)

    Article  MathSciNet  Google Scholar 

  7. Caires, L., Seco, J.C.: The type discipline of behavioral separation. In: The 40th Symposium on Principles of Programming Languages, POPL 2013, pp. 275–286. ACM (2013)

    Google Scholar 

  8. de Boer, F.S., Bravetti, M., Lee, M.D., Zavattaro, G.: A petri net based modeling of active objects and futures. Fundamenta Informaticae 159(3), 197–256 (2018)

    Article  MathSciNet  Google Scholar 

  9. DeLine, R., Fähndrich, M.: Typestates for objects. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 465–490. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-24851-4_21

    Chapter  Google Scholar 

  10. Dietl, W., Dietzel, S., Ernst, M.D., Muslu, K., Schiller, T.W.: Building and using pluggable type-checkers. In: Proceedings of the 33rd International Conference on Software Engineering, ICSE 2011, pp. 681–690. ACM (2011)

    Google Scholar 

  11. Fähndrich, M., DeLine, R.: Adoption and focus: practical linear types for imperative programming. In: Proceedings of PLDI 2002, pp. 13–24. ACM (2002)

    Google Scholar 

  12. Fähndrich, M., Leino, K.R.M.: Declaring and checking non-null types in an object-oriented language. In: Proceedings of OOPSLA 2003, pp. 302–312. ACM (2003)

    Google Scholar 

  13. Franco, J., Tasos, A., Drossopoulou, S., Wrigstad, T., Eisenbach, S.: Safely abstracting memory layouts. CoRR, abs/1901.08006 (2019)

  14. Garcia, R., Tanter, É., Wolff, R., Aldrich, J.: Foundations of typestate-oriented programming. Trans. Program. Lang. Syst. 36(4), 1–44 (2014)

    Article  Google Scholar 

  15. Gay, S.J., Gesbert, N., Ravara, A., Vasconcelos, V.T.: Modular session types for objects. Logical Methods Comput. Sci. 11(4), 1–76 (2015)

    Article  MathSciNet  Google Scholar 

  16. Gay, S.J., Hole, M.: Subtyping for session types in the pi calculus. Acta Informatica 42(2–3), 191–225 (2005)

    Article  MathSciNet  Google Scholar 

  17. Grigore, R.: Java generics are turing complete. In: Proceedings of POPL 2017, pp. 73–85. ACM (2017)

    Google Scholar 

  18. Hoare, T.: Null references: the billion dollar mistake (2009)

    Google Scholar 

  19. Honda, K.: Types for dyadic interaction. In: Best, E. (ed.) CONCUR 1993. LNCS, vol. 715, pp. 509–523. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-57208-2_35

    Chapter  Google Scholar 

  20. Hubert, L., Jensen, T., Pichardie, D.: Semantic foundations and inference of non-null annotations. In: Barthe, G., de Boer, F.S. (eds.) FMOODS 2008. LNCS, vol. 5051, pp. 132–149. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-68863-1_9

    Chapter  Google Scholar 

  21. Hüttel, H., et al.: Foundations of session types and behavioural contracts. ACM Comput. Surv. 49(1), 1–36 (2016)

    Article  Google Scholar 

  22. Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight java: a minimal core calculus for Java and GJ. Trans. Program. Lang. Syst. 23(3), 396–450 (2001)

    Article  Google Scholar 

  23. Kouzapas, D., Dardha, O., Perera, R., Gay, S.J.: Typechecking protocols with Mungo and StMungo: a session type toolchain for Java. Sci. Comput. Program. 155, 52–75 (2018)

    Article  Google Scholar 

  24. Meyer, B.: Ending null pointer crashes. Commun. ACM 60(5), 8–9 (2017)

    Article  Google Scholar 

  25. Militão, F., Aldrich, J., Caires, L.: Aliasing control with view-based typestate. In: Proceedings of the 12th Workshop on Formal Techniques for Java-Like Programs, FTFJP 2010. ACM (2010)

    Google Scholar 

  26. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348–375 (1978)

    Article  MathSciNet  Google Scholar 

  27. Nierstrasz, O.: Regular types for active objects. In: Proceedings of the 8th Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA 1993), pp. 1–15. ACM (1993)

    Google Scholar 

  28. Siek, J., Taha, W.: Gradual typing for objects. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 2–27. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-73589-2_2

    Chapter  Google Scholar 

  29. Strom, R.E., Yemini, S.: Typestate: a programming language concept for enhancing software reliability. IEEE Trans. Softw. Eng. 12(1), 157–171 (1986)

    Article  Google Scholar 

  30. Sunshine, J.: Protocol programmability. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, USA (2013). AAI3578659

    Google Scholar 

  31. Sunshine, J., Stork, S., Naden, K., Aldrich, J.: Changing state in the plaid language. In: Companion to OOPSLA 2011, pp. 37–38. ACM (2011)

    Google Scholar 

  32. The Jedis Project: Jedis (2011–2019). https://github.com/xetorthio/jedis/

  33. The Redis Project: Redis (2011–2019). https://redis.io/

  34. Voinea, A.L., Dardha, O., Gay, S.J.: Typechecking Java protocols with [St]Mungo. In: Gotsman, A., Sokolova, A. (eds.) FORTE 2020. LNCS, vol. 12136, pp. 208–224. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-50086-3_12

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to António Ravara .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Bravetti, M. et al. (2020). Behavioural Types for Memory and Method Safety in a Core Object-Oriented Language. In: Oliveira, B.C.d.S. (eds) Programming Languages and Systems. APLAS 2020. Lecture Notes in Computer Science(), vol 12470. Springer, Cham. https://doi.org/10.1007/978-3-030-64437-6_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-64437-6_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-64436-9

  • Online ISBN: 978-3-030-64437-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics