GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp); LabelBlock 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 = (LabelBlock) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2);
TickLabelEntity e1 = new TickLabelEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); TickLabelEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); e2 = (TickLabelEntity) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(e1, e2);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/LabelBlockTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/TickLabelEntityTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 12 Number of AST nodes: 11
1
GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
2
                Color.blue);
3
        LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", 
4
                Font.PLAIN, 12), gp
1
TickLabelEntity e1 = new TickLabelEntity(
2
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"
5
);
3
        ); 
6
        LabelBlock b2 = null;
4
        TickLabelEntity e2 = null;
7
        try {
5
        try {
8
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
6
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9
            ObjectOutput out = new ObjectOutputStream(buffer);
7
            ObjectOutput out = new ObjectOutputStream(buffer);
10
            out.writeObject(b1);
8
            out.writeObject(e1);
11
            out.close();
9
            out.close();
12
            ObjectInput in = new ObjectInputStream(
10
            ObjectInput in = new ObjectInputStream(
13
                    new ByteArrayInputStream(buffer.toByteArray())
11
                new ByteArrayInputStream(buffer.toByteArray())
14
);
12
            );
15
            b2 = (LabelBlock) in.readObject();
13
            e2 = (TickLabelEntity) in.readObject();
16
            in.close();
14
            in.close();
17
        }
15
        }
18
        catch (Exception e) {
16
        catch (Exception e) {
19
            e.printStackTrace();
17
            System.out.println(e.toString());
20
        }
18
        }
21
        assertEquals(b1, b2);
19
        assertEquals(e1, 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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons76
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)24.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue);
    1
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue);
    Preondition Violations
    Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                    
    2
    LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp);
    2
    LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp);
    2
    TickLabelEntity e2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    b1e2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    new LabelBlock("ABC",new Font("Dialog",Font.PLAIN,12),gp)nullTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new LabelBlock("ABC",new Font("Dialog",Font.PLAIN,12),gp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    TickLabelEntity e2 = null;
    3
    LabelBlock b2 = null;
    3
    LabelBlock b2 = null;
    1
    TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");
    Differences
    Expression1Expression2Difference
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    b2e1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    nullnew TickLabelEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),"ToolTip","URL")TYPE_COMPATIBLE_REPLACEMENT
    1
    TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");
    4
    try
    4
    try
    3
    try
    Differences
    Expression1Expression2Difference
    printStackTraceprintlnMETHOD_INVOCATION_NAME_MISMATCH
    eSystem.outAST_TYPE_MISMATCH
    e.printStackTrace()System.out.println(e.toString())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.out.println(e.toString()) 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.out.println(e.toString()) 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 System.out.println(e.toString()) 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.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    3
    try
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    out.writeObject(b1);
    7
    out.writeObject(b1);
    6
    out.writeObject(e1);
    Differences
    Expression1Expression2Difference
    b1e1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression b1 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
    Expression b1 cannot be unified with expression e1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public abstract void writeObject(java.lang.Object) throws java.io.IOException
    6
    out.writeObject(e1);
    8
    out.close();
    7
    out.close();
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    10
    b2 = (LabelBlock)in.readObject();
    10
    b2 = (LabelBlock)in.readObject();
    9
    e2 = (TickLabelEntity)in.readObject();
    Differences
    Expression1Expression2Difference
    b2e2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    org.jfree.chart.block.LabelBlockorg.jfree.chart.entity.TickLabelEntitySUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression b2 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 (LabelBlock)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (TickLabelEntity)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    e2 = (TickLabelEntity)in.readObject();
    11
    in.close();
    10
    in.close();
                                                    
    11
    assertEquals(e1, e2);
    Preondition Violations
    Unmatched statement assertEquals(e1,e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    assertEquals(e1, e2);
    12
    assertEquals(b1, b2);
    12
    assertEquals(b1, b2);
    Preondition Violations
    Unmatched statement assertEquals(b1,b2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    Precondition Violations (21)
    Row Violation
    1Unmatched statement GradientPaint gp=new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression new LabelBlock("ABC",new Font("Dialog",Font.PLAIN,12),gp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    6Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    7Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression System.out.println(e.toString()) 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.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    12Expression b1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression e1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression b1 cannot be unified with expression e1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public abstract void writeObject(java.lang.Object) throws java.io.IOException
    15Expression b2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression e2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression (LabelBlock)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression (TickLabelEntity)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Unmatched statement assertEquals(e1,e2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement assertEquals(b1,b2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Clone fragment #1 returns variables b1, b2 , while Clone fragment #2 returns variables e1, e2