ASTOR: A PROGRAM REPAIR LIBRARY FOR JAVA Matias Martinez - - PowerPoint PPT Presentation

astor a program repair library for java
SMART_READER_LITE
LIVE PREVIEW

ASTOR: A PROGRAM REPAIR LIBRARY FOR JAVA Matias Martinez - - PowerPoint PPT Presentation

ASTOR: A PROGRAM REPAIR LIBRARY FOR JAVA Matias Martinez University of Valenciennes, France Martin Monperrus University of Lille, France 1 AUTOMATIC SOFTWARE REPAIR Automatic repair is the transformation of an unacceptable behavior of a


slide-1
SLIDE 1

ASTOR: A PROGRAM REPAIR LIBRARY FOR JAVA

Matias Martinez University of Valenciennes, France Martin Monperrus University of Lille, France

1

slide-2
SLIDE 2

AUTOMATIC SOFTWARE REPAIR

➤ Automatic repair is the transformation of an unacceptable

behavior of a program execution into an acceptable one according to a specification.

2

Program P Program P’ Approach Specification (Correctness Oracle) Artifacts (Bug Report, Traces, ......)

slide-3
SLIDE 3

AUTOMATIC SOFTWARE REPAIR

➤ Emerging repair approaches during last 10 years ➤ GenProg (Weimer, Le Goues et al.) ➤ AutoFix (Pei et al.) ➤ Nopol (Xuan et al.) ➤ SPR (Long et al.) ➤ Par (Kim et al.) ➤ Angelix(Mechtaev et al.) ➤ RSRepair (Qi et al.) ➤ ……

3

slide-4
SLIDE 4

AUTOMATIC SOFTWARE REPAIR- CONTEXT

➤ A repair approach is both an algorithm and its realization in a

prototype

➤ Prototypes are hard-wired for a given programming language ➤ Prototypes are not always publicly available ➤ To reimplement those approaches from scratch


is costly

4

slide-5
SLIDE 5

OUR GOALS

➤ We wanted a Java platform for ➤ implementing existing state-of-the-art repair approaches. ➤ extending defined approaches. ➤ implement new approaches.

slide-6
SLIDE 6

ASTOR

➤ Astor: Automatic Software Transformations fOr program

Repair

➤ Implemented in Java, for repairing Java code ➤ We envision that the research community will use Astor for

setting up comparative evaluations and for exploring the design space of automatic repair for Java

6

slide-7
SLIDE 7

CONTRIBUTION

➤ Astor includes an implementation of 3 repair approaches. ➤ They can be used ‘out of the box’ ➤ Astor provides Extension points to: ➤ Extend or override behavior of implemented approaches ➤ Implement new approaches using routines that Astor

provides

7

slide-8
SLIDE 8

REPAIR APPROACHES

➤ Test-suite based repair approaches use test-suite as program

specification

➤ One or more failing test cases → program has a bug ➤ All test passes → program is valid ➤ Generate and validate approaches: ➤ Candidate Patch 1 → validation → unsuccessful ➤ Candidate Patch 2 → validation → unsuccessful ➤ …. ➤ Candidate Patch n → validation → successful

8

slide-9
SLIDE 9

REPAIR WORKFLOW

Executes the test suite: at least one failing test case Computes buggy suspiciousness of components While (not solution and not timeout) { Selects a suspicious component C Selects one repair operation O Applies O on C to generate C' Validates candidate solution with C' by executing test suite }

Steps that can be customized according to approach

9

slide-10
SLIDE 10

THREE REPAIR MODES

➤ jGenProg based on GenProg (Le Goues, Weimer et al.) ➤ Genetic programming, synthesizes patches by reusing

existing code

➤ Inserts, replaces and removes statements. ➤ jMutation based on MutationRepair (Debroy and Wong) ➤ Mutates operators on if conditions. ➤ jKali based on Kali (Qi et al.) ➤ Removes statements and blocks, adds return statements,

replace if expressions.

10

slide-11
SLIDE 11

HOW TO RUN ASTOR?

slide-12
SLIDE 12

ASTOR INSTALLATION

➤ Download ➤ git clone https://github.com/SpoonLabs/astor.git ➤ Installation (Maven): ➤ mvn clean ➤ mvn compile ➤ <Astor_folder>/target/astor-Y.X.Z-SNAPSHOT-jar-with-

dependencies.jar

12

slide-13
SLIDE 13

COMMAND

java -cp astor.jar fr.inria.main.evolution.MainAstor

  • mode jgenprog
  • location ./math_70
  • dependencies ./libs/junit-4.4.jar
  • failing org.apache.commons.BisectionSolverTest
  • out /tmp/astorDemo

13

slide-14
SLIDE 14

OUTPUT

slide-15
SLIDE 15

OUTPUT

➤ Patched source code files ➤ Summary file:

<patch> <operation generation="123" line="72" location="org.apache.commons.BisectionSolver" type="ReplaceOp"> <original>return solve(min, max)</original> <modified>return solve(f, min, max)</modified> </operation> </patch>

15

slide-16
SLIDE 16

EXPERIMENTS DONE USING ASTOR

slide-17
SLIDE 17

EVALUATION

➤ Repairing bugs from Defects4J dataset (Just et al.) ➤ Patches for 33 out of 224 bug (14.7%)

jGenProg jKali jMutRepair Chart

C1, C3, C5, C7, C13, C15, C25, C1, C5, C13, C15, C25, C26 C1, C7, C25, C26

7 6 4

Lang

  • L27

1

Math

M2, M5, M7, M8, M28, M40, M49, M50, M53, M60, M70, M71, M73, M78, M80, M81, M82, M84, M85, M95 M2, M8, M28, M32, M40, M49, M50, M78, M80, M81, M82, M84, M85, M95 M2, 28, 40, 50, 57, 58, 81, 82, 84, 85, 88

20 14 11

Time

T4, T11 T4, T11 T11

2 2 1

Total

29 22 17

17

Martinez, M., Durieux, T., Sommerard, R. Xuan, J. et Monperrus, M. Empir Software Eng (2016). doi:10.1007/s10664-016-9470-4

slide-18
SLIDE 18

EXTENDING ASTOR

slide-19
SLIDE 19

LIST OF EXTENSION POINTS

Command line arguments for extending Astor:

  • customop
  • customengine
  • opselectionstrategy
  • ingredientstrategy
slide-20
SLIDE 20

EXAMPLE OF EXTENSION POINT

java -cp astor.jar:<myjar> fr.inria.main.evolution.MainAstor

  • mode jgenprog
  • location ./examples/math_70
  • dependencies ./libs/junit-4.4.jar
  • failing org.apache.commons.BisectionSolverTest
  • out /tmp/astorDemo
  • maxtime 100
  • opselectionstrategy astor.CustomStrategy
slide-21
SLIDE 21

NEW STRATEGY TO SELECT OPERATOR

public abstract class OperatorSelectionStrategy { protected OperatorSpace operatorSpace; public OperatorSelectionStrategy(OperatorSpace space) { super(); this.operatorSpace = space; } public abstract AstorOperator getNextOperator(); public abstract AstorOperator getNextOperator(Location location); public OperatorSpace getOperatorSpace() { return operatorSpace; } }

slide-22
SLIDE 22

EXAMPLE OF EXTENSION POINT

java -cp astor.jar:<myjar> fr.inria.main.evolution.MainAstor

  • mode jgenprog
  • location ./examples/math_70
  • dependencies ./libs/junit-4.4.jar
  • failing org.apache.BisectionSolverTest
  • out /tmp/astorDemo
  • maxtime 100
  • customop astor.OperatorX:astor.OperatorY
slide-23
SLIDE 23

NEW REPAIR OPERATOR

public abstract class AstorOperator { public abstract boolean applyChangesInModel(ModificationInstance opInstance, ProgramVariant p); public abstract boolean undoChangesInModel(ModificationInstance opInstance, ProgramVariant p); public boolean canBeAppliedToPoint(ModificationPoint point){ … }; …… }

slide-24
SLIDE 24

PAPER AT ISSTA

➤ Matias Martinez and Martin Monperrus. 2016. ASTOR: a

program repair library for Java (demo). In Proceedings of the 25th International Symposium on Software Testing and Analysis (ISSTA 2016). DOI: http://dx.doi.org/ 10.1145/2931037.2948705

slide-25
SLIDE 25

CONCLUSION

➤ A repair tool implemented in Java for repairing Java code ➤ Includes 3 implementation of state of the art repair

algorithms

➤ Provides extension points for customize and implement new

approaches

➤ Source code and results publicly available

25

Questions?