Recommending Method Invocation Context Changes

47
software evolution & architecture lab University of Zurich Department of Informatics ChangeCommander Beat Fluri, Jonas Zuberbühler, and Harald C. Gall s.e.a.l. - software evolution & architecture lab Department of Informatics University of Zurich, Switzerland Recommending Method Invocation Context Changes

Transcript of Recommending Method Invocation Context Changes

Page 1: Recommending Method Invocation Context Changes

software evolution & architecture lab

University of ZurichDepartment of Informatics

ChangeCommander

Beat Fluri, Jonas Zuberbühler, and Harald C. Galls.e.a.l. - software evolution & architecture labDepartment of InformaticsUniversity of Zurich, Switzerland

Recommending Method InvocationContext Changes

Page 2: Recommending Method Invocation Context Changes

Which changes fix bugs?

Bug fix change study on Eclipse43 plugins from Platform, JDT, and PDE

15% of bugs fixes contain context changes of method invocation statements

Page 3: Recommending Method Invocation Context Changes

Which changes fix bugs?

Bug fix change study on Eclipse43 plugins from Platform, JDT, and PDE

15% of bugs fixes contain context changes of method invocation statements

Method Invocation Context ChangeMoving a method invocation into the then or the else-part of an if-statement.

Page 4: Recommending Method Invocation Context Changes

Which changes fix bugs?

Bug fix change study on Eclipse43 plugins from Platform, JDT, and PDE

15% of bugs fixes contain context changes of method invocation statements

Method Invocation Context ChangeMoving a method invocation into the then or the else-part of an if-statement.

visited.add(outputFolder);

Page 5: Recommending Method Invocation Context Changes

Which changes fix bugs?

Bug fix change study on Eclipse43 plugins from Platform, JDT, and PDE

15% of bugs fixes contain context changes of method invocation statements

Method Invocation Context ChangeMoving a method invocation into the then or the else-part of an if-statement.

visited.add(outputFolder);

if (!visited.contains(outputFolder)) {

}

Page 6: Recommending Method Invocation Context Changes

Similar conditions for all methods

Context changes tend to be similar

Similar conditions for specific methods

Page 7: Recommending Method Invocation Context Changes

Similar conditions for all methods

Context changes tend to be similar

Similar conditions for specific methods

if (myObject != null) { list.add(myObject);}

if (list != null) { list.add(myObject);}

Page 8: Recommending Method Invocation Context Changes

Similar conditions for all methods

Context changes tend to be similar

Similar conditions for specific methods

if (myObject != null) { list.add(myObject);}

if (list != null) { list.add(myObject);}

if (!list.contains(myObject)) { list.add(myObject);}

Page 9: Recommending Method Invocation Context Changes

Pattern extraction process

Page 10: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Page 11: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Page 12: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Page 13: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Invocationaggregation

Page 14: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Invocationaggregation

Patternextraction

Page 15: Recommending Method Invocation Context Changes

Pattern extraction process

Contextchanges

Invocationaggregation

Patternextraction

Page 16: Recommending Method Invocation Context Changes

Invocation aggregation

list.add(myObject) java.util.List.add(MyClass)

Method invocations Invocation signature

Page 17: Recommending Method Invocation Context Changes

Invocation aggregation

list.add(myObject) java.util.List.add(MyClass)

Method invocations Invocation signature

Page 18: Recommending Method Invocation Context Changes

Invocation aggregation

list.add(myObject) java.util.List.add(MyClass)

Method invocations Invocation signature

Page 19: Recommending Method Invocation Context Changes

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)Method invocation Invocation signature

Page 20: Recommending Method Invocation Context Changes

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)Method invocation Invocation signature

Page 21: Recommending Method Invocation Context Changes

Imports

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)Method invocation Invocation signature

Page 22: Recommending Method Invocation Context Changes

Imports

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)

JDT

Method invocation Invocation signature

Page 23: Recommending Method Invocation Context Changes

Imports

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)

JDT

Method invocation Invocation signature

Page 24: Recommending Method Invocation Context Changes

Imports

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)

JDT

Method invocation Invocation signature

Post Resolver

Match in scopevariables

Match in imports

...

Page 25: Recommending Method Invocation Context Changes

Imports

Same Package

Invocation aggregation

list.add(anObject) java.util.List.add(MyClass)

JDT

Method invocation Invocation signature

Post Resolver

Match in scopevariables

Match in imports

...

Page 26: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

list.add(myObject)

Aggregated invocations Context change patterns

!list.contains(myObject)

list != null && <qualifier> != null

Page 27: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

list.add(myObject)

Aggregated invocations Context change patterns

!list.contains(myObject)

list != null && <qualifier> != null

Page 28: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

list.add(myObject)

Aggregated invocations Context change patterns

!list.contains(myObject)

list != null && <qualifier> != null

Page 29: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Page 30: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Token streams for- conditions- method invocation

Page 31: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Token streams for- conditions- method invocation

Page 32: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Token streams for- conditions- method invocation

list.add(myObject)

Page 33: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Token streams for- conditions- method invocation

list.add(myObject)

Page 34: Recommending Method Invocation Context Changes

!<qualifier>.contains(<argument_0>)

Pattern extraction

Aggregated invocations Context change patterns

!list.contains(myObject)list != null && <qualifier> != null

Split compound conditions into single conditions

Token streams for- conditions- method invocation

list.add(myObject)

Page 35: Recommending Method Invocation Context Changes

Recommendation

Page 36: Recommending Method Invocation Context Changes

Recommendation

Page 37: Recommending Method Invocation Context Changes

Recommendation

Page 38: Recommending Method Invocation Context Changes

Recommendation

java.util.List.add(MyClass)

Page 39: Recommending Method Invocation Context Changes

Recommendation

java.util.List.add(MyClass)

Page 40: Recommending Method Invocation Context Changes

Recommendation

java.util.List.add(MyClass)

Page 41: Recommending Method Invocation Context Changes

Recommendation

java.util.List.add(MyClass)

Surrounding if already contains condition

Filter predefined method invocations

xx

Page 42: Recommending Method Invocation Context Changes

Recommendation

java.util.List.add(MyClass)

Surrounding if already contains condition

Filter predefined method invocations

xx

Page 43: Recommending Method Invocation Context Changes

ChangeCommander

Page 44: Recommending Method Invocation Context Changes

A first validation

Split history

Training set: Past context changes up to a certain release

Test set: Context changes after that particular release

Recommended context change

True positive (TP): in test setFalse positive (FP): not in test setFalse negative (FN): context change in test set but not recommended

Page 45: Recommending Method Invocation Context Changes

A first validation

Project TP #B FP FN

ArgoUML 29 11 4675 75

Azureus 15 3 - 82

Eclipse JDT 51 27 - 158

Eclipse PDE 35 25 8011 46

jEdit 1 0 1307 13

Page 46: Recommending Method Invocation Context Changes

A first validation

Project TP #B FP FN

ArgoUML 29 11 4675 75

Azureus 15 3 - 82

Eclipse JDT 51 27 - 158

Eclipse PDE 35 25 8011 46

jEdit 1 0 1307 13

Page 47: Recommending Method Invocation Context Changes

Conclusions

Recommending context changesWe leverages context change data to suggest corresponding modifications on existing or newly added method invocations.

ChangeCommanderBy integrating our recommendation approach into the development process, we aim at reducing future bugs.