Formal specifications for APIs help developers correctly use them and enable checker tools automatically verify their uses. However, formal specifications are not always available with released APIs. In this work, we demonstrate an approach for mining API preconditions from a large-scale corpus of open-source software. It considers conditions guarding API calls in client code as potential preconditions of the corresponding APIs. Then it uses consensus among a large number of API usages to keep the ones appearing in the majority. Finally, the mined preconditions are ranked based on their frequencies and reported to users. Categories and Subject Descriptors D.2.1 [Software Engineering]: Requirements/Specifications. Keywords API Preconditions, Software Mining, JML, Big Code.
Hoan Anh Nguyen, Robert Dyer 0001, Tien N. Nguyen,