Table of Contents
Fetching ...

ClassEval-T: Evaluating Large Language Models in Class-Level Code Translation

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

TL;DR

This work introduces ClassEval-T, the first class-level code translation benchmark, built by manually translating the Python-based ClassEval corpus into Java and C++ and extending it with comprehensive tests and dependencies. Through evaluations of eight diverse LLMs under holistic, min-dependency, and standalone strategies, the study reveals that class-level translation remains substantially harder than method-level translation, with commercial models performing best but still facing non-trivial error rates, particularly for C++/Java. It further analyzes dependency-awareness and provides a rich failure taxonomy across 1,243 cases, offering practical guidance on strategy selection and highlighting key research directions such as improved handling of syntax, dependencies, and runtime behavior. Overall, ClassEval-T serves as a rigorous benchmark to drive progress toward practical, class-level code translation in real-world development settings.

Abstract

In recent years, Large Language Models (LLMs) have dramatically advanced the performance of automated code translation, making their computational accuracy score reach up to over 80% on many previous benchmarks. However, most code samples in these benchmarks are short, standalone, statement/method-level, and algorithmic, which is not aligned with practical coding tasks. Therefore, it is still unknown the actual capability of LLMs in translating code samples written for daily development. To achieve this, we construct a class-level code translation benchmark, ClassEval-T, and make the first attempt to extensively assess recent LLMs' performance on class-level code translation. ClassEval-T is extended from ClassEval, a well-known class-level Python code generation benchmark consisting of multiple practical coding topics, such as database operation and game design, and diverse contextual dependencies (e.g., fields, methods, and libraries). It cost us 360 person-hours to accomplish the manual migration to Java and C++ with complete code samples and associated test suites. Subsequently, we design three translation strategies (i.e., holistic, min-dependency, and standalone) for class-level code translations and evaluate eight recent LLMs of commercial, general, and code kinds in diverse families and sizes on ClassEval-T. Experimental results demonstrate a remarkable performance drop compared with the most widely studied method-level code translation benchmark, and obvious discrepancies among LLMs appear, showing the effectiveness of ClassEval-T in measuring recent LLMs. Afterwards, we further discuss the usage scenarios for diverse translation strategies and LLMs' ability to dependency awareness when translating class samples. Finally, 1,243 failure cases made by the best-performing LLM under test are analyzed and categorized in this paper for practical guidance and future enlightenment.

ClassEval-T: Evaluating Large Language Models in Class-Level Code Translation

TL;DR

This work introduces ClassEval-T, the first class-level code translation benchmark, built by manually translating the Python-based ClassEval corpus into Java and C++ and extending it with comprehensive tests and dependencies. Through evaluations of eight diverse LLMs under holistic, min-dependency, and standalone strategies, the study reveals that class-level translation remains substantially harder than method-level translation, with commercial models performing best but still facing non-trivial error rates, particularly for C++/Java. It further analyzes dependency-awareness and provides a rich failure taxonomy across 1,243 cases, offering practical guidance on strategy selection and highlighting key research directions such as improved handling of syntax, dependencies, and runtime behavior. Overall, ClassEval-T serves as a rigorous benchmark to drive progress toward practical, class-level code translation in real-world development settings.

Abstract

In recent years, Large Language Models (LLMs) have dramatically advanced the performance of automated code translation, making their computational accuracy score reach up to over 80% on many previous benchmarks. However, most code samples in these benchmarks are short, standalone, statement/method-level, and algorithmic, which is not aligned with practical coding tasks. Therefore, it is still unknown the actual capability of LLMs in translating code samples written for daily development. To achieve this, we construct a class-level code translation benchmark, ClassEval-T, and make the first attempt to extensively assess recent LLMs' performance on class-level code translation. ClassEval-T is extended from ClassEval, a well-known class-level Python code generation benchmark consisting of multiple practical coding topics, such as database operation and game design, and diverse contextual dependencies (e.g., fields, methods, and libraries). It cost us 360 person-hours to accomplish the manual migration to Java and C++ with complete code samples and associated test suites. Subsequently, we design three translation strategies (i.e., holistic, min-dependency, and standalone) for class-level code translations and evaluate eight recent LLMs of commercial, general, and code kinds in diverse families and sizes on ClassEval-T. Experimental results demonstrate a remarkable performance drop compared with the most widely studied method-level code translation benchmark, and obvious discrepancies among LLMs appear, showing the effectiveness of ClassEval-T in measuring recent LLMs. Afterwards, we further discuss the usage scenarios for diverse translation strategies and LLMs' ability to dependency awareness when translating class samples. Finally, 1,243 failure cases made by the best-performing LLM under test are analyzed and categorized in this paper for practical guidance and future enlightenment.

Paper Structure

This paper contains 23 sections, 3 equations, 6 figures, 4 tables.

Figures (6)

  • Figure 1: Translation results of CSR, CA$_c$ and CA$_m$ on benchmarks of Yang et al. and ClassEval-T
  • Figure 2: Translation results in terms of CA and CSR on ClassEval-T with different strategies
  • Figure 3: Dependency awareness analysis among various LLMs
  • Figure 4: Failed examples for Library-related errors
  • Figure 5: Failed examples for Syntax errors
  • ...and 1 more figures