sofya.mutator.operators
Class ROP.ROPMutation

java.lang.Object
  extended by sofya.mutator.MutationImpl
      extended by sofya.mutator.MethodMutation
          extended by sofya.mutator.operators.ROP.ROPMutation
All Implemented Interfaces:
GroupableMutation, Mutation
Enclosing class:
ROP

public static class ROP.ROPMutation
extends MethodMutation
implements GroupableMutation


Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.mutator.Mutation
Mutation.Variant
 
Field Summary
 
Fields inherited from class sofya.mutator.MethodMutation
className, methodName, signature
 
Constructor Summary
protected ROP.ROPMutation(java.lang.String className, java.lang.String methodName, java.lang.String signature, int codeOffset, int relOffset, short origOpcode, short mutatedOpcode)
           
 
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, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionList il, java.util.Map linkData, Mutation.Variant variant)
          Applies the mutation; provides access to data to enable more efficient application.
 void apply(org.apache.bcel.generic.ClassGen cg, Mutation.Variant variant)
          Applies this mutation to the class file.
static Mutation deserialize(java.io.DataInput in)
           
 Mutation.Variant getDefaultVariant()
          Gets the default variant selected by the mutation generator when the mutation table was generated.
 MutationGroup getParent()
          Gets the parent mutation group of which this mutation is a member.
 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 setParent(MutationGroup mg)
          Sets the parent mutation group of which this mutation is a member.
 java.lang.String toString()
           
 void undo(org.apache.bcel.generic.ClassGen cg)
          Reverses the actions performed to apply this mutation.
 void undo(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionList il, java.util.Map linkData)
          Reverses the actions performed to apply this mutation; provides access to the additional data used by this mutation for appropriate reversal of changes.
 
Methods inherited from class sofya.mutator.MethodMutation
getClassName, getMethodName, getSignature
 
Methods inherited from class sofya.mutator.MutationImpl
getID, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sofya.mutator.Mutation
getID, setID
 

Constructor Detail

ROP.ROPMutation

protected ROP.ROPMutation(java.lang.String className,
                          java.lang.String methodName,
                          java.lang.String signature,
                          int codeOffset,
                          int relOffset,
                          short origOpcode,
                          short mutatedOpcode)
Method Detail

getType

public java.lang.String getType()
Description copied from interface: Mutation
Gets the operator type abbreviation associated with this mutation.

Specified by:
getType in interface Mutation
Returns:
The operator type that generated this mutation.

getParent

public MutationGroup getParent()
Description copied from interface: GroupableMutation
Gets the parent mutation group of which this mutation is a member.

Specified by:
getParent in interface GroupableMutation
Returns:
The mutation group containing this mutation. This may be null, in which case efficiency benefits associated with implementing the GroupableMutation interface will be lost.

setParent

public void setParent(MutationGroup mg)
Description copied from interface: GroupableMutation
Sets the parent mutation group of which this mutation is a member.

This method is automatically invoked when this mutation is added to a mutation group. It should not normally be called otherwise.

Specified by:
setParent in interface GroupableMutation
Parameters:
mg - Mutation group that now contains this mutation.

getDefaultVariant

public Mutation.Variant getDefaultVariant()
Description copied from interface: Mutation
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.

Specified by:
getDefaultVariant in interface Mutation
Returns:
A variant of this mutation selected during mutation table generation. Mutations that do not support variants may return null from this method.

getVariants

public Mutation.Variant[] getVariants()
Description copied from interface: Mutation
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.

Specified by:
getVariants in interface Mutation
Returns:
An array of the possible variants of this mutation.

accept

public void accept(MutationVisitor visitor)
            throws MutationException
Description copied from interface: Mutation
Accepts a mutation visitor to perform some operation using this mutation.

Specified by:
accept in interface 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

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

Specified by:
apply in interface Mutation
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.

apply

public void apply(org.apache.bcel.generic.ClassGen cg,
                  org.apache.bcel.generic.MethodGen mg,
                  org.apache.bcel.generic.InstructionList il,
                  java.util.Map linkData,
                  Mutation.Variant variant)
           throws MutationException
Description copied from interface: GroupableMutation
Applies the mutation; provides access to data to enable more efficient application.

Specified by:
apply in interface GroupableMutation
Parameters:
cg - BCEL classfile object for the class being mutated.
mg - BCEL method object for the method being mutated.
il - BCEL instruction list for the method being mutated.
linkData - Map to permit grouped mutations to pass information to each other.
variant - Index of the variant of the mutation to be applied.
Throws:
MutationException - If application of this mutation fails for any reason.

undo

public void undo(org.apache.bcel.generic.ClassGen cg)
Description copied from interface: Mutation
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.

Specified by:
undo in interface Mutation
Parameters:
cg - BCEL classfile object for the class to which this mutation was applied.

undo

public void undo(org.apache.bcel.generic.ClassGen cg,
                 org.apache.bcel.generic.MethodGen mg,
                 org.apache.bcel.generic.InstructionList il,
                 java.util.Map linkData)
Description copied from interface: GroupableMutation
Reverses the actions performed to apply this mutation; provides access to the additional data used by this mutation for appropriate reversal of changes. This method is used by the Mutator to automatically screen out illegal mutants when mutant verification is enabled.

Specified by:
undo in interface GroupableMutation
Parameters:
cg - BCEL classfile object for the class to which this mutation was applied.
mg - BCEL method object for the method to which this mutation was applied.
il - BCEL instruction list for the method to which this mutation was applied.
linkData - Map used to permit grouped mutations to pass information to each other.

serialize

public void serialize(java.io.DataOutput out)
               throws java.io.IOException
Description copied from interface: Mutation
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.

Specified by:
serialize in interface Mutation
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.

deserialize

public static Mutation deserialize(java.io.DataInput in)
                            throws java.io.IOException
Throws:
java.io.IOException

print

public java.lang.String print()
Description copied from interface: Mutation
Prints this mutation in a format suitable for display.

Specified by:
print in interface Mutation
Returns:
A string giving information about the mutation in a format suitable for display.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object