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));
XYItemEntity e1 = new XYItemEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL" ); XYItemEntity e2 = null; try { e2 = (XYItemEntity) e1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2));
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/entity/junit/XYItemEntityTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 8 Number of AST nodes: 7
1
Stroke stroke = new BasicStroke(2.0f);
2
        XYLineAnnotation a1 = new XYLineAnnotation
1
XYItemEntity e1 = new XYItemEntity(
3
(10.0, 20.0, 100.0, 200.0,
2
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
4
                stroke, Color.blue
3
            new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"
5
);
4
        ); 
6
        XYLineAnnotation a2 = null;
5
        XYItemEntity e2 = null;
6
        
7
        try {
7
        try {
8
            a2 = (XYLineAnnotation) a1.clone();
8
            e2 = (XYItemEntity) e1.clone();
9
        }
9
        }
10
        catch (CloneNotSupportedException e) {
10
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
11
            System.err.println("Failed to clone.");
12
        }
12
        }
13
        assertTrue(a1 != a2);
13
        assertTrue(e1 != e2);
14
        assertTrue(a1.getClass() == a2.getClass());
14
        assertTrue(e1.getClass() == e2.getClass());
15
        assertTrue(a1.equals(a2));
15
        assertTrue(e1.equals(e2));
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 comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)29.8
    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);
    2
    XYItemEntity e2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    a1e2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue)nullTYPE_COMPATIBLE_REPLACEMENT
    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
    2
    XYItemEntity e2 = null;
    3
    XYLineAnnotation a2 = null;
    3
    XYLineAnnotation a2 = null;
    1
    XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL");
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    a2e1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    nullnew XYItemEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new TimeSeriesCollection(),1,9,"ToolTip","URL")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new XYItemEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new TimeSeriesCollection(),1,9,"ToolTip","URL") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL");
    4
    try
    3
    try
    5
    a2 = (XYLineAnnotation)a1.clone();
    5
    a2 = (XYLineAnnotation)a1.clone();
    4
    e2 = (XYItemEntity)e1.clone();
    Differences
    Expression1Expression2Difference
    a2e2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    a1e1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.chart.entity.XYItemEntitySUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYLineAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (XYItemEntity)e1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    e2 = (XYItemEntity)e1.clone();
                                                    
    5
    assertTrue(e1 != e2);
    Preondition Violations
    Unmatched statement assertTrue(e1 != e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    assertTrue(e1 != e2);
                                                                                                
    6
    assertTrue(e1.getClass() == e2.getClass());
    Preondition Violations
    Unmatched statement assertTrue(e1.getClass() == e2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    assertTrue(e1.getClass() == e2.getClass());
    6
    assertTrue(a1 != a2);
    6
    assertTrue(a1 != a2);
    Preondition Violations
    Unmatched statement assertTrue(a1 != a2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
                                                              
    7
    assertTrue(e1.equals(e2));
    Preondition Violations
    Unmatched statement assertTrue(e1.equals(e2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    assertTrue(e1.equals(e2));
    7
    assertTrue(a1.getClass() == a2.getClass());
    7
    assertTrue(a1.getClass() == a2.getClass());
    Preondition Violations
    Unmatched statement assertTrue(a1.getClass() == a2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
    8
    assertTrue(a1.equals(a2));
    8
    assertTrue(a1.equals(a2));
    Preondition Violations
    Unmatched statement assertTrue(a1.equals(a2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                              
    Precondition Violations (15)
    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 XYItemEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new TimeSeriesCollection(),1,9,"ToolTip","URL") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression e2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (XYLineAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (XYItemEntity)e1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression e1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Unmatched statement assertTrue(e1 != e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement assertTrue(e1.getClass() == e2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement assertTrue(a1 != a2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement assertTrue(e1.equals(e2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement assertTrue(a1.getClass() == a2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement assertTrue(a1.equals(a2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Clone fragment #1 returns variables a1, a2 , while Clone fragment #2 returns variables e1, e2