142-15-29

DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); DefaultHighLowDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultHighLowDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2);
MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23)); MeterPlot p2 = null; try { 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(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultHighLowDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/MeterPlotTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization2()`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1",↵

1

    MeterPlot p1 = new ↵

2

                    new Date[] {new Date(123L)}, new double[] {1.2},↵

2

    MeterPlot(new DefaultValueDataset(1.23↵

3

                    new double[] {3.4}, new double[] {5.6}, new double[] {7.8},↵

4

                    new double[] {99.9});↵

5

            DefaultHighLowDatase↵

3

    ));↵

6

    t d2 = null;↵

4

            MeterPlot p2 = null;↵

7

            try {↵

5

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(d1);↵

8

                out.writeObject(p1);↵

11

                out.close();↵

9

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

10

                ObjectInput in = new ObjectInputStream(↵

13

                        new ByteArrayInputStream(buffer.toByteArray()));↵

11

                         new ByteArrayInputStream(buffer.toByteArray()));↵

14

                d2 = (DefaultHighLowDataset) in.readObject();↵

12

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

15

                in.close();↵

13

                in.close();↵

16

            }↵

14

            }↵

17

            catch (Exception e) {↵

15

            catch (Exception e) {↵

18

                e.printStackTrace();↵

16

                e.printStackTrace();↵

19

            }↵

17

            }↵

20

            assertEquals(d1, d2);

18

            assertEquals(p1, p2);

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.1
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 73

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 3
   Number of unmapped statements in the second code fragment | 3
   Time elapsed for statement mapping (ms) | 1.5
   Clone type | Type 2

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

   1

       MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23));

   1

       DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9});

   2

       MeterPlot p2 = null;

   2

       DefaultHighLowDataset d2 = null;

   3

       try

   3

       try

   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(d1);

   6 | out.writeObject(d1);
   6 | out.writeObject(p1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | p1 | VARIABLE_NAME_MISMATCH
   org.jfree.data.xy.DefaultHighLowDataset | org.jfree.chart.plot.MeterPlot | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.xy.DefaultHighLowDataset of variable d1 does not match with type org.jfree.chart.plot.MeterPlot of variable p1
   - Make classes org.jfree.data.xy.DefaultHighLowDataset and org.jfree.chart.plot.MeterPlot extend a common superclass

   6

       out.writeObject(p1);

   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 | p2 = (MeterPlot)in.readObject();

   Preondition Violations
   Unmatched statement p2=(MeterPlot)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched statement p2=(MeterPlot)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

   9

       p2 = (MeterPlot)in.readObject();

   9

       d2 = (DefaultHighLowDataset)in.readObject();

   9 | d2 = (DefaultHighLowDataset)in.readObject();

   Preondition Violations
   Unmatched statement d2=(DefaultHighLowDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched statement d2=(DefaultHighLowDataset)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

   10

       in.close();

   10

       in.close();

   11

       assertEquals(d1, d2);

   11 | assertEquals(d1, d2);
   11 | assertEquals(p1, p2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | p1 | VARIABLE_NAME_MISMATCH
   org.jfree.data.xy.DefaultHighLowDataset | org.jfree.chart.plot.MeterPlot | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.xy.DefaultHighLowDataset of variable d1 does not match with type org.jfree.chart.plot.MeterPlot of variable p1
   - Make classes org.jfree.data.xy.DefaultHighLowDataset and org.jfree.chart.plot.MeterPlot extend a common superclass

   11

       assertEquals(p1, p2);

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Type org.jfree.data.xy.DefaultHighLowDataset of variable d1 does not match with type org.jfree.chart.plot.MeterPlot of variable p1
   2 | Unmatched statement p2=(MeterPlot)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 p2=(MeterPlot)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
   4 | Unmatched statement d2=(DefaultHighLowDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Unmatched statement d2=(DefaultHighLowDataset)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
   6 | Type org.jfree.data.xy.DefaultHighLowDataset of variable d1 does not match with type org.jfree.chart.plot.MeterPlot of variable p1