XYAreaRenderer2 r1 = new XYAreaRenderer2(); Rectangle rect = new Rectangle(1, 2, 3, 4); r1.setLegendArea(rect); XYAreaRenderer2 r2 = null; try { r2 = (XYAreaRenderer2) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence rect.setBounds(99, 99, 99, 99); assertFalse(r1.equals(r2));
Rectangle r = new Rectangle(1, 2, 3, 4); LegendGraphic g1 = new LegendGraphic(r, Color.black); LegendGraphic g2 = null; try { g2 = (LegendGraphic) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence r.setBounds(4, 3, 2, 1); assertFalse(g1.equals(g2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendGraphicTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 11 Number of AST nodes: 10
1
XYAreaRenderer2 r1 = new XYAreaRenderer2();
2
        Rectangle rect = new Rectangle(1, 2, 3, 4);
1
Rectangle r = new Rectangle(1, 2, 3, 4);
3
        r1.setLegendArea(rect);
2
        LegendGraphic g1 = new LegendGraphic(r, Color.black);
4
        XYAreaRenderer2 r2 = null;
3
        LegendGraphic g2 = null;
5
        try {
4
        try {
6
            r2 = (XYAreaRenderer2) r1.clone();
5
            g2 = (LegendGraphic) g1.clone();
7
        }
6
        }
8
        catch (CloneNotSupportedException e) {
7
        catch (CloneNotSupportedException e) {
9
            e.printStackTrace();
8
            e.printStackTrace();
10
        }
9
        }
11
        assertTrue(r1 != r2);
10
        assertTrue(g1 != g2);
12
        assertTrue(r1.getClass() == r2.getClass());
11
        assertTrue(g1.getClass() == g2.getClass());
13
        assertTrue(r1.equals(r2));
12
        assertTrue(g1.equals(g2));
13
        
14
        // check independence
14
        // check independence
15
        rect.setBounds(99, 99, 99, 99);
15
        r.setBounds(4, 3, 2, 1);
16
        assertFalse(r1.equals(r2));
16
        assertFalse(g1.equals(g2));
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 comparisons44
  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 fragment0
    Time elapsed for statement mapping (ms)40.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    XYAreaRenderer2 r1 = new XYAreaRenderer2();
    1
    XYAreaRenderer2 r1 = new XYAreaRenderer2();
    2
    LegendGraphic g1 = new LegendGraphic(r, Color.black);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    new XYAreaRenderer2()new LegendGraphic(r,Color.black)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    LegendGraphic g1 = new LegendGraphic(r, Color.black);
    2
    Rectangle rect = new Rectangle(1, 2, 3, 4);
    2
    Rectangle rect = new Rectangle(1, 2, 3, 4);
    1
    Rectangle r = new Rectangle(1, 2, 3, 4);
    Differences
    Expression1Expression2Difference
    rectrVARIABLE_NAME_MISMATCH
    1
    Rectangle r = new Rectangle(1, 2, 3, 4);
    3
    r1.setLegendArea(rect);
    3
    r1.setLegendArea(rect);
    Preondition Violations
    Unmatched statement r1.setLegendArea(rect); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                        
    4
    XYAreaRenderer2 r2 = null;
    4
    XYAreaRenderer2 r2 = null;
    3
    LegendGraphic g2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    3
    LegendGraphic g2 = null;
    5
    try
    4
    try
    6
    r2 = (XYAreaRenderer2)r1.clone();
    6
    r2 = (XYAreaRenderer2)r1.clone();
    5
    g2 = (LegendGraphic)g1.clone();
    Differences
    Expression1Expression2Difference
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYAreaRenderer2)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (LegendGraphic)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    g2 = (LegendGraphic)g1.clone();
    7
    assertTrue(r1 != r2);
    7
    assertTrue(r1 != r2);
    6
    assertTrue(g1 != g2);
    Differences
    Expression1Expression2Difference
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(g1 != g2);
    8
    assertTrue(r1.getClass() == r2.getClass());
    8
    assertTrue(r1.getClass() == r2.getClass());
    7
    assertTrue(g1.getClass() == g2.getClass());
    Differences
    Expression1Expression2Difference
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(g1.getClass() == g2.getClass());
    9
    assertTrue(r1.equals(r2));
    9
    assertTrue(r1.equals(r2));
    8
    assertTrue(g1.equals(g2));
    Differences
    Expression1Expression2Difference
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    8
    assertTrue(g1.equals(g2));
    10
    rect.setBounds(99, 99, 99, 99);
    10
    rect.setBounds(99, 99, 99, 99);
    9
    r.setBounds(4, 3, 2, 1);
    Differences
    Expression1Expression2Difference
    994LITERAL_VALUE_MISMATCH
    993LITERAL_VALUE_MISMATCH
    992LITERAL_VALUE_MISMATCH
    991LITERAL_VALUE_MISMATCH
    rectrVARIABLE_NAME_MISMATCH
    9
    r.setBounds(4, 3, 2, 1);
    11
    assertFalse(r1.equals(r2));
    11
    assertFalse(r1.equals(r2));
    10
    assertFalse(g1.equals(g2));
    Differences
    Expression1Expression2Difference
    r2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    r1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.xy.XYAreaRenderer2org.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertFalse(g1.equals(g2));
    Precondition Violations (14)
    Row Violation
    1Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement r1.setLegendArea(rect); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Expression (XYAreaRenderer2)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression (LegendGraphic)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    9Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    11Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    12Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    13Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    14Clone fragment #1 returns variables r1, rect , while Clone fragment #2 returns variables