try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); e2 = (PieSectionEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); }
try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (HighLowRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/PieSectionEntityTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 8 Number of AST nodes: 8
1
try {
1
try {
2
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
2
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
3
            ObjectOutput out = new ObjectOutputStream(buffer);
3
            ObjectOutput out = new ObjectOutputStream(buffer);
4
            out.writeObject(e1);
4
            out.writeObject(r1);
5
            out.close();
5
            out.close();
6
            ObjectInput in = new ObjectInputStream(
6
            ObjectInput in = new ObjectInputStream(
7
new ByteArrayInputStream(
7
                new ByteArrayInputStream(
8
                    buffer.toByteArray())
8
buffer.toByteArray())
9
);
9
            );
10
            e2 = (PieSectionEntity) in.readObject();
10
            r2 = (HighLowRenderer) 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
        }
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 comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)11.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    try
    4
    try
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    out.writeObject(e1);
    6
    out.writeObject(e1);
    7
    out.writeObject(r1);
    Differences
    Expression1Expression2Difference
    e1r1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.PieSectionEntityorg.jfree.chart.renderer.xy.HighLowRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression e1 cannot be unified with expression r1 , 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
    7
    out.writeObject(r1);
    7
    out.close();
    8
    out.close();
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    e2 = (PieSectionEntity)in.readObject();
    9
    e2 = (PieSectionEntity)in.readObject();
    10
    r2 = (HighLowRenderer)in.readObject();
    Differences
    Expression1Expression2Difference
    e2r2VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.PieSectionEntityorg.jfree.chart.renderer.xy.HighLowRendererSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.PieSectionEntityorg.jfree.chart.renderer.xy.HighLowRendererSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (PieSectionEntity)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (HighLowRenderer)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    r2 = (HighLowRenderer)in.readObject();
    10
    in.close();
    11
    in.close();
    Precondition Violations (4)
    Row Violation
    1Expression e1 cannot be unified with expression r1 , 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 (PieSectionEntity)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression (HighLowRenderer)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Clone fragment #1 returns variable e2 with type org.jfree.chart.entity.PieSectionEntity , while Clone fragment #2 returns variable r2 with type org.jfree.chart.renderer.xy.HighLowRenderer