Abstract
Translating entire software repositories presents challenges far beyond function-level code generation, primarily due to complex inter-module dependencies and architectural constraints. This paper introduces Skeleton-Guided-Translation, a framework that utilizes structural "skeletons" to maintain architectural integrity during Java-to-C# migration. Alongside this framework, the authors present TRANSREPO-BENCH, a benchmark that replaces traditional "all-or-nothing" binary evaluations with fine-grained, test-case-level quality metrics. Our findings demonstrate that providing structural guidance is essential for repository-level translation and that current models often possess more logical capability than global build metrics suggest.
Introduction: The Challenge of Repository Translation
Most current Large Language Model (LLM) benchmarks for code translation, such as HumanEval, operate at the function level. However, real-world software modernization involves migrating entire repositories where components are deeply interconnected. When attempting to translate a whole repository at once, two major issues arise:
- Structural Chaos: LLMs often struggle to maintain inter-module coherence and dependency logic across multiple files, leading to inconsistent interfaces.
- Coarse Evaluation: Traditional metrics usually rely on "Build Success." If a single syntax error in one file prevents the entire project from compiling, the evaluation score is zero—even if 95% of the logic was translated perfectly. This binary approach fails to provide useful feedback for researchers or developers.
The Skeleton-Guided-Translation Framework
The authors propose a two-step approach to mitigate structural drift and improve translation accuracy:
Step 1: Skeleton Extraction & Translation
The framework first extracts a "skeleton" of the source repository. This preserves file structures, dependencies, interfaces, and static values, but replaces method bodies with trivial placeholders (e.g., return 0;). This skeleton is translated to the target language (C#) and verified to ensure it compiles, establishing a stable architectural contract.
Step 2: Logic Population
The LLM then populates the method bodies within this stable structural framework. By providing the model with a pre-verified structure, the framework prevents the model from "hallucinating" inconsistent signatures across different files.
Fine-Grained Evaluation Mechanism
To solve the evaluation bottleneck, the system implements a mechanism that extracts specific translated functions and injects them into a guaranteed-compilable version of the skeleton. Individual unit tests are then run against these isolated segments. This allows the framework to identify exactly which parts of the translation succeeded and which failed, decoupling "logic correctness" from "global compilation success."
TRANSREPO-BENCH
The paper introduces TRANSREPO-BENCH, a dataset designed to test this framework. It consists of:
- 13 translation tasks derived from high-quality, open-source Java repositories (specifically the "java-design-patterns" library).
- Target Skeletons: Pre-verified C# structural frameworks.
- Unit Tests: Corresponding C# unit tests and automated build configurations (YAML) to validate the results.
Key Insights and Results
The researchers evaluated several state-of-the-art models, leading to several critical observations:
- Top Performer: DeepSeek-v3 emerged as the most effective model, achieving a 71.14% build rate and a 17.56% unit test pass rate by the third iteration of refinement.
- The Necessity of Skeletons: In an ablation study, removing the skeleton caused performance to crater. Without the structural guide, models could not resolve inter-file dependencies, leading to near-zero scores for most repositories.
- The "Error Propagation" Trap: The study found that iterative refinement—asking a model to fix its own errors—is not always beneficial. In some cases, errors from early iterations accumulated, particularly with models like GPT-4-turbo, which saw its build rate drop from 60% to 50% in later stages.
- Isolation is Essential: By testing functions in isolation, the researchers revealed that models are often much better at logic than they appear to be when judged by a global build script.
Limitations and Future Work
Currently, the benchmark is limited to Java-to-C# translation. Additionally, creating the initial "gold standard" target skeleton still requires significant manual effort. Future work will focus on expanding the language scope and improving automated repair scripts to reduce the human intervention required for skeleton and unit test validation.
Summary updated