XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, JFreeChart.INFO.getLogo()); XYImageAnnotation a2 = null; try { a2 = (XYImageAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2));
FastScatterPlot p1 = new FastScatterPlot(); FastScatterPlot p2 = null; try { p2 = (FastScatterPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYImageAnnotationTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/FastScatterPlotTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 7 Number of AST nodes: 7
1
XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0,
2
                JFreeChart.INFO.getLogo());
3
        XYImageAnnotation a
1
FastScatterPlot p1 = new FastScatterPlot();
4
2 = null;
2
        FastScatterPlot p2 = null;
5
        try {
3
        try {
6
            a2 = (XYImageAnnotation) a1.clone();
4
            p2 = (FastScatterPlot) p1.clone();
7
        }
5
        }
8
        catch (CloneNotSupportedException e) {
6
        catch (CloneNotSupportedException e) {
9
            e.printStackTrace();
7
            e.printStackTrace();
8
            System.err.println("Failed to clone.");
10
        }
9
        }
11
        assertTrue(a1 != a2);
10
        assertTrue(p1 != p2);
12
        assertTrue(a1.getClass() == a2.getClass());
11
        assertTrue(p1.getClass() == p2.getClass());
13
        assertTrue(a1.equals(a2));
12
        assertTrue(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 comparisons18
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)35.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, JFreeChart.INFO.getLogo());
    1
    XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, JFreeChart.INFO.getLogo());
    1
    FastScatterPlot p1 = new FastScatterPlot();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    new XYImageAnnotation(10.0,20.0,JFreeChart.INFO.getLogo())new FastScatterPlot()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYImageAnnotation(10.0,20.0,JFreeChart.INFO.getLogo()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new FastScatterPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYImageAnnotation(10.0,20.0,JFreeChart.INFO.getLogo()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new FastScatterPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    FastScatterPlot p1 = new FastScatterPlot();
    2
    XYImageAnnotation a2 = null;
    2
    XYImageAnnotation a2 = null;
    2
    FastScatterPlot p2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    2
    FastScatterPlot p2 = null;
                
    3
    try
                                                                        
    4
    p2 = (FastScatterPlot)p1.clone();
    Preondition Violations
    Unmatched statement p2=(FastScatterPlot)p1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    p2 = (FastScatterPlot)p1.clone();
    3
    try
                
    4
    a2 = (XYImageAnnotation)a1.clone();
    4
    a2 = (XYImageAnnotation)a1.clone();
    Preondition Violations
    Unmatched statement a2=(XYImageAnnotation)a1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    5
    assertTrue(a1 != a2);
    5
    assertTrue(a1 != a2);
    5
    assertTrue(p1 != p2);
    Differences
    Expression1Expression2Difference
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    5
    assertTrue(p1 != p2);
    6
    assertTrue(a1.getClass() == a2.getClass());
    6
    assertTrue(a1.getClass() == a2.getClass());
    6
    assertTrue(p1.getClass() == p2.getClass());
    Differences
    Expression1Expression2Difference
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(p1.getClass() == p2.getClass());
    7
    assertTrue(a1.equals(a2));
    7
    assertTrue(a1.equals(a2));
    7
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYImageAnnotationorg.jfree.chart.plot.FastScatterPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a2 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 a2 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 a1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    7
    assertTrue(p1.equals(p2));
    Precondition Violations (10)
    Row Violation
    1Expression new XYImageAnnotation(10.0,20.0,JFreeChart.INFO.getLogo()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new FastScatterPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new XYImageAnnotation(10.0,20.0,JFreeChart.INFO.getLogo()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new FastScatterPlot() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement p2=(FastScatterPlot)p1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement a2=(XYImageAnnotation)a1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression a2 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 a2 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 a1 cannot be unified with expression p1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10Clone fragment #1 returns variables a1, a2 , while Clone fragment #2 returns variables p1, p2