Foundation models as oracles for refactoring correctness detection
Abstract Refactoring tools in popular Integrated Development Environments (IDEs) can introduce unintended behavioral changes or compilation errors, a persistent challenge that undermines developer trust in automated transformations. Traditional detection approaches rely on handcrafted preconditions, and static and dynamic analyses, yet remain limited in adaptability and can miss subtle correctness issues. This study examines the potential of foundation models to serve as oracles for detecting refactoring bugs in Java programs. We evaluate zero-shot prompting, without task-specific training, across 226 real refactoring bugs collected over more than a decade from widely used Java IDEs ( IntelliJ-IDEA , Eclipse , and NetBeans ), spanning 47 refactoring types. Our results indicate that foundation models can be effective for this task, although performance varies across models. In the first-run setting, GPT-OSS-20B achieved 80.5% accuracy, while GPT-5.4 reached 93.8%. We also evaluated other open-weight and proprietary models: Gemma-4-31B achieved the strongest result among open-weight models, and Gemini-3.1-Pro-Preview achieved the best overall result among all evaluated models. The two primary models were evaluated over five attempts, whereas the additional models were evaluated in a single-run comparison. Metamorphic testing indicates that model predictions remain largely consistent under the tested semantics-preserving perturbations, but these results should be interpreted as robustness evidence rather than as evidence against memorization or data contamination. Beyond detection accuracy, foundation models can provide short explanations that may help support developer inspection, operate across refactoring types without explicitly encoded refactoring-specific rules, and may serve as lightweight triage aids in development workflows. Our findings suggest that foundation models can complement traditional refactoring checks by flagging suspicious transformations for developer inspection.
Authors
- Jonhnanthan Oliveira (ORCID: https://orcid.org/0000-0002-7782-410X)
- Rohit Gheyi (ORCID: https://orcid.org/0000-0002-5562-4449)
- Baldoíno Fonseca (ORCID: https://orcid.org/0000-0002-0730-0319)
- Rian Melo (ORCID: https://orcid.org/0009-0004-1060-7890)
- Márcio Ribeiro
Institutions
- Universidade Federal de Campina Grande (BR)
- Universidade Federal de Alagoas (BR)
Publication Details
- Journal
- Empirical Software Engineering
- Published
- 2026-08-24
- DOI
- https://doi.org/10.1007/s10664-026-10951-y
- Primary Topic
- Software Engineering Research
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Coordenação de Aperfeiçoamento de Pessoal de Nível Superior
- Conselho Nacional de Desenvolvimento Científico e Tecnológico
- Fundação de Apoio à Pesquisa do Estado da Paraíba
- Instituto Nacional de Ciência e Tecnologia para Engenharia de Software