ASTOR: A PROGRAM REPAIR LIBRARY FOR JAVA
Matias Martinez University of Valenciennes, France Martin Monperrus University of Lille, France
1
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
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 program execution into an acceptable one according to a specification.
2
Program P Program P’ Approach Specification (Correctness Oracle) Artifacts (Bug Report, Traces, ......)
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
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
OUR GOALS
➤ We wanted a Java platform for ➤ implementing existing state-of-the-art repair approaches. ➤ extending defined approaches. ➤ implement new approaches.
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
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
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
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
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
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
COMMAND
java -cp astor.jar fr.inria.main.evolution.MainAstor
13
OUTPUT
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
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
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
LIST OF EXTENSION POINTS
Command line arguments for extending Astor:
EXAMPLE OF EXTENSION POINT
java -cp astor.jar:<myjar> fr.inria.main.evolution.MainAstor
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; } }
EXAMPLE OF EXTENSION POINT
java -cp astor.jar:<myjar> fr.inria.main.evolution.MainAstor
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){ … }; …… }
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
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?