Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method methodEntry = methods[i]; if (methodEntry.getName().equals(method)) { return true; } } return false;
Field[] fields = clazz.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field fieldEntry = fields[i]; if (fieldEntry.getName().equals(field)) { return true; } } return false;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/condition/HasMethod.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/condition/HasMethod.java
Method name: boolean isMethodFound(Class) Method name: boolean isFieldFound(Class)
Number of AST nodes: 6 Number of AST nodes: 6
1
Method[] methods = clazz.getDeclaredMethods();
1
Field[] fields = clazz.getDeclaredFields();
2
        for (int i = 0; i < methods.length; i++) {
2
        for (int i = 0; i < fields.length; i++) {
3
            Method methodEntry = methods[i];
3
            Field fieldEntry = fields[i];
4
            if (methodEntry.getName().equals(method)) {
4
            if (fieldEntry.getName().equals(field)) {
5
                return true;
5
                return true;
6
            }
6
            }
7
        }
7
        }
8
        return false;
8
        return false;
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.3
Clones locationClones are declared in the same class
Number of node comparisons12
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    1
    Field[] fields = clazz.getDeclaredFields();
    1
    Method[] methods = clazz.getDeclaredMethods();
                                                                                                  
    2
    for (int i = 0; i < methods.length; i++)
    2
    for (int i = 0; i < methods.length; i++)
    2
    for (int i = 0; i < fields.length; i++)
    Differences
    Expression1Expression2Difference
    methodsfieldsVARIABLE_NAME_MISMATCH
    java.lang.reflect.Method[]java.lang.reflect.Field[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.reflect.Method[] of variable methods does not match with type java.lang.reflect.Field[] of variable fields
    • Make classes java.lang.reflect.Method[] and java.lang.reflect.Field[] extend a common superclass
    2
    for (int i = 0; i < fields.length; i++)
                                                                
    3
    Field fieldEntry = fields[i];
    Preondition Violations
    Unmatched statement Field fieldEntry=fields[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    Field fieldEntry = fields[i];
    3
    Method methodEntry = methods[i];
    3
    Method methodEntry = methods[i];
    Preondition Violations
    Unmatched statement Method methodEntry=methods[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
    4
    if (methodEntry.getName().equals(method))
    4
    if (methodEntry.getName().equals(method))
    4
    if (fieldEntry.getName().equals(field))
    Differences
    Expression1Expression2Difference
    methodfieldVARIABLE_NAME_MISMATCH
    methodEntryfieldEntryVARIABLE_NAME_MISMATCH
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression methodEntry cannot be unified with expression fieldEntry , because common superclass java.lang.reflect.AccessibleObject does not declare member(s) public java.lang.String getName()
    4
    if (fieldEntry.getName().equals(field))
    5
    return true;
    5
    return true;
    6
    return false;
    6
    return false;
    Precondition Violations (4)
    Row Violation
    1Type java.lang.reflect.Method[] of variable methods does not match with type java.lang.reflect.Field[] of variable fields
    2Unmatched statement Field fieldEntry=fields[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Method methodEntry=methods[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression methodEntry cannot be unified with expression fieldEntry , because common superclass java.lang.reflect.AccessibleObject does not declare member(s) public java.lang.String getName()