142-3-5

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);
AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT; AxisLocation location2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(location1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); location2 = (AxisLocation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(location1, location2); boolean same = location1 == location2; assertEquals(true, same);

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/chart/axis/junit/AxisLocationTests.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);↵

2

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

3

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

4

            MatrixSeries m↵

1

    AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT;↵

5

    2 = null;↵

2

            AxisLocation location2 = null;↵

6

            try {↵

3

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(m1);↵

6

                out.writeObject(location1);↵

10

                out.close();↵

7

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

12

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

9

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

13

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

10

                location2 = (AxisLocation) in.readObject();↵

14

                in.close();↵

11

                in.close();↵

15

            }↵

12

            }↵

16

            catch (Exception e) {↵

13

            catch (Exception e) {↵

17

                e.printStackTrace();↵

14

                e.printStackTrace();↵

18

            }↵

15

            }↵

19

            assertEquals(m1, m2↵

16

            assertEquals(location1, location2);↵

17

            boolean same = location1 == location2;↵

20

    );

18

            assertEquals(true, same);

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

1. {Non-refactorable}

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

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

   1

       AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT;

   1

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

   2

       AxisLocation location2 = null;

   2

       m1.update(0, 0, 11.0);

   2 | m1.update(0, 0, 11.0);
   13 | assertEquals(true, same);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   update | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   m1.update(0,0,11.0) | assertEquals(true,same) | ARGUMENT_NUMBER_MISMATCH
   m1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(true,same) is a void method call, and thus it cannot be parameterized
   Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(true,same) is a void method call, and thus it cannot be parameterized

   13

       assertEquals(true, same);

   3

       m1.update(7, 2, 22.0);

   3 | m1.update(7, 2, 22.0);
   11 | assertEquals(location1, location2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   update | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   m1.update(7,2,22.0) | assertEquals(location1,location2) | ARGUMENT_NUMBER_MISMATCH
   m1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(location1,location2) is a void method call, and thus it cannot be parameterized
   Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(location1,location2) is a void method call, and thus it cannot be parameterized

   11

       assertEquals(location1, location2);

   4

       MatrixSeries m2 = null;

   5

       try

   3

       try

   6

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   7

       ObjectOutput out = new ObjectOutputStream(buffer);

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   8

       out.writeObject(m1);

   8 | out.writeObject(m1);
   6 | out.writeObject(location1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | location1 | VARIABLE_NAME_MISMATCH
   org.jfree.data.xy.MatrixSeries | org.jfree.chart.axis.AxisLocation | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.xy.MatrixSeries of variable m1 does not match with type org.jfree.chart.axis.AxisLocation of variable location1
   - Make classes org.jfree.data.xy.MatrixSeries and org.jfree.chart.axis.AxisLocation extend a common superclass

   6

       out.writeObject(location1);

   9

       out.close();

   7

       out.close();

   10

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

   8

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

   9 | location2 = (AxisLocation)in.readObject();

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

       location2 = (AxisLocation)in.readObject();

   11

       m2 = (MatrixSeries)in.readObject();

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

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

       in.close();

   10

       in.close();

   12

       boolean same = location1 == location2;

   13

       assertEquals(m1, m2);

   Precondition Violations (13)
   Row | Violation
   --- | ---
   1 | Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   2 | Expression assertEquals(true,same) is a void method call, and thus it cannot be parameterized
   3 | Expression m1.update(0,0,11.0) is a void method call, and thus it cannot be parameterized
   4 | Expression assertEquals(true,same) is a void method call, and thus it cannot be parameterized
   5 | Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   6 | Expression assertEquals(location1,location2) is a void method call, and thus it cannot be parameterized
   7 | Expression m1.update(7,2,22.0) is a void method call, and thus it cannot be parameterized
   8 | Expression assertEquals(location1,location2) is a void method call, and thus it cannot be parameterized
   9 | Type org.jfree.data.xy.MatrixSeries of variable m1 does not match with type org.jfree.chart.axis.AxisLocation of variable location1
   10 | Unmatched statement location2=(AxisLocation)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   11 | Unmatched statement location2=(AxisLocation)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 | Unmatched statement m2=(MatrixSeries)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   13 | Unmatched statement m2=(MatrixSeries)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