Vector v = new Vector(); for (int i = 0; i < fromResources.length; i++) { if (mapper.mapFileName(fromResources[i].getName()) != null) { v.addElement(fromResources[i]); } } toCopy = new Resource[v.size()]; v.copyInto(toCopy);
Vector v = new Vector(); for (int i = 0; i < names.length; i++) { if (mapper.mapFileName(names[i]) != null) { v.addElement(names[i]); } } toCopy = new String[v.size()]; v.copyInto(toCopy);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java
Method name: Map buildMap(Resource[], File, FileNameMapper) Method name: void buildMap(File, File, String[], FileNameMapper, Hashtable)
Number of AST nodes: 6 Number of AST nodes: 6
1
Vector v = new Vector();
1
Vector v = new Vector();
2
            for (int i = 0; i < fromResources.length; i++) {
2
            for (int i = 0; i < names.length; i++) {
3
                if (mapper.mapFileName(fromResources[i].getName()) != null) {
3
                if (mapper.mapFileName(names[i]) != null) {
4
                    v.addElement(fromResources[i]);
4
                    v.addElement(names[i]);
5
                }
5
                }
6
            }
6
            }
7
            toCopy = new Resource[v.size()];
7
            toCopy = new String[v.size()];
8
            v.copyInto(toCopy);
8
            v.copyInto(toCopy);
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.4
Clones locationClones are declared in the same class
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    Vector v = new Vector();
    3
    Vector v = new Vector();
    5
    for (int i = 0; i < fromResources.length; i++)
    5
    for (int i = 0; i < fromResources.length; i++)
    4
    for (int i = 0; i < names.length; i++)
    Differences
    Expression1Expression2Difference
    fromResourcesnamesVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Resource[]java.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.ant.types.Resource[] of variable fromResources does not match with type java.lang.String[] of variable names
    • Make classes org.apache.tools.ant.types.Resource[] and java.lang.String[] extend a common superclass
    4
    for (int i = 0; i < names.length; i++)
    6
    if (mapper.mapFileName(fromResources[i].getName()) != null)
    6
    if (mapper.mapFileName(fromResources[i].getName()) != null)
    5
    if (mapper.mapFileName(names[i]) != null)
    Differences
    Expression1Expression2Difference
    fromResources[i].getName()names[i]TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression fromResources[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression names[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (mapper.mapFileName(names[i]) != null)
    7
    v.addElement(fromResources[i]);
    7
    v.addElement(fromResources[i]);
    6
    v.addElement(names[i]);
    Differences
    Expression1Expression2Difference
    fromResourcesnamesVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Resource[]java.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.ant.types.Resource[] of variable fromResources does not match with type java.lang.String[] of variable names
    • Make classes org.apache.tools.ant.types.Resource[] and java.lang.String[] extend a common superclass
    6
    v.addElement(names[i]);
                                                                  
    7
    toCopy = new String[v.size()];
    Preondition Violations
    Unmatched statement toCopy=new String[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    toCopy = new String[v.size()];
    8
    toCopy = new Resource[v.size()];
    8
    toCopy = new Resource[v.size()];
    Preondition Violations
    Unmatched statement toCopy=new Resource[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
    9
    v.copyInto(toCopy);
    9
    v.copyInto(toCopy);
    8
    v.copyInto(toCopy);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.Resource[]java.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.ant.types.Resource[] of variable toCopy does not match with type java.lang.String[] of variable toCopy
    • Make classes org.apache.tools.ant.types.Resource[] and java.lang.String[] extend a common superclass
    8
    v.copyInto(toCopy);
    Precondition Violations (7)
    Row Violation
    1Type org.apache.tools.ant.types.Resource[] of variable fromResources does not match with type java.lang.String[] of variable names
    2Expression fromResources[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression names[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type org.apache.tools.ant.types.Resource[] of variable fromResources does not match with type java.lang.String[] of variable names
    5Unmatched statement toCopy=new String[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement toCopy=new Resource[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Type org.apache.tools.ant.types.Resource[] of variable toCopy does not match with type java.lang.String[] of variable toCopy