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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
We use \(\uplus \) to denote disjoint union.
References
https://github.com/MungoTypesystem/Mungo-Typechecker/ExamplePrograms/
Aldrich, J.: The Plaid programming language (2010)
Ancona, D., et al.: Behavioral types in programming languages. Found. Trends Program. Lang. 3(2–3), 95–230 (2016)
Bravetti, M., Carbone, M., Zavattaro, G.: Undecidability of asynchronous session subtyping. Inf. Comput. 256, 300–320 (2017)
Bravetti, M., Carbone, M., Zavattaro, G.: On the boundary between decidability and undecidability of asynchronous session subtyping. Theoret. Comput. Sci. 722, 19–51 (2018)
Bravetti, M., Zavattaro, G.: Process calculi as a tool for studying coordination, contracts and session types. J. Logical Algebraic Methods Program. 112, 100527 (2020)
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)
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)
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
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)
Fähndrich, M., DeLine, R.: Adoption and focus: practical linear types for imperative programming. In: Proceedings of PLDI 2002, pp. 13–24. ACM (2002)
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)
Franco, J., Tasos, A., Drossopoulou, S., Wrigstad, T., Eisenbach, S.: Safely abstracting memory layouts. CoRR, abs/1901.08006 (2019)
Garcia, R., Tanter, É., Wolff, R., Aldrich, J.: Foundations of typestate-oriented programming. Trans. Program. Lang. Syst. 36(4), 1–44 (2014)
Gay, S.J., Gesbert, N., Ravara, A., Vasconcelos, V.T.: Modular session types for objects. Logical Methods Comput. Sci. 11(4), 1–76 (2015)
Gay, S.J., Hole, M.: Subtyping for session types in the pi calculus. Acta Informatica 42(2–3), 191–225 (2005)
Grigore, R.: Java generics are turing complete. In: Proceedings of POPL 2017, pp. 73–85. ACM (2017)
Hoare, T.: Null references: the billion dollar mistake (2009)
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
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
Hüttel, H., et al.: Foundations of session types and behavioural contracts. ACM Comput. Surv. 49(1), 1–36 (2016)
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)
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)
Meyer, B.: Ending null pointer crashes. Commun. ACM 60(5), 8–9 (2017)
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)
Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348–375 (1978)
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)
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
Strom, R.E., Yemini, S.: Typestate: a programming language concept for enhancing software reliability. IEEE Trans. Softw. Eng. 12(1), 157–171 (1986)
Sunshine, J.: Protocol programmability. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, USA (2013). AAI3578659
Sunshine, J., Stork, S., Naden, K., Aldrich, J.: Changing state in the plaid language. In: Companion to OOPSLA 2011, pp. 37–38. ACM (2011)
The Jedis Project: Jedis (2011–2019). https://github.com/xetorthio/jedis/
The Redis Project: Redis (2011–2019). https://redis.io/
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
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
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)