DialBackground b1 = new DialBackground(); DialBackground b2 = null; try { b2 = (DialBackground) b1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // test a customised instance b1 = new DialBackground(); b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); b2 = null; try { b2 = (DialBackground) b1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); b1.addChangeListener(l1); assertTrue(b1.hasListener(l1)); assertFalse(b2.hasListener(l1));
StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = null; try { s2 = (StandardDialScale) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // try a customised instance s1 = new StandardDialScale(); s1.setExtent(123.4); s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); s1.setMajorTickStroke(new BasicStroke(2.0f)); s2 = null; try { s2 = (StandardDialScale) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); s1.addChangeListener(l1); assertTrue(s1.hasListener(l1)); assertFalse(s2.hasListener(l1));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialBackgroundTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 20 Number of AST nodes: 21
1
DialBackground b1 = new DialBackground();
1
StandardDialScale s1 = new StandardDialScale();
2
        DialBackground b2 = null;
2
        StandardDialScale s2 = null;
3
        try {
3
        try {
4
            b2 = (DialBackground) b1.clone();
4
            s2 = (StandardDialScale) s1.clone();
5
        }
5
        }
6
        catch (CloneNotSupportedException e) {
6
        catch (CloneNotSupportedException e) {
7
            e.printStackTrace();
7
            e.printStackTrace();
8
        }
8
        }
9
        assertTrue(b1 != b2);
9
        assertTrue(s1 != s2);
10
        assertTrue(b1.getClass() == b2.getClass());
10
        assertTrue(s1.getClass() == s2.getClass());
11
        assertTrue(b1.equals(b2));
11
        assertTrue(s1.equals(s2));
12
        
12
        
13
        // test a customised instance
13
        // try a customised instance
14
        b1 = new DialBackground(
14
        s1 = new StandardDialScale();
15
);
15
        s1.setExtent(123.4);
16
        b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
16
        s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 
17
                Color.green));
17
                4.0f, Color.white));
18
        b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
18
        s1.set
19
                GradientPaintTransformType.CENTER_VERTICAL));
19
MajorTickStroke(new BasicStroke(2.0f));
20
        b2 = null;
20
        s2 = null;
21
        try {
21
        try {
22
            b2 = (DialBackground) b1.clone();
22
            s2 = (StandardDialScale) s1.clone();
23
        }
23
        }
24
        catch (CloneNotSupportedException e) {
24
        catch (CloneNotSupportedException e) {
25
            e.printStackTrace();
25
            e.printStackTrace();
26
        }
26
        }
27
        assertTrue(b1 != b2);
27
        assertTrue(s1 != s2);
28
        assertTrue(b1.getClass() == b2.getClass());
28
        assertTrue(s1.getClass() == s2.getClass());
29
        assertTrue(b1.equals(b2));
29
        assertTrue(s1.equals(s2));
30
        
30
        
31
        // check that the listener lists are independent
31
        // check that the listener lists are independent
32
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
32
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
33
        b1.addChangeListener(l1);
33
        s1.addChangeListener(l1);
34
        assertTrue(b1.hasListener(l1));
34
        assertTrue(s1.hasListener(l1));
35
        assertFalse(b2.hasListener(l1));
35
        assertFalse(s2.hasListener(l1));
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons182
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)58.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DialBackground b1 = new DialBackground();
    1
    DialBackground b1 = new DialBackground();
    1
    StandardDialScale s1 = new StandardDialScale();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    StandardDialScale s1 = new StandardDialScale();
    2
    DialBackground b2 = null;
    2
    DialBackground b2 = null;
    2
    StandardDialScale s2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    2
    StandardDialScale s2 = null;
    3
    try
    3
    try
    4
    b2 = (DialBackground)b1.clone();
    4
    b2 = (DialBackground)b1.clone();
    4
    s2 = (StandardDialScale)s1.clone();
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    s2 = (StandardDialScale)s1.clone();
    5
    assertTrue(b1 != b2);
    5
    assertTrue(b1 != b2);
    5
    assertTrue(s1 != s2);
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    5
    assertTrue(s1 != s2);
    6
    assertTrue(b1.getClass() == b2.getClass());
    6
    assertTrue(b1.getClass() == b2.getClass());
    6
    assertTrue(s1.getClass() == s2.getClass());
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(s1.getClass() == s2.getClass());
    7
    assertTrue(b1.equals(b2));
    7
    assertTrue(b1.equals(b2));
    7
    assertTrue(s1.equals(s2));
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(s1.equals(s2));
    8
    b1 = new DialBackground();
    8
    b1 = new DialBackground();
    8
    s1 = new StandardDialScale();
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    s1 = new StandardDialScale();
                                                  
    9
    s1.setExtent(123.4);
    Preondition Violations
    Unmatched statement s1.setExtent(123.4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    s1.setExtent(123.4);
    9
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));
    9
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));
    10
    s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    Differences
    Expression1Expression2Difference
    greenwhiteVARIABLE_NAME_MISMATCH
    setPaintsetMajorTickPaintMETHOD_INVOCATION_NAME_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized
    Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized
    Expression b1 cannot be unified with expression s1 , because common superclass org.jfree.chart.plot.dial.AbstractDialLayer does not declare member(s) public void setPaint(java.awt.Paint) , public void setMajorTickPaint(java.awt.Paint)
    10
    s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    10
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    10
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    Preondition Violations
    Unmatched statement b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                              
                                                                                                      
    11
    s1.setMajorTickStroke(new BasicStroke(2.0f));
    Preondition Violations
    Unmatched statement s1.setMajorTickStroke(new BasicStroke(2.0f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    s1.setMajorTickStroke(new BasicStroke(2.0f));
    11
    b2 = null;
    11
    b2 = null;
    12
    s2 = null;
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    12
    s2 = null;
    12
    try
    13
    try
    13
    b2 = (DialBackground)b1.clone();
    13
    b2 = (DialBackground)b1.clone();
    14
    s2 = (StandardDialScale)s1.clone();
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    s2 = (StandardDialScale)s1.clone();
    14
    assertTrue(b1 != b2);
    14
    assertTrue(b1 != b2);
    15
    assertTrue(s1 != s2);
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    15
    assertTrue(s1 != s2);
    15
    assertTrue(b1.getClass() == b2.getClass());
    15
    assertTrue(b1.getClass() == b2.getClass());
    16
    assertTrue(s1.getClass() == s2.getClass());
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    16
    assertTrue(s1.getClass() == s2.getClass());
    16
    assertTrue(b1.equals(b2));
    16
    assertTrue(b1.equals(b2));
    17
    assertTrue(s1.equals(s2));
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    17
    assertTrue(s1.equals(s2));
    17
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
    18
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
    18
    b1.addChangeListener(l1);
    18
    b1.addChangeListener(l1);
    19
    s1.addChangeListener(l1);
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    19
    s1.addChangeListener(l1);
    19
    assertTrue(b1.hasListener(l1));
    19
    assertTrue(b1.hasListener(l1));
    20
    assertTrue(s1.hasListener(l1));
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    20
    assertTrue(s1.hasListener(l1));
    20
    assertFalse(b2.hasListener(l1));
    20
    assertFalse(b2.hasListener(l1));
    21
    assertFalse(s2.hasListener(l1));
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    21
    assertFalse(s2.hasListener(l1));
    Precondition Violations (17)
    Row Violation
    1Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new DialBackground() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new StandardDialScale() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s1.setExtent(123.4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized
    11Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized
    12Expression b1 cannot be unified with expression s1 , because common superclass org.jfree.chart.plot.dial.AbstractDialLayer does not declare member(s) public void setPaint(java.awt.Paint) , public void setMajorTickPaint(java.awt.Paint)
    13Unmatched statement b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement s1.setMajorTickStroke(new BasicStroke(2.0f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Expression (DialBackground)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression (StandardDialScale)s1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Clone fragment #1 returns variable b1 with type org.jfree.chart.plot.dial.DialBackground , while Clone fragment #2 returns variable s1 with type org.jfree.chart.plot.dial.StandardDialScale