Null Checker
This template inserts a if statement checking that all objects are not null.
[Null Pointer Checker]
P = program
B = fault location
<AST Analysis>
C <- collect object references (method invocations, field accesses, and qualified names) of B in P
<Context Check>
if there is any object references in C -> continue
otherwise -> stop
<Program Editing>
insert an if() statement before B
loop for all objects in C {
insert a conditional expression that checks whether a given object is null
}
concatenate conditions by using AND
if B includes return statement {
negate the concatenated conditional expression
insert a return statement that returns a default value into THEN section of the if() statement
insert B after the if() statement
} else {
insert B into THEN section of the if() statement
}
Parameter Replacer
For a method call, this template seeks variables or expressions whose type is compatible with a method parameter and within the same scope. Then, it replaces the selected parameter by a compatible variable or expression.
[Parameter Replacer]
P = program
B = fault location
<AST Analysis>
M <- collect a method call of B in P
<Context Check>
if there is any parameter in M -> continue
otherwise -> stop
<Program Editing>
TargetParam <- select a parameter in M
I <- collect all method calls in the same scope of TargetParam in P
I_selected <- select a method call which has at least one parameter whose type is compatible with TargetParam
SourceParam <- select a parameter of I_selected, which has a compatible type with TargetParam
replace TargetParam by SourceParam
Method Replacer
For a method call, this template replaces its method name by another method’s name which has compatible parameters and return type.
[
Method Replacer ]
P = program
B = fault location
<AST Analysis>
M <- collect a method call of B in P
<Context Check>
M is not empty -> continue
otherwise -> stop
<Program Editing>
I <- collect all method calls which have the same parameters in the same scope of M in P
I_selected <- select a method call
replace M by I_selected with retaining the parameters of M
Parameter Adder and Remover
For a method call, this template adds or removes one parameter of the call only if the method has overloaded siblings. When it adds a parameter, this template
seeks compatible variables and expressions in the same scope. Then, it adds one of them to the place of the new parameter.
[Parameter Adder and Remover]
P = program
B = fault location
<AST Analysis>
M <- collect a method call of B in P
<Context Check>
M has at least one (overloaded) sibling -> continue
otherwise -> stop
<Program Editing>
S <- collect all sibling methods of M in P
S_selected <- select a method call
if S_selected has more parameters than M
{
Params <- collect parameters of all methods in the same scope of M in P
replace M by S_selected
set missing parameters of S_selected by selecting parameters in Params
}
else if S_selected has fewer parameters than M
{
replace M by S_selected
}
Object Initializer
This template initializes a new object before passing it as a parameter of a method invocation.
[Object Initializer]
B = buggy statements
collect object creation operators in parameters of B into collection C
loop for all object creations in C
{
insert an assignment statement that declares a new local variable and creates a new object (using an object creation's type) to the variable
insert a method invocation statement that calls an initialization method
}
insert B after statements
Sequence Exchanger
This template changes a sequence of buggy statements.
[Sequence Exchanger]
B = buggy statements
loop for all statements in B
{
exchange a statement by the most similar statement in B
}
Range Checker
This template inserts a if statement checking that all index variables of array accesses are within lower and upper bounds.
[Range Checker]
B = buggy statements
collect array accesses of B into collection C
insert a if statement before B
loop for all index variables in C
{
insert a conditional expression that checks whether an index variable is within upper and lower bound
}
concatenate conditions using AND
if B include return statement
{
negate the concatenated the conditional expression
insert a return statement that returns a default value into THEN section of the if statement
insert B after the if statement
} else {
insert B into THEN section of the if statement
}
Collection Size Checker
This template inserts a if statement checking that an index variable is smaller than the size of a collection object if buggy statements have collection object references.
[Collection Size Checker]
B = buggy statements
collect method invocations of (@\textbf{[collection objects]}@) in B and put them into collection C
insert a if statement before B
loop for all method invocation in C
{
if a method invocation has an index parameter
{
insert a conditional expression that checks whether the index parameter is smaller than the size of its collection object
}
}
concatenate conditions using AND
if B include return statement
{
negate the concatenated the conditional expression
insert a return statement that returns a default value into THEN section of the if statement
insert B after the if statement
} else {
insert B into THEN section of the if statement
}
Lower Bound Setter
This template assigns the lower bound value to an index variable if buggy statements have array accesses.
[Lower Bound Setter]
B = buggy statements
collect array accesses of B into collection C
loop for all index variables in C
{
insert a if statement before statements having an index variable
insert a conditional expression that checks whether an index variable is smaller than lower bound
insert an assignment statement that gives the lower bound value to the index variable into THEN section of the if statement
}
insert B after all if statements
Upper Bound Setter
This template assigns the upper bound value to an index variable if buggy statements have array accesses.
[Upper Bound Setter]
B = buggy statements
collect array accesses of B into collection C
loop for all index variables in C
{
insert a if statement before statements having an index variable
insert a conditional expression that checks whether an index variable is larger than upper bound
insert an assignment statement that gives the upper bound value to the index variable into THEN section of the if statement
}
insert B after all if statements
Off-by-one Mutator
This template modifies an index variable by 1 if buggy statements have array accesses.
[Off-by-One Mutator]
B = buggy statements
collect array accesses of B into collection C
loop for all index variables in C
{
increase or decrease an index variable by 1
}
insert B
Class Cast Checker
This template inserts a if statement checking that castees implement appropriate types when there are casting operators.
[Class Cast Checker]
B = buggy statements
collect class-casting operators of B into collection C
insert a if statement before B
loop for all castees in C
{
insert a conditional expression that checks whether a castee implements its casting type
}
concatenate conditions using AND
if B include return statement
{
negate the concatenated the conditional expression
insert a return statement that returns a default value into THEN section of the if statement
insert B after the if statement
} else {
insert B into THEN section of the if statement
}
Caster Mutator
This template replaces the casting type of casting operator by another type.
[Castor Mutator]
B = buggy statements
collect class-casting operators of B into collection C
loop for all operators in C
{
replace the casting type of an operator by one of parent types of the casting type
}
Castee Mutator
This template replaces a castee by another similar variable name.
[Castee Mutator]
B = buggy statements
collect class-casting operators of B into collection C
loop for all operators in C
{
replace the castee of an operator by one of similar variable names
}
Expression Changer
This template replaces a conditional expression in buggy statements by a similar conditional expression in the same source code.
[Expression Exchanger]
B = buggy statements
collect "conditional expressions" of B into collection C
loop for all conditional expressions in C
{
replace a conditional expression by a similar conditional expression in source code
}
Expression Adder
This template inserts a similar expression into an expression in buggy statements if they have conditional expressions.
[Expression Adder]
B = buggy statements
collect "conditional expressions" of B into collection C
loop for all conditional expressions in C
{
insert another similar conditional expression before a conditional expression and concatenate them
}