CategoryTick t1 = new CategoryTick( "C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f ); CategoryTick t2 = null; try { t2 = (CategoryTick) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2));
Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); XYSplineRenderer r1 = new XYSplineRenderer(); r1.setLegendLine(legendShape); XYSplineRenderer r2 = null; try { r2 = (XYSplineRenderer) 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/CategoryTickTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYSplineRendererTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 7 Number of AST nodes: 9
1
CategoryTick t1 = new CategoryTick(
2
            "C1", new TextBlock(), TextBlockAnchor.CENTER, 
3
            TextAnchor.CENTER, 1.5f
4
        );
5
        CategoryTick t
1
Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
2
        XYSplineRenderer r1 = new XYSplineRenderer();
3
        r1.setLegendLine(legendShape);
6
2 = null;
4
        XYSplineRenderer r2 = null;
7
        try {
5
        try {
8
            t2 = (CategoryTick) t1.clone();
6
            r2 = (XYSplineRenderer) r1.clone();
9
        }
7
        }
10
        catch (CloneNotSupportedException e) {
8
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
9
            e.printStackTrace();
12
        }
10
        }
13
        assertTrue(t1 != t2);
11
        assertTrue(r1 != r2);
14
        assertTrue(t1.getClass() == t2.getClass());
12
        assertTrue(r1.getClass() == r2.getClass());
15
        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 comparisons39
  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 fragment5
    Time elapsed for statement mapping (ms)4.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                          
    1
    Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
    Preondition Violations
    Unmatched statement Rectangle2D legendShape=new Rectangle2D.Double(1.0,2.0,3.0,4.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
    1
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    1
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    Preondition Violations
    Unmatched statement CategoryTick t1=new CategoryTick("C1",new TextBlock(),TextBlockAnchor.CENTER,TextAnchor.CENTER,1.5f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                    
                                                                                                
    2
    XYSplineRenderer r1 = new XYSplineRenderer();
    Preondition Violations
    Unmatched statement XYSplineRenderer r1=new XYSplineRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    XYSplineRenderer r1 = new XYSplineRenderer();
    2
    CategoryTick t2 = null;
                                                    
                                                                      
    3
    r1.setLegendLine(legendShape);
    Preondition Violations
    Unmatched statement r1.setLegendLine(legendShape); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    r1.setLegendLine(legendShape);
                                                            
    4
    XYSplineRenderer r2 = null;
    3
    try
    3
    try
    5
    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
    5
    try
    4
    t2 = (CategoryTick)t1.clone();
    4
    t2 = (CategoryTick)t1.clone();
    Preondition Violations
    Unmatched statement t2=(CategoryTick)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
                                                                  
                                                                          
    6
    r2 = (XYSplineRenderer)r1.clone();
    Preondition Violations
    Unmatched statement r2=(XYSplineRenderer)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
    6
    r2 = (XYSplineRenderer)r1.clone();
    5
    assertTrue(t1 != t2);
    5
    assertTrue(t1 != t2);
    7
    assertTrue(r1 != r2);
    Differences
    Expression1Expression2Difference
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    7
    assertTrue(r1 != r2);
    6
    assertTrue(t1.getClass() == t2.getClass());
    6
    assertTrue(t1.getClass() == t2.getClass());
    8
    assertTrue(r1.getClass() == r2.getClass());
    Differences
    Expression1Expression2Difference
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    8
    assertTrue(r1.getClass() == r2.getClass());
    7
    assertTrue(t1.equals(t2));
    7
    assertTrue(t1.equals(t2));
    9
    assertTrue(r1.equals(r2));
    Differences
    Expression1Expression2Difference
    t2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    t1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.renderer.xy.XYSplineRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.renderer.xy.XYSplineRenderer extend a common superclass
    9
    assertTrue(r1.equals(r2));
    Precondition Violations (19)
    Row Violation
    1Unmatched statement Rectangle2D legendShape=new Rectangle2D.Double(1.0,2.0,3.0,4.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement CategoryTick t1=new CategoryTick("C1",new TextBlock(),TextBlockAnchor.CENTER,TextAnchor.CENTER,1.5f); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement XYSplineRenderer r1=new XYSplineRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement r1.setLegendLine(legendShape); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    7Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    8Expression e 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 System.err.println("Failed to clone.") 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
    12Unmatched statement t2=(CategoryTick)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
    13Unmatched statement r2=(XYSplineRenderer)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
    14Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1
    15Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    16Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1
    17Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    18Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r2
    19Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.renderer.xy.XYSplineRenderer of variable r1