AI
New System Boosts Code Translation Accuracy by 72% Using Smart Type Mapping and Isolated Testing
MockingBird uses AI-powered type resolution and mock-based validation to improve automated code translation between programming languages without manual correction.
A new approach called MockingBird tackles one of the toughest problems in automated code translation: reliably converting code from one programming language to another while ensuring it still works correctly. The system combines intelligent type mapping with a validation method that tests each piece of code independently.
The Core Challenge#
Translating code between languages like Java and Python has proven difficult for existing tools. The main obstacles are figuring out how types map across different language systems and verifying that the translated code actually does what the original code intended. Previous solutions required manual effort to fix type mappings and risked overfitting validation to test cases—essentially teaching the system to pass tests without truly capturing the original behavior.
How MockingBird Works#
The system tackles the problem in two key phases:
- Type resolution: MockingBird gathers API documentation and surrounding code context, then prompts a large language model to figure out how types from one language should map to equivalent types in another. This automation removes most manual type-mapping work.
- Isolated validation: Rather than translating test cases alongside the code, MockingBird creates mock objects in the target language using custom serialization. This lets developers validate whether each translated code unit behaves identically to the original, without the complications of test translation.
Results and Performance#
Testing on 10 Java-to-Python conversion tasks from the AlphaTrans benchmark, MockingBird lifted functional equivalence success rates from 25.14% to 43.10%—no manual correction needed. A broader evaluation of 700 code fragments showed nearly perfect results: zero false positives (incorrectly marking bad translations as good) and just 0.9% false negatives (missing broken translations). This vastly outperformed GraalVM's 2.4% false positive rate and 7.6% false negative rate.
The approach also works across different AI models—the pipeline maintained its gains whether using the larger DeepSeekCoder-33B or the smaller Devstral-24B, suggesting robustness regardless of which language model backs the system.

