StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = null; try { f2 = (StandardDialFrame) f1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); f1.addChangeListener(l1); assertTrue(f1.hasListener(l1)); assertFalse(f2.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/StandardDialFrameTests.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
StandardDialFrame f1 = new StandardDialFrame
1
StandardPieSectionLabelGenerator generator 
2
                = new StandardPieSectionLabelGenerator();
2
();
3
        PiePlot p1 = new PiePlot();
3
        StandardDialFrame f
4
        p1.setLegendLabelGenerator(generator);
4
2 = null;
5
        PiePlot p2 = null;
5
        try {
6
        try {
6
            f2 = (StandardDialFrame) f1.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(f1 != f2);
12
        assertTrue(p1 != p2);
12
        assertTrue(f1.getClass() == f2.getClass());
13
        assertTrue(p1.getClass() == p2.getClass());
13
        assertTrue(f1.equals(f2));
14
        assertTrue(p1.equals(p2));
14
        
15
        
15
        // check that the listener lists are independent
16
        // ch
16
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
17
        f1.addChangeListener(l1);
18
        assertTrue(f1.hasListener(l1)
17
ange the generator and make sure it only affects p1
19
);
18
        generator.getNumberFormat().setMinimumFractionDigits(2);
20
        assertFalse(f2.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.2
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)78.6
    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
    StandardDialFrame f1 = new StandardDialFrame();
    1
    StandardDialFrame f1 = new StandardDialFrame();
    2
    PiePlot p1 = new PiePlot();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new StandardDialFrame() 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
    StandardDialFrame f2 = null;
    2
    StandardDialFrame f2 = null;
    4
    PiePlot p2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    4
    PiePlot p2 = null;
    3
    try
    5
    try
    4
    f2 = (StandardDialFrame)f1.clone();
    4
    f2 = (StandardDialFrame)f1.clone();
    6
    p2 = (PiePlot)p1.clone();
    Differences
    Expression1Expression2Difference
    f2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (StandardDialFrame)f1.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(f1 != f2);
    5
    assertTrue(f1 != f2);
    7
    assertTrue(p1 != p2);
    Differences
    Expression1Expression2Difference
    f1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(p1 != p2);
    6
    assertTrue(f1.getClass() == f2.getClass());
    6
    assertTrue(f1.getClass() == f2.getClass());
    8
    assertTrue(p1.getClass() == p2.getClass());
    Differences
    Expression1Expression2Difference
    f1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(p1.getClass() == p2.getClass());
    7
    assertTrue(f1.equals(f2));
    7
    assertTrue(f1.equals(f2));
    9
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    f2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    f1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.StandardDialFrameorg.jfree.chart.plot.PiePlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression f2 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 f2 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 f1 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
    f1.addChangeListener(l1);
    9
    f1.addChangeListener(l1);
    Preondition Violations
    Unmatched statement f1.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(f1.hasListener(l1));
    10
    assertTrue(f1.hasListener(l1));
    Preondition Violations
    Unmatched statement assertTrue(f1.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(f2.hasListener(l1));
    11
    assertFalse(f2.hasListener(l1));
    Preondition Violations
    Unmatched statement assertFalse(f2.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 StandardDialFrame() 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 (StandardDialFrame)f1.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 f2 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 f2 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 f1 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 f1.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(f1.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(f2.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 f1, f2 , while Clone fragment #2 returns variables p1, p2