Automated Generation of Code Contracts - Generative AI to the Rescue?
Design by Contract represents an established, lightweight paradigm for engineering reliable and robust software systems by specifying verifiable expectations and obligations between software components. Due to its laborious nature, developers hardly adopt Design by Contract in practice. A plethora of research on (semi-)-automated inference to reduce the manual burden has not improved the adoption of so-called code contracts in practice. This paper examines the potential of Generative AI to automatically generate code contracts in terms of pre- and postconditions for any Java project without requiring any additional auxiliary artifact. To fine-tune two state-of-the-art Large Language Models, CodeT5 and CodeT5+, we derive a dataset of more than 14k Java methods comprising contracts in form of Java Modeling Language (JML) annotations, and train the models on the task of generating contracts. We examine the syntactic and semantic validity of the contracts generated for software projects not used in the fine-tuning and find that more than 95% of the generated contracts are syntactically correct and exhibit remarkably high completeness and semantic correctness. To this end, our fully automated method sets the stage for future research and eventual broader adoption of Design by Contract in software development practice.
Tue 22 OctDisplayed time zone: Pacific Time (US & Canada) change
09:00 - 10:30 | |||
09:00 30mDay opening | GPCE24 Opening GPCE | ||
09:30 30mTalk | Automated Generation of Code Contracts - Generative AI to the Rescue? GPCE Sandra Greiner University of Southern Denmark, Noah Bühlmann University of Bern, Manuel Ohrndorf University of Bern, Christos Tsigkanos University of Athens, Greece, Oscar Nierstrasz feenk.com, Timo Kehrer University of Bern Link to publication DOI Pre-print | ||
10:00 30mTalk | An Extensible Feature-Oriented Approach for Fine-Grained Code Quality Analysis GPCE |