try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (PaintMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); }
try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DialTextAnnotation) 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/junit/PaintMapTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java
Method name: void testSerialization2() 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(m1);
4
            out.writeObject(a1);
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
            m2 = (PaintMap) in.readObject();
9
            a2 = (DialTextAnnotation) in.readObject();
10
            in.close();
10
            in.close();
11
        }
11
        }
12
        catch (Exception e) {
12
        catch (Exception e) {
13
            e.printStackTrace();
13
            e.printStackTrace();
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)10.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    try
    15
    try
    6
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    16
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    7
    ObjectOutput out = new ObjectOutputStream(buffer);
    17
    ObjectOutput out = new ObjectOutputStream(buffer);
    8
    out.writeObject(m1);
    8
    out.writeObject(m1);
    18
    out.writeObject(a1);
    Differences
    Expression1Expression2Difference
    m1a1VARIABLE_NAME_MISMATCH
    org.jfree.chart.PaintMaporg.jfree.chart.plot.dial.DialTextAnnotationVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.PaintMap of variable m1 does not match with type org.jfree.chart.plot.dial.DialTextAnnotation of variable a1
    • Make classes org.jfree.chart.PaintMap and org.jfree.chart.plot.dial.DialTextAnnotation extend a common superclass
    18
    out.writeObject(a1);
    9
    out.close();
    19
    out.close();
    10
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    20
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    11
    m2 = (PaintMap)in.readObject();
    11
    m2 = (PaintMap)in.readObject();
    Preondition Violations
    Unmatched statement m2=(PaintMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement m2=(PaintMap)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
                                                                      
                                                                                          
    21
    a2 = (DialTextAnnotation)in.readObject();
    Preondition Violations
    Unmatched statement a2=(DialTextAnnotation)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement a2=(DialTextAnnotation)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
    21
    a2 = (DialTextAnnotation)in.readObject();
    12
    in.close();
    22
    in.close();
    Precondition Violations (5)
    Row Violation
    1Type org.jfree.chart.PaintMap of variable m1 does not match with type org.jfree.chart.plot.dial.DialTextAnnotation of variable a1
    2Unmatched statement m2=(PaintMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement m2=(PaintMap)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
    4Unmatched statement a2=(DialTextAnnotation)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement a2=(DialTextAnnotation)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