ContourEntity e1 = new ContourEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); ContourEntity e2 = null; try { e2 = (ContourEntity) e1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2));
XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); XYErrorRenderer r2 = null; try { r2 = (XYErrorRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/ContourEntityTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 7 Number of AST nodes: 8
1
ContourEntity e1 = new ContourEntity(
2
            new Rectangle2D.Double
1
XYErrorRenderer r1 = new XYErrorRenderer();
3
(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"
2
        r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
4
        ); 
3
        
5
        ContourEntity e
4
        Color.white));
6
2 = null;
5
        XYErrorRenderer r2 = null;
7
        
8
        try {
6
        try {
9
            e2 = (ContourEntity) e1.clone();
7
            r2 = (XYErrorRenderer) r1.clone();
10
        }
8
        }
11
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
12
            System.err.println("Failed to clone.");
10
            e.printStackTrace();
13
        }
11
        }
14
        assertTrue(e1 != e2);
12
        assertTrue(r1 != r2);
15
        assertTrue(e1.getClass() == e2.getClass());
13
        assertTrue(r1.getClass() == r2.getClass());
16
        assertTrue(e1.equals(e2));
14
        assertTrue(r1.equals(r2));
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons26
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)135.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    ContourEntity e1 = new ContourEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");
    1
    ContourEntity e1 = new ContourEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");
    1
    XYErrorRenderer r1 = new XYErrorRenderer();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    new ContourEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),"ToolTip","URL")new XYErrorRenderer()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYErrorRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYErrorRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    XYErrorRenderer r1 = new XYErrorRenderer();
                                                                                                                                                                        
    2
    r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    Preondition Violations
    Unmatched statement r1.setErrorPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    2
    ContourEntity e2 = null;
    2
    ContourEntity e2 = null;
    3
    XYErrorRenderer r2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    3
    XYErrorRenderer r2 = null;
    3
    try
    3
    try
    4
    try
    Differences
    Expression1Expression2Difference
    printlnprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    System.erreAST_TYPE_MISMATCH
    System.err.println("Failed to clone.")e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.err.println("Failed to clone.") 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 e 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 System.err.println("Failed to clone.") 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
    4
    try
    4
    e2 = (ContourEntity)e1.clone();
    4
    e2 = (ContourEntity)e1.clone();
    5
    r2 = (XYErrorRenderer)r1.clone();
    Differences
    Expression1Expression2Difference
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (ContourEntity)e1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYErrorRenderer)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    r2 = (XYErrorRenderer)r1.clone();
    5
    assertTrue(e1 != e2);
    5
    assertTrue(e1 != e2);
    6
    assertTrue(r1 != r2);
    Differences
    Expression1Expression2Difference
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(r1 != r2);
    6
    assertTrue(e1.getClass() == e2.getClass());
    6
    assertTrue(e1.getClass() == e2.getClass());
    7
    assertTrue(r1.getClass() == r2.getClass());
    Differences
    Expression1Expression2Difference
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(r1.getClass() == r2.getClass());
    7
    assertTrue(e1.equals(e2));
    7
    assertTrue(e1.equals(e2));
    8
    assertTrue(r1.equals(r2));
    Differences
    Expression1Expression2Difference
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.ContourEntityorg.jfree.chart.renderer.xy.XYErrorRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression e2 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 e2 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 e1 cannot be unified with expression r1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    8
    assertTrue(r1.equals(r2));
    Precondition Violations (15)
    Row Violation
    1Expression new XYErrorRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new XYErrorRenderer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement r1.setErrorPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    6Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    7Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    10Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    11Expression (ContourEntity)e1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression (XYErrorRenderer)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression e2 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)
    14Expression e2 cannot be unified with expression r2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    15Expression e1 cannot be unified with expression r1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)