142-3-4

MatrixSeries m1 = new MatrixSeries("Test", 8, 3); m1.update(0, 0, 11.0); m1.update(7, 2, 22.0); MatrixSeries m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (MatrixSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2);
CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset 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 = (CategoryTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/MatrixSeriesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/CategoryTableXYDatasetTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 13 |  | Number of AST nodes: 13

1

    MatrixSeries m1 = new MatrixSeries("Test", 8, 3);↵

1

    CategoryTableXYDataset d1 = new CategoryTableXYDataset();↵

2

            m1.update(0, 0, 11.0);↵

2

            d1.add(1.0, 1.1, "Series 1");↵

3

            m1.update(7, 2, 22.0);↵

3

            d1.add(2.0, 2.2, "Series 1");↵

4

            MatrixSeries m2 = null;↵

4

            CategoryTableXYDataset d2 = null;↵

5

            try {↵

5

            try {↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                out.writeObject(m1);↵

8

                out.writeObject(d1);↵

9

                out.close();↵

9

                out.close();↵

10

                ObjectInput in = new ObjectInputStream(↵

10

                ObjectInput in = new ObjectInputStream(↵

11

                        new ByteArrayInputStream(buffer.toByteArray())↵

11

                    new ByteArrayInputStream(buffer.toByteArray())↵

12

    );↵

12

                );↵

13

                m2 = (MatrixSeries) in.readObject();↵

13

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

14

                in.close();↵

14

                in.close();↵

15

            }↵

15

            }↵

16

            catch (Exception e) {↵

16

            catch (Exception e) {↵

17

                e.printStackTrace();↵

17

                e.printStackTrace();↵

18

            }↵

18

            }↵

19

            assertEquals(m1, m2);

19

            assertEquals(d1, d2);

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 13
   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) | 23.4
   Clone type | Type 2

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

   1

       MatrixSeries m1 = new MatrixSeries("Test", 8, 3);

   1 | MatrixSeries m1 = new MatrixSeries("Test", 8, 3);
   1 | CategoryTableXYDataset d1 = new CategoryTableXYDataset();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | d1 | VARIABLE_NAME_MISMATCH
   new MatrixSeries("Test",8,3) | new CategoryTableXYDataset() | ARGUMENT_NUMBER_MISMATCH

   1

       CategoryTableXYDataset d1 = new CategoryTableXYDataset();

   2

       m1.update(0, 0, 11.0);

   2 | m1.update(0, 0, 11.0);
   2 | d1.add(1.0, 1.1, "Series 1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   update | add | METHOD_INVOCATION_NAME_MISMATCH
   0 | 1.0 | LITERAL_VALUE_MISMATCH
   m1 | d1 | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression m1.update(0,0,11.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.add(1.0,1.1,"Series 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   Expression d1.add(1.0,1.1,"Series 1") is a void method call, and thus it cannot be parameterized

   2

       d1.add(1.0, 1.1, "Series 1");

   3

       m1.update(7, 2, 22.0);

   3 | m1.update(7, 2, 22.0);
   3 | d1.add(2.0, 2.2, "Series 1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   update | add | METHOD_INVOCATION_NAME_MISMATCH
   7 | 2.0 | LITERAL_VALUE_MISMATCH
   m1 | d1 | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression m1.update(7,2,22.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.add(2.0,2.2,"Series 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   Expression d1.add(2.0,2.2,"Series 1") is a void method call, and thus it cannot be parameterized

   3

       d1.add(2.0, 2.2, "Series 1");

   4

       MatrixSeries m2 = null;

   4 | MatrixSeries m2 = null;
   4 | CategoryTableXYDataset d2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m2 | d2 | VARIABLE_NAME_MISMATCH

   4

       CategoryTableXYDataset d2 = null;

   5

       try

   5

       try

   6

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   6

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   7

       ObjectOutput out = new ObjectOutputStream(buffer);

   7

       ObjectOutput out = new ObjectOutputStream(buffer);

   8

       out.writeObject(m1);

   8 | out.writeObject(m1);
   8 | out.writeObject(d1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | d1 | VARIABLE_NAME_MISMATCH

   8

       out.writeObject(d1);

   9

       out.close();

   9

       out.close();

   10

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

   10

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

   11

       m2 = (MatrixSeries)in.readObject();

   11 | m2 = (MatrixSeries)in.readObject();
   11 | d2 = (CategoryTableXYDataset)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m2 | d2 | VARIABLE_NAME_MISMATCH

   11

       d2 = (CategoryTableXYDataset)in.readObject();

   12

       in.close();

   12

       in.close();

   13

       assertEquals(m1, m2);

   13 | assertEquals(m1, m2);
   13 | assertEquals(d1, d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | d1 | VARIABLE_NAME_MISMATCH
   m2 | d2 | VARIABLE_NAME_MISMATCH

   13

       assertEquals(d1, d2);

   Precondition Violations (8)
   Row | Violation
   --- | ---
   1 | Expression m1.update(0,0,11.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression d1.add(1.0,1.1,"Series 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   4 | Expression d1.add(1.0,1.1,"Series 1") is a void method call, and thus it cannot be parameterized
   5 | Expression m1.update(7,2,22.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression d1.add(2.0,2.2,"Series 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   8 | Expression d1.add(2.0,2.2,"Series 1") is a void method call, and thus it cannot be parameterized