AI migrated legacy COBOL programs to Java, bugs included
TL;DR Highlight
Running COBOL and generated Java side by side let an agent reach near-full branch coverage.
Who Should Read
Backend developers migrating legacy code with AI who need a way to check the result matches the original
Core Mechanics
- Run original and output side by side
- The COBOL source and the generated Java are each instrumented with mocks and run off-mainframe on commodity hardware.
- Deterministic parity checks compare outputs for the same inputs.
- Witness Search pushes through branches
- An agent varies input mocks to get through program branches one by one.
- Parity-preserving mutations follow.
- Locked Paragraphs explain the stalls
- When input search can't go deeper, an analyzer identifies the condition blocking exploration.
- That condition is the Locked Paragraph, and resolving it gets past the input-search plateau.
- Coverage improved in three case studies
- Two open-source programs and one internal production-like COBOL program, 430 to 4,114 lines.
- Nearly complete coverage on the open-source ones and 91.90% branch coverage on the internal one.
- Every accepted test matched
- The generated Java matched the COBOL reference in all accepted test cases.
- The authors claim a novel way to validate agentic coding output with a deterministic oracle.
Community Reactions
- Opinion that COBOL is the whole mainframe environment
- Commenters say 99.99% uptime and live CPU swapping aren't replaced by a language port.
- Several asked how JCL, CICS, sort processors, and messaging map to Java.
- Criticism that the test scale is tiny
- A commenter noted the largest case was 4kloc while production COBOL is hundreds of billions of lines.
- The IRS was cited as having about 160 programs averaging 230kloc.
- Experience with an LLM inventing preprocessor behavior
- A commenter fed real production code with a custom preprocessor to LLMs without an agent harness.
- The models made up what it did, and Gemini 2.5 didn't even notice the preprocessor.
- Example of GOTO translation adding new bugs
- A commenter showed that with COUNTER at 10, COBOL prints 11 while a while-loop translation prints nothing.
- Similar tools mentioned include Mechanical Orchard's approach and the coboltwin comparison tool.
How to Apply
- Write a script comparing old and new code on the same inputs
- Pick one function you're migrating today and build a harness that calls both implementations.
- Feed 20 sample inputs and diff the outputs for exact equality.
- Replace external dependencies with mocks and run locally
- Swap DB, messaging, and file calls for JSON-in/JSON-out mocks.
- Make both implementations read the same mock data so runs are reproducible.
- Have an agent analyze uncovered branches
- Extract branches never hit from your coverage report and give them to an LLM.
- Ask what condition blocks each one and have it generate inputs that reach it.
- Set the pass criterion as output parity
- Add a CI step that fails whenever the two implementations differ.
- Accept LLM-generated tests only if they pass on the original first.
Try It
# Paste into Claude or ChatGPT (simplified version of the paper's method: blocked-branch analysis)
I'm migrating legacy code to a new language. I'll give you the original code and a coverage report. Do the following.
[Original code]
{{original code}}
[Branches never executed]
{{uncovered branches}}
[Instructions]
1. For each uncovered branch, explain in one line the condition blocking entry (the equivalent of a Locked Paragraph).
2. Write input mock values as JSON that would get through that condition.
3. State the expected output on the original. If you don't know, say so.
Next step: feed the inputs to both the original and the new implementation and diff the outputs.Terminology
Related Papers
Gemini 4 Neon is the new #1 on the Models Engineering Index
Gemini 4 Neon ranks first on the Models Engineering Index with 68.0, combining multiple benchmarks.
LLMs can read and write executables byte by byte from a hex dump
Given only a hex dump and no tools, an LLM analyzed, patched and wrote working executables.
Claude was trained on protein sequences at scale
Next-amino-acid tests on obscure proteins show only the latest Claude models predict them
Remembered as Brief: Stored Preferences SilentlyRemove Decision-Critical Information
A stored 'keep it short' preference silently drops warnings; listing must-know points first restores content.
All AI-generated code should be Open Source
A blog argues AI-generated code should be open source; most HN commenters disagreed.
What thousands of conversations look like inside a language model
Mapping Qwen3-1.7B states showed Chinese sitting apart from English, while German and Croatian overlapped it.
AI, activity, and outcomes in software engineering
AI sped up writing code, but shipping speed did not rise as much, says a talk
LLMs Play Zachtronics' TIS-100
16 LLMs played TIS-100 and set 133 new Pareto frontier points across 18 puzzles