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