try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (EmptyBlock) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); }
try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (CompositeTitle) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/AbstractBlockTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/CompositeTitleTests.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(b1);
4
            out.writeObject(t1);
5
            out.close();
5
            out.close();
6
            ObjectInput in = new ObjectInputStream(
6
            ObjectInput in = new ObjectInputStream(
7
                    new ByteArrayInputStream(buffer.toByteArray())
7
                new ByteArrayInputStream(buffer.toByteArray())
8
);
8
            );
9
            b2 = (EmptyBlock) in.readObject();
9
            t2 = (CompositeTitle) in.readObject();
10
            in.close();
10
            in.close();
11
        }
11
        }
12
        catch (Exception e) {
12
        catch (Exception e) {
13
            fail(e.toString());
13
            System.out.println(e.toString());
14
        }
14
        }
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.2
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)13.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    try
    3
    try
    4
    try
    Differences
    Expression1Expression2Difference
    failprintlnMETHOD_INVOCATION_NAME_MISMATCH
    fail(e.toString())System.out.println(e.toString())TYPE_COMPATIBLE_REPLACEMENT
    System.outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression fail(e.toString()) 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 fail(e.toString()) 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 fail(e.toString()) 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 fail(e.toString()) 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
    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(b1);
    6
    out.writeObject(b1);
    7
    out.writeObject(t1);
    Differences
    Expression1Expression2Difference
    b1t1VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.EmptyBlockorg.jfree.chart.title.CompositeTitleSUBCLASS_TYPE_MISMATCH
    7
    out.writeObject(t1);
    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
    b2 = (EmptyBlock)in.readObject();
    9
    b2 = (EmptyBlock)in.readObject();
    10
    t2 = (CompositeTitle)in.readObject();
    Differences
    Expression1Expression2Difference
    b2t2VARIABLE_NAME_MISMATCH
    org.jfree.chart.block.EmptyBlockorg.jfree.chart.title.CompositeTitleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.block.EmptyBlockorg.jfree.chart.title.CompositeTitleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (EmptyBlock)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (CompositeTitle)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    t2 = (CompositeTitle)in.readObject();
    10
    in.close();
    11
    in.close();
    Precondition Violations (11)
    Row Violation
    1Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    4Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    5Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression System.out.println(e.toString()) 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 System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    9Expression (EmptyBlock)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression (CompositeTitle)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Clone fragment #1 returns variable b2 with type org.jfree.chart.block.EmptyBlock , while Clone fragment #2 returns variable t2 with type org.jfree.chart.title.CompositeTitle