Skip to main content
QUICK REVIEW

[论文解读] A4: Automatically Assisting Android API Migrations Using Code Examples.

Maxime Lamothe, Weiyi Shang|arXiv (Cornell University)|Dec 12, 2018
Software Engineering Research参考文献 62被引用 14
一句话总结

本文提出 A4,一种从代码示例(如 Google Samples)自动学习 Android API 迁移模式并将其应用于真实 Android 应用的方法。通过分析示例中使用方式的变化,A4 在 80 个案例中的 71 个成功实现了 API 迁移,或提供可操作的指导。

ABSTRACT

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.

研究动机与目标

  • 解决由于频繁的 API 变更而导致的 Android API 迁移手动、耗时的问题。
  • 弥补开发者仅知 *迁移什么* 而不知 *如何迁移* 的知识空白。
  • 利用公开的代码示例(如 Google Samples)提取可重用的迁移模式。
  • 开发一个自动化系统,将学习到的模式应用于真实 Android 应用代码,以提供实际的迁移辅助。

提出的方法

  • 分析 Google Samples 等公开代码示例中不同 Android 版本间 API 使用方式的变化,以提取迁移模式。
  • 将 API 迁移模式建模为转换规则,将旧的 API 调用映射到新的 API 调用,并保留相应的使用语义。
  • 解析并比较不同 Android 版本下代码示例的 AST(抽象语法树),以检测 API 使用方式的语义变化。
  • 将学习到的迁移模式应用于开源 Android 应用的源代码,以建议或自动执行迁移。
  • 使用启发式方法以及语法/语义匹配技术,在应用前验证并优化迁移建议。

实验结果

研究问题

  • RQ1代码示例能否有效揭示可重用的 Android API 迁移模式?
  • RQ2自动学习到的迁移模式在多大程度上可应用于真实世界的 Android 应用?
  • RQ3所提出方法生成的迁移建议在真实迁移场景中的准确性和实用性如何?
  • RQ4与仅依赖官方文档的手动迁移相比,该系统能否显著降低开发者的迁移工作量?

主要发现

  • 所提出的方法在 80 个测试案例中的 71 个成功学习并应用了 API 迁移模式。
  • 在 71% 的案例中,系统能够自动完成 API 调用的迁移,仅需极少或无需人工干预。
  • 在剩余的 9 个案例中,系统提供了可操作的指导,可协助开发者完成迁移。
  • 与仅依赖官方文档相比,该方法通过提供基于实际使用的迁移示例,展现出更优的实用性。
  • 该方法在真实开源 Android 应用上表现出实际适用性,显示出与开发工作流集成的强大潜力。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。