DialBackground b1 = new DialBackground(); DialBackground b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, 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 { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2);
StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, 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 { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2);
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 testSerialization() Method name: void testSerialization()
Number of AST nodes: 24 Number of AST nodes: 25
1
DialBackground b1 = new DialBackground();
1
StandardDialScale s1 = new StandardDialScale();
2
        DialBackground b2 = null;
2
        StandardDialScale s2 = null;
3
        try {
3
        try {
4
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
4
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
5
            ObjectOutput out = new ObjectOutputStream(buffer);
5
            ObjectOutput out = new ObjectOutputStream(buffer);
6
            out.writeObject(b1);
6
            out.writeObject(s1);
7
            out.close();
7
            out.close();
8
            ObjectInput in = new ObjectInputStream(
8
            ObjectInput in = new ObjectInputStream(
9
                    new ByteArrayInputStream(buffer.toByteArray()));
9
                    new ByteArrayInputStream(buffer.toByteArray()));
10
            b2 = (DialBackground) in.readObject();
10
            s2 = (StandardDialScale) in.readObject();
11
            in.close();
11
            in.close();
12
        }
12
        }
13
        catch (Exception e) {
13
        catch (Exception e) {
14
            e.printStackTrace();
14
            e.printStackTrace();
15
        }
15
        }
16
        assertEquals(b1, b2);
16
        assertEquals(s1, s2);
17
        
17
        
18
        // test a customised instance
18
        // try a customised instance
19
        b1 = new DialBackground(
19
        s1 = new StandardDialScale();
20
);
20
        s1.setExtent(123.4);
21
        b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
21
        s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 
22
                Color.green));
22
                4.0f, Color.white));
23
        b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
23
        s1.set
24
                GradientPaintTransformType.CENTER_VERTICAL));
24
MajorTickStroke(new BasicStroke(2.0f));
25
        b2 = null;
25
        s2 = null;
26
        try {
26
        try {
27
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
27
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
28
            ObjectOutput out = new ObjectOutputStream(buffer);
28
            ObjectOutput out = new ObjectOutputStream(buffer);
29
            out.writeObject(b1);
29
            out.writeObject(s1);
30
            out.close();
30
            out.close();
31
            ObjectInput in = new ObjectInputStream(
31
            ObjectInput in = new ObjectInputStream(
32
                    new ByteArrayInputStream(buffer.toByteArray()));
32
                    new ByteArrayInputStream(buffer.toByteArray()));
33
            b2 = (DialBackground) in.readObject();
33
            s2 = (StandardDialScale) in.readObject();
34
            in.close();
34
            in.close();
35
        }
35
        }
36
        catch (Exception e) {
36
        catch (Exception e) {
37
            e.printStackTrace();
37
            e.printStackTrace();
38
        }
38
        }
39
        assertEquals(b1, b2);
39
        assertEquals(s1, s2);
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.5
Clones locationClones are in different classes having the same super class
Number of node comparisons241
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements23
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)68.9
    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
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    out.writeObject(b1);
    6
    out.writeObject(b1);
    6
    out.writeObject(s1);
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    6
    out.writeObject(s1);
    7
    out.close();
    7
    out.close();
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    b2 = (DialBackground)in.readObject();
    9
    b2 = (DialBackground)in.readObject();
    9
    s2 = (StandardDialScale)in.readObject();
    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
    Preondition Violations
    Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    s2 = (StandardDialScale)in.readObject();
    10
    in.close();
    10
    in.close();
    11
    assertEquals(b1, b2);
    11
    assertEquals(b1, b2);
    11
    assertEquals(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
    11
    assertEquals(s1, s2);
    12
    b1 = new DialBackground();
    12
    b1 = new DialBackground();
    12
    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
    12
    s1 = new StandardDialScale();
                                                    
    13
    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
    13
    s1.setExtent(123.4);
    13
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));
    13
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));
    14
    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)
    14
    s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));
    14
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    14
    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
                                                                                                                                                                                                                                              
                                                                                                      
    15
    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
    15
    s1.setMajorTickStroke(new BasicStroke(2.0f));
    15
    b2 = null;
    15
    b2 = null;
    16
    s2 = null;
    Differences
    Expression1Expression2Difference
    b2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    16
    s2 = null;
    16
    try
    17
    try
    17
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    18
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    18
    ObjectOutput out = new ObjectOutputStream(buffer);
    19
    ObjectOutput out = new ObjectOutputStream(buffer);
    19
    out.writeObject(b1);
    19
    out.writeObject(b1);
    20
    out.writeObject(s1);
    Differences
    Expression1Expression2Difference
    b1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.dial.DialBackgroundorg.jfree.chart.plot.dial.StandardDialScaleSUBCLASS_TYPE_MISMATCH
    20
    out.writeObject(s1);
    20
    out.close();
    21
    out.close();
    21
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    22
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    22
    b2 = (DialBackground)in.readObject();
    22
    b2 = (DialBackground)in.readObject();
    23
    s2 = (StandardDialScale)in.readObject();
    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
    Preondition Violations
    Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23
    s2 = (StandardDialScale)in.readObject();
    23
    in.close();
    24
    in.close();
    24
    assertEquals(b1, b2);
    24
    assertEquals(b1, b2);
    25
    assertEquals(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
    25
    assertEquals(s1, s2);
    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)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression (StandardDialScale)in.readObject() 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)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression (StandardDialScale)in.readObject() 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