MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); MultipleXYSeriesLabelGenerator g2 = null; try { g2 = (MultipleXYSeriesLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence g1.addSeriesLabel(3, "Add3"); assertFalse(g1.equals(g2)); g2.addSeriesLabel(3, "Add3"); assertTrue(g1.equals(g2));
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/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.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
MultipleXYSeriesLabelGenerator g1
2
                = new MultipleXYSeriesLabelGenerator();
3
        MultipleXYSeriesLabelGenerator g
1
XYSeries s1 = new XYSeries("Series");
2
        s1.add(1.0, 1.1);
3
        XYSeriesCollection c1 = new XYSeriesCollection();
4
        c1.addSeries(s1);
4
2 = null;
5
        XYSeriesCollection c2 = null;
5
        try {
6
        try {
6
            g2 = (MultipleXYSeriesLabelGenerator) g1.clone();
7
            c2 = (XYSeriesCollection) c1.clone();
7
        }
8
        }
8
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
9
            e.printStackTrace();
10
            e.printStackTrace();
10
        }
11
        }
11
        assertTrue(g1 != g2);
12
        assertTrue(c1 != c2);
12
        assertTrue(g1.getClass() == g2.getClass());
13
        assertTrue(c1.getClass() == c2.getClass());
13
        assertTrue(g1.equals(g2));
14
        assertTrue(c1.equals(c2));
14
        // check independence
15
        // check independence
15
        g1.addSeriesLabel(3, "Add3");
16
        s1.
16
        assertFalse(g1.equals(g2));
17
        g2.addSeriesLabel(3, "Add3");
17
setDescription("XYZ");
18
        assertTrue(g1.equals(g2));
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons76
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)58.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                
    1
    XYSeries s1 = new XYSeries("Series");
    Preondition Violations
    Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    XYSeries s1 = new XYSeries("Series");
                                          
    2
    s1.add(1.0, 1.1);
    Preondition Violations
    Unmatched statement s1.add(1.0,1.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    s1.add(1.0, 1.1);
    1
    MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator();
    1
    MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator();
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new MultipleXYSeriesLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    2
    MultipleXYSeriesLabelGenerator g2 = null;
    2
    MultipleXYSeriesLabelGenerator g2 = null;
    5
    XYSeriesCollection c2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    5
    XYSeriesCollection c2 = null;
    3
    try
    6
    try
    4
    g2 = (MultipleXYSeriesLabelGenerator)g1.clone();
    4
    g2 = (MultipleXYSeriesLabelGenerator)g1.clone();
    7
    c2 = (XYSeriesCollection)c1.clone();
    Differences
    Expression1Expression2Difference
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (MultipleXYSeriesLabelGenerator)g1.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
    7
    c2 = (XYSeriesCollection)c1.clone();
    5
    assertTrue(g1 != g2);
    5
    assertTrue(g1 != g2);
    8
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(c1 != c2);
    6
    assertTrue(g1.getClass() == g2.getClass());
    6
    assertTrue(g1.getClass() == g2.getClass());
    9
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    9
    assertTrue(c1.getClass() == c2.getClass());
    7
    assertTrue(g1.equals(g2));
    7
    assertTrue(g1.equals(g2));
    10
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression g2 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 g2 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 g1 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));
    8
    g1.addSeriesLabel(3, "Add3");
    8
    g1.addSeriesLabel(3, "Add3");
    4
    c1.addSeries(s1);
    Differences
    Expression1Expression2Difference
    addSeriesLabeladdSeriesMETHOD_INVOCATION_NAME_MISMATCH
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g1.addSeriesLabel(3,"Add3")c1.addSeries(s1)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized
    Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized
    Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addSeriesLabel(int, java.lang.String) , public void addSeries(org.jfree.data.xy.XYSeries)
    Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized
    Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized
    4
    c1.addSeries(s1);
    9
    assertFalse(g1.equals(g2));
    9
    assertFalse(g1.equals(g2));
    12
    assertFalse(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    g2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    g1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.labels.MultipleXYSeriesLabelGeneratororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression g2 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 g2 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 g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12
    assertFalse(c1.equals(c2));
    10
    g2.addSeriesLabel(3, "Add3");
    10
    g2.addSeriesLabel(3, "Add3");
    Preondition Violations
    Unmatched statement g2.addSeriesLabel(3,"Add3"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
                                                              
    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
    assertTrue(g1.equals(g2));
    11
    assertTrue(g1.equals(g2));
    Preondition Violations
    Unmatched statement assertTrue(g1.equals(g2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                
    Precondition Violations (25)
    Row Violation
    1Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s1.add(1.0,1.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression new MultipleXYSeriesLabelGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (MultipleXYSeriesLabelGenerator)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression g2 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)
    8Expression g2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    9Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized
    13Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized
    14Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addSeriesLabel(int, java.lang.String) , public void addSeries(org.jfree.data.xy.XYSeries)
    15Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized
    18Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized
    19Expression g2 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)
    20Expression g2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    21Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    22Unmatched statement g2.addSeriesLabel(3,"Add3"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    24Unmatched statement assertTrue(g1.equals(g2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    25Clone fragment #1 returns variables g2, g1 , while Clone fragment #2 returns variables