paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Code–Test Co-translation: Towards Practical and Effective Program Migration in the Wild

代码–测试协同翻译:面向真实世界程序的实用且有效的程序迁移
OOPSLA 10(OOPSLA2)2026匹配度 3/10 · 该论文属于LLM驱动的代码翻译/程序迁移,虽然契合“LLM作为工具”且以强模型(DeepSeek-V3)做问题驱动的真实程序迁移研究,但其核心并非用户关注的四条主线(静态分析×ML/Agent、LLM改进静态分析与形式化验证、浮点程序分析、贝叶斯程序分析),与研究方向仅有较弱的PL×AI大领域重叠。引用 0 inbox
Xitao Li, Xiaofei Xie, Jiang Wu, Ting Liu, Haijun Wang
crossref: 2026-10-02

AI 速览

一句话:提出代码–测试协同翻译问题与CoTTrans框架,用测试一致性指标提升LLM程序迁移的准确性与稳定性。

程序迁移需将软件从一种语言翻译到另一种语言。现有LLM方法与基准多局限于简单片段,且假设目标语言测试已可用,难以应对真实程序。本文提出代码–测试协同翻译(CTCT)问题:程序与其测试套件应联合翻译以保持语义一致。实证研究发现测试一致性难度量且迭代修复易状态退化。为此提出CoTTrans,状态质量感知的翻译–修复框架,并设计测试用例一致性(TCC)指标,量化语法与语义一致性,结合测试通过率评估状态质量并回溯。BigCodeBench上,DeepSeek-V3正确性分数从0.360升至0.675,优于现有方法。

问题
现有LLM代码翻译方法与基准多针对简单片段,且假设目标语言测试已可用,无法应对真实程序迁移中程序与测试需共同保持语义一致的场景。
方法
将程序迁移建模为代码–测试协同翻译(CTCT),提出状态质量感知的迭代翻译–修复框架CoTTrans;其TCC指标从语法与语义量化源/目标测试一致性,并结合测试通过率评估状态质量、触发自适应回溯。
评估
在BigCodeBench上以DeepSeek-V3等模型评估,翻译正确性分数从0.360提升至0.675,TCC在测试一致性度量上优于现有指标。
原文摘要(Abstract)

Program migration, which involves translating software systems from one programming language to another, is essential for modernizing legacy systems and improving maintainability. Recent large language models (LLMs) have demonstrated strong performance in code translation; however, existing methods and benchmarks still exhibit key limitations. (1) They primarily focus on simple, self-contained snippets that fail to capture the complexity of real-world programs, and (2) they often assume that target-language test cases are readily available for evaluation and feedback, an unrealistic assumption given the difficulty of manually creating equivalent tests across languages. In this paper, we argue for a more practical setting, termed the Code–Test Co-Translation (CTCT) problem, where both the program and its associated test suite should be jointly translated to preserve semantic and functional consistency. Through an empirical study on real-world programs, we identify two major challenges in CTCT: (1) the difficulty of measuring test-case consistency in the absence of ground truth, and (2) the ineffectiveness of existing iterative translation–repair strategies, which suffer from state degradation and poor initialization traps when handling complex, real-world features. To address these issues, we propose CoTTrans, a state-quality–aware iterative translation–repair framework guided by a novel Test Case Consistency (TCC) metric. TCC quantifies both syntactic and semantic consistency between source and translated tests, enabling fine-grained feedback that drives LLM-based refinement. CoTTrans further integrates TCC with test pass rates to assess state quality and triggers adaptive backtracking when low-quality states are detected during the translation. Evaluated on the BigCodeBench dataset, CoTTrans improves the translation correctness score from 0.360 to 0.675 on DeepSeek-V3, substantially outperforming existing methods, while TCC demonstrates superior effectiveness in measuring test consistency compared with existing metrics. These results show that CoTTrans enhances translation stability and accuracy, establishing a practical foundation for reliable code–test co-evolution in real-world program migration.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot12149,
  title = {Code–Test Co-translation: Towards Practical and Effective Program Migration in the Wild},
  author = {Xitao Li and Xiaofei Xie and Jiang Wu and Ting Liu and Haijun Wang},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {OOPSLA2},
  year = {2026},
  doi = {10.1145/3839490}
}