一句话:用符号合成与 LLM 两个引擎自动重构 Java 废弃 API,量化 Javadoc 代码提示对重构成功率的提升。
在 Amazon 等公司,手动重构遗留代码以消除对已废弃 API 的调用既易错又耗时。本文研究废弃 Java API 的重构能在多大程度上被自动化,并量化 Javadoc 代码提示对该任务的收益。为此作者构建了两个自动重构引擎:符号引擎基于类型导向与基于组件的程序合成,神经引擎则使用大语言模型。他们将两个引擎应用于重构 Oracle JDK 15 中已废弃的方法,并在有、无代码提示两种设定下进行对比。实验表明,代码提示是此类自动化的使能条件:即使表现最差的引擎在带提示任务上也能正确重构 71%,而缺少提示时最好也只有 14%。因此,向 Javadoc 中补充更多代码提示可以显著提升使用废弃 API 的代码的重构效果。
When done manually by engineers at Amazon and other companies, refactoring legacy code in order to eliminate uses of deprecated APIs is an error-prone and time-consuming process. In this paper, we investigate to which degree refactorings for deprecated Java APIs can be automated, and quantify the benefit of Javadoc code hints for this task. To this end, we build a symbolic and a neural engine for the automatic refactoring of deprecated APIs. The former is based on type-directed and component-based program synthesis, whereas the latter uses LLMs. We applied our engines to refactor the deprecated methods in the Oracle JDK 15. Our experiments show that code hints are enabling for the automation of this task: even the worst engine correctly refactors 71% of the tasks with code hints, which drops to at best 14% on tasks without. Adding more code hints to Javadoc can hence boost the refactoring of code that uses deprecated APIs.
@inproceedings{paperbot9000,
title = {Quantifying the benefits of code hints for refactoring deprecated Java APIs},
author = {Cristina David and Pascal Kesseli and Daniel Kroening and Hanliang Zhang},
booktitle = {FSE},
year = {2025},
doi = {10.1145/3696630.3728567}
}