ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (ShipNeedle) in.readObject(); in.close();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (IntervalBarRenderer) in.readObject(); in.close();
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/ShipNeedleTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/IntervalBarRendererTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 7 Number of AST nodes: 7
1
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
1
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
2
            ObjectOutput out = new ObjectOutputStream(buffer);
2
            ObjectOutput out = new ObjectOutputStream(buffer);
3
            out.writeObject(n1);
3
            out.writeObject(r1);
4
            out.close();
4
            out.close();
5
            ObjectInput in = new ObjectInputStream(
5
            ObjectInput in = new ObjectInputStream(
6
                new ByteArrayInputStream(buffer.toByteArray())
6
                new ByteArrayInputStream(buffer.toByteArray())
7
            );
7
            );
8
            n2 = (ShipNeedle) in.readObject();
8
            r2 = (IntervalBarRenderer) in.readObject();
9
            in.close();
9
            in.close();
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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons28
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    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(n1);
    6
    out.writeObject(n1);
    6
    out.writeObject(r1);
    Differences
    Expression1Expression2Difference
    n1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.needle.ShipNeedleorg.jfree.chart.renderer.category.IntervalBarRendererVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.needle.ShipNeedle of variable n1 does not match with type org.jfree.chart.renderer.category.IntervalBarRenderer of variable r1
    • Make classes org.jfree.chart.needle.ShipNeedle and org.jfree.chart.renderer.category.IntervalBarRenderer extend a common superclass
    6
    out.writeObject(r1);
    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
    r2 = (IntervalBarRenderer)in.readObject();
    Preondition Violations
    Unmatched statement r2=(IntervalBarRenderer)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    r2 = (IntervalBarRenderer)in.readObject();
    9
    n2 = (ShipNeedle)in.readObject();
    9
    n2 = (ShipNeedle)in.readObject();
    Preondition Violations
    Unmatched statement n2=(ShipNeedle)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    10
    in.close();
    10
    in.close();
    Precondition Violations (3)
    Row Violation
    1Type org.jfree.chart.needle.ShipNeedle of variable n1 does not match with type org.jfree.chart.renderer.category.IntervalBarRenderer of variable r1
    2Unmatched statement r2=(IntervalBarRenderer)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement n2=(ShipNeedle)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted