Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); XYLineAnnotation a2 = null; try { a2 = (XYLineAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2));
RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red); p1.setSeparatorPaint(gp); RingPlot p2 = null; try { p2 = (RingPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } 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/XYLineAnnotationTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/RingPlotTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 8 Number of AST nodes: 9
1
Stroke stroke = new BasicStroke(2.0f);
2
        XYLineAnnotation a1 = new XYLineAnnotation
1
RingPlot p1 = new RingPlot(null);
3
(10.0, 20.0, 100.0, 200.0,
2
        GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow,
4
                stroke, Color.blue);
3
                3.0f, 4.0f, Color.red);
5
        XYLineAnnotation a
4
        p1.setSeparatorPaint(gp);
6
2 = null;
5
        RingPlot p2 = null;
7
        try {
6
        try {
8
            a2 = (XYLineAnnotation) a1.clone();
7
            p2 = (RingPlot) p1.clone();
9
        }
8
        }
10
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
10
            e.printStackTrace();
12
        }
11
        }
13
        assertTrue(a1 != a2);
12
        assertTrue(p1 != p2);
14
        assertTrue(a1.getClass() == a2.getClass());
13
        assertTrue(p1.getClass() == p2.getClass());
15
        assertTrue(a1.equals(a2));
14
        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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons46
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)74.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Stroke stroke = new BasicStroke(2.0f);
                                                                                  
    2
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
    2
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
    1
    RingPlot p1 = new RingPlot(null);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue)new RingPlot(null)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new RingPlot(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new RingPlot(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    RingPlot p1 = new RingPlot(null);
                                                                                                                                                                        
    2
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red);
    Preondition Violations
    Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.yellow,3.0f,4.0f,Color.red); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red);
                                                            
    3
    p1.setSeparatorPaint(gp);
    Preondition Violations
    Unmatched statement p1.setSeparatorPaint(gp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    p1.setSeparatorPaint(gp);
    3
    XYLineAnnotation a2 = null;
    3
    XYLineAnnotation a2 = null;
    4
    RingPlot p2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    4
    RingPlot p2 = null;
    4
    try
    4
    try
    5
    try
    Differences
    Expression1Expression2Difference
    printlnprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    System.erreAST_TYPE_MISMATCH
    System.err.println("Failed to clone.")e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    5
    try
    5
    a2 = (XYLineAnnotation)a1.clone();
    5
    a2 = (XYLineAnnotation)a1.clone();
    6
    p2 = (RingPlot)p1.clone();
    Differences
    Expression1Expression2Difference
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYLineAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (RingPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    p2 = (RingPlot)p1.clone();
    6
    assertTrue(a1 != a2);
    6
    assertTrue(a1 != a2);
    7
    assertTrue(p1 != p2);
    Differences
    Expression1Expression2Difference
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(p1 != p2);
    7
    assertTrue(a1.getClass() == a2.getClass());
    7
    assertTrue(a1.getClass() == a2.getClass());
    8
    assertTrue(p1.getClass() == p2.getClass());
    Differences
    Expression1Expression2Difference
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(p1.getClass() == p2.getClass());
    8
    assertTrue(a1.equals(a2));
    8
    assertTrue(a1.equals(a2));
    9
    assertTrue(p1.equals(p2));
    Differences
    Expression1Expression2Difference
    a2p2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_TYPE_MISMATCH
    a1p1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.plot.RingPlotSUBCLASS_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)
    9
    assertTrue(p1.equals(p2));
    Precondition Violations (19)
    Row Violation
    1Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new RingPlot(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new RingPlot(null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.yellow,3.0f,4.0f,Color.red); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement p1.setSeparatorPaint(gp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    9Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    10Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    13Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    14Expression (XYLineAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression (RingPlot)p1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression 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)
    17Expression 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)
    18Expression 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)
    19Clone fragment #1 returns variables , while Clone fragment #2 returns variables p1