Slide 1

Slide 1 text

APIDiff: Detecting API Breaking Changes Aline Brito, Laerte Xavier, Andre Hora, Marco Tulio Valente SANER 2018, Tool Track

Slide 2

Slide 2 text

Motivation Libraries have a key importance in modern software development 2

Slide 3

Slide 3 text

Motivation Libraries have a key importance in modern software development 3

Slide 4

Slide 4 text

Library services are provided via APIs 4

Slide 5

Slide 5 text

In theory, APIs should be stable 5

Slide 6

Slide 6 text

But, 28% out of 500K API changes break backward compatibility Historical and Impact Analysis of API Breaking Changes: A Large-Scale Study SANER, 2017 6

Slide 7

Slide 7 text

Which changes break my code? How stable is this library? 7

Slide 8

Slide 8 text

8 On the owner side… Write migration documents Identify and revert accidental breaking changes

Slide 9

Slide 9 text

9 On the client side… Analyze the amount of breaking changes over time Select more stable libraries to depend on

Slide 10

Slide 10 text

APIDiff Detecting API Breaking Changes

Slide 11

Slide 11 text

11 APIDiff The tool analyses libraries available on git

Slide 12

Slide 12 text

Catalog of Breaking and Non-breaking Changes detected by APIDiff

Slide 13

Slide 13 text

Breaking Changes (BC) Changes performed in API elements that may break client applications 13 We exclude changes performed on deprecated API elements

Slide 14

Slide 14 text

14 Element Breaking Changes (BC) Type REMOVE TYPE, LOST VISIBILITY, CHANGE IN SUPERTYPE, ADD FINAL MODIFIER, REMOVE STATIC MODIFIER, RENAME TYPE, MOVE TYPE Method REMOVE METHOD, LOST VISIBILITY, CHANGE IN RETURN TYPE, CHANGE IN PARAMETER LIST, CHANGE IN EXCEPTION LIST, ADD FINAL MODIFIER, REMOVE STATIC MODIFIER, MOVE METHOD, RENAME METHOD, PUSH DOWN METHOD, INLINE METHOD Field REMOVE FIELD, LOST VISIBILITY, CHANGE IN FIELD TYPE, CHANGE IN FIELD DEFAULT VALUE, ADD FINAL MODIFIER, MOVE FIELD, PUSH DOWN FIELD

Slide 15

Slide 15 text

Example: Change in Access Modifiers 15 public int M1(String){ ... } private int M1(String){ ... }

Slide 16

Slide 16 text

Example: Change in Parameter List 16 public int M1(Context){ ... } public int M1(){ ... }

Slide 17

Slide 17 text

Example: Element Removal 17 public class C1{ ... } public class C1{ ... }

Slide 18

Slide 18 text

Example: Refactoring Operations 18 public int M1(String, Integer){ ... } public int M2(String, Integer){ ... }

Slide 19

Slide 19 text

Non-breaking Changes (NBC) Changes that do not break clients 19

Slide 20

Slide 20 text

20 Element Non-Breaking Changes (NBC) Type ADD TYPE, GAIN VISIBILITY, REMOVE FINAL MODIFIER, ADD STATIC MODIFIER, ADD SUPERTYPE, EXTRACT SUPERTYPE, DEPRECATED TYPE Method ADD METHOD, PULL UP METHOD, GAIN VISIBILITY, REMOVE FINAL MODIFIER, ADD STATIC MODIFIER, DEPRECATED METHOD, EXTRACT METHOD Field ADD FIELD, PULL UP FIELD, GAIN VISIBILITY, REMOVE FINAL MODIFIER, DEPRECATED FIELD

Slide 21

Slide 21 text

Example: Change in Access Modifiers 21 private int M1(String){ ... } public int M1(String){ ... }

Slide 22

Slide 22 text

Example: Add Element 22 public class C1{ public void M1(){ … } } public class C1{ }

Slide 23

Slide 23 text

Examples 23

Slide 24

Slide 24 text

24 An image loading and caching library 20K stars A framework to implement unit tests 6K stars

Slide 25

Slide 25 text

Example 1: Detecting Changes in Version Histories 25

Slide 26

Slide 26 text

26 Detecting Changes in Version Histories Useful to analyze several commits at once Useful to assess libraries stability

Slide 27

Slide 27 text

Detecting Changes in Version Histories 27 APIDiff diff = new APIDiff( “bumptech/glide”, “https://github.com/bumptech/glide.git”); Result result = diff.detectChangeAllHistory(“master”, Classifier.API);

Slide 28

Slide 28 text

Detecting Changes in Version Histories 28 APIDiff diff = new APIDiff( “bumptech/glide”, “https://github.com/bumptech/glide.git”); Result result = diff.detectChangeAllHistory(“master”, Classifier.API);

Slide 29

Slide 29 text

Example 2: Fetching New Commits 29

Slide 30

Slide 30 text

30 Fetching New Commits Useful to monitor changes in a repository Contributors are notified shortly after BCs are introduced

Slide 31

Slide 31 text

Fetching New Commits 31 APIDiff diff = new APIDiff( “bumptech/glide”, “https://github.com/bumptech/glide.git”); Result result = diff.fetchAndDetectChange(Classifier.API);

Slide 32

Slide 32 text

Fetching New Commits 32 APIDiff diff = new APIDiff( “bumptech/glide”, “https://github.com/bumptech/glide.git”); Result result = diff.fetchAndDetectChange(Classifier.API);

Slide 33

Slide 33 text

Example 3: Detecting Changes in Specific Commits 33

Slide 34

Slide 34 text

34 Detecting Changes in Specific Commits Useful to analyze pull requests Useful to detect accidental BCs

Slide 35

Slide 35 text

Detecting Changes in Specific Commits 35 APIDiff diff = new APIDiff( “mockito/mockito”, “https://github.com/mockito/mockito.git”); Result result = diff.detectChangeAtCommit( "4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API);

Slide 36

Slide 36 text

Detecting Changes in Specific Commits 36 APIDiff diff = new APIDiff( “mockito/mockito”, “https://github.com/mockito/mockito.git”); Result result = diff.detectChangeAtCommit( "4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API);

Slide 37

Slide 37 text

Detecting Changes in Specific Commits 37 APIDiff diff = new APIDiff( “mockito/mockito”, “https://github.com/mockito/mockito.git”); Result result = diff.detectChangeAtCommit( "4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API); Category: Add Method Description: Method answersWithDelay(long, Answer) added in class org.mockito.AdditionalAnswers

Slide 38

Slide 38 text

Result Type 38 - category : String - description : String - path : String - element : String - javadoc : Boolean - deprecated : Boolean - breakingChange : Boolean - revCommit: RevCommit Change

Slide 39

Slide 39 text

Example 4: Filtering Packages 39

Slide 40

Slide 40 text

40 Filtering Packages It is also possible to filter in/out packages Useful to detect changes in internal implementations

Slide 41

Slide 41 text

Filtering Packages 41 Result result = diff.detectChangeAtCommit( "4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API);

Slide 42

Slide 42 text

Architecture

Slide 43

Slide 43 text

43

Slide 44

Slide 44 text

44 Processing Module ● Git operations ● Instances library

Slide 45

Slide 45 text

45 Refactoring Module detects refactoring actions (reused from RefDiff) RefDiff: Detecting Refactorings in Version Histories Danilo Silva, Marco Tulio Valente - MSR, 2017

Slide 46

Slide 46 text

46 Analysis Module detects the changes in the library history

Slide 47

Slide 47 text

Future Work 47

Slide 48

Slide 48 text

Future Work 48 ● Evaluate the precision of APIDiff ● Support to other programming languages ● Feature to analyze changes at release level

Slide 49

Slide 49 text

https://github.com/aserg-ufmg/apidiff 49

Slide 50

Slide 50 text

Thank you! Aline Brito, Laerte Xavier, Andre Hora, Marco Tulio Valente SANER 2018, Tool Track