Escalating LLM-based Code Translation Benchmarking into the Class-level Era

Pengyu Xue, Linhao Wu, Chengyi Wang, Xiang Li, Zhen Yang, Ruikai Jin, Yuxiang Zhang, Jia Li, Yifei Pei, Zhaoyan Shen, Xiran Lyu · DOI

Introduction

While Large Language Models (LLMs) have demonstrated proficiency in translating short, standalone code snippets, they face significant hurdles when tasked with translating entire classes. Existing benchmarks primarily focus on "method-level" or "statement-level" tasks—algorithmic snippets that exist in isolation. However, real-world software development relies on object-oriented structures where methods share fields, call one another, and depend on specific library ecosystems. This paper introduces ClassEval-T, the first benchmark designed to evaluate class-level code translation, revealing a dramatic performance drop (often exceeding 50%) compared to traditional benchmarks due to complex inter-dependencies.

The ClassEval-T Benchmark

To address the limitations of existing datasets, the researchers developed ClassEval-T. This benchmark features 94 practical coding tasks involving database operations, game design, and more, across three parallel languages: Python, Java, and C++. Unlike previous benchmarks that focus on isolated logic, ClassEval-T requires models to maintain consistency across 386 methods while managing class states and dependencies.

Comparison of ClassEval-T with existing code translation benchmarks, highlighting its unique class-level granularity and practical focus.

The dataset was created through 360 person-hours of manual migration to ensure semantic equivalence and high test coverage (~99% statement coverage). As shown in the comparison above, ClassEval-T is the only benchmark categorized as "Practical" with "Class-level" granularity, providing a more rigorous testbed for professional software engineering tasks.

Experimental Setup

The study evaluated a wide range of LLMs, including commercial giants and open-source models, to determine their effectiveness in class-level migration.

Overview of the Large Language Models (LLMs) evaluated in the study, categorized by type and scale.

Researchers tested three distinct translation strategies:

  1. Holistic: Translating the entire class in a single prompt.
  2. Min-Dependency: Translating methods sequentially while providing the class "skeleton" (fields and signatures) as context.
  3. Standalone: Translating methods in total isolation.

Beyond standard metrics like Compilation Success Rate (CSR), the team introduced DEP (Dependency Evaluation) to manually assess whether a model is correctly aware of the fields and libraries required for functional code.

Key Findings and Results

The evaluation revealed a "Class-Level Cliff": LLMs experienced a 51% to 79% decline in computational accuracy when moving from method-level to class-level tasks. Even the highest-performing models achieved a class-level accuracy of only approximately 26%.

  • Commercial Dominance: DeepSeek-V3, GPT-4o, and Claude-3.5-Sonnet consistently outperformed open-source alternatives. DeepSeek-V3 showed remarkable parity with GPT-4o, often exceeding it in specific language pairs.
  • Language Disparity: Models are significantly more effective at translating to Python than to Java or C++. C++ proved the most challenging due to its verbose syntax and strict header requirements, often resulting in outputs that exceeded the token limits of smaller models.
  • Context Sensitivity: For frontier models, the Holistic strategy is most effective as they possess the reasoning capacity to maintain consistency. In contrast, smaller models often "hallucinate" dependencies or produce truncated code when given the entire class context at once.
  • Error Taxonomy: Manual analysis of 1,243 failures showed that while Python errors are typically functional, C++ and Java failures are dominated by syntax errors and calls to non-existent functions.

Conclusion and Future Work

ClassEval-T demonstrates that current LLMs are still far from providing reliable "one-click" class migration. While they excel at isolated logic, the inter-method dependencies of object-oriented programming remain a significant challenge. Future research should focus on expanding language diversity (e.g., Rust) and scaling toward "repository-level" translation, which involves managing multiple files and complex directory structures. Additionally, providing models with structural guidance, such as Abstract Syntax Trees, may help reduce the high rate of syntax-related failures in verbose languages like C++.

Summary updated

BibTeX
@article{xue2025escalating,
  author = {Pengyu Xue and Linhao Wu and Chengyi Wang and Xiang Li and Zhen Yang and Ruikai Jin and Yuxiang Zhang and Jia Li and Yifei Pei and Zhaoyan Shen and Xiran Lyu},
  title = {{Escalating LLM-based Code Translation Benchmarking into the Class-level Era}},
  journal = {Proc. ACM Softw. Eng.},
  year = {2025},
  doi = {10.1145/3728940},
}
Figure