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