1-11-157

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(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (AreaRenderer) 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/chart/renderer/category/junit/AreaRendererTests.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(r1);↵

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

                a2 = (XYTextAnnotation) in.readObject();↵

8

                r2 = (AreaRenderer) in.readObject();↵

9

                in.close();

9

                in.close();

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 28

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 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(r1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.annotations.XYTextAnnotation | org.jfree.chart.renderer.category.AreaRenderer | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression a1 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

   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

       a2 = (XYTextAnnotation)in.readObject();

   9 | a2 = (XYTextAnnotation)in.readObject();
   9 | r2 = (AreaRenderer)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.annotations.XYTextAnnotation | org.jfree.chart.renderer.category.AreaRenderer | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.annotations.XYTextAnnotation | org.jfree.chart.renderer.category.AreaRenderer | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (XYTextAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (AreaRenderer)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   9

       r2 = (AreaRenderer)in.readObject();

   10

       in.close();

   10

       in.close();

   Precondition Violations (4)
   Row | Violation
   --- | ---
   1 | Expression a1 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
   2 | Expression (XYTextAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression (AreaRenderer)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Clone fragment #1 returns variable a2 with type org.jfree.chart.annotations.XYTextAnnotation , while Clone fragment #2 returns variable r2 with type org.jfree.chart.renderer.category.AreaRenderer