XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); IntervalXYDelegate d2 = null; try { d2 = (IntervalXYDelegate) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));
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/data/xy/junit/IntervalXYDelegateTests.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
XYSeries s1 = new XYSeries("Series");
1
XYSeries s1 = new XYSeries("Series");
2
        s1.add(1.2, 3.4);
2
        s1.add(1.0, 1.1);
3
        XYSeriesCollection c1 = new XYSeriesCollection();
3
        XYSeriesCollection c1 = new XYSeriesCollection();
4
        c1.addSeries(s1);
4
        c1.addSeries(s1);
5
        IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
5
        
6
        
7
        IntervalXYDelegate d2 = null;
6
XYSeriesCollection c2 = null;
8
        try {
7
        try {
9
            d2 = (IntervalXYDelegate) d1.clone();
8
            c2 = (XYSeriesCollection) c1.clone();
10
        }
9
        }
11
        catch (CloneNotSupportedException e) {
10
        catch (CloneNotSupportedException e) {
12
            System.err.println("Failed to clone.");
11
            e.printStackTrace();
13
        }
12
        }
14
        assertTrue(d1 != d2);
13
        assertTrue(c1 != c2);
15
        assertTrue(d1.getClass() == d2.getClass());
14
        assertTrue(c1.getClass() == c2.getClass());
16
        assertTrue(d1.equals(d
15
        assertTrue(c1.equals(c2));
16
        // check independence
17
        s1.setDescription("XYZ");
17
2));
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons50
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)35.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    XYSeries s1 = new XYSeries("Series");
    1
    XYSeries s1 = new XYSeries("Series");
    2
    s1.add(1.2, 3.4);
    2
    s1.add(1.2, 3.4);
    2
    s1.add(1.0, 1.1);
    Differences
    Expression1Expression2Difference
    1.21.0LITERAL_VALUE_MISMATCH
    3.41.1LITERAL_VALUE_MISMATCH
    2
    s1.add(1.0, 1.1);
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    4
    c1.addSeries(s1);
    4
    c1.addSeries(s1);
    5
    IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
    5
    IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
    5
    XYSeriesCollection c2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    d1c2VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    new IntervalXYDelegate(c1)nullTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new IntervalXYDelegate(c1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    XYSeriesCollection c2 = null;
    6
    IntervalXYDelegate d2 = null;
                                                                
    7
    try
    7
    try
    6
    try
    Differences
    Expression1Expression2Difference
    printlnprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    System.erreAST_TYPE_MISMATCH
    System.err.println("Failed to clone.")e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    6
    try
    8
    d2 = (IntervalXYDelegate)d1.clone();
    8
    d2 = (IntervalXYDelegate)d1.clone();
    7
    c2 = (XYSeriesCollection)c1.clone();
    Differences
    Expression1Expression2Difference
    d2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    d1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IntervalXYDelegate)d1.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
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    c2 = (XYSeriesCollection)c1.clone();
    9
    assertTrue(d1 != d2);
    9
    assertTrue(d1 != d2);
    8
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    d1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    d2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    assertTrue(c1 != c2);
    10
    assertTrue(d1.getClass() == d2.getClass());
    10
    assertTrue(d1.getClass() == d2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    d1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    d2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    assertTrue(c1.getClass() == c2.getClass());
    11
    assertTrue(d1.equals(d2));
    11
    assertTrue(d1.equals(d2));
    10
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    d2c2VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    d1c1VARIABLE_NAME_MISMATCH
    org.jfree.data.xy.IntervalXYDelegateorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 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 d2 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 d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 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));
                                                              
    11
    s1.setDescription("XYZ");
    Preondition Violations
    Unmatched statement s1.setDescription("XYZ"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    s1.setDescription("XYZ");
                                                                  
    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 (32)
    Row Violation
    1Expression new IntervalXYDelegate(c1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    4Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    5Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    8Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    9Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression (IntervalXYDelegate)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression c2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression d2 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)
    26Expression d2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    27Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression d1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    30Unmatched statement s1.setDescription("XYZ"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31Unmatched 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
    32Clone fragment #1 returns variables , while Clone fragment #2 returns variables s1, c1, c2