一句话:结合静态分析与 RAG 的 LLM 缺陷修复框架,在 ArkTS/OpenHarmony 应用上实现约 99% 的修复率。
该论文针对 LLM 修复新兴编程语言缺陷时面临的训练数据稀缺与上下文窗口受限问题,提出 HapRepair 框架。由于 ArkTS 在 OpenHarmony 平台广泛使用但代码语料不足,直接使用 LLM 进行缺陷修复效果不佳。HapRepair 将静态分析工具 CodeLinter 集成到迭代修复流程中用于缺陷检测,并利用 RAG 与 ArkAnalyzer 提升修复方案质量;同时提出 Surrounding Context Extractor 和 Context Combination Tool 来缓解 LLM 上下文窗口限制,支持多缺陷修复。实验在 OpenHarmony 应用测试集上进行,HapRepair 的缺陷修复率达到约 99%,而直接基于缺陷信息使用 LLM 修复仅约 37%,表明该框架在新语言且代码语料有限场景下具有高可靠性与效率。
Software defect detection and repair are essential software engineering tasks that mitigate potential risks in the early development stages. Large Language Models (LLMs) have demonstrated significant capabilities in software defect detection and repair. However, it is hard for LLMs to handle the new programming languages such as ArkTS (which is predominantly used in the OpenHarmony platform) due to training data shortage. Additionally, LLM-based multi-defect repair suffers from the limitation of the context window of LLMs. These issues significantly affect the performance of LLM-based defect repair in new programming languages. To address the above challenges, we propose HapRepair, a defect repair framework that integrates static analysis tools with retrieval-augmented generation (RAG) to improve the effectiveness of the defect repair. Specifically, we integrate CodeLinter into our iterative defect repair framework for defect detection, which is the basis of defect repair, and utilize RAG together with ArkAnalyzer to improve the quality of our repair solutions. To overcome the context window limitation of LLMs, we propose the Surrounding Context Extractor and the Context Combination Tool. Experiment results show that HapRepair effectively repairs defects in OpenHarmony Apps, demonstrating high reliability and efficiency in addressing code issues, achieving a defect repair rate of about 99% on the test set, compared to only about 37% when directly using LLMs for defect repair based on the defect information. Our approach demonstrates a robust solution for defect repair on new programming languages that have limited code corpus.
@inproceedings{paperbot8991,
title = {HapRepair: Learn to Repair OpenHarmony Apps},
author = {Zhihao Lin and Mingyi Zhou and Wei Ma and Chi Chen and Yun Yang and Jun Wang and Chunming Hu and Li Li},
booktitle = {FSE},
year = {2025},
doi = {10.1145/3696630.3728556}
}