PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { c2 = (StandardEntityCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence c1.clear(); assertFalse(c1.equals(c2)); c2.clear(); assertTrue(c1.equals(c2));
XYPlot p1 = new XYPlot(); p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); 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)); // check for independence p1.setQuadrantPaint(1, Color.red); assertFalse(p1.equals(p2)); p2.setQuadrantPaint(1, Color.red); assertTrue(p1.equals(p2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
Method name: void testCloning() Method name: void testCloning_QuadrantPaint()
Number of AST nodes: 13 Number of AST nodes: 12
1
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
2
                2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
3
                "ToolTip", "URL");
4
        StandardEntityCollection c1 = new StandardEntityCollection();
5
        c1.add(e1);
6
        StandardEntityCollection c
1
XYPlot p1 = new XYPlot();
2
        p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 
3
                3.0f, 4.0f, Color.blue));
7
2 = null;
4
        XYPlot p2 = null;
8
        try {
5
        try {
9
            c2 = (StandardEntityCollection) c1.clone();
6
            p2 = (XYPlot) p1.clone();
10
        }
7
        }
11
        catch (CloneNotSupportedException e) {
8
        catch (CloneNotSupportedException e) {
12
            e.printStackTrace();
9
            e.printStackTrace();
13
        }
10
        }
14
        assertTrue(c1 != c2);
11
        assertTrue(p1 != p2);
15
        assertTrue(c1.getClass() == c2.getClass());
12
        assertTrue(p1.getClass() == p2.getClass());
16
        assertTrue(c1.equals(c2));
13
        assertTrue(p1.equals(p2));
17
        
14
        
18
        // check independence
15
        // check for independence
19
        c1.clear();
16
        p1.setQuadrantPaint(1, Color.red);
20
        assertFalse(c1.equals(c2));
17
        assertFalse(p1.equals(p2));
21
        c2.clear();
18
        p2.setQuadrantPaint(1, Color.red);
22
        assertTrue(c1.equals(c2));
19
        assertTrue(p1.equals(p2));
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 comparisons58
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)81.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    Preondition Violations
    Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                                                                  
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    1
    XYPlot p1 = new XYPlot();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new StandardEntityCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    XYPlot p1 = new XYPlot();
    3
    c1.add(e1);
    3
    c1.add(e1);
    2
    p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    Differences
    Expression1Expression2Difference
    addsetQuadrantPaintMETHOD_INVOCATION_NAME_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1.add(e1)p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression c1.add(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.add(e1) is a void method call, and thus it cannot be parameterized
    Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
    Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.entity.ChartEntity) , public void setQuadrantPaint(int, java.awt.Paint)
    Expression c1.add(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.add(e1) is a void method call, and thus it cannot be parameterized
    Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
    2
    p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    4
    StandardEntityCollection c2 = null;
    4
    StandardEntityCollection c2 = null;
    3
    XYPlot p2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    3
    XYPlot p2 = null;
    5
    try
    4
    try
    6
    c2 = (StandardEntityCollection)c1.clone();
    6
    c2 = (StandardEntityCollection)c1.clone();
    5
    p2 = (XYPlot)p1.clone();
    Differences
    Expression1Expression2Difference
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (StandardEntityCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    p2 = (XYPlot)p1.clone();
    7
    assertTrue(c1 != c2);
    7
    assertTrue(c1 != c2);
    6
    assertTrue(p1 != p2);
    Differences
    Expression1Expression2Difference
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(p1 != p2);
    8
    assertTrue(c1.getClass() == c2.getClass());
    8
    assertTrue(c1.getClass() == c2.getClass());
    7
    assertTrue(p1.getClass() == p2.getClass());
    Differences
    Expression1Expression2Difference
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(p1.getClass() == p2.getClass());
    9
    assertTrue(c1.equals(c2));
    9
    assertTrue(c1.equals(c2));
    8
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    8
    assertTrue(p1.equals(p2));
    10
    c1.clear();
    10
    c1.clear();
    9
    p1.setQuadrantPaint(1, Color.red);
    Differences
    Expression1Expression2Difference
    clearsetQuadrantPaintMETHOD_INVOCATION_NAME_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1.clear()p1.setQuadrantPaint(1,Color.red)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression c1.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.clear() is a void method call, and thus it cannot be parameterized
    Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void clear() , public void setQuadrantPaint(int, java.awt.Paint)
    Expression c1.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c1.clear() is a void method call, and thus it cannot be parameterized
    Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    9
    p1.setQuadrantPaint(1, Color.red);
    11
    assertFalse(c1.equals(c2));
    11
    assertFalse(c1.equals(c2));
    10
    assertFalse(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertFalse(p1.equals(p2));
    12
    c2.clear();
    12
    c2.clear();
    11
    p2.setQuadrantPaint(1, Color.red);
    Differences
    Expression1Expression2Difference
    clearsetQuadrantPaintMETHOD_INVOCATION_NAME_MISMATCH
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c2.clear()p2.setQuadrantPaint(1,Color.red)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression c2.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p2.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2.clear() is a void method call, and thus it cannot be parameterized
    Expression p2.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void clear() , public void setQuadrantPaint(int, java.awt.Paint)
    Expression c2.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p2.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression c2.clear() is a void method call, and thus it cannot be parameterized
    Expression p2.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    11
    p2.setQuadrantPaint(1, Color.red);
    13
    assertTrue(c1.equals(c2));
    13
    assertTrue(c1.equals(c2));
    12
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    c2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    c1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.XYPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12
    assertTrue(p1.equals(p2));
    Precondition Violations (41)
    Row Violation
    1Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression new StandardEntityCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new XYPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression c1.add(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression c1.add(e1) is a void method call, and thus it cannot be parameterized
    7Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
    8Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.entity.ChartEntity) , public void setQuadrantPaint(int, java.awt.Paint)
    9Expression c1.add(e1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression c1.add(e1) is a void method call, and thus it cannot be parameterized
    12Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
    13Expression (StandardEntityCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression (XYPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    16Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    17Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    18Expression c1.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression c1.clear() is a void method call, and thus it cannot be parameterized
    21Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    22Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void clear() , public void setQuadrantPaint(int, java.awt.Paint)
    23Expression c1.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression c1.clear() is a void method call, and thus it cannot be parameterized
    26Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    27Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    28Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    29Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    30Expression c2.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression p2.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression c2.clear() is a void method call, and thus it cannot be parameterized
    33Expression p2.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    34Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void clear() , public void setQuadrantPaint(int, java.awt.Paint)
    35Expression c2.clear() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    36Expression p2.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    37Expression c2.clear() is a void method call, and thus it cannot be parameterized
    38Expression p2.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
    39Expression c2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    40Expression c2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    41Expression c1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)