for (Iterator i = children.iterator(); i.hasNext();) { UnknownElement el = (UnknownElement) i.next(); el.maybeConfigure(); Child child = (Child) el.getRealThing(); child.injectParent(this); child.perform(); }
for (Iterator i = nestedTasks.iterator(); i.hasNext();) { Task nestedTask = (Task) i.next(); nestedTask.perform(); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Sequential.java
Method name: void execute() Method name: void execute()
Number of AST nodes: 6 Number of AST nodes: 3
1
for (Iterator i = children.iterator(); i.hasNext();) {
1
for (Iterator i = nestedTasks.iterator(); i.hasNext();) {
2
                UnknownElement el = (UnknownElement) i.next();
2
            
3
                el.maybeConfigure();
4
                Child child = (Child) el.getRealThing();
5
                child.injectParent(this);
6
                child
3
Task nestedTask = (Task) i.next();
7
.perform();
4
            nestedTask.perform();
8
            }
5
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons18
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)719.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    for (Iterator i = children.iterator(); i.hasNext(); )
    1
    for (Iterator i = children.iterator(); i.hasNext(); )
    1
    for (Iterator i = nestedTasks.iterator(); i.hasNext(); )
    Differences
    Expression1Expression2Difference
    childrennestedTasksVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.VectorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable children does not match with type java.util.Vector of variable nestedTasks
    • Make classes java.util.List and java.util.Vector extend a common superclass
    1
    for (Iterator i = nestedTasks.iterator(); i.hasNext(); )
    2
    UnknownElement el = (UnknownElement)i.next();
    2
    UnknownElement el = (UnknownElement)i.next();
    2
    Task nestedTask = (Task)i.next();
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.UnknownElementorg.apache.tools.ant.TaskSUBCLASS_TYPE_MISMATCH
    elnestedTaskVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.UnknownElementorg.apache.tools.ant.TaskSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.UnknownElementorg.apache.tools.ant.TaskSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (UnknownElement)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (Task)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    Task nestedTask = (Task)i.next();
    3
    el.maybeConfigure();
    3
    el.maybeConfigure();
    3
    nestedTask.perform();
    Differences
    Expression1Expression2Difference
    maybeConfigureperformMETHOD_INVOCATION_NAME_MISMATCH
    elnestedTaskVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.UnknownElementorg.apache.tools.ant.TaskSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression el.maybeConfigure() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression nestedTask.perform() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression el.maybeConfigure() is a void method call, and thus it cannot be parameterized
    Expression nestedTask.perform() is a void method call, and thus it cannot be parameterized
    3
    nestedTask.perform();
    4
    Child child = (Child)el.getRealThing();
    4
    Child child = (Child)el.getRealThing();
    Preondition Violations
    Unmatched statement Child child=(Child)el.getRealThing(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    5
    child.injectParent(this);
    5
    child.injectParent(this);
    Preondition Violations
    Unmatched statement child.injectParent(this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    6
    child.perform();
    6
    child.perform();
    Preondition Violations
    Unmatched statement child.perform(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    Precondition Violations (11)
    Row Violation
    1Type java.util.List of variable children does not match with type java.util.Vector of variable nestedTasks
    2Expression (UnknownElement)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (Task)i.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression el.maybeConfigure() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression nestedTask.perform() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression el.maybeConfigure() is a void method call, and thus it cannot be parameterized
    7Expression nestedTask.perform() is a void method call, and thus it cannot be parameterized
    8Unmatched statement Child child=(Child)el.getRealThing(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement child.injectParent(this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement child.perform(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Clone fragment #1 returns variables el , while Clone fragment #2 returns variables