StrokeMap m1 = new StrokeMap(); StrokeMap m2 = null; try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2));
SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); SimpleHistogramDataset d2 = null; try { d2 = (SimpleHistogramDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that clone is independent of the original d2.addBin(new SimpleHistogramBin(2.0, 3.0)); d2.addObservation(2.3); assertFalse(d1.equals(d2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/StrokeMapTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 10 Number of AST nodes: 10
1
StrokeMap m1 = new StrokeMap();
1
S
2
        StrokeMap m
2
impleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");
3
2 = null;
3
        SimpleHistogramDataset d2 = null;
4
        try {
4
        try {
5
            m2 = (StrokeMap) m1.clone();
5
            d2 = (SimpleHistogramDataset) d1.clone();
6
        }
6
        }
7
        catch (CloneNotSupportedException e) {
7
        catch (CloneNotSupportedException e) {
8
            e.printStackTrace();
8
            e.printStackTrace();
9
        }
9
        }
10
        assertTrue(m1.equals(m2));
10
        assertTrue(d1 != d2);
11
        
11
       
12
        m1.put("K1", new BasicStroke(1.1f));
13
        m1.put("K2", new BasicStroke(2.2f
12
 assertTrue(d1.getClass() == d2.getClass());
14
));
13
        assertTrue(d1.equals(d2));
15
        try {
14
        
16
            m2 = (StrokeMap) m1.clone();
15
        
17
        }
18
        catch (CloneNotSupportedException e) {
19
            e.printStackTrace(
16
// check that clone is independent of the original
17
        d2.addBin(new SimpleHistogramBin(2.0, 3.0));
20
);
18
        d2.addObservation(2.3);
21
        }
22
        assertTrue(m1.equals(m2));
19
        assertFalse(d1.equals(d2));
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons53
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)15.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                              
    1
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");
    Preondition Violations
    Unmatched statement SimpleHistogramDataset d1=new SimpleHistogramDataset("Dataset 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");
    1
    StrokeMap m1 = new StrokeMap();
    1
    StrokeMap m1 = new StrokeMap();
    Preondition Violations
    Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                    
                                                                        
    2
    SimpleHistogramDataset d2 = null;
    2
    StrokeMap m2 = null;
                                              
    3
    try
    3
    try
                                                                                      
    4
    d2 = (SimpleHistogramDataset)d1.clone();
    Preondition Violations
    Unmatched statement d2=(SimpleHistogramDataset)d1.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
    4
    d2 = (SimpleHistogramDataset)d1.clone();
    4
    m2 = (StrokeMap)m1.clone();
    4
    m2 = (StrokeMap)m1.clone();
    Preondition Violations
    Unmatched statement m2=(StrokeMap)m1.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
                                                            
                                                                                                
    6
    assertTrue(d1.getClass() == d2.getClass());
    5
    assertTrue(m1.equals(m2));
    5
    assertTrue(m1.equals(m2));
    7
    assertTrue(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    m2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.statistics.SimpleHistogramDatasetVARIABLE_TYPE_MISMATCH
    m1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.statistics.SimpleHistogramDatasetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d2
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.statistics.SimpleHistogramDataset extend a common superclass
    Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d1
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.statistics.SimpleHistogramDataset extend a common superclass
    7
    assertTrue(d1.equals(d2));
    6
    m1.put("K1", new BasicStroke(1.1f));
    6
    m1.put("K1", new BasicStroke(1.1f));
    Preondition Violations
    Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    7
    m1.put("K2", new BasicStroke(2.2f));
    7
    m1.put("K2", new BasicStroke(2.2f));
    Preondition Violations
    Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    10
    assertTrue(m1.equals(m2));
    10
    assertTrue(m1.equals(m2));
    5
    assertTrue(d1 != d2);
    Differences
    Expression1Expression2Difference
    m1.equals(m2)d1 != d2TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 != d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    assertTrue(d1 != d2);
                                                                                                
    8
    d2.addBin(new SimpleHistogramBin(2.0, 3.0));
    Preondition Violations
    Unmatched statement d2.addBin(new SimpleHistogramBin(2.0,3.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    d2.addBin(new SimpleHistogramBin(2.0, 3.0));
                                                        
    9
    d2.addObservation(2.3);
                                                                  
    10
    assertFalse(d1.equals(d2));
    Precondition Violations (11)
    Row Violation
    1Unmatched statement SimpleHistogramDataset d1=new SimpleHistogramDataset("Dataset 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement d2=(SimpleHistogramDataset)d1.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
    4Unmatched statement m2=(StrokeMap)m1.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
    5Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d2
    6Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d1
    7Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression d1 != d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Unmatched statement d2.addBin(new SimpleHistogramBin(2.0,3.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted