|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.mutator.selectors.MethodMutationSelector
public class MethodMutationSelector
Mutation selector that selects by method name and signature.
This selector will only select mutations of the MethodMutation
type. It parses method name and signature information extracted
from source code by a certain method diffing tool, and uses that
information to compare against method names and signatures supplied
by BCEL to implement the selection.
Nested Class Summary | |
---|---|
protected static class |
MethodMutationSelector.TypeSignature
Data class that records signature information about a selected method. |
Field Summary | |
---|---|
protected java.util.Map |
nameSigTable
Map that stores dot-concatenated class name and method names as keys to TypeSignature values recording the formal argument
and return types. |
Constructor Summary | |
---|---|
protected |
MethodMutationSelector()
|
|
MethodMutationSelector(java.util.Collection methodNames)
Creates a new mutation selector. |
|
MethodMutationSelector(java.lang.String[] methodNames)
Creates a new mutation selector. |
Method Summary | |
---|---|
protected void |
addMethod(java.lang.String methodDesc)
Adds a selected method. |
Mutation.Variant |
getVariant(Mutation mutation)
Gets the selected variant. |
boolean |
isSelected(Mutation mutation)
Reports whether a mutation is selected.. |
static void |
main(java.lang.String[] argv)
Test driver to verify the textual method parsing and comparison function. |
void |
setMutationCount(int mutationCount)
Sets the total number of mutations that may be passed to this selector (typically the number of mutations in a mutation table). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map nameSigTable
TypeSignature
values recording the formal argument
and return types. The keys are the nearest 'meeting point' between
the format supplied by the diff tool and that supplied by BCEL,
allowing the fastest initial lookup to determine if the mutation is
selected before applying the more costly signature comparison.
Constructor Detail |
---|
protected MethodMutationSelector()
public MethodMutationSelector(java.lang.String[] methodNames)
methodNames
- Array of method descriptions supplied by the
diffing tool. Mutations occurring in the selected methods will
be selected.public MethodMutationSelector(java.util.Collection methodNames)
methodNames
- Collection of method descriptions supplied by the
diffing tool, as strings. Mutations occurring in the selected methods
will be selected.Method Detail |
---|
public boolean isSelected(Mutation mutation)
Argument and return types are compared using an ends-with test against the string conversion of the types retrieved from the mutation. This is because the method description format it is being compared against (apparently) originates from source code where fully qualified type names are rarely used (only if disambiguation is required). Note that this approach is NOT implemented commutatively, since we know that BCEL will always return the fully qualified type string (thus an unqualified class name is considered a separate type from one with package qualifiers, a distinction permitted by the Java type system as a consequence of the implicit namespaces created by Java packages). The safety of this approach is guaranteed by the requirement that ambiguous type names be fully qualified in the source code, as mentioned above.
isSelected
in interface MutationSelector
mutation
- Mutation to be checked for selection.
true
if this selector implements a selection
criteria that the given mutation meets, false
otherwise.public Mutation.Variant getVariant(Mutation mutation)
MutationSelector
Some mutation operators, such as the arithmetic operator change (AOP), generate multiple variants at a single location.
getVariant
in interface MutationSelector
mutation
- Mutation for which to retrieve the selected variant.
public void setMutationCount(int mutationCount)
MutationSelector
This is useful for some selectors, such as those that implement random selection criteria.
setMutationCount
in interface MutationSelector
mutationCount
- Total number of mutations from which this selector
may select.protected void addMethod(java.lang.String methodDesc)
This method is responsible for parsing a textual method description received from the diffing tool.
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |