ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYTextAnnotation) in.readObject(); in.close();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); ko2 = (KeyedObject) in.readObject(); in.close();
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYTextAnnotationTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjectTests.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(a1);
3
            out.writeObject(ko1);
4
            out.close();
4
            out.close();
5
            ObjectInput in = new ObjectInputStream(
5
            ObjectInput in = new ObjectInputStream(
6
new ByteArrayInputStream(
6
                new ByteArrayInputStream(
7
                    buffer.toByteArray())
7
buffer.toByteArray())
8
);
8
            );
9
            a2 = (XYTextAnnotation) in.readObject();
9
            ko2 = (KeyedObject) in.readObject();
10
            in.close();
10
            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 statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    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(a1);
    6
    out.writeObject(a1);
    6
    out.writeObject(ko1);
    Differences
    Expression1Expression2Difference
    a1ko1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYTextAnnotationorg.jfree.data.KeyedObjectSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a1 cannot be unified with expression ko1 , 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(ko1);
    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
    a2 = (XYTextAnnotation)in.readObject();
    9
    a2 = (XYTextAnnotation)in.readObject();
    9
    ko2 = (KeyedObject)in.readObject();
    Differences
    Expression1Expression2Difference
    a2ko2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYTextAnnotationorg.jfree.data.KeyedObjectSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYTextAnnotationorg.jfree.data.KeyedObjectSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYTextAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (KeyedObject)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    ko2 = (KeyedObject)in.readObject();
    10
    in.close();
    10
    in.close();
    Precondition Violations (4)
    Row Violation
    1Expression a1 cannot be unified with expression ko1 , 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
    2Expression (XYTextAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (KeyedObject)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Clone fragment #1 returns variable a2 with type org.jfree.chart.annotations.XYTextAnnotation , while Clone fragment #2 returns variable ko2 with type org.jfree.data.KeyedObject