DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = null; try { i2 = (DialPointer) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); i1.addChangeListener(l1); assertTrue(i1.hasListener(l1)); assertFalse(i2.hasListener(l1));
DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { a2 = (DialTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); a1.addChangeListener(l1); assertTrue(a1.hasListener(l1)); assertFalse(a2.hasListener(l1));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialPointerTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 11 Number of AST nodes: 11
1
DialPointer i1 = new DialPointer.Pin(1);
1
Dial
2
        DialPointer i
2
TextAnnotation a1 = new DialTextAnnotation("A1");
3
2 = null;
3
        DialTextAnnotation a2 = null;
4
        try {
4
        try {
5
            i2 = (DialPointer) i1.clone();
5
            a2 = (DialTextAnnotation) a1.clone();
6
        }
6
        }
7
        catch (CloneNotSupportedException e) {
7
        catch (CloneNotSupportedException e) {
8
            e.printStackTrace();
8
            e.printStackTrace();
9
        }
9
        }
10
        assertTrue(i1 != i2);
10
        assertTrue(a1 != a2);
11
        assertTrue(i1.getClass() == i2.getClass());
11
        assertTrue(a1.getClass() == a2.getClass());
12
        assertTrue(i1.equals(i2));
12
        assertTrue(a1.equals(a2));
13
        
13
        
14
        // check that the listener lists are independent
14
        // check that the listener lists are independent
15
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
15
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
16
        i1.addChangeListener(l1);
16
        a1.addChangeListener(l1);
17
        assertTrue(i1.hasListener(l1));
17
        assertTrue(a1.hasListener(l1));
18
        assertFalse(i2.hasListener(l1));
18
        assertFalse(a2.hasListener(l1));
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 having the same super class
Number of node comparisons58
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)38.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DialPointer i1 = new DialPointer.Pin(1);
    1
    DialPointer i1 = new DialPointer.Pin(1);
    2
    DialTextAnnotation a2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    i1a2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    new DialPointer.Pin(1)nullTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    DialTextAnnotation a2 = null;
    2
    DialPointer i2 = null;
    2
    DialPointer i2 = null;
    1
    DialTextAnnotation a1 = new DialTextAnnotation("A1");
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    i2a1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    nullnew DialTextAnnotation("A1")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DialTextAnnotation a1 = new DialTextAnnotation("A1");
    3
    try
    3
    try
    4
    i2 = (DialPointer)i1.clone();
    4
    i2 = (DialPointer)i1.clone();
    4
    a2 = (DialTextAnnotation)a1.clone();
    Differences
    Expression1Expression2Difference
    i2a2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    i1a1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DialPointer)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression i1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    a2 = (DialTextAnnotation)a1.clone();
                                                    
    5
    assertTrue(a1 != a2);
    Preondition Violations
    Unmatched statement assertTrue(a1 != a2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    assertTrue(a1 != a2);
                                                                                                
    6
    assertTrue(a1.getClass() == a2.getClass());
    Preondition Violations
    Unmatched statement assertTrue(a1.getClass() == a2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    assertTrue(a1.getClass() == a2.getClass());
                                                              
    7
    assertTrue(a1.equals(a2));
    Preondition Violations
    Unmatched statement assertTrue(a1.equals(a2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    assertTrue(a1.equals(a2));
    5
    assertTrue(i1 != i2);
    5
    assertTrue(i1 != i2);
    11
    assertFalse(a2.hasListener(l1));
    Differences
    Expression1Expression2Difference
    i1 != i2a2.hasListener(l1)TYPE_COMPATIBLE_REPLACEMENT
    assertTrueassertFalseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression i1 != i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a2.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(i1 != i2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(a2.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(i1 != i2) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(a2.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    11
    assertFalse(a2.hasListener(l1));
    6
    assertTrue(i1.getClass() == i2.getClass());
    6
    assertTrue(i1.getClass() == i2.getClass());
    Preondition Violations
    Unmatched statement assertTrue(i1.getClass() == i2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
    7
    assertTrue(i1.equals(i2));
    7
    assertTrue(i1.equals(i2));
    Preondition Violations
    Unmatched statement assertTrue(i1.equals(i2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                              
    8
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
    8
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
    9
    i1.addChangeListener(l1);
    9
    i1.addChangeListener(l1);
    9
    a1.addChangeListener(l1);
    Differences
    Expression1Expression2Difference
    i1a1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    a1.addChangeListener(l1);
    10
    assertTrue(i1.hasListener(l1));
    10
    assertTrue(i1.hasListener(l1));
    Preondition Violations
    Unmatched statement assertTrue(i1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
    11
    assertFalse(i2.hasListener(l1));
    11
    assertFalse(i2.hasListener(l1));
    10
    assertTrue(a1.hasListener(l1));
    Differences
    Expression1Expression2Difference
    i2a1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.chart.plot.dial.DialTextAnnotationSUBCLASS_TYPE_MISMATCH
    assertFalseassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(i2.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(a1.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(i2.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(a1.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    10
    assertTrue(a1.hasListener(l1));
    Precondition Violations (29)
    Row Violation
    1Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (DialPointer)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression i1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement assertTrue(a1 != a2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement assertTrue(a1.getClass() == a2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement assertTrue(a1.equals(a2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Expression i1 != i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression a2.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression assertTrue(i1 != i2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression assertFalse(a2.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression assertTrue(i1 != i2) is a void method call, and thus it cannot be parameterized
    17Expression assertFalse(a2.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    18Unmatched statement assertTrue(i1.getClass() == i2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19Unmatched statement assertTrue(i1.equals(i2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Expression i1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Unmatched statement assertTrue(i1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Expression i2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression assertFalse(i2.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression assertTrue(a1.hasListener(l1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression assertFalse(i2.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    28Expression assertTrue(a1.hasListener(l1)) is a void method call, and thus it cannot be parameterized
    29Clone fragment #1 returns variables i1, i2, l1 , while Clone fragment #2 returns variables a1, a2