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));
DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = null; try { d2 = (DefaultTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); s1.add(3.0, 3.3); assertFalse(d1.equals(d2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 12 Number of AST nodes: 13
1
OHLCSeriesCollection c1 = new OHLCSeriesCollection();
1
DefaultTableXYDataset d1 = new DefaultTableXYDataset();
2
        OHLCSeries s1 = new OHLCSeries("Series");
2
        XYSeries s1 = new XYSeries("Series 1", true, false);
3
        s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3
3
        s1.add(1.0, 1.1);
4
);
4
        s1.add(2.0, 2.2);
5
        c1.addSeries(s1);
5
        d1.addSeries(s1);
6
        OHLCSeriesCollection c2 = null;
6
        DefaultTableXYDataset d2 = null;
7
        try {
7
        try {
8
            c2 = (OHLCSeriesCollection) c1.clone();
8
            d2 = (DefaultTableXYDataset) d1.clone();
9
        }
9
        }
10
        catch (CloneNotSupportedException e) {
10
        catch (CloneNotSupportedException e) {
11
            e.printStackTrace();
11
            e.printStackTrace();
12
        }
12
        }
13
        assertTrue(c1 != c2);
13
        assertTrue(d1 != d2);
14
        assertTrue(c1.getClass() == c2.getClass());
14
        assertTrue(d1.getClass() == d2.getClass());
15
        assertTrue(c1.equals(c2));
15
        assertTrue(d1.equals(d2));
16
        
17
        // check independence
16
        
18
        s1.setDescription("XYZ");
17
s1.add(3.0, 3.3);
19
        assertFalse(c1.equals(c2));
18
        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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons50
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)66.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    1
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    1
    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new OHLCSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultTableXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    2
    OHLCSeries s1 = new OHLCSeries("Series");
    2
    OHLCSeries s1 = new OHLCSeries("Series");
    2
    XYSeries s1 = new XYSeries("Series 1", true, false);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    new OHLCSeries("Series")new XYSeries("Series 1",true,false)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYSeries("Series 1",true,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeries("Series 1",true,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    XYSeries s1 = new XYSeries("Series 1", true, false);
    3
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    3
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    3
    s1.add(1.0, 1.1);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    s1.add(new Year(2006),1.0,1.1,1.2,1.3)s1.add(1.0,1.1)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s1 cannot be unified with expression s1 , because common superclass org.jfree.data.general.Series does not declare member(s) public void add(org.jfree.data.time.RegularTimePeriod, double, double, double, double) , public void add(double, double)
    Expression s1.add(new Year(2006),1.0,1.1,1.2,1.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.add(1.0,1.1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.add(new Year(2006),1.0,1.1,1.2,1.3) is a void method call, and thus it cannot be parameterized
    Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
    3
    s1.add(1.0, 1.1);
                                          
    4
    s1.add(2.0, 2.2);
    Preondition Violations
    Unmatched statement s1.add(2.0,2.2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    s1.add(2.0, 2.2);
    4
    c1.addSeries(s1);
    4
    c1.addSeries(s1);
    5
    d1.addSeries(s1);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression s1 cannot be unified with expression s1 , because common superclass type org.jfree.data.general.Series cannot be passed as an argument to public void addSeries(org.jfree.data.time.ohlc.OHLCSeries)
    Expression c1 cannot be unified with expression d1 , because common superclass org.jfree.data.xy.AbstractXYDataset does not declare member(s) public void addSeries(org.jfree.data.time.ohlc.OHLCSeries) , public void addSeries(org.jfree.data.xy.XYSeries)
    5
    d1.addSeries(s1);
    5
    OHLCSeriesCollection c2 = null;
    5
    OHLCSeriesCollection c2 = null;
    6
    DefaultTableXYDataset d2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    6
    DefaultTableXYDataset d2 = null;
    6
    try
    7
    try
    7
    c2 = (OHLCSeriesCollection)c1.clone();
    7
    c2 = (OHLCSeriesCollection)c1.clone();
    8
    d2 = (DefaultTableXYDataset)d1.clone();
    Differences
    Expression1Expression2Difference
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (OHLCSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DefaultTableXYDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    d2 = (DefaultTableXYDataset)d1.clone();
    8
    assertTrue(c1 != c2);
    8
    assertTrue(c1 != c2);
    9
    assertTrue(d1 != d2);
    Differences
    Expression1Expression2Difference
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    9
    assertTrue(d1 != d2);
    9
    assertTrue(c1.getClass() == c2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    10
    assertTrue(d1.getClass() == d2.getClass());
    Differences
    Expression1Expression2Difference
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    10
    assertTrue(d1.getClass() == d2.getClass());
    10
    assertTrue(c1.equals(c2));
    10
    assertTrue(c1.equals(c2));
    11
    assertTrue(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    11
    assertTrue(d1.equals(d2));
    11
    s1.setDescription("XYZ");
    11
    s1.setDescription("XYZ");
    12
    s1.add(3.0, 3.3);
    Differences
    Expression1Expression2Difference
    setDescriptionaddMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    s1.setDescription("XYZ")s1.add(3.0,3.3)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression s1.setDescription("XYZ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.add(3.0,3.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.setDescription("XYZ") is a void method call, and thus it cannot be parameterized
    Expression s1.add(3.0,3.3) is a void method call, and thus it cannot be parameterized
    Expression s1.setDescription("XYZ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.add(3.0,3.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.setDescription("XYZ") is a void method call, and thus it cannot be parameterized
    Expression s1.add(3.0,3.3) is a void method call, and thus it cannot be parameterized
    12
    s1.add(3.0, 3.3);
    12
    assertFalse(c1.equals(c2));
    12
    assertFalse(c1.equals(c2));
    13
    assertFalse(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.data.time.ohlc.OHLCSeriesCollectionorg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    13
    assertFalse(d1.equals(d2));
    Precondition Violations (22)
    Row Violation
    1Expression new OHLCSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultTableXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new XYSeries("Series 1",true,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new XYSeries("Series 1",true,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression s1 cannot be unified with expression s1 , because common superclass org.jfree.data.general.Series does not declare member(s) public void add(org.jfree.data.time.RegularTimePeriod, double, double, double, double) , public void add(double, double)
    6Expression s1.add(new Year(2006),1.0,1.1,1.2,1.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression s1.add(1.0,1.1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s1.add(new Year(2006),1.0,1.1,1.2,1.3) is a void method call, and thus it cannot be parameterized
    9Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
    10Unmatched statement s1.add(2.0,2.2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Expression s1 cannot be unified with expression s1 , because common superclass type org.jfree.data.general.Series cannot be passed as an argument to public void addSeries(org.jfree.data.time.ohlc.OHLCSeries)
    12Expression c1 cannot be unified with expression d1 , because common superclass org.jfree.data.xy.AbstractXYDataset does not declare member(s) public void addSeries(org.jfree.data.time.ohlc.OHLCSeries) , public void addSeries(org.jfree.data.xy.XYSeries)
    13Expression (OHLCSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression (DefaultTableXYDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression s1.setDescription("XYZ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression s1.add(3.0,3.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression s1.setDescription("XYZ") is a void method call, and thus it cannot be parameterized
    18Expression s1.add(3.0,3.3) is a void method call, and thus it cannot be parameterized
    19Expression s1.setDescription("XYZ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression s1.add(3.0,3.3) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression s1.setDescription("XYZ") is a void method call, and thus it cannot be parameterized
    22Expression s1.add(3.0,3.3) is a void method call, and thus it cannot be parameterized