LegendItemCollection c1 = new LegendItemCollection(); LegendItem item1 = new LegendItem("Item 1"); c1.add(item1); LegendItemCollection c2 = null; try { c2 = (LegendItemCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); Rectangle2D item1Shape = (Rectangle2D) item1.getShape(); item1Shape.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(c1.equals(c2));
OHLCSeriesCollection c1 = new OHLCSeriesCollection(); OHLCSeries s1 = new OHLCSeries("Series"); s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); OHLCSeriesCollection c2 = null; try { c2 = (OHLCSeriesCollection) 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/junit/LegendItemCollectionTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 12 Number of AST nodes: 12
1
LegendItemCollection c1 = new LegendItemCollection();
1
OHLCSeriesCollection c1 = new OHLCSeriesCollection();
2
        LegendItem item1 = new LegendItem("Item 1"
2
        OHLCSeries s1 = new OHLCSeries("Series");
3
);
3
        s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
4
        c1.add(item1);
4
        c1.addSeries(s1);
5
        LegendItemCollection c2 = null;
5
        OHLCSeriesCollection c2 = null;
6
        try {
6
        try {
7
            c2 = (LegendItemCollection) c1.clone();
7
            c2 = (OHLCSeriesCollection) c1.clone();
8
        }
8
        }
9
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
10
            e.printStackTrace();
10
            e.printStackTrace();
11
        }
11
        }
12
        assertTrue(c1 != c2);
12
        assertTrue(c1 != c2);
13
        assertTrue(c1.getClass() == c2.getClass());
13
        assertTrue(c1.getClass() == c2.getClass());
14
        assertTrue(c1.equals(c2));
14
        assertTrue(c1.equals(c2));
15
        
15
        Rectangle2D item1Shape = (Rectangle2D) item1.getShape();
16
        
16
        item1Shape.setRect(1.0, 2.0, 3.0, 4.0
17
// check independence
17
);
18
        s1.setDescription("XYZ");
18
        assertFalse(c1.equals(c2));
19
        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 comparisons104
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)9.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                
    1
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    Preondition Violations
    Unmatched statement OHLCSeriesCollection c1=new OHLCSeriesCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    1
    LegendItemCollection c1 = new LegendItemCollection();
    1
    LegendItemCollection c1 = new LegendItemCollection();
    Preondition Violations
    Unmatched statement LegendItemCollection c1=new LegendItemCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                
                                                                                        
    2
    OHLCSeries s1 = new OHLCSeries("Series");
    2
    LegendItem item1 = new LegendItem("Item 1");
    2
    LegendItem item1 = new LegendItem("Item 1");
    Preondition Violations
    Unmatched statement LegendItem item1=new LegendItem("Item 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                              
                                                                                        
    3
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    Preondition Violations
    Unmatched statement s1.add(new Year(2006),1.0,1.1,1.2,1.3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    3
    c1.add(item1);
    3
    c1.add(item1);
    Preondition Violations
    Unmatched statement c1.add(item1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                      
                                            
    4
    c1.addSeries(s1);
    Preondition Violations
    Unmatched statement c1.addSeries(s1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    c1.addSeries(s1);
    4
    LegendItemCollection c2 = null;
                                                                    
                                                                    
    5
    OHLCSeriesCollection c2 = null;
    5
    try
    6
    try
    6
    c2 = (LegendItemCollection)c1.clone();
    6
    c2 = (LegendItemCollection)c1.clone();
    Preondition Violations
    Unmatched statement c2=(LegendItemCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                  
                                                                                  
    7
    c2 = (OHLCSeriesCollection)c1.clone();
    Preondition Violations
    Unmatched statement c2=(OHLCSeriesCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7
    c2 = (OHLCSeriesCollection)c1.clone();
    7
    assertTrue(c1 != c2);
    7
    assertTrue(c1 != c2);
    8
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    8
    assertTrue(c1 != c2);
    8
    assertTrue(c1.getClass() == c2.getClass());
    8
    assertTrue(c1.getClass() == c2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    9
    assertTrue(c1.getClass() == c2.getClass());
    9
    assertTrue(c1.equals(c2));
    9
    assertTrue(c1.equals(c2));
    10
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    10
    assertTrue(c1.equals(c2));
    10
    Rectangle2D item1Shape = (Rectangle2D)item1.getShape();
                                                                                                                      
                                                              
    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
    item1Shape.setRect(1.0, 2.0, 3.0, 4.0);
    11
    item1Shape.setRect(1.0, 2.0, 3.0, 4.0);
    Preondition Violations
    Unmatched statement item1Shape.setRect(1.0,2.0,3.0,4.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                    
    12
    assertFalse(c1.equals(c2));
    12
    assertFalse(c1.equals(c2));
    12
    assertFalse(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    org.jfree.chart.LegendItemCollectionorg.jfree.data.time.ohlc.OHLCSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    • Make classes org.jfree.chart.LegendItemCollection and org.jfree.data.time.ohlc.OHLCSeriesCollection extend a common superclass
    12
    assertFalse(c1.equals(c2));
    Precondition Violations (18)
    Row Violation
    1Unmatched statement OHLCSeriesCollection c1=new OHLCSeriesCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement LegendItemCollection c1=new LegendItemCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement LegendItem item1=new LegendItem("Item 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement s1.add(new Year(2006),1.0,1.1,1.2,1.3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement c1.add(item1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement c1.addSeries(s1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement c2=(LegendItemCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    8Unmatched statement c2=(OHLCSeriesCollection)c1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    9Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    10Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    11Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    12Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    13Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    14Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1
    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 item1Shape.setRect(1.0,2.0,3.0,4.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    17Type org.jfree.chart.LegendItemCollection of variable c2 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c2
    18Type org.jfree.chart.LegendItemCollection of variable c1 does not match with type org.jfree.data.time.ohlc.OHLCSeriesCollection of variable c1