DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { a2 = (DialTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); a1.addChangeListener(l1); assertTrue(a1.hasListener(l1)); assertFalse(a2.hasListener(l1));
XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); IntervalXYDelegate d2 = null; try { d2 = (IntervalXYDelegate) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/IntervalXYDelegateTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 11 Number of AST nodes: 11
1
DialTextAnnota
1
XYSeries s1 = new XYSeries("Series");
2
        s1.add(1.2, 3.4);
2
tion a1 = new DialTextAnnotation("A1");
3
        XYSeriesCollection c1 = new XYSeriesCollection();
3
        DialTextAnnotation a
4
        c1.addSeries(s1);
5
        IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
6
        
4
2 = null;
7
        IntervalXYDelegate d2 = null;
5
        try {
8
        try {
6
            a2 = (DialTextAnnotation) a1.clone();
9
            d2 = (IntervalXYDelegate) d1.clone();
7
        }
10
        }
8
        catch (CloneNotSupportedException e) {
11
        catch (CloneNotSupportedException e) {
9
            e.printStackTrace();
12
            System.err.println("Failed to clone.");
10
        }
13
        }
11
        assertTrue(a1 != a2);
14
        assertTrue(d1 != d2);
12
        assertTrue(a1.getClass() == a2.getClass());
15
        assertTrue(d1.getClass() == d2.getClass());
13
        assertTrue(a1.equals(a2));
16
        assertTrue(d1.equals(
14
        
15
        // check that the listener lists are independent
16
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
17
        a1.addChangeListener(l1);
18
        assertTrue(a1.hasListener(l1));
19
        assertFalse(a2.hasListener(l1));
17
d2));
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 comparisons75
  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)46.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                
    1
    XYSeries s1 = new XYSeries("Series");
    Preondition Violations
    Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    XYSeries s1 = new XYSeries("Series");
                                          
    2
    s1.add(1.2, 3.4);
    Preondition Violations
    Unmatched statement s1.add(1.2,3.4); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    s1.add(1.2, 3.4);
    1
    DialTextAnnotation a1 = new DialTextAnnotation("A1");
    1
    DialTextAnnotation a1 = new DialTextAnnotation("A1");
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    a1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    new DialTextAnnotation("A1")new XYSeriesCollection()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
                                            
    4
    c1.addSeries(s1);
    Preondition Violations
    Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    c1.addSeries(s1);
    2
    DialTextAnnotation a2 = null;
    2
    DialTextAnnotation a2 = null;
    5
    IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    a2d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    nullnew IntervalXYDelegate(c1)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new IntervalXYDelegate(c1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
                                                                
    6
    IntervalXYDelegate d2 = null;
    3
    try
    3
    try
    7
    try
    Differences
    Expression1Expression2Difference
    printStackTraceprintlnMETHOD_INVOCATION_NAME_MISMATCH
    eSystem.errAST_TYPE_MISMATCH
    e.printStackTrace()System.err.println("Failed to clone.")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression System.err.println("Failed to clone.") 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 e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    7
    try
    4
    a2 = (DialTextAnnotation)a1.clone();
    4
    a2 = (DialTextAnnotation)a1.clone();
    8
    d2 = (IntervalXYDelegate)d1.clone();
    Differences
    Expression1Expression2Difference
    a2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    a1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IntervalXYDelegate)d1.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 d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    d2 = (IntervalXYDelegate)d1.clone();
    5
    assertTrue(a1 != a2);
    5
    assertTrue(a1 != a2);
    9
    assertTrue(d1 != d2);
    Differences
    Expression1Expression2Difference
    a1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    a2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    assertTrue(d1 != d2);
    6
    assertTrue(a1.getClass() == a2.getClass());
    6
    assertTrue(a1.getClass() == a2.getClass());
    10
    assertTrue(d1.getClass() == d2.getClass());
    Differences
    Expression1Expression2Difference
    a1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    a2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    assertTrue(d1.getClass() == d2.getClass());
    7
    assertTrue(a1.equals(a2));
    7
    assertTrue(a1.equals(a2));
    11
    assertTrue(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    a2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    a1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialTextAnnotationorg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a2 cannot be unified with expression d2 , 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 d2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a1 cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    11
    assertTrue(d1.equals(d2));
    8
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
                                                                                                                                    
    9
    a1.addChangeListener(l1);
    9
    a1.addChangeListener(l1);
    Preondition Violations
    Unmatched statement a1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    10
    assertTrue(a1.hasListener(l1));
    10
    assertTrue(a1.hasListener(l1));
    Preondition Violations
    Unmatched statement assertTrue(a1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
    11
    assertFalse(a2.hasListener(l1));
    11
    assertFalse(a2.hasListener(l1));
    Preondition Violations
    Unmatched statement assertFalse(a2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    Precondition Violations (40)
    Row Violation
    1Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s1.add(1.2,3.4); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression new IntervalXYDelegate(c1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    11Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    12Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    15Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    16Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression (IntervalXYDelegate)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression a2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression a2 cannot be unified with expression d2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    33Expression a2 cannot be unified with expression d2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    34Expression a1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    35Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    36Expression a1 cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    37Unmatched statement a1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    38Unmatched statement assertTrue(a1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    39Unmatched statement assertFalse(a2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    40Clone fragment #1 returns variables a1, a2 , while Clone fragment #2 returns variables c1