arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2105.02389cs.SE
收藏

在不更改的情况下迁移客户端代码示例

Migrating Client Code without Change Examples

Hao Zhong, Na Meng

摘要:

API开发人员开发软件库来修复错误、添加新功能或重构代码。为了从这种库演变中受益,客户端项目的程序员必须重复地升级他们的库使用,并使他们的代码库适应任何库API破坏性变化(例如,API重命名)。这样的自适应变化可能是乏味的并且容易出错。现有的工具在帮助程序员将客户端项目从旧的库版本迁移到新的库版本方面提供了有限的支持。例如,一些工具提取库版本之间的API映射,并且仅建议简单的自适应更改(即,语句更新);其它工具建议或自动化更复杂的编辑(例如,语句插入)。然而,当新的库版本可用时,用户通常需要提供足够的人工构建的示例来指导自动迁移,这既麻烦又耗时。在本文中,我们提出了一种新的方法,AutoUpdate,以进一步提高最先进的。而不是从变化的例子中学习,我们设计的AutoUpdate自动迁移在编译器导向的方式。也就是说,给定由升级库触发的编译错误,AutoUpdate利用13个迁移操作符来生成候选编辑,并暂时应用每个编辑,直到错误得到解决或所有编辑都被探索。我们做了两个实验。第一个实验涉及在5个流行库的版本之间迁移371个教程示例。AutoUpdate减少了92.7%的任务的迁移相关编译错误。它为32.4%的任务消除了此类错误,并且33.9%的任务具有与手动迁移相同的编辑。在第二个实验中,我们应用AutoUpdate迁移了两个真实的Lucene客户端项目。AutoUpdate成功地迁移了这两个项目,并且迁移的代码通过了所有测试。

英文摘要:

API developers evolve software libraries to fix bugs, add new features, or refactor code. To benefit from such library evolution, the programmers of client projects have to repetitively upgrade their library usages and adapt their codebases to any library API breaking changes (e.g., API renaming). Such adaptive changes can be tedious and error-prone. Existing tools provide limited support to help programmers migrate client projects from old library versions to new ones. For instance, some tools extract API mappings be-tween library versions and only suggest simple adaptive changes (i.e., statement updates); other tools suggest or automate more complicated edits (e.g., statement insertions) based on user-provided exemplar code migrations. However, when new library versions are available, it is usually cumbersome and time-consuming for users to provide sufficient human-crafted samples in order to guide automatic migration. In this paper, we propose a novel approach, AutoUpdate, to further improve the state of the art. Instead of learning from change examples, we designed AutoUpdate to automate migration in a compiler-directed way. Namely, given a compilation error triggered by upgrading libraries, AutoUpdate exploits 13 migration opera-tors to generate candidate edits, and tentatively applies each edit until the error is resolved or all edits are explored. We conducted two experiments. The first experiment involves migrating 371 tutorial examples between versions of 5 popular libraries. AutoUpdate reduced migration-related compilation errors for 92.7% of tasks. It eliminated such errors for 32.4% of tasks, and 33.9% of the tasks have identical edits to manual migrations. In the second experiment, we applied AutoUpdate to migrate two real client projects of lucene. AutoUpdate successfully migrated both projects, and the migrated code passed all tests.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑