XYPlot p1 = new XYPlot(); Point2D p = new Point2D.Double(1.2, 3.4); p1.setQuadrantOrigin(p); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); assertTrue(p2.getQuadrantOrigin() != p);
StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemLabelGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.java
Method name: void testCloning_QuadrantOrigin() Method name: void testCloning_LegendItemLabelGenerator()
Number of AST nodes: 10 Number of AST nodes: 10
1
XYPlot p1 = new XYPlot();
2
        Point2D p = new Point2D.Double(1.2, 3.4
1
StandardCategorySeriesLabelGenerator generator 
2
                = new StandardCategorySeriesLabelGenerator("Series {0}");
3
);
3
        BarRenderer r1 = new BarRenderer();
4
        p1.setQuadrantOrigin(p);
4
        r1.set
5
        XYPlot p
5
LegendItemLabelGenerator(generator);
6
2 = null;
6
        BarRenderer r2 = null;
7
        try {
7
        try {
8
            p2 = (XYPlot) p1.clone();
8
            r2 = (BarRenderer) r1.clone();
9
        }
9
        }
10
        catch (CloneNotSupportedException e) {
10
        catch (CloneNotSupportedException e) {
11
            e.printStackTrace();
11
            e.printStackTrace();
12
        }
12
        }
13
        assertTrue(p1 != p2);
13
        assertTrue(r1 != r2);
14
        assertTrue(p1.getClass() == p2.getClass());
14
        assertTrue(r1.getClass() == r2.getClass());
15
        assertTrue(p1.equals(p2));
15
        assertTrue(r1.equals(r2));
16
        
17
        // check that the generator has been cloned
16
        assertTrue(p2.getQuadrantOrigin() != p
18
        assertTrue(r1.getLegendItemLabelGenerator() 
17
);
19
                != r2.getLegendItemLabelGenerator());
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 comparisons57
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)175.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                      
    1
    StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}");
    Preondition Violations
    Unmatched statement StandardCategorySeriesLabelGenerator generator=new StandardCategorySeriesLabelGenerator("Series {0}"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}");
    1
    XYPlot p1 = new XYPlot();
    1
    XYPlot p1 = new XYPlot();
    2
    BarRenderer r1 = new BarRenderer();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new XYPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new BarRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    BarRenderer r1 = new BarRenderer();
    2
    Point2D p = new Point2D.Double(1.2, 3.4);
    2
    Point2D p = new Point2D.Double(1.2, 3.4);
    Preondition Violations
    Unmatched statement Point2D p=new Point2D.Double(1.2,3.4); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                      
                                                                                              
    3
    r1.setLegendItemLabelGenerator(generator);
    Preondition Violations
    Unmatched statement r1.setLegendItemLabelGenerator(generator); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    r1.setLegendItemLabelGenerator(generator);
    3
    p1.setQuadrantOrigin(p);
    3
    p1.setQuadrantOrigin(p);
    Preondition Violations
    Unmatched statement p1.setQuadrantOrigin(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
    4
    XYPlot p2 = null;
    4
    XYPlot p2 = null;
    4
    BarRenderer r2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    4
    BarRenderer r2 = null;
    5
    try
    5
    try
    6
    p2 = (XYPlot)p1.clone();
    6
    p2 = (XYPlot)p1.clone();
    6
    r2 = (BarRenderer)r1.clone();
    Differences
    Expression1Expression2Difference
    p2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (BarRenderer)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    r2 = (BarRenderer)r1.clone();
    7
    assertTrue(p1 != p2);
    7
    assertTrue(p1 != p2);
    7
    assertTrue(r1 != r2);
    Differences
    Expression1Expression2Difference
    p1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(r1 != r2);
    8
    assertTrue(p1.getClass() == p2.getClass());
    8
    assertTrue(p1.getClass() == p2.getClass());
    8
    assertTrue(r1.getClass() == r2.getClass());
    Differences
    Expression1Expression2Difference
    p1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(r1.getClass() == r2.getClass());
    9
    assertTrue(p1.equals(p2));
    9
    assertTrue(p1.equals(p2));
    9
    assertTrue(r1.equals(r2));
    Differences
    Expression1Expression2Difference
    p2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    p1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.renderer.category.BarRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression p2 cannot be unified with expression r2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression p2 cannot be unified with expression r2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression p1 cannot be unified with expression r1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    9
    assertTrue(r1.equals(r2));
                                                                                                                                                                              
    10
    assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());
    Preondition Violations
    Unmatched statement assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator());
    10
    assertTrue(p2.getQuadrantOrigin() != p);
    10
    assertTrue(p2.getQuadrantOrigin() != p);
    Preondition Violations
    Unmatched statement assertTrue(p2.getQuadrantOrigin() != p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
    Precondition Violations (14)
    Row Violation
    1Unmatched statement StandardCategorySeriesLabelGenerator generator=new StandardCategorySeriesLabelGenerator("Series {0}"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression new XYPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new BarRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Unmatched statement Point2D p=new Point2D.Double(1.2,3.4); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement r1.setLegendItemLabelGenerator(generator); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement p1.setQuadrantOrigin(p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression (XYPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression (BarRenderer)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression p2 cannot be unified with expression r2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    10Expression p2 cannot be unified with expression r2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    11Expression p1 cannot be unified with expression r1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12Unmatched statement assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement assertTrue(p2.getQuadrantOrigin() != p); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Clone fragment #1 returns variables p1, p2 , while Clone fragment #2 returns variables r1, r2