Proceedings

Can We Translate Code Better with LLMs and Call Graph Analysis?

Download BibTeX Cite

Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence. Main Track. Pages 7625-7633.

https://doi.org/10.24963/ijcai.2025/848

Abstract

This paper proposes an innovative code translation method aimed at addressing the accuracy issues encountered by large language models (LLMs) in translating code of complex large-scale software projects. The method utilizes the Language Server Protocol to obtain the call graph of the entire codebase, and optimizes the input prompt of the LLM accordingly, significantly improving the correctness of translation at the compilation stage. Moreover, this method introduces the bridged debuggers technique based on the Debug Adapter Protocol and dynamic test case generation, effectively fixing runtime errors. Experiments on multiple mainstream datasets demonstrate that, compared to existing code translation methods and LLMs, this method achieves a significant improvement in translation accuracy.

  1. [Achiam et al., 2023] Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Alt- man, Shyamal Anadkat, et al. Gpt-4 technical report. arXiv preprint arXiv:2303.08774, 2023.
  2. [Aggarwal et al., 2015] Karan Aggarwal, Mohammad Salameh, and Abram Hindle. Using machine translation for converting python 2 to python 3 code. Technical report, PeerJ PrePrints, 2015.
  3. [Ahmad et al., 2021a] Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. Unified pre-training for program understanding and generation. arXiv preprint arXiv:2103.06333, 2021.
  4. [Ahmad et al., 2021b] Wasi Uddin Ahmad, Md Golam Rah- man Tushar, Saikat Chakraborty, and Kai-Wei Chang. Avatar: A parallel corpus for java-python program transla- tion. arXiv preprint arXiv:2108.11590, 2021.
  5. [Anthropic, 2024] Anthropic. Claude 3 sonnet. https://www. anthropic.com/news/claude-3-family, 2024. [apa, 2023] Apache commons cli. https://commons.apache. org/proper/commons-cli/, 2023. Link
  6. [Feng et al., 2020] Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. arXiv preprint arXiv:2002.08155, 2020.
  7. [Graham et al., 1982] Susan L Graham, Peter B Kessler, and Marshall K McKusick. Gprof: A call graph execution pro- filer. ACM Sigplan Notices, 17(6):120-126, 1982.
  8. [Haugeland et al., 2021] Sindre Grønstøl Haugeland, Phu H Nguyen, Hui Song, and Franck Chauvel. Migrating mono- liths to microservices-based customizable multi-tenant cloud-native apps. In 2021 47th Euromicro Conference on Software Engineering and Advanced Applications (SEAA), pages 170-177. IEEE, 2021.
  9. [Jav, 2023] Java 2 csharp translator for eclipse. https:// sourceforge.net/projects/j2cstranslator/, 2023. Link
  10. [Karaivanov et al., 2014] Svetoslav Karaivanov, Veselin Raychev, and Martin Vechev. Phrase-based statistical translation of programming languages. In Proceedings of the 2014 ACM international symposium on new ideas, new paradigms, and reflections on programming & software, pages 173-184, 2014.
  11. [Li et al., 2023] Raymond Li, Loubna Ben Allal, Yangtian Zi, Niklas Muennighoff, Denis Kocetkov, Chenghao Mou, Marc Marone, Christopher Akiki, Jia Li, Jenny Chim, et al. Starcoder: may the source be with you! arXiv preprint arXiv:2305.06161, 2023.
  12. [Ling et al., 2022] Michael Ling, Yijun Yu, Haitao Wu, Yuan Wang, James R Cordy, and Ahmed E Hassan. In rust we trust: a transpiler from unsafe c to safer rust. In Pro- ceedings of the ACM/IEEE 44th international conference on software engineering: companion proceedings, pages 354-355, 2022.
  13. [Liu et al., 2024] Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. Is your code generated by chatgpt really correct? rigorous evaluation of large lan- guage models for code generation. Advances in Neural Information Processing Systems, 36, 2024.
  14. [Lu et al., 2021] Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin Clement, Dawn Drain, Daxin Jiang, Duyu Tang, et al. Codexglue: A machine learning benchmark dataset for code understanding and generation. arXiv preprint arXiv:2102.04664, 2021.
  15. [Mariano et al., 2022] Benjamin Mariano, Yanju Chen, Yu Feng, Greg Durrett, and Is ¸il Dillig. Automated transpi- lation of imperative to functional code using neural-guided program synthesis. Proceedings of the ACM on Program- ming Languages, 6(OOPSLA1):1-27, 2022.
  16. [Microsoft, 2016] Microsoft. Language server proto- col. https://microsoft.github.io/language-server-protocol/, 2016. Link
  17. [Microsoft, 2021] Microsoft. Debug adapter protocol. https: //microsoft.github.io/debug-adapter-protocol/, 2021. Link
  18. [Nguyen et al., 2013] Anh Tuan Nguyen, Tung Thanh Nguyen, and Tien N Nguyen. Lexical statistical machine translation for language migration. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engi- neering, pages 651-654, 2013.
  19. [Nijkamp et al., 2022] Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. Codegen: An open large language model for code with multi-turn program synthe- sis. arXiv preprint arXiv:2203.13474, 2022.
  20. [OpenAI, 2022] OpenAI. Chatgpt. https://www.openai.com/ chatgpt, 2022. Link
  21. [Orlanski et al., 2023] Gabriel Orlanski, Kefan Xiao, Xavier Garcia, Jeffrey Hui, Joshua Howland, Jonathan Malmaud, Jacob Austin, Rishabh Singh, and Michele Catasta. Mea- suring the impact of programming language distribution. In International Conference on Machine Learning, pages 26619-26645. PMLR, 2023.
  22. [Puri et al., 2021] Ruchir Puri, David S Kung, Geert Janssen, Wei Zhang, Giacomo Domeniconi, Vladimir Zolotov, Ju- lian Dolby, Jie Chen, Mihir Choudhury, Lindsey Decker, et al. Codenet: A large-scale ai for code dataset for learning a diversity of coding tasks. arXiv preprint arXiv:2105.12655, 2021.
  23. [py2, 2024] py2java: Python to java language translator. https://pypi.org/project/py2java/, 2024. Link
  24. [Ramos et al., 2024] Daniel Ramos, Inês Lynce, Vasco Man- quinho, Ruben Martins, and Claire Le Goues. Batfix: Re- pairing language model-based transpilation. ACM Trans- actions on Software Engineering and Methodology, 2024.
  25. [Roziere et al., 2020] Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. Advances in neural information processing systems, 33:20601-20611, 2020.
  26. [Roziere et al., 2021] Baptiste Roziere, Jie M Zhang, Fran- cois Charton, Mark Harman, Gabriel Synnaeve, and Guillaume Lample. Leveraging automated unit tests for unsupervised code translation. arXiv preprint arXiv:2110.06773, 2021.
  27. [Schultes, 2021] Dominik Schultes. Sequalsk-a bidirec- tional swift-kotlin-transpiler. In 2021 IEEE/ACM 8th In- ternational Conference on Mobile Software Engineering and Systems (MobileSoft), pages 73-83. IEEE, 2021.
  28. [Sha, 2023] Automated java-¿csharp coversion. https:// github.com/mono/sharpen, 2023. Link
  29. [Touvron et al., 2023] Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.
  30. [Vaswani et al., 2017] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
  31. [Wang et al., 2021] Yue Wang, Weishi Wang, Shafiq Joty, and Steven CH Hoi. Codet5: Identifier-aware unified pre- trained encoder-decoder models for code understanding and generation. arXiv preprint arXiv:2109.00859, 2021.
  32. [Wang et al., 2022] Xin Wang, Yasheng Wang, Yao Wan, Fei Mi, Yitong Li, Pingyi Zhou, Jin Liu, Hao Wu, Xin Jiang, and Qun Liu. Compilable neural code generation with compiler feedback. arXiv preprint arXiv:2203.05132, 2022.
  33. [Yang et al., 2024] Zhen Yang, Fang Liu, Zhongxing Yu, Jacky Wai Keung, Jia Li, Shuo Liu, Yifan Hong, Xiaoxue Ma, Zhi Jin, and Ge Li. Exploring and unleashing the power of large language models in automated code trans- lation. Proceedings of the ACM on Software Engineering, 1(FSE):1585-1608, 2024.
  34. [Zheng et al., 2023] Qinkai Zheng, Xiao Xia, Xu Zou, Yux- iao Dong, Shan Wang, Yufei Xue, Lei Shen, Zihan Wang, Andi Wang, Yang Li, et al. Codegeex: A pre-trained model for code generation with multilingual benchmark- ing on humaneval-x. In Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 5673-5684, 2023.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards