Skip to content
Automatic Program Repair with On-Demand Candidate Generation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Automatic Program Repair with On-Demand Candidate Generation.

Given a faulty program and a test suite that has test failures, SketchFix tries to find a repair for the faulty program such that all tests pass.

Hello World Example

  1. Import the to Eclipse. A faulty program: and a failing test case written in JUnit test framework.
	public int simpleExpError() {
		int a = 2; 
		int b = 1;
		//expect to have int c = a;
		int c = b;
		return c;
	public void test1() {
		assertEquals(2, new SimpleEXPReplace().simpleExpError());

Step 1: Run Here I assume the Fault Location is known.

	public static void main(String[] args) {
   	StaticAnalyzer analyzer = new StaticAnalyzer();
   	analyzer.setConfigFile(ConfigType.SIMPLE, "SimpleConfig.txt");

SimpleConfig.txt is a config file similar to Defects4J build properties.


Step2: SketchFix generates a list of sketches. One of them is as below:

import edSketch.request.SketchFix;

public class SimpleEXPReplace {

    public int simpleExpError() {
        int a = 2;
        int b = 1;
        // expect to have int c = a;
        int c = ((Integer) SketchFix.EXP(new Object[] { b, a }, 0, new String[] { "b", "a" }, int.class).invoke());
        return c;

The parameter list: visible variable list, hold id, a string array simply for the purpose of printing results, target type.

Replace this file with and execute the JUnit test case with

import edSketch.executor.SketchExecutor;
import edSketch.request.SketchFix;

public class SketchFixDriver {
	public static void main(String[] arg){
		org.junit.runner.JUnitCore core = new org.junit.runner.JUnitCore();
		org.junit.runner.Result result1 = null;
		Class target1 = Class.forName("TestSimpleEXPReplace");
		do {
			try {
				result1 =;
				if (result1.wasSuccessful() ) {
					System.out.println("Found solution:  " + SketchFix.getString());
			} catch (Exception e) {}
		} while (SketchExecutor.incrementCounter());

If SketchFix finds a solution that passes all tests, it prints the result as below:

Generate 3 candidates for the type int: [b, a, 0]
Found solution:
 Hole 0	a
You can’t perform that action at this time.