BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); BlockBorder 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 = (BlockBorder) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(b1.equals(b2));
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (StandardEntityCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/BlockBorderTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 11 Number of AST nodes: 13
1
BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 
1
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
2
                4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
2
                2.0, 3.0, 4.0), new 
3
                Color.yellow));
4
        BlockBorder b
3
DefaultPieDataset(), 0, 1, "Key", 
4
                "ToolTip", "URL");
5
        StandardEntityCollection c1 = new StandardEntityCollection();
6
        c1.add(e1);
5
2 = null;
7
        StandardEntityCollection c2 = null;
6
        try {
8
        try {
7
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
8
            ObjectOutput out = new ObjectOutputStream(buffer);
10
            ObjectOutput out = new ObjectOutputStream(buffer);
9
            out.writeObject(b1);
11
            out.writeObject(c1);
10
            out.close();
12
            out.close();
11
            ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
13
            ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
12
                    buffer.toByteArray()));
14
                    buffer.toByteArray()));
13
            b2 = (BlockBorder) in.readObject();
15
            c2 = (StandardEntityCollection) in.readObject();
14
            in.close();
16
            in.close();
15
        }
17
        }
16
        catch (Exception e) {
18
        catch (Exception e) {
17
            fail(e.toString());
19
            e.printStackTrace();
18
        }
20
        }
19
        assertTrue(b1.equals(b2));
21
        assertEquals(c1, c2);
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons79
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)15.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                                                                                  
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    Preondition Violations
    Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    1
    BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    1
    BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    Preondition Violations
    Unmatched statement BlockBorder b1=new BlockBorder(new RectangleInsets(1.0,2.0,3.0,4.0),new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                                                                
                                                                                                                                
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    Preondition Violations
    Unmatched statement StandardEntityCollection c1=new StandardEntityCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    2
    BlockBorder b2 = null;
                                                  
                                
    3
    c1.add(e1);
    Preondition Violations
    Unmatched statement c1.add(e1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    c1.add(e1);
                                                                            
    4
    StandardEntityCollection c2 = null;
    3
    try
    3
    try
    5
    try
    Differences
    Expression1Expression2Difference
    failprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    fail(e.toString())e.printStackTrace()TYPE_COMPATIBLE_REPLACEMENT
    fail(e.toString())e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression fail(e.toString()) 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 fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression fail(e.toString()) 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 fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    5
    try
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    out.writeObject(b1);
    6
    out.writeObject(b1);
    8
    out.writeObject(c1);
    Differences
    Expression1Expression2Difference
    b1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.BlockBorderorg.jfree.chart.entity.StandardEntityCollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.block.BlockBorder of variable b1 does not match with type org.jfree.chart.entity.StandardEntityCollection of variable c1
    • Make classes org.jfree.chart.block.BlockBorder and org.jfree.chart.entity.StandardEntityCollection extend a common superclass
    8
    out.writeObject(c1);
    7
    out.close();
    9
    out.close();
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    10
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    b2 = (BlockBorder)in.readObject();
    9
    b2 = (BlockBorder)in.readObject();
    Preondition Violations
    Unmatched statement b2=(BlockBorder)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement b2=(BlockBorder)in.readObject(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                          
                                                                                                      
    11
    c2 = (StandardEntityCollection)in.readObject();
    Preondition Violations
    Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11
    c2 = (StandardEntityCollection)in.readObject();
    10
    in.close();
    12
    in.close();
    11
    assertTrue(b1.equals(b2));
    11
    assertTrue(b1.equals(b2));
    13
    assertEquals(c1, c2);
    Differences
    Expression1Expression2Difference
    assertTrueassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    assertTrue(b1.equals(b2))assertEquals(c1,c2)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertTrue(b1.equals(b2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(b1.equals(b2)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(b1.equals(b2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(b1.equals(b2)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    13
    assertEquals(c1, c2);
    Precondition Violations (25)
    Row Violation
    1Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement BlockBorder b1=new BlockBorder(new RectangleInsets(1.0,2.0,3.0,4.0),new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement StandardEntityCollection c1=new StandardEntityCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement c1.add(e1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    8Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    9Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    12Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    13Type org.jfree.chart.block.BlockBorder of variable b1 does not match with type org.jfree.chart.entity.StandardEntityCollection of variable c1
    14Unmatched statement b2=(BlockBorder)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement b2=(BlockBorder)in.readObject(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    16Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    18Expression assertTrue(b1.equals(b2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertTrue(b1.equals(b2)) is a void method call, and thus it cannot be parameterized
    21Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    22Expression assertTrue(b1.equals(b2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression assertTrue(b1.equals(b2)) is a void method call, and thus it cannot be parameterized
    25Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized