115-1-5

KeyedObjects2D ko2D1 = new KeyedObjects2D(); ko2D1.addObject(new Double(234.2), "Row1", "Col1"); ko2D1.addObject(null, "Row1", "Col2"); ko2D1.addObject(new Double(345.9), "Row2", "Col1"); ko2D1.addObject(new Double(452.7), "Row2", "Col2"); KeyedObjects2D ko2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2D2 = (KeyedObjects2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko2D1, ko2D2);
XYBarRenderer r1 = new XYBarRenderer(); r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); XYBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2);

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

1

    KeyedObjects2D ko2D1 = new KeyedObjects2D();↵

2

            ko2D1.addObject(new Double(234.2), "Row1", "Col1");↵

3

            ko2D1.addObject(null, "Row1", "Col2");↵

4

            ko2D1.addObject(new Double(345.9), "Row2", "Col1");↵

5

            ko2D1.addObject(new Double(452.7), "Row2", "Col2"↵

1

    XYBarRenderer r1 = new XYBarRenderer();↵

6

    );↵

2

            r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());↵

7

            KeyedObjects2D ko2D2 = null;↵

3

            XYBarRenderer r2 = null;↵

8

            try {↵

4

            try {↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

5

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

6

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                out.writeObject(ko2D1);↵

7

                out.writeObject(r1);↵

12

                out.close();↵

8

                out.close();↵

13

                ObjectInput in = new ObjectInputStream(↵

9

                ObjectInput in = new ObjectInputStream(↵

14

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

10

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

15

                ko2D2 = (KeyedObjects2D) in.readObject();↵

11

                r2 = (XYBarRenderer) in.readObject();↵

16

                in.close();↵

12

                in.close();↵

17

            }↵

13

            }↵

18

            catch (Exception e) {↵

14

            catch (Exception e) {↵

19

                e.printStackTrace();↵

15

                e.printStackTrace();↵

20

            }↵

16

            }↵

21

            assertEquals(ko2D1, ko2D2);

17

            assertEquals(r1, r2);

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

1. {Non-refactorable}

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

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

   1

       XYBarRenderer r1 = new XYBarRenderer();

   1

       KeyedObjects2D ko2D1 = new KeyedObjects2D();

   2

       ko2D1.addObject(new Double(234.2), "Row1", "Col1");

   3

       XYBarRenderer r2 = null;

   3

       ko2D1.addObject(null, "Row1", "Col2");

   4

       ko2D1.addObject(new Double(345.9), "Row2", "Col1");

   5

       ko2D1.addObject(new Double(452.7), "Row2", "Col2");

   5 | ko2D1.addObject(new Double(452.7), "Row2", "Col2");
   12 | assertEquals(r1, r2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   addObject | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   ko2D1.addObject(new Double(452.7),"Row2","Col2") | assertEquals(r1,r2) | ARGUMENT_NUMBER_MISMATCH
   ko2D1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression ko2D1.addObject(new Double(452.7),"Row2","Col2") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(r1,r2) is a void method call, and thus it cannot be parameterized
   Expression ko2D1.addObject(new Double(452.7),"Row2","Col2") is a void method call, and thus it cannot be parameterized
   Expression assertEquals(r1,r2) is a void method call, and thus it cannot be parameterized

   12

       assertEquals(r1, r2);

   6

       KeyedObjects2D ko2D2 = null;

   7

       try

   4

       try

   8

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   5

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   9

       ObjectOutput out = new ObjectOutputStream(buffer);

   6

       ObjectOutput out = new ObjectOutputStream(buffer);

   10

       out.writeObject(ko2D1);

   10 | out.writeObject(ko2D1);
   7 | out.writeObject(r1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   ko2D1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.data.KeyedObjects2D | org.jfree.chart.renderer.xy.XYBarRenderer | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.KeyedObjects2D of variable ko2D1 does not match with type org.jfree.chart.renderer.xy.XYBarRenderer of variable r1
   - Make classes org.jfree.data.KeyedObjects2D and org.jfree.chart.renderer.xy.XYBarRenderer extend a common superclass

   7

       out.writeObject(r1);

   11

       out.close();

   8

       out.close();

   12

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

   9

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

   10 | r2 = (XYBarRenderer)in.readObject();

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

       r2 = (XYBarRenderer)in.readObject();

   13

       ko2D2 = (KeyedObjects2D)in.readObject();

   13 | ko2D2 = (KeyedObjects2D)in.readObject();

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

   14

       in.close();

   11

       in.close();

   15

       assertEquals(ko2D1, ko2D2);

   15 | assertEquals(ko2D1, ko2D2);
   2 | r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | setPositiveItemLabelPositionFallback | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals(ko2D1,ko2D2) | r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()) | ARGUMENT_NUMBER_MISMATCH
   | r1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals(ko2D1,ko2D2) is a void method call, and thus it cannot be parameterized
   Expression r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(ko2D1,ko2D2) is a void method call, and thus it cannot be parameterized
   Expression r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()) is a void method call, and thus it cannot be parameterized

   2

       r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());

   Precondition Violations (13)
   Row | Violation
   --- | ---
   1 | Expression ko2D1.addObject(new Double(452.7),"Row2","Col2") is a void method call, and thus it cannot be parameterized
   2 | Expression assertEquals(r1,r2) is a void method call, and thus it cannot be parameterized
   3 | Expression ko2D1.addObject(new Double(452.7),"Row2","Col2") is a void method call, and thus it cannot be parameterized
   4 | Expression assertEquals(r1,r2) is a void method call, and thus it cannot be parameterized
   5 | Type org.jfree.data.KeyedObjects2D of variable ko2D1 does not match with type org.jfree.chart.renderer.xy.XYBarRenderer of variable r1
   6 | Unmatched statement r2=(XYBarRenderer)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   7 | Unmatched statement r2=(XYBarRenderer)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
   8 | Unmatched statement ko2D2=(KeyedObjects2D)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   9 | Unmatched statement ko2D2=(KeyedObjects2D)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 | Expression assertEquals(ko2D1,ko2D2) is a void method call, and thus it cannot be parameterized
   11 | Expression r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()) is a void method call, and thus it cannot be parameterized
   12 | Expression assertEquals(ko2D1,ko2D2) is a void method call, and thus it cannot be parameterized
   13 | Expression r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()) is a void method call, and thus it cannot be parameterized