TestElement element = (TestElement) testBeanClass.newInstance(); // configure(element); // super.clear(); // set name, enabled. modifyTestElement(element); // put the default values back into the // new element return element;
BSFTestElement o = (BSFTestElement) super.clone(); o.init(); return o;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/testbeans/gui/TestBeanGUI.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/util/BSFTestElement.java
Method name: TestElement createTestElement() Method name: Object clone()
Number of AST nodes: 3 Number of AST nodes: 3
1
TestElement element = (TestElement) testBeanClass.newInstance();
1
BSFTestElement o = (BSFTestElement) 
2
			// configure(element);
3
			// super.clear(); // set name, enabled.
4
			modifyTestElement(element); // put the default values back into the
5
			// new element
6
			return element
2
super.clone();
3
        o.init();
7
;
4
       return o;
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.0
Clones locationClones are in different classes
Number of node comparisons7
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    TestElement element = (TestElement)testBeanClass.newInstance();
    2
    TestElement element = (TestElement)testBeanClass.newInstance();
    1
    BSFTestElement o = (BSFTestElement)super.clone();
    Differences
    Expression1Expression2Difference
    org.apache.jmeter.testelement.TestElementorg.apache.jmeter.util.BSFTestElementSUBCLASS_TYPE_MISMATCH
    elementoVARIABLE_NAME_MISMATCH
    org.apache.jmeter.testelement.TestElementorg.apache.jmeter.util.BSFTestElementSUBCLASS_TYPE_MISMATCH
    org.apache.jmeter.testelement.TestElementorg.apache.jmeter.util.BSFTestElementSUBCLASS_TYPE_MISMATCH
    testBeanClass.newInstance()super.clone()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (TestElement)testBeanClass.newInstance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression testBeanClass.newInstance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Super method call BSFTestElement o=(BSFTestElement)super.clone(); cannot be extracted from method
    1
    BSFTestElement o = (BSFTestElement)super.clone();
                            
    2
    o.init();
    Preondition Violations
    Unmatched statement o.init(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    o.init();
    3
    modifyTestElement(element);
    3
    modifyTestElement(element);
    Preondition Violations
    Unmatched statement modifyTestElement(element); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                
    4
    return element;
    4
    return element;
    3
    return o;
    Differences
    Expression1Expression2Difference
    elementoVARIABLE_NAME_MISMATCH
    org.apache.jmeter.testelement.TestElementorg.apache.jmeter.util.BSFTestElementSUBCLASS_TYPE_MISMATCH
    3
    return o;
    Precondition Violations (5)
    Row Violation
    1Expression (TestElement)testBeanClass.newInstance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression testBeanClass.newInstance() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Super method call BSFTestElement o=(BSFTestElement)super.clone(); cannot be extracted from method
    4Unmatched statement o.init(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement modifyTestElement(element); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted