Presentation Information

[A-11-10]A Study of Java Legacy Code Migration Methods Using RAG

◎△Koki Furue1, Masahiro Gotanda2, Akihito Kohiga1, Takahiro Koita2 (1. Doshisha Univ., 2. Graduate School of Doshisha Univ.)

Keywords:

Large Language Model,Retrieval-Augmented Generation,Legacy Code Migration

In software modernization, code migration accompanying version upgrades requires considerable effort. This study examines the impact of incorporating migration knowledge retrieved via RAG into LLM-based automated migration, focusing on code correction and dependency identification. The proposed method has three steps. First, an AST is built using a syntax analysis tool to generate a type reference list R. Next, package names from R generate natural language queries, and top-three migration knowledge items are retrieved from a FAISS database indexing the Oracle Migration Guide and JDK Release Notes. Finally, GPT-4o outputs converted code and dependencies to dynamically generate a configuration file for compile verification. Evaluation used 45 JMigBench function pairs (Java 8 to 11), with CSR and CodeBLEU as metrics. Three conditions were compared: no RAG, RAG for dependency identification only, and the proposed method applying RAG to both. CSR improved from 46.7% to 68.9% and 77.8%, confirming RAG's contribution. However, CodeBLEU decreased as RAG promotes conversion but the migration target may differ from the reference. Future work includes a self-correction mechanism and search optimization.