Software defects are an inherent part of software development and maintenance. To address these defects, Automated Program Repair (APR) has been developed to fix bugs automatically. With the advent of Large Language Models, Code Language Models (CLMs) trained on code corpora excels in code generation, making them suitable for APR applications. Despite this progress, a significant limitation remains: many bugs necessitate multi-point edits for repair, yet current CLM-based APRs are restricted to single-point bug fixes, which severely narrows the scope of repairable bugs. Moreover, these tools typically only consider the direct context of the buggy line when building prompts for the CLM, leading to suboptimal repair outcomes due to the limited information provided. This paper introduces a novel approach, ARJA-CLM, which integrates the multiobjective evolutionary algorithm with CLM to fix multilocation bugs in Java projects. We also propose a context-aware prompt construction stratege, which enriches the prompt with additional information about accessible fields and methods for the CLM generating candidate statements. Our experiments on the Defects4J and APR-2024 competition benchmark demonstrate that ARJA-CLM surpasses many state-of-the-art repair systems, and performs well on multi-point bugs. The results also reveal that CLMs effectively utilize the provided field and method information within context-aware prompts to produce candidate statements.
翻译:软件缺陷是软件开发和维护过程中固有的组成部分。为应对这些缺陷,自动程序修复技术被开发用于自动修复错误。随着大语言模型的出现,基于代码语料库训练的代码语言模型在代码生成方面表现卓越,使其适用于自动程序修复应用。尽管取得这些进展,仍存在一个显著局限:许多缺陷需要多点编辑才能修复,而当前基于代码语言模型的自动程序修复工具仅限于单点错误修复,这严重缩小了可修复缺陷的范围。此外,这些工具在为代码语言模型构建提示时通常仅考虑错误代码行的直接上下文,由于提供信息有限导致修复效果欠佳。本文提出一种新颖方法ARJA-CLM,将多目标进化算法与代码语言模型相结合以修复Java项目中的多位置错误。我们还提出一种上下文感知的提示构建策略,通过为代码语言模型提供可访问字段和方法的附加信息来丰富提示内容以生成候选语句。我们在Defects4J和APR-2024竞赛基准测试上的实验表明,ARJA-CLM超越了许多最先进的修复系统,并在多点错误修复中表现优异。结果还显示,代码语言模型能有效利用上下文感知提示中提供的字段和方法信息来生成候选语句。