1-13-290

ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (CategoryAnchor) in.readObject(); in.close();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultTableXYDataset) in.readObject(); in.close();

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/CategoryAnchorTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.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(d1);↵

4

                out.close();↵

4

                out.close();↵

5

                ObjectInput in = new ObjectInputStream(↵

5

                ObjectInput in = new ObjectInputStream(↵

6

                    new ByteArrayInputStream(buffer.toByteArray())↵

6

                        new ByteArrayInputStream(buffer.toByteArray())↵

7

                );↵

7

    );↵

8

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

8

                d2 = (DefaultTableXYDataset) 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 | 6
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 0.0
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   8

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   9

       ObjectOutput out = new ObjectOutputStream(buffer);

   6

       out.writeObject(a1);

   6 | out.writeObject(a1);
   10 | out.writeObject(d1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.axis.CategoryAnchor | org.jfree.data.xy.DefaultTableXYDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.axis.CategoryAnchor of variable a1 does not match with type org.jfree.data.xy.DefaultTableXYDataset of variable d1
   - Make classes org.jfree.chart.axis.CategoryAnchor and org.jfree.data.xy.DefaultTableXYDataset extend a common superclass

   10

       out.writeObject(d1);

   7

       out.close();

   11

       out.close();

   8

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   12

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   9

       a2 = (CategoryAnchor)in.readObject();

   9 | a2 = (CategoryAnchor)in.readObject();

   Preondition Violations
   Unmatched statement a2=(CategoryAnchor)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   13 | d2 = (DefaultTableXYDataset)in.readObject();

   Preondition Violations
   Unmatched statement d2=(DefaultTableXYDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   13

       d2 = (DefaultTableXYDataset)in.readObject();

   10

       in.close();

   14

       in.close();

   Precondition Violations (3)
   Row | Violation
   --- | ---
   1 | Type org.jfree.chart.axis.CategoryAnchor of variable a1 does not match with type org.jfree.data.xy.DefaultTableXYDataset of variable d1
   2 | Unmatched statement a2=(CategoryAnchor)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement d2=(DefaultTableXYDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted