Typestate protocol specification in JML

The Java Modeling Language (JML) is a language for specifying the behavior of Java source code. However, it can describe the protocols of Java classes and interfaces only implicitly. Typestate protocol specification is a more direct, lightweight and abstract way of documenting usage protocols for object-oriented programs. In this paper, we propose a technique for incorporating the typestate concept into JML for specifying protocols of Java classes and interfaces, based on our previous research on typestate protocol specifications [4]. This paper presents a set of formal translation rules for encoding typestate protocol specifications into pre/post-condition specifications. It shows how typestate protocol specifications can be mixed with pre/post-condition specifications and how violations of code contracts in inheritance can be handled. Finally, our proposed technique is demonstrated within the Java/JML environment to show its effectiveness.

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

[2]  C. A. R. HOARE,et al.  An axiomatic basis for computer programming , 1969, CACM.

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

[4]  Gerald Baumgartner,et al.  Compiler and tool support for debugging object protocols , 2000, SIGSOFT '00/FSE-8.

[5]  Edmund M. Clarke,et al.  Formal Methods: State of the Art and Future Directions Working Group Members , 1996 .

[6]  Albert L. Baker,et al.  Preliminary design of JML: a behavioral interface specification language for java , 2006, SOEN.

[7]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

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

[9]  Jonathan Aldrich,et al.  Lightweight object specification with typestates , 2005, ESEC/FSE-13.

[10]  Ib Holm Sørensen A Specification Language , 1981, Program Specification.

[11]  David Harel,et al.  Statecharts: A Visual Formalism for Complex Systems , 1987, Sci. Comput. Program..

[12]  Roger Duke,et al.  Object-Z: a specification language advocated for the description of standards , 1995 .

[13]  Bertrand Meyer,et al.  Specification Language , 1980, On the Construction of Programs.

[14]  K. Rustan M. Leino,et al.  The Spec# Programming System: An Overview , 2004, CASSIS.

[15]  Yoonsik Cheon,et al.  Specifying and Checking Method Call Sequences in JML , 2005, Software Engineering Research and Practice.

[16]  Gary T. Leavens,et al.  JML's Rich, Inherited Specifications for Behavioral Subtypes , 2006, ICFEM.