Meditor: Inference and Application of API Migration Edits
Authors:
- 1 May 2019
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 335-346
Abstract
Developers build programs based on software libraries. When a library evolves, programmers need to migrate their client code from the library's old release(s) to new release(s). Due to the API backwards incompatibility issues, such code migration may require developers to replace API usage and apply extra edits (e.g., statement insertions or deletions) to ensure the syntactic or semantic correctness of migrated code. Existing tools extract API replacement rules without handling the additional edits necessary to fulfill a migration task. This paper presents our novel approach, Meditor, which extracts and applies the necessary edits together with API replacement changes. Meditor has two phases: inference and application of migration edits. For edit inference, Meditor mines open source repositories for migration-related (MR) commits, and conducts program dependency analysis on changed Java files to locate and cluster MR code changes. From these changes, Meditor further generalizes API migration edits by abstracting away unimportant details (e.g., concrete variable identifiers). For edit application, Meditor matches a given program with inferred edits to decide which edit is applicable, customizes each applicable edit, and produces a migrated version for developers to review. We applied Meditor to four popular libraries: Lucene, CraftBukkit, Android SDK, and Commons IO. By searching among 602,249 open source projects on GitHub, Meditor identified 1,368 unique migration edits. Among these edits, 885 edits were extracted from single updated statements, while the other 483 more complex edits were from multiple co-changed statements. We sampled 937 inferred edits for manual inspection and found all of them to be correct. Our evaluation shows that Meditor correctly applied code migrations in 218 out of 225 cases. This research will help developers automatically adapt client code to different library versions.Keywords
This publication has 39 references indexed in Scilit:
- The impact of tangled code changes on defect prediction modelsEmpirical Software Engineering, 2015
- Lexical statistical machine translation for language migration2013
- Seeking the ground truth2012
- A graph-based approach to API usage adaptationACM SIGPLAN Notices, 2010
- Graph-based mining of multiple object usage patterns2009
- Recommending adaptive changes for framework evolution2008
- Mining framework usage changes from instantiation code2008
- Automatically generating refactorings to support API evolutionACM SIGSOFT Software Engineering Notes, 2005
- CatchUp!2005
- Bugs as deviant behavior2001