Type-Safe Eventful Sessions in Java

Raymond Hu (homepage), Olivier Pernet, Dimitrios Kouzapas, Nobuko Yoshida (homepage), Kohei Honda (homepage)


Event-driven programming is a major paradigm in concurrent and communication-based programming, and a widely adopted approach to building scalable high-concurrency servers. However, traditional event-driven programs are more difficult to read, write and verify than their multi-threaded counterparts due to low-level APIs and fragmentation of control flow across disjoint event handlers. This paper presents a Java language extension and a novel type discipline for type-safe event-driven session programming that counters the problems of traditional event-based programming with abstractions and safety guarantees based on session types, while retaining the expressiveness and performance characteristics of events. The type discipline extends session types and their primitives with asynchronous input, session typecase and session set types, ensuring event-handling safety and event progress in addition to the standard type soundness and communication safety. The advantages, expressiveness and performance of event-driven session programming are demonstrated through a range of examples and benchmarks, including a session-typed SMTP server.



See here for the latest benchmarks for the new SJSelector API. This online appendix presents the extended benchmarks omitted from the above paper, including the complete source code for the benchmark applications and the full data sets collected.

To compile an SJ program, from the sessionj directory do e.g.

   bin/sessionjc tests/src/mypackage/MyProgram.sj -d tests/classes/

and to run a compiled program, do

   bin/sessionj -cp tests/classes/ mypackage.MyProgram

Note: the SJ compiler currently accepts only Java 1.4, due to the version of Polyglot used.

Further information and materials regarding SJ can be found here (an older version of SJ, some syntax and features have since changed) and here (transport-independent session programming using SJ).