int index = -1; for (int i = 0; i < entries.size() && index == -1; ++i) { Object element = entries.elementAt(i); if (element instanceof ConstantCPInfo) { ConstantCPInfo constantEntry = (ConstantCPInfo) element; if (constantEntry.getValue().equals(constantValue)) { index = i; } } } return index;
int index = -1; for (int i = 0; i < entries.size() && index == -1; ++i) { Object element = entries.elementAt(i); if (element instanceof ClassCPInfo) { ClassCPInfo classinfo = (ClassCPInfo) element; if (classinfo.getClassName().equals(className)) { index = i; } } } return index;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java
Method name: int getConstantEntry(Object) Method name: int getClassEntry(String)
Number of AST nodes: 8 Number of AST nodes: 8
1
int index = -1;
1
int index = -1;
2
        for (int i = 0; i < entries.size() && index == -1; ++i) {
2
        for (int i = 0; i < entries.size() && index == -1; ++i) {
3
            Object element = entries.elementAt(i);
3
            Object element = entries.elementAt(i);
4
            if (element instanceof ConstantCPInfo) {
4
            if (element instanceof ClassCPInfo) {
5
                ConstantCPInfo constantEntry = (ConstantCPInfo) element;
5
                ClassCPInfo classinfo = (ClassCPInfo) element;
6
                if (constantEntry.getValue().equals(constantValue)) {
6
                if (classinfo.getClassName().equals(className)) {
7
                    index = i;
7
                    index = i;
8
                }
8
                }
9
            }
9
            }
10
        }
10
        }
11
        return index;
11
        return index;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons13
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)3.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int index = -1;
    1
    int index = -1;
    2
    for (int i = 0; i < entries.size() && index == -1; ++i)
    2
    for (int i = 0; i < entries.size() && index == -1; ++i)
    3
    Object element = entries.elementAt(i);
    3
    Object element = entries.elementAt(i);
    4
    if (element instanceof ConstantCPInfo)
    4
    if (element instanceof ConstantCPInfo)
    4
    if (element instanceof ClassCPInfo)
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantCPInfoorg.apache.tools.ant.taskdefs.optional.depend.constantpool.ClassCPInfoSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression element instanceof ConstantCPInfo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression element instanceof ClassCPInfo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    if (element instanceof ClassCPInfo)
    5
    ConstantCPInfo constantEntry = (ConstantCPInfo)element;
    5
    ConstantCPInfo constantEntry = (ConstantCPInfo)element;
    5
    ClassCPInfo classinfo = (ClassCPInfo)element;
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantCPInfoorg.apache.tools.ant.taskdefs.optional.depend.constantpool.ClassCPInfoSUBCLASS_TYPE_MISMATCH
    constantEntryclassinfoVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantCPInfoorg.apache.tools.ant.taskdefs.optional.depend.constantpool.ClassCPInfoSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantCPInfoorg.apache.tools.ant.taskdefs.optional.depend.constantpool.ClassCPInfoSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (ConstantCPInfo)element cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (ClassCPInfo)element cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    ClassCPInfo classinfo = (ClassCPInfo)element;
                                                                                                      
    6
    if (classinfo.getClassName().equals(className))
    Preondition Violations
    Unmatched statement if(classinfo.getClassName().equals(className)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    if (classinfo.getClassName().equals(className))
                          
    7
    index = i;
    Preondition Violations
    Unmatched statement index=i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    index = i;
    6
    if (constantEntry.getValue().equals(constantValue))
    6
    if (constantEntry.getValue().equals(constantValue))
    Preondition Violations
    Unmatched statement if(constantEntry.getValue().equals(constantValue)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                              
    7
    index = i;
    7
    index = i;
    Preondition Violations
    Unmatched statement index=i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                          
    8
    return index;
    8
    return index;
    Precondition Violations (8)
    Row Violation
    1Expression element instanceof ConstantCPInfo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression element instanceof ClassCPInfo cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (ConstantCPInfo)element cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (ClassCPInfo)element cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement if(classinfo.getClassName().equals(className)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement index=i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement if(constantEntry.getValue().equals(constantValue)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement index=i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted