GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); b1.setBounds(bounds1); ColorBlock b2 = null; try { b2 = (ColorBlock) b1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check independence bounds1.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2));
XYPlot plot = new XYPlot(); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); LegendTitle t1 = new LegendTitle(plot); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); t1.setBounds(bounds1); LegendTitle t2 = null; try { t2 = (LegendTitle) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); // check independence bounds1.setFrame(40.0, 30.0, 20.0, 10.0); assertFalse(t1.equals(t2)); t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0)); assertTrue(t1.equals(t2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/ColorBlockTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendTitleTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 14 Number of AST nodes: 15
1
GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
2
                Color.blue);
1
XYPlot plot = new XYPlot();
3
        Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
2
        Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
4
        ColorBlock b1 = new ColorBlock(gp, 
3
        LegendTitle t1 = new LegendTitle(plot);
5
1.0, 2.0
4
        t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 
6
);
5
                4.0f, Color.yellow));
7
        b1.setBounds(bounds1);
6
        t1.setBounds(bounds1);
8
        ColorBlock b2 = null;
7
        LegendTitle t2 = null;
9
        
10
        try {
8
        try {
11
            b2 = (ColorBlock) b1.clone();
9
            t2 = (LegendTitle) t1.clone();
12
        }
10
        }
13
        catch (CloneNotSupportedException e) {
11
        catch (CloneNotSupportedException e) {
14
            fail(e.toString());
12
            e.printStackTrace();
15
        }
13
        }
16
        assertTrue(b1 != b2);
14
        assertTrue(t1 != t2);
17
        assertTrue(b1.getClass() == b2.getClass());
15
        assertTrue(t1.getClass() == t2.getClass());
18
        assertTrue(b1.equals(b2));
16
        assertTrue(t1.equals(t2));
19
        
17
        
20
        // check independence
18
        // check independence
21
        bounds1.setRect(1.0, 2.0, 3.0, 4.0);
19
        bounds1.setFrame(40.0, 30.0, 20.0, 10.0);
22
        assertFalse(b1.equals(b2));
20
        assertFalse(t1.equals(t2));
23
        b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
21
        t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0));
24
        assertTrue(b1.equals(b2));
22
        assertTrue(t1.equals(t2));
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)47.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                            
    1
    XYPlot plot = new XYPlot();
    Preondition Violations
    Unmatched statement XYPlot plot=new XYPlot(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    XYPlot plot = new XYPlot();
    1
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue);
    1
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue);
    Preondition Violations
    Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                    
    2
    Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
    2
    Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
    3
    ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0);
    3
    ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0);
    3
    LegendTitle t1 = new LegendTitle(plot);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    new ColorBlock(gp,1.0,2.0)new LegendTitle(plot)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    LegendTitle t1 = new LegendTitle(plot);
                                                                                                                                                                                    
    4
    t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    Preondition Violations
    Unmatched statement t1.setBackgroundPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    4
    b1.setBounds(bounds1);
    4
    b1.setBounds(bounds1);
    5
    t1.setBounds(bounds1);
    Differences
    Expression1Expression2Difference
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    5
    t1.setBounds(bounds1);
    5
    ColorBlock b2 = null;
    5
    ColorBlock b2 = null;
    6
    LegendTitle t2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    6
    LegendTitle t2 = null;
    6
    try
    6
    try
    7
    try
    Differences
    Expression1Expression2Difference
    failprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    fail(e.toString())e.printStackTrace()TYPE_COMPATIBLE_REPLACEMENT
    fail(e.toString())e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    7
    try
    7
    b2 = (ColorBlock)b1.clone();
    7
    b2 = (ColorBlock)b1.clone();
    8
    t2 = (LegendTitle)t1.clone();
    Differences
    Expression1Expression2Difference
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (ColorBlock)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (LegendTitle)t1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    t2 = (LegendTitle)t1.clone();
    8
    assertTrue(b1 != b2);
    8
    assertTrue(b1 != b2);
    9
    assertTrue(t1 != t2);
    Differences
    Expression1Expression2Difference
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    9
    assertTrue(t1 != t2);
    9
    assertTrue(b1.getClass() == b2.getClass());
    9
    assertTrue(b1.getClass() == b2.getClass());
    10
    assertTrue(t1.getClass() == t2.getClass());
    Differences
    Expression1Expression2Difference
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    10
    assertTrue(t1.getClass() == t2.getClass());
    10
    assertTrue(b1.equals(b2));
    10
    assertTrue(b1.equals(b2));
    11
    assertTrue(t1.equals(t2));
    Differences
    Expression1Expression2Difference
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    11
    assertTrue(t1.equals(t2));
    11
    bounds1.setRect(1.0, 2.0, 3.0, 4.0);
    11
    bounds1.setRect(1.0, 2.0, 3.0, 4.0);
    12
    bounds1.setFrame(40.0, 30.0, 20.0, 10.0);
    Differences
    Expression1Expression2Difference
    1.040.0LITERAL_VALUE_MISMATCH
    2.030.0LITERAL_VALUE_MISMATCH
    3.020.0LITERAL_VALUE_MISMATCH
    4.010.0LITERAL_VALUE_MISMATCH
    setRectsetFrameMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression bounds1.setRect(1.0,2.0,3.0,4.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression bounds1.setFrame(40.0,30.0,20.0,10.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression bounds1.setRect(1.0,2.0,3.0,4.0) is a void method call, and thus it cannot be parameterized
    Expression bounds1.setFrame(40.0,30.0,20.0,10.0) is a void method call, and thus it cannot be parameterized
    12
    bounds1.setFrame(40.0, 30.0, 20.0, 10.0);
    12
    assertFalse(b1.equals(b2));
    12
    assertFalse(b1.equals(b2));
    13
    assertFalse(t1.equals(t2));
    Differences
    Expression1Expression2Difference
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    13
    assertFalse(t1.equals(t2));
    13
    b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    13
    b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    14
    t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0));
    Differences
    Expression1Expression2Difference
    1.040.0LITERAL_VALUE_MISMATCH
    2.030.0LITERAL_VALUE_MISMATCH
    3.020.0LITERAL_VALUE_MISMATCH
    4.010.0LITERAL_VALUE_MISMATCH
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    14
    t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0));
    14
    assertTrue(b1.equals(b2));
    14
    assertTrue(b1.equals(b2));
    15
    assertTrue(t1.equals(t2));
    Differences
    Expression1Expression2Difference
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.ColorBlockorg.jfree.chart.title.LegendTitleSUBCLASS_TYPE_MISMATCH
    15
    assertTrue(t1.equals(t2));
    Precondition Violations (22)
    Row Violation
    1Unmatched statement XYPlot plot=new XYPlot(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new ColorBlock(gp,1.0,2.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new LegendTitle(plot) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement t1.setBackgroundPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    11Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    12Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    15Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    16Expression (ColorBlock)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression (LegendTitle)t1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression bounds1.setRect(1.0,2.0,3.0,4.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression bounds1.setFrame(40.0,30.0,20.0,10.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression bounds1.setRect(1.0,2.0,3.0,4.0) is a void method call, and thus it cannot be parameterized
    21Expression bounds1.setFrame(40.0,30.0,20.0,10.0) is a void method call, and thus it cannot be parameterized
    22Clone fragment #1 returns variables , while Clone fragment #2 returns variables t1