Enhancing Automated Contract Generation in Object-Oriented Programming: A Context-Aware LLM-Based Approach

Page content

Context

Design by Contract represents an established, lightweight paradigm for engineering reliable and robust software systems by specifying verifiable expectations and obligations between software components, notably objects in object-oriented programming. For example, OpenJML is an open-source tool for specifying and verifying properties of Java programs using the Java Modeling Language (JML).

Motivation

To mitigate the burden of specifying contracts manually, we recently proposed an LLM-empowered approach to statically generate correct and complete contracts from source code without any upfront investment or auxiliary data. The results are remarkable, though still far from perfect and actionable in practice. For example, we found the model hallucinating and referencing non-existing Java symbols, and similar problems related to visibility violations in OpenJML.

Goal

The goal of this project is to mitigate the shortcomings of the current approach by providing more context information to the model; e.g., the declared fields of a class, the entire class, or even the entire project. The potential improvements shall be evaluated on an existing benchmark.

Requirements

Nice-to-have: Some experience in playing with Large Language Models

Essential: You feel confident with programming in both Java and Python You have heard about the principle of Design by Contract

Pointers

OpenJML: https://www.openjml.org/

Hugging Face: https://huggingface.co/

Greiner, S., Bühlmann, N., Ohrndorf, M., Tsigkanos, C., Nierstrasz, O., and Kehrer, T. (2024). Automated Generation of Code Contracts - Generative AI to the Rescue? ACM SIGPLAN International Conference on Generative Programming: Concepts & Experiences (GPCE 2024)

Greiner, S., Bühlmann, N., Ohrndorf, M., Tsigkanos, C., Nierstrasz, O., and Kehrer, T. (2024). Automated Generation of Code Contracts - Generative AI to the Rescue? [Data set]. ACM. https://doi.org/10.5281/ZENODO.13351003

Contact

Manuel Ohrndorf, manuel.ohrndorf@unibe.ch Roman Machacek, roman.machacek@unibe.ch