ABSTRACT
Postconditions are predicates that specify the intended behavior of a program by capturing properties about the program state when the program finishes its execution. Although postconditions can help to improve many software reliability analyses, they are seldom found accompanying source code. Thus, tools that assist developers in specifying postconditions are useful. This tool demo paper presents EvoSpex, a tool based on evolutionary computation that automatically infers postconditions of Java methods. Given a target Java method and a test suite for it, our tool executes the test suite to obtain valid pre/post state pairs for the method under analysis. Then, these pairs are mutated to obtain (allegedly) invalid ones, and finally a postcondition assertion characterizing the current method behavior is produced, by using an evolutionary algorithm that searches for an assertion that is satisfied by the valid pre/post state pairs and leaves out the invalid ones. EvoSpex implements a classic genetic algorithm that explores the space of candidate postconditions over a JML-like specification language. The algorithm is guided by a fitness function that aims at precisely capturing the valid state pairs, rejecting the invalid ones, and that also favors more succinct assertions.
- Earl T. Barr, Mark Harman, Phil McMinn, Muzammil Shahbaz, and Shin Yoo. 2015. The Oracle Problem in Software Testing: A Survey. IEEE Trans. Software Eng., 41, 5 (2015), 507–525. https://doi.org/10.1109/TSE.2014.2372785 Google ScholarDigital Library
- Patrice Chalin, Joseph R. Kiniry, Gary T. Leavens, and Erik Poll. 2005. Beyond Assertions: Advanced Specification and Verification with JML and ESC/Java2. In Formal Methods for Components and Objects, 4th International Symposium, FMCO 2005, Amsterdam, The Netherlands, November 1-4, 2005, Revised Lectures. 342–363. https://doi.org/10.1007/11804192_16 Google ScholarDigital Library
- Robert W. Floyd. 1967. Assigning meanings to programs. In Mathematical Aspects of Computer Science, Proceedings of Symposia in Applied Mathematics 19, J. T. Schwartz (Ed.). Providence. 19–32. Google Scholar
- Carlo A. Furia, Martin Nordio, Nadia Polikarpova, and Julian Tschannen. 2017. AutoProof: auto-active functional verification of object-oriented programs. Int. J. Softw. Tools Technol. Transf., 19, 6 (2017), 697–716. https://doi.org/10.1007/s10009-016-0419-0 Google ScholarDigital Library
- Charles A. R. Hoare. 1969. An Axiomatic Basis for Computer Programming. Commun. ACM, 12, 10 (1969), 576–580. https://doi.org/10.1145/363235.363259 Google ScholarDigital Library
- Daniel Jackson. 2006. Software Abstractions - Logic, Language, and Analysis. MIT Press. isbn:978-0-262-10114-1 http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10928 Google Scholar
- Gunel Jahangirova, David Clark, Mark Harman, and Paolo Tonella. 2016. Test oracle assessment and improvement. In Proceedings of the 25th International Symposium on Software Testing and Analysis, ISSTA 2016, Saarbrücken, Germany, July 18-20, 2016, Andreas Zeller and Abhik Roychoudhury (Eds.). ACM, 247–258. https://doi.org/10.1145/2931037.2931062 Google ScholarDigital Library
- Calvin Loncaric, Michael D. Ernst, and Emina Torlak. 2018. Generalized Data Structure Synthesis. In Proceedings of the 40th International Conference on Software Engineering (ICSE ’18). Association for Computing Machinery, New York, NY, USA. 958–968. isbn:9781450356381 https://doi.org/10.1145/3180155.3180211 Google ScholarDigital Library
- Bertrand Meyer. 1997. Object-Oriented Software Construction, 2nd Edition. Prentice-Hall. isbn:0-13-629155-4 Google ScholarDigital Library
- Facundo Molina, Pablo Ponzio, Nazareno Aguirre, and Marcelo F. Frias. 2021. EvoSpex: An Evolutionary Algorithm for Learning Postconditions. In 43rd IEEE/ACM International Conference on Software Engineering, ICSE 2021, Madrid, Spain, 22-30 May 2021. IEEE, 1223–1235. https://doi.org/10.1109/ICSE43902.2021.00112 Google ScholarDigital Library
- Todd W. Schiller and Michael D. Ernst. 2012. Reducing the barriers to writing verified specifications. In Proceedings of the 27th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2012, part of SPLASH 2012, Tucson, AZ, USA, October 21-25, 2012, Gary T. Leavens and Matthew B. Dwyer (Eds.). ACM, 95–112. https://doi.org/10.1145/2384616.2384624 Google ScholarDigital Library
Index Terms
- EvoSpex: A Search-Based Tool for Postcondition Inference
Recommendations
Fuzzing class specifications
ICSE '22: Proceedings of the 44th International Conference on Software EngineeringExpressing class specifications via executable constraints is important for various software engineering tasks such as test generation, bug finding and automated debugging, but developers rarely write them. Techniques that infer specifications from code ...
Inferring specifications to detect errors in code
AbstractA new technique is presented to statically check a given procedure against a user-provided property. The method requires no annotations; it automatically infers a context-dependent specification for each procedure call, so that only as much ...
An algorithm and tool to infer practical postconditions
ICSE '18: Proceedings of the 40th International Conference on Software Engineering: Companion ProceeedingsManually writing pre- and postconditions to document the behavior of a large library is a time-consuming task; what is needed is a way to automatically infer them. Conventional wisdom is that, if one has preconditions, then one can use the strongest ...
Comments