DateTick t1 = new DateTick( new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0 ); DateTick t2 = null; try { t2 = (DateTick) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2));
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/axis/junit/DateTickTests.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
DateTick t1 = new DateTick(
2
            new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0
3
        );
4
        DateTick t
1
XYErrorRenderer r1 = new XYErrorRenderer();
2
        r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
3
                Color.white));
5
2 = null;
4
        XYErrorRenderer r2 = null;
6
        try {
5
        try {
7
            t2 = (DateTick) t1.clone();
6
            r2 = (XYErrorRenderer) r1.clone();
8
        }
7
        }
9
        catch (CloneNotSupportedException e) {
8
        catch (CloneNotSupportedException e) {
10
            System.err.println("Failed to clone.");
9
            e.printStackTrace();
11
        }
10
        }
12
        assertTrue(t1 != t2);
11
        assertTrue(r1 != r2);
13
        assertTrue(t1.getClass() == t2.getClass());
12
        assertTrue(r1.getClass() == r2.getClass());
14
        assertTrue(t1.equals(t2));
13
        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 comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)5.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    1
    XYErrorRenderer r1 = new XYErrorRenderer();
    Preondition Violations
    Unmatched statement XYErrorRenderer r1=new XYErrorRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    XYErrorRenderer r1 = new XYErrorRenderer();
    1
    DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0);
    1
    DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0);
    Preondition Violations
    Unmatched statement DateTick t1=new DateTick(new Date(0L),"Label",TextAnchor.CENTER,TextAnchor.CENTER,10.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                          
                                                                                                                                                                        
    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 the extracted code, because it has control dependencies from statements that will be extracted
    2
    r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    2
    DateTick t2 = null;
                                            
                                                          
    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
    t2 = (DateTick)t1.clone();
    4
    t2 = (DateTick)t1.clone();
    Preondition Violations
    Unmatched statement t2=(DateTick)t1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                          
                                                                        
    5
    r2 = (XYErrorRenderer)r1.clone();
    Preondition Violations
    Unmatched statement r2=(XYErrorRenderer)r1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5
    r2 = (XYErrorRenderer)r1.clone();
    5
    assertTrue(t1 != t2);
    5
    assertTrue(t1 != t2);
    6
    assertTrue(r1 != r2);
    Differences
    Expression1Expression2Difference
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    6
    assertTrue(r1 != r2);
    6
    assertTrue(t1.getClass() == t2.getClass());
    6
    assertTrue(t1.getClass() == t2.getClass());
    7
    assertTrue(r1.getClass() == r2.getClass());
    Differences
    Expression1Expression2Difference
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    7
    assertTrue(r1.getClass() == r2.getClass());
    7
    assertTrue(t1.equals(t2));
    7
    assertTrue(t1.equals(t2));
    8
    assertTrue(r1.equals(r2));
    Differences
    Expression1Expression2Difference
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.DateTickorg.jfree.chart.renderer.xy.XYErrorRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1
    • Make classes org.jfree.chart.axis.DateTick and org.jfree.chart.renderer.xy.XYErrorRenderer extend a common superclass
    8
    assertTrue(r1.equals(r2));
    Precondition Violations (18)
    Row Violation
    1Unmatched statement XYErrorRenderer r1=new XYErrorRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement DateTick t1=new DateTick(new Date(0L),"Label",TextAnchor.CENTER,TextAnchor.CENTER,10.0); cannot be moved before the extracted code, because it has control dependencies 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 the extracted code, because it has control dependencies 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
    11Unmatched statement t2=(DateTick)t1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    12Unmatched statement r2=(XYErrorRenderer)r1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    13Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1
    14Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    15Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1
    16Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    17Type org.jfree.chart.axis.DateTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r2
    18Type org.jfree.chart.axis.DateTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYErrorRenderer of variable r1