Foundation Models as Oracles for Refactoring Correctness Detection
This study demonstrates that foundation models can effectively serve as adaptable, zero-shot oracles for detecting refactoring bugs in Java programs, achieving high accuracy across diverse IDEs and refactoring types while providing explanatory insights to complement traditional static and dynamic analysis tools.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are a master carpenter who has spent years building beautiful, sturdy tables. You have a set of automated machines (like IDEs) that can help you move a table leg from one side to another or swap out a drawer. These machines are supposed to do the job perfectly without changing how the table functions.
However, sometimes these machines make a mistake. They might move a leg in a way that makes the table wobble, or they might cut a piece off that causes the whole thing to collapse. In the world of software, these mistakes are called refactoring bugs. They can be subtle (the table wobbles) or obvious (the table falls apart and won't even stand up).
For a long time, to catch these mistakes, developers had to write very specific, manual rules for every possible way a machine could mess up. It was like trying to write a rulebook for every single way a table could break. It was hard, slow, and the machines kept finding new ways to break things that the rulebook didn't cover.
The New Idea: The "Super-Inspector"
This paper asks a simple question: Can a "Super-Inspector" (a Foundation Model, which is a type of advanced AI) look at the "Before" and "After" of a table being moved and tell us if it's broken?
The researchers didn't teach the AI specific rules about tables. Instead, they just showed it examples of broken tables and asked, "Is this broken?" This is called zero-shot prompting—like handing a smart person a broken chair and asking, "Is this safe to sit on?" without giving them a manual first.
The Experiment
The researchers gathered 226 real-life examples of broken tables (software bugs) that had happened over the last decade in popular software tools like IntelliJ, Eclipse, and NetBeans. These bugs fell into two categories:
- The "Collapse" (Compilation Errors): The code is so messed up it won't even run.
- The "Wobble" (Behavioral Changes): The code runs, but it does something different than it should (like printing the wrong number or crashing when it shouldn't).
They asked several different "Super-Inspectors" (AI models) to look at these 226 cases and say, "Is this broken?"
What They Found
1. The AI is surprisingly good at spotting mistakes.
- The best AI inspectors (like Gemini-3.1-Pro-Preview and GPT-5.4) got it right almost every time (around 94% to 99% accuracy).
- Even a smaller, free-to-use AI (GPT-OSS-20B) did a pretty good job (around 80% accuracy).
- The AI didn't just say "Yes/No." It could explain why the table was wobbly, which helps the human carpenter understand the problem.
2. Some mistakes are harder than others.
- The AI was great at spotting the "Wobbles" (behavioral changes).
- It was slightly worse at spotting the "Collapses" (compilation errors), especially when the error was very subtle or involved complex rules about how the table parts connect.
- Interestingly, the AI sometimes got confused by the way the table was described. If you added a fake screw or changed the color of the wood (metamorphic testing) without actually changing the structure, the AI still spotted the break. This suggests it's looking at the structure, not just memorizing the picture.
3. The "Big Project" Problem.
- When the researchers tried to use the AI on huge, real-world projects where they only showed it a "diff" (a list of what changed, without the whole picture), the AI often said, "I don't know."
- This happened in about 40% of the cases. The AI realized that without seeing the whole workshop (the full codebase), it couldn't be sure if moving a part would break something hidden in another room.
The Verdict
The paper concludes that these AI "Super-Inspectors" are not perfect replacements for the old, strict rulebooks (traditional tools). The old tools are like a laser level: they are fast, cheap, and 100% accurate for things they can measure.
However, the AI is like a wise, experienced carpenter.
- It can spot tricky problems that the laser level misses.
- It can explain why something is wrong in plain English.
- It can handle new types of wood (new programming languages) without needing a new manual written for them.
The Best Strategy: Use the fast, cheap laser level first. If that doesn't catch everything, or if the problem is weird, ask the AI "Super-Inspector" to take a second look. They work best as a team, not as rivals.
Important Note: The paper only tested this on Java code (a specific type of programming language). It does not claim this works for all languages or that it can replace human judgment entirely. The AI is a helpful assistant, not a magic wand that fixes everything automatically.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.