DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = null; try { i2 = (DialValueIndicator) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); i1.addChangeListener(l1); assertTrue(i1.hasListener(l1)); assertFalse(i2.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/DialValueIndicatorTests.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
DialValueIndicator i1 = new DialValueIndicator(0);
2
        DialValueIndicator i
1
XYSeries s1 = new XYSeries("Series");
2
        s1.add(1.2, 3.4);
3
        XYSeriesCollection c1 = new XYSeriesCollection();
4
        c1.addSeries(s1);
5
        IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
6
        
3
2 = null;
7
        IntervalXYDelegate d2 = null;
4
        try {
8
        try {
5
            i2 = (DialValueIndicator) i1.clone();
9
            d2 = (IntervalXYDelegate) d1.clone();
6
        }
10
        }
7
        catch (CloneNotSupportedException e) {
11
        catch (CloneNotSupportedException e) {
8
            e.printStackTrace();
12
            System.err.println("Failed to clone.");
9
        }
13
        }
10
        assertTrue(i1 != i2);
14
        assertTrue(d1 != d2);
11
        assertTrue(i1.getClass() == i2.getClass());
15
        assertTrue(d1.getClass() == d2.getClass());
12
        assertTrue(i1.equals(i2));
16
        assertTrue(d1.equals(
13
        
14
        // check that the listener lists are independent
15
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
16
        i1.addChangeListener(l1);
17
        assertTrue(i1.hasListener(l1));
18
        assertFalse(i2.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)48.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
    DialValueIndicator i1 = new DialValueIndicator(0);
    1
    DialValueIndicator i1 = new DialValueIndicator(0);
    3
    XYSeriesCollection c1 = new XYSeriesCollection();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    i1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.XYSeriesCollectionSUBCLASS_TYPE_MISMATCH
    new DialValueIndicator(0)new XYSeriesCollection()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new DialValueIndicator(0) 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 DialValueIndicator(0) 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
    DialValueIndicator i2 = null;
    2
    DialValueIndicator i2 = null;
    5
    IntervalXYDelegate d1 = new IntervalXYDelegate(c1);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    i2d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.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
    i2 = (DialValueIndicator)i1.clone();
    4
    i2 = (DialValueIndicator)i1.clone();
    8
    d2 = (IntervalXYDelegate)d1.clone();
    Differences
    Expression1Expression2Difference
    i2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    i1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i2 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 (DialValueIndicator)i1.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 i1 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(i1 != i2);
    5
    assertTrue(i1 != i2);
    9
    assertTrue(d1 != d2);
    Differences
    Expression1Expression2Difference
    i1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    i2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i1 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 i2 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(i1.getClass() == i2.getClass());
    6
    assertTrue(i1.getClass() == i2.getClass());
    10
    assertTrue(d1.getClass() == d2.getClass());
    Differences
    Expression1Expression2Difference
    i1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    i2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i1 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 i2 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(i1.equals(i2));
    7
    assertTrue(i1.equals(i2));
    11
    assertTrue(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    i2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    i1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialValueIndicatororg.jfree.data.xy.IntervalXYDelegateSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i2 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 i2 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 i2 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 i1 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 i1 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
    i1.addChangeListener(l1);
    9
    i1.addChangeListener(l1);
    Preondition Violations
    Unmatched statement i1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    10
    assertTrue(i1.hasListener(l1));
    10
    assertTrue(i1.hasListener(l1));
    Preondition Violations
    Unmatched statement assertTrue(i1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                          
    11
    assertFalse(i2.hasListener(l1));
    11
    assertFalse(i2.hasListener(l1));
    Preondition Violations
    Unmatched statement assertFalse(i2.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 DialValueIndicator(0) 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 DialValueIndicator(0) 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 i2 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 (DialValueIndicator)i1.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 i1 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 i1 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 i2 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 i1 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 i2 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 i2 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 i2 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 i2 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 i1 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 i1 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 i1.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(i1.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(i2.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 i1, i2 , while Clone fragment #2 returns variables c1