apimigrator: an api-usage migration tool for android appsmfazzini/slides/2020... · android eclair...

28
APIMIGRATOR: An API-Usage Migration Tool for Android Apps Mattia Fazzini Qi Xin Alessandro Orso

Upload: others

Post on 03-Oct-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR: An API-Usage Migration Tool for Android Apps

Mattia Fazzini Qi Xin Alessandro Orso

Page 2: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Mobile Applications

Page 3: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Platform

Page 4: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

PlatformTight Coupling

Page 5: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Platforms Change

Page 6: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Platforms Change FrequentlyAndroid

Eclair

Ice Cream

Marshmallow

DonutPetit Four Cupcake

HoneycombFroyo Gingerbread

LollipopJelly Bean KitKat

PieNougat Oreo

1.1

Android 10

Page 7: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

AppDeveloper

Adaptive Maintenance

Platform

App

New Platform

Page 8: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Platform FragmentationAndroid 10

Ice CreamJelly Bean

KitKat

Lollipop

Marshmallow

Oreo

Pie

Nougat

Page 9: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 10: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 11: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 12: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

API-Usage Migrations

API-Usage Changespublic NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network)

public NetworkInfo[] getAllNetworkInfo()Old API Usage

Page 13: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

API Updates

API-Usage Changespublic NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network)

public NetworkInfo[] getAllNetworkInfo()Old API Usage

Page 14: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

API Updates

API-Usage Changespublic NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network)

public NetworkInfo[] getAllNetworkInfo()Old API Usage

Page 15: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Migration ExampleMigration Example Before Migration Example After

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; }

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

Page 16: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; }

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

Migration ExampleMigration Example Before Migration Example After

Page 17: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; }

Migration ExampleMigration Example Before Migration Example After

Page 18: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR Overview

Identify API usages requiring

migration in target app

Find migration examples for identified API

usages

Abstract migration examples into

generic migration patches and rank

them

Migrate and validate API

usages in target app based on

patches

API-UsageAnalysis

Migration ExamplesSearch

Update ExamplesAnalysis

API-UsageMigrationMigration

Examples

GenericMigrationPatches

API-UsageMigration

Report

Page 19: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR Overview

Identify API usages requiring

migration in target app

Find migration examples for identified API

usages

Abstract migration examples into

generic migration patches and rank

them

Migrate and validate API

usages in target app based on

patches

API-UsageAnalysis

Migration ExamplesSearch

Update ExamplesAnalysis

API-UsageMigrationMigration

Examples

GenericMigrationPatches

API-UsageMigration

Report

Page 20: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR Overview

Identify API usages requiring

migration in target app

Find migration examples for identified API

usages

Abstract migration examples into

generic migration patches and rank

them

Migrate and validate API

usages in target app based on

patches

API-UsageAnalysis

Migration ExamplesSearch

Update ExamplesAnalysis

API-UsageMigrationMigration

Examples

GenericMigrationPatches

API-UsageMigration

Report

Page 21: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR Overview

Identify API usages requiring

migration in target app

Find migration examples for identified API

usages

Abstract migration examples into

generic migration patches and rank

them

Migrate and validate API

usages in target app based on

patches

API-UsageAnalysis

Migration ExamplesSearch

Update ExamplesAnalysis

API-UsageMigrationMigration

Examples

GenericMigrationPatches

API-UsageMigration

Report

Page 22: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

APIMIGRATOR Overview

Identify API usages requiring

migration in target app

Find migration examples for identified API

usages

Abstract migration examples into

generic migration patches and rank

them

Migrate and validate API

usages in target app based on

patches

API-UsageAnalysis

Migration ExamplesSearch

Update ExamplesAnalysis

API-UsageMigrationMigration

Examples

GenericMigrationPatches

API-UsageMigration

Report

Page 23: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly
Page 24: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly
Page 25: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Empirical Evaluation

RQ2 (EFFICIENCY): What is the cost of running APIMIGRATOR?

Research Questions

RQ1 (EFFECTIVENESS): Can APIMIGRATOR migrate API usages in real-world apps?

RQ2 (EFFICIENCY): What is the cost of running APIMIGRATOR?

Page 26: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

EvaluationRQ1 (EFFECTIVENESS): Can APIMIGRATOR migrate API usages in real-world apps?

• 37/41 (90%) successful update rate (for API-usage occurrences)• 25/37 (68%) automatic validation rate (for API-usage occurrences)

• 17/20 (85%) successful update rate (for API usages)

APPEVOLVE is effective in automatically updating API usages.

RQ2 (EFFICIENCY): What is the cost of running APIMIGRATOR?

API-UsageAnalysis

Update ExamplesSearch

Update ExamplesAnalysis

API-UsageUpdate

28s 10h27m 2s204ms 20s

The cost of the update examples search phase dominates the cost of the other phases.

Average Execution Time

Page 27: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Summary

Page 28: APIMIGRATOR: An API-Usage Migration Tool for Android Appsmfazzini/slides/2020... · Android Eclair Ice Cream Marshmallow Petit Four Cupcake Donut Froyo Gingerbread Honeycomb Jelly

Summary

https://zenodo.org/record/3668385APIMIGRATOR VM