373-7-10

ThermometerPlot p1 = new ThermometerPlot(); p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); ThermometerPlot 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 = (ThermometerPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2));
MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (MatrixSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);

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

1

    ThermometerPlot p1 = new ThermometerPlot();↵

1

    MatrixSeries s1 = new MatrixSeries("Series", 2, 3);↵

2

            p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵

2

            s1.↵

3

                    4.0f, Color.blue));↵

4

            ThermometerPlot p↵

3

    update(0, 0, 1.1);↵

4

            MatrixSeriesCollection c1 = new MatrixSeriesCollection();↵

5

            c1.addSeries(s1);↵

5

    2 = null;↵

6

            MatrixSeriesCollection c2 = null;↵

6

            try {↵

7

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(p1);↵

10

                out.writeObject(c1);↵

10

                out.close();↵

11

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

12

                ObjectInput in = new ObjectInputStream(↵

12

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

13

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

13

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

14

                c2 = (MatrixSeriesCollection) in.readObject();↵

14

                in.close();↵

15

                in.close();↵

15

            }↵

16

            }↵

16

            catch (Exception e) {↵

17

            catch (Exception e) {↵

17

                e.printStackTrace();↵

18

                e.printStackTrace();↵

18

            }↵

19

            }↵

19

            assertTrue(p1.equals(p2));

20

            assertEquals(c1, c2);

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

1. {Non-refactorable}

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

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

   1

       MatrixSeries s1 = new MatrixSeries("Series", 2, 3);

   1

       ThermometerPlot p1 = new ThermometerPlot();

   2

       s1.update(0, 0, 1.1);

   2

       p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));

   3

       MatrixSeriesCollection c1 = new MatrixSeriesCollection();

   3

       ThermometerPlot p2 = null;

   4

       c1.addSeries(s1);

   5

       MatrixSeriesCollection c2 = null;

   4

       try

   6

       try

   5

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   7

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   6

       ObjectOutput out = new ObjectOutputStream(buffer);

   8

       ObjectOutput out = new ObjectOutputStream(buffer);

   7

       out.writeObject(p1);

   7 | out.writeObject(p1);
   9 | out.writeObject(c1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   p1 | c1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.ThermometerPlot | org.jfree.data.xy.MatrixSeriesCollection | VARIABLE_TYPE_MISMATCH

   Preondition Violations

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

   9

       out.writeObject(c1);

   8

       out.close();

   10

       out.close();

   9

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

   11

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

   10

       p2 = (ThermometerPlot)in.readObject();

   10 | p2 = (ThermometerPlot)in.readObject();

   Preondition Violations
   Unmatched statement p2=(ThermometerPlot)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=(ThermometerPlot)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

   12 | c2 = (MatrixSeriesCollection)in.readObject();

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

   12

       c2 = (MatrixSeriesCollection)in.readObject();

   11

       in.close();

   13

       in.close();

   12

       assertTrue(p1.equals(p2));

   12 | assertTrue(p1.equals(p2));
   14 | assertEquals(c1, c2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(p1.equals(p2)) | assertEquals(c1,c2) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized

   14

       assertEquals(c1, c2);

   Precondition Violations (9)
   Row | Violation
   --- | ---
   1 | Type org.jfree.chart.plot.ThermometerPlot of variable p1 does not match with type org.jfree.data.xy.MatrixSeriesCollection of variable c1
   2 | Unmatched statement p2=(ThermometerPlot)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=(ThermometerPlot)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 c2=(MatrixSeriesCollection)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 c2=(MatrixSeriesCollection)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 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   7 | Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
   8 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   9 | Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized