Introduction
Mainframes continue to serve as the foundational infrastructure for global finance, insurance, and government sectors. Currently, over 200 billion lines of COBOL code remain in production, performing critical transaction processing. However, the aging workforce and the need for cloud-native agility have made modernizing this legacy code into Java a top business priority.
IBM researchers have addressed this challenge within the watsonx Code Assistant for Z (WCA4Z) by developing an automated, hybrid evaluation system. This system is designed to ensure the quality and semantic correctness of COBOL-to-Java translations at scale, overcoming the inherent "black box" nature of Large Language Models (LLMs).
The Challenge of Legacy Modernization
Modernizing mainframe code with LLMs introduces two significant hurdles. First is Model Opacity: LLMs are prone to hallucinations and may lack the robustness required for mission-critical systems. Second is Verification Complexity: Proving that a Java translation is semantically equivalent to the original COBOL is a mathematically undecidable problem. While manual review by Subject Matter Experts (SMEs) is the gold standard, it is impossible to scale for millions of lines of code.
The Automated Evaluation Pipeline
To solve the scaling issue, the researchers built a structured ETL (Extract, Transform, Load) pipeline that triggers automatically whenever a new translation is generated. This pipeline ensures that every snippet of generated code is subjected to a rigorous battery of tests before being presented to a developer.
As shown in the architecture, the pipeline includes several key stages:
- File Listener & Validator: Captures the output from the inference pipeline and ensures basic structural integrity.
- Dataset & Eval Set Processors: Prepares the code for specific benchmarks like GenApp or IMS2.
- Evaluation DB: Stores results for longitudinal tracking and dashboarding.
A Hybrid Strategy for Semantic Equivalence
The core of the system is a "hybrid" evaluation strategy that combines rigid analytic checkers with flexible "LLM-as-a-Judge" (LaaJ) techniques.
Static Analytic Checkers
Using the Tree-sitter parser, the system performs precise checks to verify if the code is parsable and if variable usages remain consistent. A particularly innovative feature is the application of the Needleman-Wunsch algorithm. Originally designed for biological sequence alignment, the algorithm is used here to ensure that middleware calls (such as SQL or CICS) in the Java code align perfectly with those in the source COBOL. This prevents "hallucinated" or missing database calls that might otherwise bypass a simple syntax parser.
LLM-as-a-Judge (LaaJ)
To capture the nuances of idiomatic code that static checkers might miss, the system employs an LLM to act as a critic. The judge grades translations on a 7-point scale, ranging from "No attempt" to "Fully accurate and idiomatic."
To maintain the judge's accuracy, the team uses partial order benchmarks. These are sets of translations where one version is known to be superior to another, allowing the team to calibrate the LLM's scoring logic and ensure it remains "honest" and consistent.
Key Insights: Beyond "JOBOL"
A common pitfall in automated modernization is the creation of "JOBOL"—COBOL logic forced into Java syntax, resulting in unmaintainable, non-idiomatic code. WCA4Z avoids this by using a two-phase approach: a Class Designer first establishes the object-oriented structure, followed by method-level translation. This ensures the output is true, idiomatic Java.
Furthermore, the team utilizes Heatmap Diagnostics. By mapping evaluation scores back to specific COBOL statements, they can identify which language features the LLM struggles with. For example, simple arithmetic statements like ADD typically score high (~5.04/7), while complex CALL statements are significantly more difficult (~2/7), providing a clear roadmap for future model fine-tuning.
Results and Operational Impact
The automated pipeline has significantly reduced the reliance on manual SME review. In comparative analyses, the system successfully differentiated between model versions, showing that while models might perform similarly on basic syntax, they vary significantly in their handling of complex middleware. This data-driven approach allows for continuous integration and faster iteration on translation models, ensuring that the path from legacy COBOL to modern Java is both safe and efficient.
Conclusion
By combining the precision of bio-informatics-inspired static analysis with the holistic reasoning of LLM-based judges, IBM has created a scalable framework for mainframe modernization. Future work will focus on bridging the semantic gap in error handling and refining coverage models to address the most difficult COBOL patterns identified by the system.
Summary updated