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));
XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = null; try { c2 = (XYSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2));
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/data/xy/junit/XYSeriesCollectionTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 11 Number of AST nodes: 12
1
DialPointer i1 = new DialPointer.Pin(1);
2
        DialPointer i
1
XYSeries s1 = new XYSeries("Series");
2
        s1.add(1.0, 1.1);
3
        XYSeriesCollection c1 = new XYSeriesCollection();
4
        c1.addSeries(s1);
3
2 = null;
5
        XYSeriesCollection c2 = null;
4
        try {
6
        try {
5
            i2 = (DialPointer) i1.clone();
7
            c2 = (XYSeriesCollection) c1.clone();
6
        }
8
        }
7
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
8
            e.printStackTrace();
10
            e.printStackTrace();
9
        }
11
        }
10
        assertTrue(i1 != i2);
12
        assertTrue(c1 != c2);
11
        assertTrue(i1.getClass() == i2.getClass());
13
        assertTrue(c1.getClass() == c2.getClass());
12
        assertTrue(i1.equals(i2));
14
        assertTrue(c1.equals(c2));
13
        
14
        // check that the listener lists are independent
15
        // check independence
15
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
16
        
16
        i1.addChangeListener(l1);
17
        assertTrue(i1.hasListener(l1));
18
        assertFalse(i2.hasListener(l1
17
s1.setDescription("XYZ");
19
));
18
        assertFalse(c1.equals(c2));
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 comparisons82
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)53.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                
    1
    XYSeries s1 = new XYSeries("Series");
    Preondition Violations
    Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    XYSeries s1 = new XYSeries("Series");
                                          
    2
    s1.add(1.0, 1.1);
    Preondition Violations
    Unmatched statement s1.add(1.0,1.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    s1.add(1.0, 1.1);
    1
    DialPointer i1 = new DialPointer.Pin(1);
    1
    DialPointer i1 = new DialPointer.Pin(1);
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialPointer.Pinorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    DialPointer.PinXYSeriesCollectionTYPE_COMPATIBLE_REPLACEMENT
    new DialPointer.Pin(1)new XYSeriesCollection()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
                                            
    4
    c1.addSeries(s1);
    Preondition Violations
    Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    c1.addSeries(s1);
    2
    DialPointer i2 = null;
    2
    DialPointer i2 = null;
    5
    XYSeriesCollection c2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    5
    XYSeriesCollection c2 = null;
    3
    try
    6
    try
    4
    i2 = (DialPointer)i1.clone();
    4
    i2 = (DialPointer)i1.clone();
    7
    c2 = (XYSeriesCollection)c1.clone();
    Differences
    Expression1Expression2Difference
    i2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DialPointer)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    c2 = (XYSeriesCollection)c1.clone();
    5
    assertTrue(i1 != i2);
    5
    assertTrue(i1 != i2);
    8
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(c1 != c2);
    6
    assertTrue(i1.getClass() == i2.getClass());
    6
    assertTrue(i1.getClass() == i2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    9
    assertTrue(c1.getClass() == c2.getClass());
    7
    assertTrue(i1.equals(i2));
    7
    assertTrue(i1.equals(i2));
    10
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    i2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialPointerorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i2 cannot be unified with expression c2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression i2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression i1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertTrue(c1.equals(c2));
    8
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
                                                                                                                                    
    9
    i1.addChangeListener(l1);
    9
    i1.addChangeListener(l1);
    Preondition Violations
    Unmatched statement i1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    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
    s1.setDescription("XYZ");
    Preondition Violations
    Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11
    s1.setDescription("XYZ");
    11
    assertFalse(i2.hasListener(l1));
    11
    assertFalse(i2.hasListener(l1));
    Preondition Violations
    Unmatched statement assertFalse(i2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
                                                                  
    12
    assertFalse(c1.equals(c2));
    Preondition Violations
    Unmatched statement assertFalse(c1.equals(c2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    assertFalse(c1.equals(c2));
    Precondition Violations (18)
    Row Violation
    1Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s1.add(1.0,1.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new DialPointer.Pin(1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression (DialPointer)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression i2 cannot be unified with expression c2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    11Expression i2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12Expression i1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    13Unmatched statement i1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched 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
    15Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16Unmatched statement assertFalse(i2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement assertFalse(c1.equals(c2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Clone fragment #1 returns variables i1, i2 , while Clone fragment #2 returns variables c1, c2