StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { r2 = (StandardDialRange) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); r1.addChangeListener(l1); assertTrue(r1.hasListener(l1)); assertFalse(r2.hasListener(l1));
StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialRangeTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/PiePlotTests.java
Method name: void testCloning() Method name: void testCloning_LegendLabelGenerator()
Number of AST nodes: 11 Number of AST nodes: 11
1
StandardDialRange r1 = new StandardDialRange
1
StandardPieSectionLabelGenerator generator 
2
                = new StandardPieSectionLabelGenerator();
2
();
3
        PiePlot p1 = new PiePlot();
3
        StandardDialRange r
4
        p1.setLegendLabelGenerator(generator);
4
2 = null;
5
        PiePlot p2 = null;
5
        try {
6
        try {
6
            r2 = (StandardDialRange) r1.clone();
7
            p2 = (PiePlot) p1.clone();
7
        }
8
        }
8
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
9
            e.printStackTrace();
10
            e.printStackTrace();
10
        }
11
        }
11
        assertTrue(r1 != r2);
12
        assertTrue(p1 != p2);
12
        assertTrue(r1.getClass() == r2.getClass());
13
        assertTrue(p1.getClass() == p2.getClass());
13
        assertTrue(r1.equals(r2));
14
        assertTrue(p1.equals(p2));
14
        
15
        
15
        // check that the listener lists are independent
16
        // ch
16
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
17
        r1.addChangeListener(l1);
18
        assertTrue(r1.hasListener(l1)
17
ange the generator and make sure it only affects p1
19
);
18
        generator.getNumberFormat().setMinimumFractionDigits(2);
20
        assertFalse(r2.hasListener(l1));
19
        assertFalse(p1.equals(p2));
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons72
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)79.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                              
    1
    StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator();
    Preondition Violations
    Unmatched statement StandardPieSectionLabelGenerator generator=new StandardPieSectionLabelGenerator(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator();
    1
    StandardDialRange r1 = new StandardDialRange();
    1
    StandardDialRange r1 = new StandardDialRange();
    2
    PiePlot p1 = new PiePlot();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new StandardDialRange() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new PiePlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    PiePlot p1 = new PiePlot();
                                                                                      
    3
    p1.setLegendLabelGenerator(generator);
    Preondition Violations
    Unmatched statement p1.setLegendLabelGenerator(generator); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    p1.setLegendLabelGenerator(generator);
    2
    StandardDialRange r2 = null;
    2
    StandardDialRange r2 = null;
    4
    PiePlot p2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    4
    PiePlot p2 = null;
    3
    try
    5
    try
    4
    r2 = (StandardDialRange)r1.clone();
    4
    r2 = (StandardDialRange)r1.clone();
    6
    p2 = (PiePlot)p1.clone();
    Differences
    Expression1Expression2Difference
    r2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (StandardDialRange)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (PiePlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    p2 = (PiePlot)p1.clone();
    5
    assertTrue(r1 != r2);
    5
    assertTrue(r1 != r2);
    7
    assertTrue(p1 != p2);
    Differences
    Expression1Expression2Difference
    r1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(p1 != p2);
    6
    assertTrue(r1.getClass() == r2.getClass());
    6
    assertTrue(r1.getClass() == r2.getClass());
    8
    assertTrue(p1.getClass() == p2.getClass());
    Differences
    Expression1Expression2Difference
    r1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(p1.getClass() == p2.getClass());
    7
    assertTrue(r1.equals(r2));
    7
    assertTrue(r1.equals(r2));
    9
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    r2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    r1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialRangeorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression r2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression r2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression r1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    9
    assertTrue(p1.equals(p2));
    8
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
                                                                                                                                    
    9
    r1.addChangeListener(l1);
    9
    r1.addChangeListener(l1);
    Preondition Violations
    Unmatched statement r1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
                                                                                                                            
    10
    generator.getNumberFormat().setMinimumFractionDigits(2);
    10
    assertTrue(r1.hasListener(l1));
    10
    assertTrue(r1.hasListener(l1));
    Preondition Violations
    Unmatched statement assertTrue(r1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
                                                                  
    11
    assertFalse(p1.equals(p2));
    Preondition Violations
    Unmatched statement assertFalse(p1.equals(p2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    assertFalse(p1.equals(p2));
    11
    assertFalse(r2.hasListener(l1));
    11
    assertFalse(r2.hasListener(l1));
    Preondition Violations
    Unmatched statement assertFalse(r2.hasListener(l1)); 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 StandardPieSectionLabelGenerator generator=new StandardPieSectionLabelGenerator(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression new StandardDialRange() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new PiePlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Unmatched statement p1.setLegendLabelGenerator(generator); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression (StandardDialRange)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (PiePlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression r2 cannot be unified with expression p2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    8Expression r2 cannot be unified with expression p2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    9Expression r1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10Unmatched statement r1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement assertTrue(r1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement assertFalse(p1.equals(p2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement assertFalse(r2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Clone fragment #1 returns variables r1, r2 , while Clone fragment #2 returns variables p1, p2