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));
BlockContainer c1 = new BlockContainer(new FlowArrangement()); c1.add(new EmptyBlock(1.2, 3.4)); BlockContainer c2 = null; try { c2 = (BlockContainer) c1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2));
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/block/junit/BlockContainerTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 7 Number of AST nodes: 8
1
CategoryTick t1 = new CategoryTick(
2
            "C1", new TextBlock(), TextBlockAnchor.CENTER, 
3
            TextAnchor.CENTER, 1.5f
4
        );
5
        CategoryTick t
1
BlockContainer c1 = new BlockContainer(new FlowArrangement());
2
        c1.add(new EmptyBlock(1.2, 3.4));
3
        
6
2 = null;
4
        BlockContainer c2 = null;
5
        
7
        try {
6
        try {
8
            t2 = (CategoryTick) t1.clone();
7
            c2 = (BlockContainer) c1.clone();
9
        }
8
        }
10
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
10
            System.err.println("Failed to clone.");
12
        }
11
        }
13
        assertTrue(t1 != t2);
12
        assertTrue(c1 != c2);
14
        assertTrue(t1.getClass() == t2.getClass());
13
        assertTrue(c1.getClass() == c2.getClass());
15
        assertTrue(t1.equals(t2));
14
        assertTrue(c1.equals(c2));
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 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)4.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                  
    1
    BlockContainer c1 = new BlockContainer(new FlowArrangement());
    Preondition Violations
    Unmatched statement BlockContainer c1=new BlockContainer(new FlowArrangement()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    BlockContainer c1 = new BlockContainer(new FlowArrangement());
    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
    c1.add(new EmptyBlock(1.2, 3.4));
    Preondition Violations
    Unmatched statement c1.add(new EmptyBlock(1.2,3.4)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    c1.add(new EmptyBlock(1.2, 3.4));
    2
    CategoryTick t2 = null;
                                                    
                                                        
    3
    BlockContainer c2 = null;
    3
    try
    4
    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
                                                                  
                                                                      
    5
    c2 = (BlockContainer)c1.clone();
    Preondition Violations
    Unmatched statement c2=(BlockContainer)c1.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
    c2 = (BlockContainer)c1.clone();
    5
    assertTrue(t1 != t2);
    5
    assertTrue(t1 != t2);
    6
    assertTrue(c1 != c2);
    Differences
    Expression1Expression2Difference
    t1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    t2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    6
    assertTrue(c1 != c2);
    6
    assertTrue(t1.getClass() == t2.getClass());
    6
    assertTrue(t1.getClass() == t2.getClass());
    7
    assertTrue(c1.getClass() == c2.getClass());
    Differences
    Expression1Expression2Difference
    t1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    t2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    7
    assertTrue(c1.getClass() == c2.getClass());
    7
    assertTrue(t1.equals(t2));
    7
    assertTrue(t1.equals(t2));
    8
    assertTrue(c1.equals(c2));
    Differences
    Expression1Expression2Difference
    t2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    t1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.CategoryTickorg.jfree.chart.block.BlockContainerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1
    • Make classes org.jfree.chart.axis.CategoryTick and org.jfree.chart.block.BlockContainer extend a common superclass
    8
    assertTrue(c1.equals(c2));
    Precondition Violations (11)
    Row Violation
    1Unmatched statement BlockContainer c1=new BlockContainer(new FlowArrangement()); 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 c1.add(new EmptyBlock(1.2,3.4)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched 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
    5Unmatched statement c2=(BlockContainer)c1.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
    6Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1
    7Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    8Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1
    9Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    10Type org.jfree.chart.axis.CategoryTick of variable t2 does not match with type org.jfree.chart.block.BlockContainer of variable c2
    11Type org.jfree.chart.axis.CategoryTick of variable t1 does not match with type org.jfree.chart.block.BlockContainer of variable c1