1-131-137

ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CompassPlot) in.readObject(); in.close();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (MeterPlot) in.readObject(); in.close();

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CompassPlotTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/MeterPlotTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization1()`
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(p1);↵

3

                out.writeObject(p1);↵

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

                p2 = (CompassPlot) in.readObject();↵

7

                p2 = (MeterPlot) in.readObject();↵

8

                in.close();

8

                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
   --- | --- | --- | --- | ---

   7

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   9

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   8

       ObjectOutput out = new ObjectOutputStream(buffer);

   10

       ObjectOutput out = new ObjectOutputStream(buffer);

   9

       out.writeObject(p1);

   9 | out.writeObject(p1);
   11 | out.writeObject(p1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.CompassPlot | org.jfree.chart.plot.MeterPlot | SUBCLASS_TYPE_MISMATCH

   11

       out.writeObject(p1);

   10

       out.close();

   12

       out.close();

   11

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

   13

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

   12

       p2 = (CompassPlot)in.readObject();

   12 | p2 = (CompassPlot)in.readObject();
   14 | p2 = (MeterPlot)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.CompassPlot | org.jfree.chart.plot.MeterPlot | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.CompassPlot | org.jfree.chart.plot.MeterPlot | SUBCLASS_TYPE_MISMATCH

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

   14

       p2 = (MeterPlot)in.readObject();

   13

       in.close();

   15

       in.close();

   Precondition Violations (3)
   Row | Violation
   --- | ---
   1 | Expression (CompassPlot)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression (MeterPlot)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Clone fragment #1 returns variable p2 with type org.jfree.chart.plot.CompassPlot , while Clone fragment #2 returns variable p2 with type org.jfree.chart.plot.MeterPlot