KeyedObjects2D o1 = new KeyedObjects2D(); o1.setObject(new Integer(1), "V1", "C1"); o1.setObject(null, "V2", "C1"); o1.setObject(new Integer(3), "V3", "C2"); KeyedObjects2D o2 = null; try { o2 = (KeyedObjects2D) o1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(o1 != o2); assertTrue(o1.getClass() == o2.getClass()); assertTrue(o1.equals(o2)); // check independence o1.addObject("XX", "R1", "C1"); assertFalse(o1.equals(o2));
MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { c2 = (MatrixSeriesCollection) 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/data/junit/KeyedObjects2DTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/MatrixSeriesCollectionTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 12 Number of AST nodes: 12
1
KeyedObjects2D o1 = new KeyedObjects2D();
1
MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
2
        o1.setObject(new Integer(1), "V1", "C1");
2
        s1.
3
        o1.setObject(null, "V2", "C1"
3
update(0, 0, 1.1);
4
);
4
        MatrixSeriesCollection c1 = new MatrixSeriesCollection();
5
        o1.setObject(new Integer(3), "V3", "C2");
5
        c1.
6
        KeyedObjects2D o
6
addSeries(s1);
7
2 = null;
7
        MatrixSeriesCollection c2 = null;
8
        try {
8
        try {
9
            o2 = (KeyedObjects2D) o1.clone();
9
            c2 = (MatrixSeriesCollection) c1.clone();
10
        }
10
        }
11
        catch (CloneNotSupportedException e) {
11
        catch (CloneNotSupportedException e) {
12
            e.printStackTrace();
12
            e.printStackTrace();
13
        }
13
        }
14
        assertTrue(o1 != o2);
14
        assertTrue(c1 != c2);
15
        assertTrue(o1.getClass() == o2.getClass());
15
        assertTrue(c1.getClass() == c2.getClass());
16
        assertTrue(o1.equals(o2));
16
        assertTrue(c1.equals(c2));
17
        
18
        // check independence
17
        // check independence
19
        o1.addObject("XX", "R1", "C1");
18
        s1.setDescription("XYZ");
20
        assertFalse(o1.equals(o2));
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)10.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                        
    1
    MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
    Preondition Violations
    Unmatched statement MatrixSeries s1=new MatrixSeries("Series",2,3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
    1
    KeyedObjects2D o1 = new KeyedObjects2D();
    1
    KeyedObjects2D o1 = new KeyedObjects2D();
    Preondition Violations
    Unmatched statement KeyedObjects2D o1=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
                                                
    2
    s1.update(0, 0, 1.1);
    2
    o1.setObject(new Integer(1), "V1", "C1");
    2
    o1.setObject(new Integer(1), "V1", "C1");
    Preondition Violations
    Unmatched statement o1.setObject(new Integer(1),"V1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
                                                                                                                        
    3
    MatrixSeriesCollection c1 = new MatrixSeriesCollection();
    Preondition Violations
    Unmatched statement MatrixSeriesCollection c1=new MatrixSeriesCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    MatrixSeriesCollection c1 = new MatrixSeriesCollection();
    3
    o1.setObject(null, "V2", "C1");
    3
    o1.setObject(null, "V2", "C1");
    Preondition Violations
    Unmatched statement o1.setObject(null,"V2","C1"); 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
    o1.setObject(new Integer(3), "V3", "C2");
    4
    o1.setObject(new Integer(3), "V3", "C2");
    Preondition Violations
    Unmatched statement o1.setObject(new Integer(3),"V3","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                        
                                                                        
    5
    MatrixSeriesCollection c2 = null;
    5
    KeyedObjects2D o2 = null;
                                                        
    6
    try
    6
    try
                                                                                      
    7
    c2 = (MatrixSeriesCollection)c1.clone();
    Preondition Violations
    Unmatched statement c2=(MatrixSeriesCollection)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 = (MatrixSeriesCollection)c1.clone();
    7
    o2 = (KeyedObjects2D)o1.clone();
    7
    o2 = (KeyedObjects2D)o1.clone();
    Preondition Violations
    Unmatched statement o2=(KeyedObjects2D)o1.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
                                                                      
    8
    assertTrue(o1 != o2);
    8
    assertTrue(o1 != o2);
    8
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    o1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    o2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    8
    assertTrue(c1 != c2);
    9
    assertTrue(o1.getClass() == o2.getClass());
    9
    assertTrue(o1.getClass() == o2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    o1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    o2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    9
    assertTrue(c1.getClass() == c2.getClass());
    10
    assertTrue(o1.equals(o2));
    10
    assertTrue(o1.equals(o2));
    10
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    o2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    o1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    10
    assertTrue(c1.equals(c2));
                                                              
    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
    o1.addObject("XX", "R1", "C1");
    11
    o1.addObject("XX", "R1", "C1");
    Preondition Violations
    Unmatched statement o1.addObject("XX","R1","C1"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
    12
    assertFalse(o1.equals(o2));
    12
    assertFalse(o1.equals(o2));
    12
    assertFalse(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    o2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    o1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjects2Dorg.jfree.data.xy.MatrixSeriesCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    • Make classes org.jfree.data.KeyedObjects2D and org.jfree.data.xy.MatrixSeriesCollection extend a common superclass
    12
    assertFalse(c1.equals(c2));
    Precondition Violations (19)
    Row Violation
    1Unmatched statement MatrixSeries s1=new MatrixSeries("Series",2,3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement KeyedObjects2D o1=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement o1.setObject(new Integer(1),"V1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement MatrixSeriesCollection c1=new MatrixSeriesCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement o1.setObject(null,"V2","C1"); 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 o1.setObject(new Integer(3),"V3","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement c2=(MatrixSeriesCollection)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
    9Unmatched statement o2=(KeyedObjects2D)o1.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
    10Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    11Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    12Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    13Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    14Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    15Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
    16Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    17Unmatched statement o1.addObject("XX","R1","C1"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Type org.jfree.data.KeyedObjects2D of variable o2 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c2
    19Type org.jfree.data.KeyedObjects2D of variable o1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1