Anda di halaman 1dari 24

MINING API MAPPING

FOR LANGUAGE
MIGRATION
Seyed Hamed Moghimi
Sharif University of Technology
Data Mining - Fall 2014
Based on Zhong, Hao, et al. "Mining API mapping for
language migration."Proceedings of the 32nd
ACM/IEEE International Conference on Software
Engineering-Volume 1. ACM, 2010.

CONTENTS

Introduction and Definitions

Proposed Approach

Evaluation and Conclusion

2
22

INTRODUCTION

Many well-known projects provide multiple


versions in different languages.
To

address business requirements and survive in


competing marketing
For example: Lucene and WordNet

Manual migration is tedious and error-prone.


For

Some approaches and tools exist.


For

example: Java to C# and vice versa


example: Java2CSharp

But tools are limited to a subset of language


API
Because

of large number of APIs

3
22

PROBLEM AND SOLUTION


The problem is to implement a tool for
automatic migration from a language to
another.
The solution is based on mining client codes
which have two versions in source and
destination language
Why client codes instead of API codes?

API source codes dont always exist.


2. API implementations have one point of analysis
whereas API usage may have multiple points for
mining
3. Mapping relations are often complex.
1.

4
22

DEFINITIONS

API:
Application Programming Interface.
API Library: A library that provide reusable
APIs.
Client Code: A code that uses or extends an
API.
Mapping Relation

Entities

E1 in Language L1

Entities

E2 in Language L2

Migration from E1 to E2 maintains behavior b

Class Mapping Relation


5

Method Mapping Relation

22

CONTENTS

Introduction and Definitions

Proposed Approach

Evaluation and Conclusion

6
22

LETS LOOK AT AN EXAMPLE

7
22

PROPOSED APPROACH
MAM (Mining API Mapping) steps:
1. Align Client Code
2. Mapping API Classes
3. Mapping API Methods

8
22

1. ALIGNING CLIENT CODE


Process two code versions and find class and
method pairs which have similar functionality.
Using name similarities.

Between

classes and methods defined in client

code.

Using Levenstein measure by SimMetrics.

9
22

ALIGNING CLIENT CODES


(EXAMPLE)

10
22

2. MAPPING API CLASSES

For each aligned class pair :


Analyze

their fields and for each , if their names


are similar consider as a relation.

For each aligned method pair :


Analyze

their parameters and for each , if their


names are similar consider as a relation

11
22

MAPPING API CLASSES


(EXAMPLE)

12
22

3. MAPPING API METHODS

This step includes three major works:


Introducing ATG for modeling dependencies
2. Building an ATG for each client code
3. Comparing ATGs and find mapping relations
1.

13
22

API TRANSFORMATION GRAPH

Defined
for each client code method
An ATG is a directed graph
is a set of all variables playing role in

Class

fields, input arguments, local variables,

etc.

is a set of all methods (client and API) that


invoked by
is a set of directed edges

denotes that is data dependent to


denotes that is parameter or input for
denotes that returns

14
22

BUILDING SUB GRAPHS OF AN


ATG

15
22

BUILDING COMPLETE ATGS

16
22

COMPARING ATGS
At last we need to compare two built ATGs to
mine mapping relations.
The mapping relations should satisfy these
criteria:

The mapped API methods implement the same


functionality.
2. The mapping relation describes the relation
between parameters and receivers of mapped
API methods.
3. The mapping relation describes the relation
between returns of mapped API methods
1.

17
22

Returns set of all similar variables


Returns next method
of variable

Merges current method with


Next method to create an
Intermediate merged method

18
22

COMPARING ATGS EXAMPLE

NO!

Mapped?

Mapped?
YES!

19
22

CONTENTS

Introduction and Definitions

Proposed Approach

Evaluation and Conclusion

20
22

EVALUATIONS

Subjects are 15 open source project in both


Java and C# languages.

21
22

EVALUATIONS (CONT.)

Results of comparison between MAM and


manually written relations

22
22

CONCLUSION
A novel approach to Mine mapping relations of
APIs
From existing projects with multiple versions
Evaluated on projects written in Java and C#
Better results than existing tool Java2CSharp

But Only evaluated on Java and C#


Which

are very similar in syntax and API

23
22

Thanks For Your


Attention

If there are any questions

Anda mungkin juga menyukai