A4: Automatically Assisting Android API Migrations Using Code Examples

The fast-paced evolution of Android APIs has posed a challenging task for Android app developers. To leverage the newly and frequently released APIs from Android, developers often must spend considerable effort on API migrations. Prior research work and Android official documentation typically provide enough information to guide developers in identifying both the changed API calls that need to be migrated and the corresponding API calls in the new version of Android (what to migrate). However, the API migration task is still challenging since developers lack the knowledge of how to migrate the API calls. In addition to the official documentation, there exist code examples, such as Google Samples, that illustrate the usage of APIs. We posit that by analyzing the changes of API usage in code examples, we may be able to learn API migration patterns to assist developers with API migrations. In this paper, we propose an approach that automatically learns API migration patterns from code examples and applies these patterns to the source code of Android apps for API migration. To evaluate our approach, we migrate API calls in open source Android apps by learning API migration patterns from both public and manually generated code examples. We find that our approach can successfully learn API migration patterns and provide API migration assistance in 71 out of 80 cases. In particular, our approach can either automatically migrate API calls with little to no extra modifications needed or provide guidance to assist with the migrations. Our approach can be adopted by Android developers to reduce the effort they spend on regularly migrating Android APIs.

[1]  Jun Li,et al.  SWIN: Towards Type-Safe Java Program Adaptation between APIs , 2015, PEPM.

[2]  Benoit Baudry,et al.  Empirical evidence of large-scale diversity in API usage of object-oriented software , 2013, 2013 IEEE 13th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[3]  Martin P. Robillard,et al.  SemDiff: Analysis and recommendation support for API evolution , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[4]  Alexander Serebrenik,et al.  Analyzing the Eclipse API Usage: Putting the Developer in the Loop , 2013, 2013 17th European Conference on Software Maintenance and Reengineering.

[5]  Alessandra Gorla,et al.  What did Really Change with the New Release of the App? , 2018, 2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR).

[6]  Miryung Kim,et al.  An Empirical Study of API Stability and Adoption in the Android Ecosystem , 2013, 2013 IEEE International Conference on Software Maintenance.

[7]  Danny Dig,et al.  API code recommendation using statistical learning from fine-grained changes , 2016, SIGSOFT FSE.

[8]  Ying Zou,et al.  API usage pattern recommendation for software development , 2017, J. Syst. Softw..

[9]  Jian Pei,et al.  MAPO: mining API usages from open source repositories , 2006, MSR '06.

[10]  Gabriele Bavota,et al.  How do API changes trigger stack overflow discussions? a study on the Android SDK , 2014, ICPC 2014.

[11]  Robert J. Walker,et al.  Informing Eclipse API production and consumption , 2007, eclipse '07.

[12]  Collin McMillan,et al.  ExPort: Detecting and visualizing API usages in large source code repositories , 2013, 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[13]  Alberto Bacchelli,et al.  On the reaction to deprecation of clients of 4 + 1 popular Java APIs and the JDK , 2018, Empirical Software Engineering.

[14]  Weiyi Shang,et al.  Exploring the Use of Automated API Migrating Techniques in Practice: An Experience Report on Android , 2018, 2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR).

[15]  Alexander Serebrenik,et al.  Eclipse API usage: the good and the bad , 2013, Software Quality Journal.

[16]  Robert L. Glass,et al.  Loyal Opposition - Frequently Forgotten Fundamental Facts about Software Engineering , 2001, IEEE Softw..

[17]  Ralph E. Johnson,et al.  How do APIs evolve? A story of refactoring , 2006, J. Softw. Maintenance Res. Pract..

[18]  Jun Li,et al.  How Does Web Service API Evolution Affect Clients? , 2013, 2013 IEEE 20th International Conference on Web Services.

[19]  Alberto Bacchelli,et al.  fine-GRAPE: fine-grained APi usage extractor – an approach and dataset to investigate API usage , 2016, Empirical Software Engineering.

[20]  Zhendong Su,et al.  Detecting API documentation errors , 2013, OOPSLA.

[21]  Christoph Treude,et al.  Measuring API documentation on the web , 2011, Web2SE '11.

[22]  Tao Xie,et al.  Automated detection of api refactorings in libraries , 2007, ASE '07.

[23]  Anh Tuan Nguyen,et al.  T2API: synthesizing API code usage templates from English texts with statistical translation , 2016, SIGSOFT FSE.

[24]  Kai Chen,et al.  Mining succinct and high-coverage API usage patterns from source code , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[25]  Li-Te Cheng,et al.  How a good software practice thwarts collaboration: the multiple roles of APIs in software development , 2004, SIGSOFT '04/FSE-12.

[26]  Anh Tuan Nguyen,et al.  Statistical Learning of API Fully Qualified Names in Code Snippets of Online Forums , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[27]  J. Henkel,et al.  CatchUp! Capturing and replaying refactorings to support API evolution , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[28]  Sarah Nadi,et al.  The Android Update Problem: An Empirical Study , 2018, 2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR).

[29]  Rastislav Bodík,et al.  Jungloid mining: helping to navigate the API jungle , 2005, PLDI '05.

[30]  Shaohua Wang,et al.  How Do Developers React to RESTful API Evolution? , 2014, ICSOC.

[31]  Robert J. Walker,et al.  Seeking the ground truth: a retroactive study on the evolution and migration of software libraries , 2012, SIGSOFT FSE.

[32]  Xiangyu Zhang,et al.  Automatic Model Generation from Documentation for Java API Functions , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[33]  Westley Weimer,et al.  Synthesizing API usage examples , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[34]  Shaohua Wang,et al.  What Do Client Developers Concern When Using Web APIs? An Empirical Study on Developer Forums and Stack Overflow , 2016, 2016 IEEE International Conference on Web Services (ICWS).

[35]  Gabriele Bavota,et al.  API change and fault proneness: a threat to the success of Android apps , 2013, ESEC/FSE 2013.

[36]  Jonathan Aldrich,et al.  Checking framework interactions with relationships , 2008, ECOOP.

[37]  Miryung Kim,et al.  Visualizing API Usage Examples at Scale , 2018, CHI.

[38]  Shuai Lu,et al.  Summarizing Source Code with Transferred API Knowledge , 2018, IJCAI.

[39]  Jacques Klein,et al.  Characterising Deprecated Android APIs , 2018, 2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR).

[40]  Ralph E. Johnson,et al.  The role of refactorings in API evolution , 2005, 21st IEEE International Conference on Software Maintenance (ICSM'05).

[41]  Trong Duc Nguyen,et al.  Statistical Migration of API Usages , 2017, 2017 IEEE/ACM 39th International Conference on Software Engineering Companion (ICSE-C).

[42]  Gabriele Bavota,et al.  On the Impact of API Change-and Fault-Proneness on the User Ratings of Android Apps — Additional Analyses — , 2014 .

[43]  Gabriele Bavota,et al.  MDroid+: A Mutation Testing Framework for Android , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering: Companion (ICSE-Companion).

[44]  Wei Wu,et al.  The impact of imperfect change rules on framework API evolution identification: an empirical study , 2014, Empirical Software Engineering.

[45]  Michael W. Godfrey,et al.  Detecting API usage obstacles: A study of iOS and Android developer questions , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[46]  Christoph Treude,et al.  Augmenting API Documentation with Insights from Stack Overflow , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[47]  Jun Li,et al.  Transforming Programs between APIs with Many-to-Many Mappings , 2016, ECOOP.

[48]  Anh Tuan Nguyen,et al.  Statistical learning approach for mining API usage mappings for code migration , 2014, ASE.

[49]  Trong Duc Nguyen,et al.  Mapping API Elements for Code Migration with Vector Representations , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering Companion (ICSE-C).

[50]  Gabriele Bavota,et al.  Mining energy-greedy API usage patterns in Android apps: an empirical study , 2014, MSR 2014.

[51]  Michael W. Godfrey Practical data exchange for reverse engineering frameworks: some requirements, some experience, some headaches , 2001, SOEN.

[52]  Martin P. Robillard,et al.  A field study of API learning obstacles , 2011, Empirical Software Engineering.

[53]  Reid Holmes,et al.  Live API documentation , 2014, ICSE.

[54]  Miryung Kim,et al.  Sydit: creating and applying a program transformation from an example , 2011, ESEC/FSE '11.

[55]  Michael W. Godfrey,et al.  Recommending Posts concerning API Issues in Developer Q&A Sites , 2015, 2015 IEEE/ACM 12th Working Conference on Mining Software Repositories.

[56]  Mark Harman,et al.  API-Constrained Genetic Improvement , 2016, SSBSE.

[57]  Shay Artzi,et al.  F4F: taint analysis of framework-based web applications , 2011, OOPSLA '11.

[58]  Jian Pei,et al.  MAPO: Mining and Recommending API Usage Patterns , 2009, ECOOP.

[59]  Miryung Kim,et al.  Lase: Locating and applying systematic edits by learning from examples , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[60]  Wei Wu,et al.  AURA: a hybrid approach to identify framework evolution , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.