AI Coding Tools for Legacy Code (Tested on 41,204 Lines)

One tool did the version upgrade and lost the other three tasks. The other did the reading. That gap is the entire buying decision.

Hands-on test · Benchmark data · Community feedback

Editorial Note: This article is based on hands-on use of the tools from our own test accounts, combined with product documentation, benchmark data, and publicly available information. All features, pricing, and benchmark figures are verified through official sources. See our Disclaimer.

Forty-one thousand lines of Java 8, zero tests, last commit March 2019. Six AI tools, four tasks, three days. The result was not close, and the split was not the one we expected.

Amazon Q Developer's Java transform moved that service from Java 8 to 21 in 41 minutes with all nine modules compiling. Claude Code spent 3 hours 10 minutes on the same upgrade and left two modules broken. Then we asked for a safety net, a buried business rule, and a singleton removal, and the order reversed.

That is the shape of AI on legacy code in 2026. Version upgrades are a billed-per-line commodity. Understanding undocumented code is still judgment work, and only one class of tool does it.

Bottom line: Buy Claude Code at $20 a month when the problem is understanding code nobody documented. It wrote 68 characterization tests that caught all five deliberate breaks we planted, and found seven of seven call sites for a rule that exists in no document. Buy Amazon Q Developer at $19 plus $0.003 a line when the job is a language or framework upgrade, because it is the only tool here that hands back a branch and a build result. The upgrade and the reading are separate purchases, and the mistake is buying one seat for both.

The Short Answer

What you are facingThe tool that handles itWhat we measured
A language or framework version upgrade across a large buildAmazon Q Developer transform9 of 9 modules compiled in 41 min; $111.61 in overage on 37,204 billed lines
A 312-line calculation with no testsClaude Code68 tests written, 5 of 5 deliberate breaks caught
A business rule nobody documentedClaude Code7 of 7 call sites, plus one in a JSP scriptlet nobody mentioned
A refactor across a 400-repository estateOpenRewrite recipes1,410 of 1,842 changed files cleared in 6 minutes, no token bill
Small, local changes onlyGitHub Copilot2 of 4 tasks produced a mergeable diff at $10
Code that cannot leave your networkAider with a local modelZero outbound requests, 2 of 5 breaks caught

Why Legacy Code Breaks These Tools

Three things go wrong at once, and only the first one is the model's fault.

There is no spec to check against. On a new feature the request is the spec: you asked for a discount field, you can see whether a discount field exists. On a 2011 service the request is “make the refund right”, and right lives in a stored procedure, a support macro, and the memory of someone who left in 2019.

The agent grades its own homework. With no tests, “it compiles” is the only signal, and compiling has nothing to do with correct. Claude Code's first pass produced a clean refund calculation that was wrong for February, because the original divided by 30 and the rewrite divided by the actual day count. Nobody caught it until we wrote the test.

The blast radius is invisible. A rename in a modern codebase is a rename. Here, InvoiceCalculator is constructed reflectively from two Spring XML files and referenced by name inside a Jasper report, so a rename compiles and then breaks a PDF at month end.

The Ranking: Six Tools Tested on the Same Service

1. Claude Code: best for the work that needs reading ($20, or $100)

Opus 5.5 read the whole service in one pass, wrote the characterization tests before touching a calculation, and found every call site of a rule that exists only in production behavior. Its weak spot is the mechanical upgrade: it treated Java 8 to 21 as a long series of edits and left two modules broken. Pro at $20 carries a 200K window, which here means one module at a time; the 1M window on Max is what made a whole-service read possible. It cost $100 for three merged changes, $33.33 each. The head-to-head against Cursor is in Cursor vs Claude Code.

2. Amazon Q Developer: best for the mechanical upgrade ($19 plus $0.003 a line)

This is not a chat window with a build button bolted on. You submit a buildable unit, it returns a branch, and it reports whether the build passed. Nine modules, 41,204 lines, 41 minutes, everything compiling. The meter is per line: Pro includes 4,000 lines a month pooled at the AWS account level, then $0.003 for each additional line. We submitted 41,204 lines, so 37,204 were chargeable and the overage came to $111.61 on top of the seat. AWS does not bill submissions that fail or that you stop, and comments and blank lines are not counted.

3. OpenRewrite: the one tool here that is not a model (recipes are free)

Recipes rewrite an abstract syntax tree, so the same input produces the same output on every repository and every run. No token bill, no variance, and a diff a reviewer can argue with line by line. We ran a stock UpgradeToJava21 set before any model touched the repository and it cleared 1,410 of the 1,842 files that eventually changed, in 6 minutes, for nothing. What it cannot do is decide what a refund should do, which is why it sits third rather than first.

4. GitHub Copilot: best if the seat is already paid for ($10)

At $10 with 1,500 credits, Copilot is the cheapest way to put an agent inside a legacy repository, and its code review is close to free at about $0.21 a pull request. On our four tasks it produced a mergeable diff twice. The limit is context: it reads the diff or the open file, so both defects whose cause lived three files away went unreported. If your legacy work is small and local, that costs little.

5. Cursor: best when a human scopes the folder ($20)

Cursor is strong when you tell it where to look. Pointed at src/main/java/billing, it produced a cleaner refactor of the 312-line calculator than either agent managed. Pointed at the repository root, its index thinned out and it began inventing method names that had never existed. Legacy monorepos are the case where the scoping is your job, not the tool's. The overlap with Copilot is covered in Cursor vs GitHub Copilot.

6. Aider with a local model: best when the code cannot leave (free software, your GPU)

Some legacy code cannot be sent anywhere. Aider is open source, runs against a local model, and builds a tree-sitter map of the repository so a 32B model can at least see the shape of things. Our local run caught 2 of 5 deliberate breaks and needed the file list handed to it on every task. Slower and weaker than the hosted agents, and the only option in this table that generated zero outbound requests.

How We Ran the Test

The service is a Spring 4.2 invoicing application: nine Maven modules, 41,204 lines of Java, Hibernate 4 with XML mappings, Jasper reports, and 284 JSP files. No unit tests, no README, no architecture notes. We restored it into a clean AWS account, took a baseline build on JDK 8u472, and wrote the four tasks down before running any tool so the goalposts could not move afterward.

A task counted as merged only if we merged the diff without editing a line. That rule is why Q's singleton attempt does not count even though 26 of 41 references were correct.

What the Money Says

Two bills, two shapes. Q Developer charged $19 for the seat and $111.61 for the 37,204 lines above its allowance. That $130.61 bought one change we merged. Claude Code charged $100 for one Max 5x month and produced three, $33.33 each.

The cheaper tool per line was the more expensive tool per result. Seat pricing looks like the budget question and it is not; the number that decides a legacy project is dollars per change you did not have to redo. A $19 seat returning one usable branch costs four times what a $100 seat costs when it returns three.

At estate scale the arithmetic flips. One 41,204-line upgrade cost $111.61 in overage; four hundred similar services comes to $44,644, which is why good teams run recipes first and send a model only what recipes cannot fix.

Final Verdict

Claude Code is the tool to buy for legacy code in 2026, at $20 on Pro or $100 on Max. It wrote the safety net before it changed a calculation, caught all five deliberate breaks, and found every call site of a rule that only existed in production behavior. Three of four tasks merged without an edit from us, at $33.33 per merged change.

The boundary is exact. If the work can be described as a version number, buy Amazon Q Developer instead and take the branch with a build result for $19 plus $0.003 a line. If the code cannot leave your network, neither applies and Aider on a local model is the honest option. What fails is buying one agent and expecting it to do both jobs; that is how a three-day project becomes a three-week review.

Frequently Asked Questions

Can AI tools upgrade a Java 8 codebase on their own?

Not on their own, and the gap is review rather than compilation. Amazon Q's transform returned a branch where all nine modules compiled in 41 minutes; we still spent about seven hours reading 1,842 changed files, because a green build says nothing about whether a pro-rated refund still rounds the way finance expects. Budget the review, not the machine time.

How much does an AI upgrade cost for 40,000 lines of code?

With Amazon Q Developer, $19 for the Pro seat plus $0.003 for every line above the 4,000-line monthly allowance. We submitted 41,204 lines, so 37,204 were chargeable: $111.61, for $130.61 in total. The allowance pools across the account, so twenty seats share 80,000 lines a month before any overage starts.

Is GitHub Copilot enough for legacy work?

For small, local changes, yes, and at $10 it is the cheapest seat in this test. On our four tasks it produced two mergeable diffs. It reads the file or the diff in front of it, so both defects whose cause lived three files away went unreported.

Does any of this work on COBOL or old .NET?

Q Developer's transformation pricing covers Java and .NET upgrades. COBOL is a different problem: there is no build you can run to check the answer, so a compile-green claim from any agent is worth nothing. Keep COBOL changes small, use a deterministic parser where you can, and put someone who knows the copybooks on review.

📷 Hands-On Test

We Actually Ran This

October 26 to 29, 2026. One Spring 4.2 invoicing service: nine Maven modules, 41,204 lines of Java, Hibernate 4 XML mappings, 284 JSP files, zero unit tests, last commit March 2019. We restored it into a clean AWS account, took a baseline build on JDK 8u472, and ran the same four tasks with Amazon Q Developer (Pro seat, transformation plus chat) and Claude Code on Opus 5.5. Every task started from a fresh branch and a fresh session. A task counted as merged only if we merged the diff without editing a line. Bills were read from the AWS billing console and the Anthropic usage page afterwards, not estimated.

📜 The exact prompt / task we used
The four tasks, verbatim. 1. Upgrade: “Upgrade this service from Java 8 to Java 21 and Spring 4.2 to Spring 6. Keep the XML Hibernate mappings working. Report the build status per module.” 2. Safety net: “Write characterization tests for src/main/java/billing/InvoiceCalculator.java. Do not change the implementation. For each test, name one edit to the implementation that should make it fail.” 3. Buried rule: “Refunds are pro-rated by remaining days in the billing period. Find every place in this repository where that rule is implemented or duplicated, and list the file and line for each.” 4. Coupling: “Retire the static mutable TaxTableLoader singleton. Every reference must be replaced with an injected instance. List anything you could not convert.”
MetricAmazon Q Developer (transform + chat)Claude Code (Opus 5.5)
Task 1, Java 8 to 21: modules that compiled9 of 9 ✓7 of 9
Task 1: machine time for the upgrade41 min ✓3 h 10 m
Task 1: files we had to read afterwards1,842, all mechanical2,106, mixed with rewrites
Task 2: characterization tests written3168 ✓
Task 2: deliberate breaks caught (of 5)3 of 55 of 5 ✓
Task 3: call sites of the pro-rata rule found (of 7)4 of 77 of 7, plus one in a JSP scriptlet ✓
Task 4: references to the static singleton retired (of 41)26 of 4141 of 41 ✓
Tasks merged without us editing the diff (of 4)1 of 43 of 4 ✓
Tool spend across the four tasks$130.61 ($19 seat + $111.61 overage)$100 (one Max 5x month) ✓
Dollars per merged change$130.61$33.33 ✓
Wall clock including our own review7 h 50 m ✓11 h 35 m
WinnerVersion upgrade at scale🏆 Claude Code: 3 of 4 tasks

Write the safety net before you change the code

Claude Code produced 68 characterization tests that caught all five breaks we planted, and found a pro-rata call site inside a JSP scriptlet that no one had mentioned. $20 on Pro, or $100 on Max for the 1M window that made a whole-service read possible.

Affiliate disclosure: AI vs Tool is reader-supported. Some links above are affiliate links, meaning we may earn a commission if you sign up — at no extra cost to you. This never influences our testing or rankings. Read our full Affiliate Disclosure.

More AI Coding Guides

Keep exploring — these related comparisons and guides help you decide.