LevelRenderer r1 = new LevelRenderer(); r1.setItemMargin(0.123); r1.setMaximumItemWidth(0.234); LevelRenderer r2 = null; try { r2 = (LevelRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2));
NumberFormat nf = new DecimalFormat("0"); RelativeDateFormat df1 = new RelativeDateFormat(); df1.setSecondFormatter(nf); RelativeDateFormat df2 = null; df2 = (RelativeDateFormat) df1.clone(); assertTrue(df1 != df2); assertTrue(df1.getClass() == df2.getClass()); assertTrue(df1.equals(df2)); // is the clone independent nf.setMinimumFractionDigits(2); assertFalse(df1.equals(df2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/LevelRendererTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/util/junit/RelativeDateFormatTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 10 Number of AST nodes: 10
1
LevelRenderer r1 = new LevelRenderer();
2
        r1.setItemMargin(0.123
1
NumberFormat nf = new DecimalFormat("0");
3
);
2
        RelativeDateFormat df1 = new RelativeDateFormat();
4
        r1.setMaximumItemWidth(0.234);
3
        df1.set
5
        LevelRenderer r2 = null;
6
        try {
7
            r2 = (LevelRenderer) r1.clone();
8
        }
9
        catch (CloneNotSupportedException e) {
10
            System.err.println("Failed to 
4
SecondFormatter(nf);
5
        RelativeDateFormat df2 = null;
11
clone.");
6
        df2 = (RelativeDateFormat) df1.clone();
12
        }
13
        assertTrue(r1 != r2);
7
        assertTrue(df1 != df2);
14
        assertTrue(r1.getClass() == r2.getClass());
8
        assertTrue(df1.getClass() == df2.getClass());
15
        assertTrue(r1.equals(r2));
9
        assertTrue(df1.equals(df2));
10
    
16
        assertTrue(checkIndependence(r1, r
11
        // is the clone independent
12
        nf.setMinimumFractionDigits(2);
17
2));
13
        assertFalse(df1.equals(df2));
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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons80
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                        
    1
    NumberFormat nf = new DecimalFormat("0");
    Preondition Violations
    Unmatched statement NumberFormat nf=new DecimalFormat("0"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    NumberFormat nf = new DecimalFormat("0");
    1
    LevelRenderer r1 = new LevelRenderer();
    1
    LevelRenderer r1 = new LevelRenderer();
    Preondition Violations
    Unmatched statement LevelRenderer r1=new LevelRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                    
                                                                                                          
    2
    RelativeDateFormat df1 = new RelativeDateFormat();
    Preondition Violations
    Unmatched statement RelativeDateFormat df1=new RelativeDateFormat(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    RelativeDateFormat df1 = new RelativeDateFormat();
    2
    r1.setItemMargin(0.123);
    2
    r1.setItemMargin(0.123);
    Preondition Violations
    Unmatched statement r1.setItemMargin(0.123); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                          
                                                                
    3
    df1.setSecondFormatter(nf);
    Preondition Violations
    Unmatched statement df1.setSecondFormatter(nf); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    df1.setSecondFormatter(nf);
    3
    r1.setMaximumItemWidth(0.234);
    3
    r1.setMaximumItemWidth(0.234);
    Preondition Violations
    Unmatched statement r1.setMaximumItemWidth(0.234); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                      
                                                                  
    4
    RelativeDateFormat df2 = null;
    4
    LevelRenderer r2 = null;
                                                      
                                                                                  
    5
    df2 = (RelativeDateFormat)df1.clone();
    7
    assertTrue(r1 != r2);
    7
    assertTrue(r1 != r2);
    6
    assertTrue(df1 != df2);
    Differences
    Expression1Expression2Difference
    r1df1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    r2df2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    6
    assertTrue(df1 != df2);
    8
    assertTrue(r1.getClass() == r2.getClass());
    8
    assertTrue(r1.getClass() == r2.getClass());
    7
    assertTrue(df1.getClass() == df2.getClass());
    Differences
    Expression1Expression2Difference
    r1df1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    r2df2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    7
    assertTrue(df1.getClass() == df2.getClass());
    9
    assertTrue(r1.equals(r2));
    9
    assertTrue(r1.equals(r2));
    8
    assertTrue(df1.equals(df2));
    Differences
    Expression1Expression2Difference
    r2df2VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    r1df1VARIABLE_NAME_MISMATCH
    org.jfree.chart.renderer.category.LevelRendererorg.jfree.chart.util.RelativeDateFormatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    • Make classes org.jfree.chart.renderer.category.LevelRenderer and org.jfree.chart.util.RelativeDateFormat extend a common superclass
    8
    assertTrue(df1.equals(df2));
                                                                        
    9
    nf.setMinimumFractionDigits(2);
    Preondition Violations
    Unmatched statement nf.setMinimumFractionDigits(2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    9
    nf.setMinimumFractionDigits(2);
                                                                      
    10
    assertFalse(df1.equals(df2));
    10
    assertTrue(checkIndependence(r1, r2));
    10
    assertTrue(checkIndependence(r1, r2));
    Preondition Violations
    Unmatched statement assertTrue(checkIndependence(r1,r2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    Precondition Violations (14)
    Row Violation
    1Unmatched statement NumberFormat nf=new DecimalFormat("0"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement LevelRenderer r1=new LevelRenderer(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement RelativeDateFormat df1=new RelativeDateFormat(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement r1.setItemMargin(0.123); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement df1.setSecondFormatter(nf); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement r1.setMaximumItemWidth(0.234); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    8Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    9Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    10Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    11Type org.jfree.chart.renderer.category.LevelRenderer of variable r2 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df2
    12Type org.jfree.chart.renderer.category.LevelRenderer of variable r1 does not match with type org.jfree.chart.util.RelativeDateFormat of variable df1
    13Unmatched statement nf.setMinimumFractionDigits(2); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Unmatched statement assertTrue(checkIndependence(r1,r2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted