sofya.mutator
Interface Mutation

All Known Subinterfaces:
GroupableMutation
All Known Implementing Classes:
AFC.AFCMutation, AOC.AOCMutation, AOP.AOPMutation, ClassMutation, HFA.HFAMutation, HFR.HFRMutation, IOD.IODMutation, LCC.LCCMutation, MethodMutation, MutationGroup, MutationImpl, ROP.ROPMutation

public interface Mutation

A mutation implements the transformation(s) that create a "mutated" variant of a Java class.

A mutation class should also provide a static method named deserialize that takes a single parameter of type DataInput and returns a Mutation. This method is used by the framework to provide transparent automatic support for new mutation operators, though it cannot be enforced by the interface due to the need for a static method.

Version:
05/23/2006
Author:
Alex Kinneer
See Also:
MutationOperator, MutationGenerator, Mutator

Nested Class Summary
static interface Mutation.Variant
          A variant of a mutation representing one of a number of mutually exclusive substitutions that can be used to produce a mutant.
 
Method Summary
 void accept(MutationVisitor visitor)
          Accepts a mutation visitor to perform some operation using this mutation.
 void apply(org.apache.bcel.generic.ClassGen cg, Mutation.Variant variant)
          Applies this mutation to the class file.
 Mutation.Variant getDefaultVariant()
          Gets the default variant selected by the mutation generator when the mutation table was generated.
 MutationID getID()
          Gets the ID associated with this mutation.
 java.lang.String getType()
          Gets the operator type abbreviation associated with this mutation.
 Mutation.Variant[] getVariants()
          Gets all of the possible variants of this mutation.
 java.lang.String print()
          Prints this mutation in a format suitable for display.
 void serialize(java.io.DataOutput out)
          Serializes this mutation.
 void setID(MutationID mid)
          Sets the ID associated with this mutation.
 void undo(org.apache.bcel.generic.ClassGen cg)
          Reverses the actions performed to apply this mutation.
 

Method Detail

accept

void accept(MutationVisitor visitor)
            throws MutationException
Accepts a mutation visitor to perform some operation using this mutation.

Parameters:
visitor - Mutation visitor that is visiting this mutation.
Throws:
MutationException - If an action performed on this mutation by the visitor fails (this permits the exception to propagate).

apply

void apply(org.apache.bcel.generic.ClassGen cg,
           Mutation.Variant variant)
           throws MutationException
Applies this mutation to the class file.

Parameters:
cg - BCEL classfile object for the class being mutated.
variant - Index of the variant of the mutation to be applied.
Throws:
MutationException - If application of this mutation fails for any reason.

undo

void undo(org.apache.bcel.generic.ClassGen cg)
Reverses the actions performed to apply this mutation. This method is used by the Mutator to automatically screen out illegal mutants when mutant verification is enabled.

Parameters:
cg - BCEL classfile object for the class to which this mutation was applied.

getVariants

Mutation.Variant[] getVariants()
Gets all of the possible variants of this mutation.

A variant is one of set of mutually exclusive mutations that can be applied at the same code location. The simplest example of this is an operator mutation, where mutliple alternate operators can be substituted to produce a mutant.

Returns:
An array of the possible variants of this mutation.

getDefaultVariant

Mutation.Variant getDefaultVariant()
Gets the default variant selected by the mutation generator when the mutation table was generated.

A default variant ensures that a mutation can be applied without requiring user intervention. The policy for selecting an initial default is determined by the generating mutation operator, and is typically random.

Returns:
A variant of this mutation selected during mutation table generation. Mutations that do not support variants may return null from this method.

getType

java.lang.String getType()
Gets the operator type abbreviation associated with this mutation.

Returns:
The operator type that generated this mutation.

getID

MutationID getID()
Gets the ID associated with this mutation.

Mutation IDs are automatically assigned and managed by the framework.

Returns:
The ID of this mutation.

setID

void setID(MutationID mid)
Sets the ID associated with this mutation.

This method is called automatically by the framework, and should not be called anywhere else.

Parameters:
mid - ID to be assigned to this mutation.

serialize

void serialize(java.io.DataOutput out)
               throws java.io.IOException
Serializes this mutation.

A mutation class should also provide a static method named deserialize that takes a single parameter of type DataInput and returns a Mutation. This method is used by the framework to provide transparent automatic support for new mutation operators, though it cannot be enforced by the interface due to the need for a static method.

Parameters:
out - Data output sink to which the mutation should be serialized.
Throws:
java.io.IOException - If serialization of this mutation fails for any I/O related reason.

print

java.lang.String print()
Prints this mutation in a format suitable for display.

Returns:
A string giving information about the mutation in a format suitable for display.