Document Open Access Logo

On Using VeriFast, VerCors, Plural, and KeY to Check Object Usage (Experience Paper)

Authors João Mota , Marco Giunti , António Ravara

Thumbnail PDF


  • Filesize: 0.87 MB
  • 29 pages

Document Identifiers

Author Details

João Mota
  • NOVA LINCS and NOVA School of Science and Technology, Caparica, Portugal
Marco Giunti
  • NOVA LINCS and NOVA School of Science and Technology, Caparica, Portugal
  • School of Computing, Engineering & Digital Technologies, Teesside University, Middlesbrough, UK
António Ravara
  • NOVA LINCS and NOVA School of Science and Technology, Caparica, Portugal


We would like to thank several members of the developer teams for the detailed responses and enlightening discussions, in particular, Bart Jacobs (VeriFast), Marieke Huisman (VerCors), Lukas Armborst (VerCors), Reiner Hähnle (KeY), Eduard Kamburjan (KeY), and Richard Bubel (KeY). Their feedback was indispensable for the development of this study.

Cite AsGet BibTex

João Mota, Marco Giunti, and António Ravara. On Using VeriFast, VerCors, Plural, and KeY to Check Object Usage (Experience Paper). In 37th European Conference on Object-Oriented Programming (ECOOP 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 263, pp. 40:1-40:29, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)


Typestates are a notion of behavioral types that describe protocols for stateful objects, specifying the available methods for each state. Ensuring methods are called in the correct order (protocol compliance), and that, if and when the program terminates, all objects are in the final state (protocol completion) is crucial to write better and safer programs. Objects of this kind are commonly shared among different clients or stored in collections, which may also be shared. However, statically checking protocol compliance and completion when objects are shared is challenging. To evaluate the support given by state of the art verification tools in checking the correct use of shared objects with protocol, we present a survey on four tools for Java: VeriFast, VerCors, Plural, and KeY. We describe the implementation of a file reader, linked-list, and iterator, check for each tool its ability to statically guarantee protocol compliance and completion, even when objects are shared in collections, and evaluate the programmer’s effort in making the code acceptable to these tools. With this study, we motivate the need for lightweight methods to verify the presented kinds of programs.

Subject Classification

ACM Subject Classification
  • Theory of computation → Program reasoning
  • Theory of computation → Logic and verification
  • Theory of computation → Separation logic
  • Java
  • Typestates
  • VeriFast
  • VerCors
  • Plural
  • KeY


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Wolfgang Ahrendt, Bernhard Beckert, Richard Bubel, Reiner Hähnle, Peter H. Schmitt, and Mattias Ulbrich, editors. Deductive Software Verification - The KeY Book - From Theory to Practice, volume 10001 of Lecture Notes in Computer Science. Springer, 2016. URL:
  2. Bernardo Almeida, Andreia Mordido, Peter Thiemann, and Vasco T. Vasconcelos. Polymorphic lambda calculus with context-free session types. Inf. Comput., 289(Part A), 2022. URL:
  3. Davide Ancona et al. Behavioral types in programming languages. Foundations and Trends in Programming Languages, 3(2-3):95-230, 2016. URL:
  4. Lorenzo Bacchiani, Mario Bravetti, Marco Giunti, João Mota, and António Ravara. A Java typestate checker supporting inheritance. Sci. Comput. Program., 221, 2022. URL:
  5. Bernhard Beckert and Reiner Hähnle. Reasoning and Verification: State of the Art and Current Trends. IEEE Intell. Syst., 29(1):20-29, 2014. URL:
  6. Nels E. Beckman. Modular typestate checking in concurrent Java programs. In Companion to the 24th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 737-738. ACM, 2009. URL:
  7. Nels E. Beckman, Kevin Bierhoff, and Jonathan Aldrich. Verifying correct usage of atomic blocks and typestate. In Proceedings of the 23rd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 227-244. ACM, 2008. URL:
  8. Jan A. Bergstra and Jan Willem Klop. Process Algebra for Synchronous Communication. Inf. Control., 60(1-3):109-137, 1984. URL:
  9. Kevin Bierhoff and Jonathan Aldrich. Lightweight object specification with typestates. In Proceedings of the 10th European Software Engineering Conference held jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pages 217-226. ACM, 2005. URL:
  10. Kevin Bierhoff and Jonathan Aldrich. Modular typestate checking of aliased objects. In Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 301-320. ACM, 2007. URL:
  11. Simon Bliudze, Anastasia Mavridou, Radoslaw Szymanek, and Alina Zolotukhina. Exogenous coordination of concurrent software components with JavaBIP. Softw. Pract. Exp., 47(11):1801-1836, 2017. URL:
  12. Simon Bliudze, Petra van Den Bos, Marieke Huisman, Robert Rubbens, and Larisa Safina. JavaBIP meets VerCors: Towards the Safety of Concurrent Software Systems in Java. In 26th International Conference on Fundamental Approaches to Software Engineering, 2023. Google Scholar
  13. Stefan Blom, Saeed Darabi, Marieke Huisman, and Wytse Oortwijn. The VerCors Tool Set: Verification of Parallel and Concurrent Software. In Proceedings of Integrated Formal Methods, volume 10510 of Lecture Notes in Computer Science, pages 102-110. Springer, 2017. URL:
  14. Stefan Blom and Marieke Huisman. Witnessing the elimination of magic wands. Int. J. Softw. Tools Technol. Transf., 17(6):757-781, 2015. URL:
  15. Stefan Blom, Marieke Huisman, and Marina Zaharieva-Stojanovski. History-Based Verification of Functional Behaviour of Concurrent Programs. In Radu Calinescu and Bernhard Rumpe, editors, Software Engineering and Formal Methods - 13th International Conference, Proceedings, volume 9276 of Lecture Notes in Computer Science, pages 84-98. Springer, 2015. URL:
  16. Jan Boerman, Marieke Huisman, and Sebastiaan J. C. Joosten. Reasoning About JML: Differences Between KeY and OpenJML. In Integrated Formal Methods - 14th International Conference, Proceedings, volume 11023 of Lecture Notes in Computer Science, pages 30-46. Springer, 2018. URL:
  17. Richard Bornat, Cristiano Calcagno, Peter O'Hearn, and Matthew Parkinson. Permission accounting in separation logic. In The 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 259-270, 2005. URL:
  18. John Boyland. Checking Interference with Fractional Permissions. In Static Analysis, 10th International Symposium, Proceedings, volume 2694 of Lecture Notes in Computer Science, pages 55-72. Springer, 2003. URL:
  19. Mario Bravetti, Adrian Francalanza, Iaroslav Golovanov, Hans Hüttel, Mathias Jakobsen, Mikkel Kettunen, and António Ravara. Behavioural Types for Memory and Method Safety in a Core Object-Oriented Language. In Asian Symposium on Programming Languages and Systems, volume 12470 of Lecture Notes in Computer Science, pages 105-124. Springer, 2020. URL:
  20. Daniel Bruns, Wojciech Mostowski, and Mattias Ulbrich. Implementation-level verification of algorithms with KeY. Int. J. Softw. Tools Technol. Transf., 17(6):729-744, 2015. URL:
  21. Yoonsik Cheon and Ashaveena Perumandla. Specifying and Checking Method Call Sequences in JML. In Hamid R. Arabnia and Hassan Reza, editors, Proceedings of the International Conference on Software Engineering Research and Practice, volume 2, pages 511-516. CSREA Press, 2005. Google Scholar
  22. David R. Cok. JML and OpenJML for Java 16. In FTfJP 2021: 23rd ACM International Workshop on Formal Techniques for Java-like Programs, 2021, Proceedings, pages 65-67. ACM, 2021. URL:
  23. Leonardo De Moura and Nikolaj Bjørner. Z3: An efficient SMT solver. In International conference on Tools and Algorithms for the Construction and Analysis of Systems, pages 337-340. Springer, 2008. URL:
  24. Robert DeLine and Manuel Fähndrich. Typestates for Objects. In 18th European Conference on Object-Oriented Programming, Proceedings, volume 3086 of Lecture Notes in Computer Science, pages 465-490. Springer, 2004. URL:
  25. José Duarte and António Ravara. Retrofitting Typestates into Rust. In 25th Brazilian Symposium on Programming Languages, pages 83-91. ACM, 2021. URL:
  26. Catarina Gamboa, Paulo Alexandre Santos, Christopher Steven Timperley, and Alcides Fonseca. User-driven Design and Evaluation of Liquid Types in Java. CoRR, abs/2110.05444, 2021. URL:
  27. David Harel. Dynamic logic. In Handbook of philosophical logic, pages 497-604. Springer, 1984. Google Scholar
  28. David Harel. Statecharts: A Visual Formalism for Complex Systems. Sci. Comput. Program., 8(3):231-274, 1987. URL:
  29. Hans-Dieter A. Hiep, Jinting Bian, Frank S. de Boer, and Stijn de Gouw. A Tutorial on Verifying LinkedList Using KeY. In Deductive Software Verification: Future Perspectives - Reflections on the Occasion of 20 Years of KeY, volume 12345 of Lecture Notes in Computer Science, pages 221-245. Springer, 2020. URL:
  30. Charles Antony Richard Hoare. An axiomatic basis for computer programming. Communications of the ACM, 12(10):576-580, 1969. URL:
  31. J.P. Hollander. Verification of a model checking algorithm in VerCors, August 2021. URL:
  32. Kohei Honda, Vasco Thudichum Vasconcelos, and Makoto Kubo. Language Primitives and Type Discipline for Structured Communication-Based Programming. In Proceedings of Programming Languages and Systems, volume 1381 of Lecture Notes in Computer Science, pages 122-138. Springer, 1998. URL:
  33. Marieke Huisman and Raúl E. Monti. On the Industrial Application of Critical Software Verification with VerCors. In Proceedings of Leveraging Applications of Formal Methods, volume 12478 of Lecture Notes in Computer Science, pages 273-292. Springer, 2020. URL:
  34. Hans Hüttel, Ivan Lanese, Vasco T. Vasconcelos, Luís Caires, Marco Carbone, Pierre-Malo Deniélou, Dimitris Mostrous, Luca Padovani, António Ravara, Emilio Tuosto, Hugo Torres Vieira, and Gianluigi Zavattaro. Foundations of Session Types and Behavioural Contracts. ACM Comput. Surv., 49(1):3:1-3:36, 2016. URL:
  35. Reiner Hähnle. Private communication, July 2022. Google Scholar
  36. Bart Jacobs. Modular Verification of Liveness Properties of the I/O Behavior of Imperative Programs. In Leveraging Applications of Formal Methods, Verification and Validation: Verification Principles, Proceedings, volume 12476 of Lecture Notes in Computer Science, pages 509-524. Springer, 2020. URL:
  37. Bart Jacobs. Private communication, March 2022. Google Scholar
  38. Bart Jacobs, Jan Smans, Pieter Philippaerts, Frédéric Vogels, Willem Penninckx, and Frank Piessens. VeriFast: A Powerful, Sound, Predictable, Fast Verifier for C and Java. In NASA Formal Methods - Third International Symposium, Proceedings, volume 6617 of Lecture Notes in Computer Science, pages 41-55. Springer, 2011. URL:
  39. Bart Jacobs, Jan Smans, and Frank Piessens. A Quick Tour of the VeriFast Program Verifier. In Programming Languages and Systems - 8th Asian Symposium, Proceedings, volume 6461 of Lecture Notes in Computer Science, pages 304-311. Springer, 2010. URL:
  40. Ioannis T. Kassios. Dynamic Frames: Support for Framing, Dependencies and Sharing Without Restrictions. In Formal Methods, 14th International Symposium on Formal Methods, Hamilton, Proceedings, volume 4085 of Lecture Notes in Computer Science, pages 268-283. Springer, 2006. URL:
  41. Taekgoo Kim, Kevin Bierhoff, Jonathan Aldrich, and Sungwon Kang. Typestate protocol specification in JML. In Proceedings of the 8th International Workshop on Specification and Verification of Component-Based Systems, pages 11-18. ACM, 2009. URL:
  42. Sophie Lathouwers and Marieke Huisman. Formal Specifications Investigated: A Classification and Analysis of Annotations for Deductive Verifiers. In 10th IEEE/ACM International Conference on Formal Methods in Software Engineering, FormaliSE@ICSE 2022, pages 69-79. ACM, 2022. URL:
  43. Gary T. Leavens, Albert L. Baker, and Clyde Ruby. Preliminary design of JML: A behavioral interface specification language for Java. ACM SIGSOFT Softw. Eng. Notes, 31(3):1-38, 2006. URL:
  44. K Rustan M Leino and Peter Müller. A basis for verifying multi-threaded programs. In European Symposium on Programming, pages 378-393. Springer, 2009. URL:
  45. K Rustan M Leino, Peter Müller, and Jan Smans. Verification of concurrent programs with Chalice. In Foundations of Security Analysis and Design V, pages 195-222. Springer, 2009. URL:
  46. Bertrand Meyer. Applying 'design by contract'. Computer, 25(10):40-51, 1992. URL:
  47. João Mota, Marco Giunti, and António Ravara. Java Typestate Checker. In Proc. of Coordination Models and Languages (COORDINATION), volume 12717 of Lecture Notes in Computer Science, pages 121-133. Springer, 2021. URL:
  48. Peter Müller, Malte Schwerhoff, and Alexander J. Summers. Viper: A Verification Infrastructure for Permission-Based Reasoning. In Proceedings of Verification, Model Checking, and Abstract Interpretation, volume 9583 of Lecture Notes in Computer Science, pages 41-62. Springer, 2016. URL:
  49. Oscar Nierstrasz. Regular types for active objects. ACM sigplan Notices, 28(10):1-15, 1993. Google Scholar
  50. Peter O'Hearn. Resources, concurrency, and local reasoning. Theoretical computer science, 375(1-3):271-307, 2007. URL:
  51. Peter O'Hearn, John Reynolds, and Hongseok Yang. Local reasoning about programs that alter data structures. In International Workshop on Computer Science Logic, pages 1-19. Springer, 2001. URL:
  52. Wytse Hendrikus Marinus Oortwijn. Deductive techniques for model-based concurrency verification. PhD thesis, University of Twente, 2019. Google Scholar
  53. Matthew J. Parkinson and Alexander J. Summers. The Relationship between Separation Logic and Implicit Dynamic Frames. In Proceedings of Programming Languages and Systems, volume 6602 of Lecture Notes in Computer Science, pages 439-458. Springer, 2011. URL:
  54. Willem Penninckx, Bart Jacobs, and Frank Piessens. Sound, Modular and Compositional Verification of the Input/Output Behavior of Programs. In Programming Languages and Systems, Proceedings, volume 9032 of Lecture Notes in Computer Science, pages 158-182. Springer, 2015. URL:
  55. John C Reynolds. Separation logic: A logic for shared mutable data structures. In Proceedings 17th Annual IEEE Symposium on Logic in Computer Science, pages 55-74. IEEE, 2002. URL:
  56. R.B. Rubbens. Improving Support for Java Exceptions and Inheritance in VerCors. Master’s thesis, University of Twente, 2020. URL:
  57. Ayesha Sadiq, Yuan-Fang Li, and Sea Ling. A survey on the use of access permission-based specifications for program verification. Journal of Systems and Software, 159, 2020. URL:
  58. Jan Smans, Bart Jacobs, Frank Piessens, and Wolfram Schulte. An Automatic Verifier for Java-Like Programs Based on Dynamic Frames. In Fundamental Approaches to Software Engineering, 11th International Conference, Held as Part of the Joint European Conferences on Theory and Practice of Software, Proceedings, volume 4961 of Lecture Notes in Computer Science, pages 261-275. Springer, 2008. URL:
  59. Robert E. Strom and Shaula Yemini. Typestate: A Programming Language Concept for Enhancing Software Reliability. IEEE Trans. Software Eng., 12(1):157-171, 1986. URL:
  60. André Trindade, João Mota, and António Ravara. Typestates to Automata and back: a tool. In Proceedings 13th Interaction and Concurrency Experience, ICE 2020, volume 324 of EPTCS, pages 25-42, 2020. URL:
  61. André Trindade, João Mota, and António Ravara. Typestate Editor., 2022.
  62. Joshua Yanovski, Hoang-Hai Dang, Ralf Jung, and Derek Dreyer. GhostCell: Separating Permissions from Data in Rust. Proc. ACM Program. Lang., 5(ICFP):1-30, 2021. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail