Abstract
Typestate reflects how the legal operations on imperative objects can change at runtime as their internal state changes. A typestate checker can statically ensure, for instance, that an object method is only called when the object is in a state for which the operation is well defined. Prior work has shown how modular typestate checking can be achieved thanks to access permissions and state guarantees. However, typestate was not treated as a primitive language concept: typestate checkers are an additional verification layer on top of an existing language. In contrast, a typestate-oriented programming (TSOP) language directly supports expressing typestates. For example, in the Plaid programming language, the typestate of an object directly corresponds to its class, and that class can change dynamically. Plaid objects have not only typestate-dependent interfaces but also typestate-dependent behaviors and runtime representations.
This article lays foundations for TSOP by formalizing a nominal object-oriented language with mutable state that integrates typestate change and typestate checking as primitive concepts. We first describe a statically typed language—Featherweight Typestate (FT)—where the types of object references are augmented with access permissions and state guarantees. We describe a novel flow-sensitive permission-based type system for FT. Because static typestate checking is still too rigid for some applications, we then extend this language into a gradually typed language—Gradual Featherweight Typestate (GFT). This language extends the notion of gradual typing to account for typestate: gradual typestate checking seamlessly combines static and dynamic checking by automatically inserting runtime checks into programs. The gradual type system of GFT allows programmers to write dynamically safe code even when the static type checker can only partly verify it.
- Amal Ahmed, Matthew Fluet, and Greg Morrisett. 2007. L3: A linear language with locations. Fundamenta Informaticae 77, 4, 397--449. Google Scholar
Digital Library
- Jonathan Aldrich, Joshua Sunshine, Darpan Saini, and Zachary Sparks. 2009. Typestate-oriented programming. In Proceedings of the 24th ACM SIGPLAN Conference Companion on Object-Oriented Programming Systems Languages and Applications (OOPSLA’09). ACM, New York, NY, 1015--1022. Google Scholar
Digital Library
- Henry G. Baker. 1994. Minimizing reference count updating with deferred and anchored pointers for functional data structures. ACM SIGPLAN Notices 29, 9, 38--43. Google Scholar
Digital Library
- Kevin Bierhoff and Jonathan Aldrich. 2007. Modular typestate checking of aliased objects. In Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems and Applications. ACM, New York, NY, 301--320. Google Scholar
Digital Library
- Kevin Bierhoff, Nels E. Beckman, and Jonathan Aldrich. 2009. Practical API protocol checking with access permissions. In Proceedings of the 23rd European Conference on Object-Oriented Programming (ECOOP’09). Springer-Verlag, Berlin, Heidelberg, 195--219. Google Scholar
Digital Library
- Gavin Bierman, Erik Meijer, and Mads Torgersen. 2010. Adding dynamic types to C. In Proceedings of the 24th European Conference on Object-Oriented Programming (ECOOP’10). Springer-Verlag, Berlin, Heidelberg, 76--100. Google Scholar
Digital Library
- Eric Bodden. 2010. Efficient hybrid typestate analysis by determining continuation-equivalent states. In Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering (ICSE’10). ACM, New York, NY, 5--14. Google Scholar
Digital Library
- John Boyland. 2003. Checking interference with fractional permissions. In Proceedings of the 10th International Conference on Static Analysis (SAS’03). Springer-Verlag, Berlin, Heidelberg, 55--72. Google Scholar
Digital Library
- John Boyland and William Retert. 2005. Connecting effects and uniqueness with adoption. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’05). ACM, New York, NY, 283--295. Google Scholar
Digital Library
- Robert DeLine and Manuel Fähndrich. 2004. Typestates for objects. In ECOOP 2004—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 3086. Springer, 465--490.Google Scholar
- Sophia Drossopoulou, Ferruccio Damiani, Mariangiola Dezani-Ciancaglini, and Paola Giannini. 2001. Fickle: Dynamic object re-classification. In Proceedings of the 15th European Conference on Object-Oriented Programming (ECOOP’01). Springer-Verlag, Berlin, Heidelberg. 130--149. Google Scholar
Digital Library
- Stephen J. Fink, Eran Yahav, Nurit Dor, G. Ramalingam, and Emmanuel Geay. 2008. Effective typestate verification in the presence of aliasing. ACM Transactions on Software Engineering and Methodology 17, 2, Article No. 9. Google Scholar
Digital Library
- Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. 1994. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Boston, MA. Google Scholar
Digital Library
- Ronald Garcia, Roger Wolff, Éric Tanter, and Jonathan Aldrich. 2013. Featherweight Typestate. Technical Report CMU-ISR-13-112. Carnegie Mellon University, Pittsburgh, PA.Google Scholar
- Simon Gay, Vasco Vasconcelos, António Ravara, Nils Gesbert, and Alexandre Caldeira. 2010. Modular session types for distributed object-oriented programming. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’10). ACM, New York, NY, 299--312. Google Scholar
Digital Library
- Jean-Yves Girard. 1987. Linear logic. Theoretical Computer Science 50, 1, 1--102. Google Scholar
Digital Library
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. 2001. Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23, 3, 396--450. Google Scholar
Digital Library
- Ciera Jaspan and Jonathan Aldrich. 2009. Checking framework interactions with relationships. In ECOOP 2009—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 5653. Springer, 27--51. Google Scholar
Digital Library
- Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2, 6:1--6:34. Google Scholar
Digital Library
- Yossi Levanoni and Erez Petrank. 2006. An on-the-fly reference-counting garbage collector for Java. ACM Transactions on Programming Languages and Systems 28, 1, 1--69. Google Scholar
Digital Library
- Karl Naden, Robert Bocchino, Jonathan Aldrich, and Kevin Bierhoff. 2012. A type system for borrowing permissions. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’12). ACM, New York, NY, 557--570. Google Scholar
Digital Library
- Nomair A. Naeem and Ondrej Lhoták. 2008. Typestate-like analysis of multiple interacting objects. In Proceedings of the 23rd ACM SIGPLAN Conference on Object-Oriented Programming Systems Languages and Applications (OOPSLA’08). ACM, New York, NY, 347--366. Google Scholar
Digital Library
- Mangala G. Nanda, Christian Grothoff, and Satish Chandra. 2005. Deriving object typestates in the presence of inter-object references. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’05). ACM, New York, NY, 77--96. Google Scholar
Digital Library
- Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press, Cambridge, MA. Google Scholar
Digital Library
- Amr Sabry and Matthias Felleisen. 1993. Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation 6, 3--4, 289--360. Google Scholar
Digital Library
- Darpan Saini, Joshua Sunshine, and Jonathan Aldrich. 2010. A theory of typestate-oriented programming. In Proceedings of the 12th Workshop on Formal Techniques for Java-Like Programs (FTFJP’10). ACM, New York, NY, Article No. 9. Google Scholar
Digital Library
- Jeremy Siek and Walid Taha. 2006. Gradual typing for functional languages. In Proceedings of the Scheme and Functional Programming Workshop. ACM, New York, NY.Google Scholar
- Jeremy Siek and Walid Taha. 2007. Gradual typing for objects. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’07). Springer-Verlag, Berlin, Heidelberg, 2--27. Google Scholar
Digital Library
- Jeremy G. Siek and Manish Vachharajani. 2008. Gradual typing with unification-based inference. In Proceedings of the 2008 Symposium on Dynamic Languages (DLS’08). ACM, New York, NY, 7:1--7:12. Google Scholar
Digital Library
- Sven Stork. 2013. Æminium: Freeing Programmers from the Shackles of Sequentiality. Ph.D. Dissertation. Carnegie Mellon University, Pittsburgh, PA.Google Scholar
- Robert E. Strom and Shaula Yemini. 1986. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering 12, 1, 157--171. Google Scholar
Digital Library
- Joshua Sunshine, Karl Naden, Sven Stork, Jonathan Aldrich, and Éric Tanter. 2011. First-class state change in plaid. In Proceedings of the 2011 ACM International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’11). ACM, New York, NY, 713--732. Google Scholar
Digital Library
- David Walker. 2005. Substructural type systems. In Advanced Topics in Types and Programming Languages, Benjamin Pierce (Ed.). MIT Press, Cambridge, MA, 3--43.Google Scholar
- Roger Wolff, Ronald Garcia, Éric Tanter, and Jonathan Aldrich. 2011. Gradual typestate. In ECOOP 2011—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 6813. Springer, 459--483. Google Scholar
Digital Library
- Roger Wolff, Ronald Garcia, Éric Tanter, and Jonathan Aldrich. 2013. Gradual Featherweight Typestate. Technical Report CMU-ISR-13-113. Carnegie Mellon University, Pittsburgh, PA.Google Scholar
Index Terms
Foundations of Typestate-Oriented Programming
Recommendations
Typestate-oriented programming
OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference companion on Object oriented programming systems languages and applicationsObjects model the world, and state is fundamental to a faithful modeling. Engineers use state machines to understand and reason about state transitions, but programming languages provide little support for reasoning about or implementing these state ...
Modular typestate checking of aliased objects
Proceedings of the 2007 OOPSLA conferenceObjects often define usage protocols that clients must follow inorder for these objects to work properly. Aliasing makes itnotoriously difficult to check whether clients and implementations are compliant with such protocols. Accordingly, existing ...
Java Typestate Checker
Coordination Models and LanguagesAbstractDetecting programming errors and vulnerabilities in software is increasingly important, and building tools that help developers with this task is a crucial area of investigation on which the industry depends. In object-oriented languages, one ...






Comments