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.
翻译:API 开发者进化软件库以修补错误、添加新功能或 Refactor 错误。为了从这样的图书馆进化中受益,客户项目的编程者必须重复更新其图书馆的用法,并根据任何图书馆 API 破碎变化(例如 API 重命名) 调整其代码库(例如 API 重命名) 。这种适应性变化可能是乏味和容易出错的。 现有工具为帮助程序者将客户项目从旧图书馆版本迁移到新版本提供了有限的支持。 例如,一些工具提取 API 映射为通向图书馆版本,只建议简单的适应性变化( 即, 声明更新); 其它工具建议或自动更新更复杂的编辑( 例如, 声明插入) 。 然而, 当有了新的图书馆版本时, 用户通常会很麻烦和费时间地提供足够的人造样本, 以指导自动迁移。 在本文中, 我们建议一种全新的编辑方法, 自动更新, 进一步改进艺术状态。 而不是从更改的示例中, 我们设计了第一个自动更新到自动升级到自动升级的服务器 4 4, 升级的服务器 将自动升级到自动升级到自动升级到自动升级到自动升级到升级到升级到升级到升级到升级到升级到升级到自动变换的日历的日历的版本, 。