while (e.hasMoreElements()) { String name = (String) e.nextElement(); String className = props.getProperty(name); AntTypeDefinition def = new AntTypeDefinition(); def.setName(name); def.setClassName(className); def.setClassLoader(classLoader); antTypeTable.put(name, def); }
while (e.hasMoreElements()) { RuntimeConfigurable childWrapper = (RuntimeConfigurable) e.nextElement(); UnknownElement childElement = new UnknownElement(childWrapper.getElementTag()); parentElement.addChild(childElement); childElement.setProject(getProject()); childElement.setRuntimeConfigurableWrapper(childWrapper); childWrapper.setProxy(childElement); replaceChildren(childWrapper, childElement); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/ComponentHelper.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/Task.java
Method name: void initTypes() Method name: void replaceChildren(RuntimeConfigurable, UnknownElement)
Number of AST nodes: 8 Number of AST nodes: 8
1
while (e.hasMoreElements()) {
1
while (e.hasMoreElements()) {
2
            String name = (String) e.nextElement();
2
            
3
            String className = props.getProperty(name);
4
            AntTypeDefinition def = new AntTypeDefinition();
5
            def.setName(name);
6
            def.setClassName(className);
7
            def.setClassLoader(classLoader);
8
            antTypeTable.put(name, def
3
RuntimeConfigurable childWrapper =
4
                (RuntimeConfigurable) e.nextElement();
5
            UnknownElement childElement =
6
                new UnknownElement(childWrapper.getElementTag());
7
            parentElement.addChild(childElement);
8
            childElement.setProject(getProject());
9
            childElement.setRuntimeConfigurableWrapper(childWrapper);
10
            childWrapper.setProxy(childElement);
9
);
11
            replaceChildren(childWrapper, childElement);
10
        }
12
        }
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.1
Clones locationClones are in different classes
Number of node comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)2.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    while (e.hasMoreElements())
    2
    while (e.hasMoreElements())
                                                                                                                                                      
    3
    RuntimeConfigurable childWrapper = (RuntimeConfigurable)e.nextElement();
    Preondition Violations
    Unmatched statement RuntimeConfigurable childWrapper=(RuntimeConfigurable)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    RuntimeConfigurable childWrapper = (RuntimeConfigurable)e.nextElement();
                                                                                                                                                                    
    4
    UnknownElement childElement = new UnknownElement(childWrapper.getElementTag());
    Preondition Violations
    Unmatched statement UnknownElement childElement=new UnknownElement(childWrapper.getElementTag()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    UnknownElement childElement = new UnknownElement(childWrapper.getElementTag());
                                                                                    
    5
    parentElement.addChild(childElement);
    Preondition Violations
    Unmatched statement parentElement.addChild(childElement); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    parentElement.addChild(childElement);
    5
    String name = (String)e.nextElement();
    5
    String name = (String)e.nextElement();
    Preondition Violations
    Unmatched statement String name=(String)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
                                                                                      
    6
    childElement.setProject(getProject());
    Preondition Violations
    Unmatched statement childElement.setProject(getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    childElement.setProject(getProject());
    6
    String className = props.getProperty(name);
    6
    String className = props.getProperty(name);
    Preondition Violations
    Unmatched statement String className=props.getProperty(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
                                                                                                                            
    7
    childElement.setRuntimeConfigurableWrapper(childWrapper);
    Preondition Violations
    Unmatched statement childElement.setRuntimeConfigurableWrapper(childWrapper); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    childElement.setRuntimeConfigurableWrapper(childWrapper);
    7
    AntTypeDefinition def = new AntTypeDefinition();
    7
    AntTypeDefinition def = new AntTypeDefinition();
    Preondition Violations
    Unmatched statement AntTypeDefinition def=new AntTypeDefinition(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                      
                                                                                  
    8
    childWrapper.setProxy(childElement);
    Preondition Violations
    Unmatched statement childWrapper.setProxy(childElement); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    childWrapper.setProxy(childElement);
    8
    def.setName(name);
    8
    def.setName(name);
    Preondition Violations
    Unmatched statement def.setName(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                              
    9
    def.setClassName(className);
    9
    def.setClassName(className);
    9
    replaceChildren(childWrapper, childElement);
    Differences
    Expression1Expression2Difference
    setClassNamereplaceChildrenMETHOD_INVOCATION_NAME_MISMATCH
    def.setClassName(className)replaceChildren(childWrapper,childElement)ARGUMENT_NUMBER_MISMATCH
    defMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression def.setClassName(className) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression replaceChildren(childWrapper,childElement) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method replaceChildren
    Expression def.setClassName(className) is a void method call, and thus it cannot be parameterized
    Expression replaceChildren(childWrapper,childElement) is a void method call, and thus it cannot be parameterized
    Expression def.setClassName(className) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression replaceChildren(childWrapper,childElement) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method replaceChildren
    Expression def.setClassName(className) is a void method call, and thus it cannot be parameterized
    Expression replaceChildren(childWrapper,childElement) is a void method call, and thus it cannot be parameterized
    9
    replaceChildren(childWrapper, childElement);
    10
    def.setClassLoader(classLoader);
    10
    def.setClassLoader(classLoader);
    Preondition Violations
    Unmatched statement def.setClassLoader(classLoader); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    11
    antTypeTable.put(name, def);
    11
    antTypeTable.put(name, def);
    Preondition Violations
    Unmatched statement antTypeTable.put(name,def); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    Precondition Violations (20)
    Row Violation
    1Unmatched statement RuntimeConfigurable childWrapper=(RuntimeConfigurable)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement UnknownElement childElement=new UnknownElement(childWrapper.getElementTag()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement parentElement.addChild(childElement); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement String name=(String)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement childElement.setProject(getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement String className=props.getProperty(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement childElement.setRuntimeConfigurableWrapper(childWrapper); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement AntTypeDefinition def=new AntTypeDefinition(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement childWrapper.setProxy(childElement); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement def.setName(name); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression def.setClassName(className) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression replaceChildren(childWrapper,childElement) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression def.setClassName(className) is a void method call, and thus it cannot be parameterized
    14Expression replaceChildren(childWrapper,childElement) is a void method call, and thus it cannot be parameterized
    15Expression def.setClassName(className) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression replaceChildren(childWrapper,childElement) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression def.setClassName(className) is a void method call, and thus it cannot be parameterized
    18Expression replaceChildren(childWrapper,childElement) is a void method call, and thus it cannot be parameterized
    19Unmatched statement def.setClassLoader(classLoader); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement antTypeTable.put(name,def); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted