Typechecking protocols with Mungo and StMungo: A session type toolchain for Java

Abstract Static typechecking is an important feature of many standard programming languages. However, static typing focuses on data rather than communication, and therefore does not help programmers correctly implement communication protocols in distributed systems. The theory of session types provides a basis for tackling this problem; we use it to develop two tools that support static typechecking of communication protocols in Java. The first tool, Mungo, extends Java with typestate definitions, which allow classes to be associated with state machines defining permitted sequences of method calls: for example, communication methods. The second tool, StMungo, takes a session type describing a communication protocol, and generates a typestate specification of the permitted sequences of messages in the protocol. Protocol implementations can be validated by Mungo against their typestate definitions and then compiled with a standard Java compiler. The result is a toolchain for static typechecking of communication protocols in Java. We formalise and prove soundness of the typestate inference system used by Mungo, and show that our toolchain can be used to typecheck a client for the standard Simple Mail Transfer Protocol (SMTP).

[1]  James R. Larus,et al.  Language support for fast and reliable message-based communication in singularity OS , 2006, EuroSys.

[2]  Nobuko Yoshida,et al.  Multiparty asynchronous session types , 2008, POPL '08.

[3]  Sophia Drossopoulou,et al.  A Distributed Object-Oriented Language with Session Types , 2005, TGC.

[4]  Nobuko Yoshida,et al.  Structured Interactional Exceptions in Session Types , 2008, CONCUR.

[5]  Sophia Drossopoulou,et al.  Objects and session types , 2009, Inf. Comput..

[6]  Message P Forum,et al.  MPI: A Message-Passing Interface Standard , 1994 .

[7]  Jonathan Aldrich,et al.  Modular typestate checking of aliased objects , 2007, OOPSLA.

[8]  Luca Padovani,et al.  The chemical approach to typestate-oriented programming , 2015, OOPSLA.

[9]  Nobuko Yoshida,et al.  Hybrid Session Verification Through Endpoint API Generation , 2016, FASE.

[10]  Kohei Honda,et al.  An Interaction-based Language and its Typing System , 1994, PARLE.

[11]  Nobuko Yoshida,et al.  The Scribble Protocol Language , 2013, TGC.

[12]  Éric Tanter,et al.  First-class state change in plaid , 2011, OOPSLA '11.

[13]  Vasco Thudichum Vasconcelos,et al.  Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited: Two Systems for Higher-Order Session Communication , 1998, SecReT@ICALP.

[14]  Görel Hedin An Introductory Tutorial on JastAdd Attribute Grammars , 2009, GTTSE.

[15]  Eric Bodden,et al.  The Clara framework for hybrid typestate analysis , 2010, International Journal on Software Tools for Technology Transfer.

[16]  Ondrej Lhoták,et al.  Adding trace matching with free variables to AspectJ , 2005, OOPSLA '05.

[17]  Jonathan Aldrich,et al.  Verifying correct usage of atomic blocks and typestate , 2008, OOPSLA.

[18]  Robert DeLine,et al.  Typestates for Objects , 2004, ECOOP.

[19]  Vasco Thudichum Vasconcelos,et al.  Linear type theory for asynchronous session types , 2009, Journal of Functional Programming.

[20]  Éric Tanter,et al.  Gradual Typestate , 2011, ECOOP.

[21]  Éric Tanter,et al.  Foundations of Typestate-Oriented Programming , 2014, ACM Trans. Program. Lang. Syst..

[22]  Nobuko Yoshida,et al.  SPY: Local Verification of Global Protocols , 2013, RV.

[23]  Nobuko Yoshida,et al.  Type-Safe Eventful Sessions in Java , 2010, ECOOP.

[24]  Sophia Drossopoulou,et al.  Session Types for Object-Oriented Languages , 2006, ECOOP.

[25]  Message Passing Interface Forum MPI: A message - passing interface standard , 1994 .

[26]  Luca Padovani,et al.  Typing Copyless Message Passing , 2012, Log. Methods Comput. Sci..

[27]  Robert E. Strom,et al.  Typestate: A programming language concept for enhancing software reliability , 1986, IEEE Transactions on Software Engineering.

[28]  Robert DeLine,et al.  Enforcing high-level protocols in low-level software , 2001, PLDI '01.

[29]  Robert DeLine,et al.  Adoption and focus: practical linear types for imperative programming , 2002, PLDI '02.

[30]  Jonathan Aldrich,et al.  Practical API Protocol Checking with Access Permissions , 2009, ECOOP.

[31]  Nobuko Yoshida,et al.  Multiparty Session C: Safe Parallel Programming with Message Optimisation , 2012, TOOLS.

[32]  Dimitrios Kouzapas,et al.  Typechecking protocols with Mungo and StMungo , 2016, PPDP.

[33]  Riccardo Pucella,et al.  Haskell session types with (almost) no class , 2008, Haskell '08.

[34]  Peter Thiemann,et al.  An Implementation of Session Types , 2004, PADL.

[35]  Sophia Drossopoulou,et al.  Amalgamating sessions and methods in object-oriented languages with generics , 2009, Theor. Comput. Sci..

[36]  Nobuko Yoshida,et al.  Protocols by Default - Safe MPI Code Generation Based on Session Types , 2015, CC.

[37]  Simon J. Gay,et al.  Subtyping for session types in the pi calculus , 2005, Acta Informatica.

[38]  Jonathan Aldrich,et al.  Typestate-oriented programming , 2009, OOPSLA Companion.

[39]  Nobuko Yoshida,et al.  Safe Parallel Programming with Session Java , 2011, COORDINATION.

[40]  Nobuko Yoshida,et al.  Session-Based Distributed Programming in Java , 2008, ECOOP.

[41]  António Ravara,et al.  Modular session types for distributed object-oriented programming , 2010, POPL '10.

[42]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[43]  Sophia Drossopoulou,et al.  Bounded Session Types for Object Oriented Languages , 2006, FMCO.

[44]  Jonathan Aldrich,et al.  Aliasing control with view-based typestate , 2010, FTfJP@ECOOP.