Abstract
Context: Legacy software systems remain critical to modern organizations, but face challenges to evolve due tooutdated technologies, poor documentation, and accumulated technical debt. Recent advances in Artificial Intelli-gence (AI), particularly Large Language Models (LLMs), have introduced new opportunities for automating softwareengineering tasks, including code generation and system modernization. However, their applicability and effectivenessin legacy contexts are not yet fully understood.Objective: This study aims to systematically analyze how AI techniques are applied to support code generationand modernization of legacy software systems, identifying current approaches, benefits, limitations, and researchgaps.Method: Our study conducted a Systematic Literature Review (SLR) with total of 1,349 studies retrieved frommajor digital libraries, and 52 primary studies selected through rigorous inclusion and exclusion criteria. Data extrac-tion and quality assessment were performed to analyze AI techniques, tools, and application contexts.Results: The analysis identified four main categories of AI techniques: Prompt Engineering, Fine-Tuning, DeepLearning, and Traditional Machine Learning. Transformer-based models dominate recent approaches, particularly ingenerative tasks. The findings indicate improvements in developer productivity, maintainability, and support for legacysystem modernization. However, significant challenges remain, including trust, reliability, semantic inaccuracies, lackof explainability, and integration with developer’s ecosystem.Conclusion: AI techniques, especially prompt-based approaches, show a strong potential support for legacy soft-ware evolution. However, effective adoption requires human oversight, iterative validation, and context-aware design.Key research gaps persist in reliability, trustworthiness and long-term quality assurance, indicating the need for furtherempirical studies to enable robust AI-driven modernization of legacy systems.