115-22-26

TickLabelEntity e1 = new TickLabelEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); TickLabelEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); e2 = (TickLabelEntity) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(e1, e2);
DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.1, 2.2, "R1", "C1"); d1.add(3.3, 4.4, "R1", "C2"); d1.add(null, new Double(5.5), "R1", "C3"); d1.add(new Double(6.6), null, "R2", "C3"); DefaultStatisticalCategoryDataset 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 = (DefaultStatisticalCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(d1, d2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/TickLabelEntityTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization1()`
Number of AST nodes: 11 |  | Number of AST nodes: 15

1

    TickLabelEntity e1 = new TickLabelEntity(↵

1

    DefaultStatisticalCategoryDataset d1 ↵

2

                new Rectangle2D.Double(1.0, 2.0, ↵

2

                = new DefaultStatisticalCategoryDataset();↵

3

            d1.add(1.1, 2.2, "R1", "C1");↵

3

    3.0, 4.0), "ToolTip", "URL"↵

4

            d1.add(3.3, 4.↵

4

            ↵

5

    4, "R1", "C2");↵

6

            d1.add(null, new Double(5.5), "R1", "C3");↵

5

    ); ↵

7

            d1.add(new Double(6.6), null, "R2", "C3");↵

6

            TickLabelEntity e2 = null;↵

8

            DefaultStatisticalCategoryDataset d2 = null;↵

7

            try {↵

9

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(e1);↵

12

                out.writeObject(d1);↵

11

                out.close();↵

13

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

14

                ObjectInput in = new ObjectInputStream(↵

13

                    new ByteArrayInputStream(buffer.toByteArray())↵

15

                        new ByteArrayInputStream(buffer.toByteArray())↵

14

                );↵

16

    );↵

15

                e2 = (TickLabelEntity) in.readObject();↵

17

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

16

                in.close();↵

18

                in.close();↵

17

            }↵

19

            }↵

18

            catch (Exception e) {↵

20

            catch (Exception e) {↵

19

                System.out.println(e.toString());↵

21

                fail(e.toString());↵

20

            }↵

22

            }↵

21

            assertEquals(e1, e2);

23

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

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 | 7
   Time elapsed for statement mapping (ms) | 2.3
   Clone type | Type 3

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

   1

       DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset();

   1

       TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL");

   2

       d1.add(1.1, 2.2, "R1", "C1");

   2

       TickLabelEntity e2 = null;

   3

       d1.add(3.3, 4.4, "R1", "C2");

   4

       d1.add(null, new Double(5.5), "R1", "C3");

   5

       d1.add(new Double(6.6), null, "R2", "C3");

   6

       DefaultStatisticalCategoryDataset d2 = null;

   3

       try

   3 | try
   7 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   println | fail | METHOD_INVOCATION_NAME_MISMATCH
   System.out |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized

   7

       try

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   8

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   9

       ObjectOutput out = new ObjectOutputStream(buffer);

   6

       out.writeObject(e1);

   6 | out.writeObject(e1);
   10 | out.writeObject(d1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   e1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.entity.TickLabelEntity | org.jfree.data.statistics.DefaultStatisticalCategoryDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.entity.TickLabelEntity of variable e1 does not match with type org.jfree.data.statistics.DefaultStatisticalCategoryDataset of variable d1
   - Make classes org.jfree.chart.entity.TickLabelEntity and org.jfree.data.statistics.DefaultStatisticalCategoryDataset extend a common superclass

   10

       out.writeObject(d1);

   7

       out.close();

   11

       out.close();

   8

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

   12

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

   9

       e2 = (TickLabelEntity)in.readObject();

   9 | e2 = (TickLabelEntity)in.readObject();

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

   13 | d2 = (DefaultStatisticalCategoryDataset)in.readObject();

   Preondition Violations
   Unmatched statement d2=(DefaultStatisticalCategoryDataset)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=(DefaultStatisticalCategoryDataset)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

   13

       d2 = (DefaultStatisticalCategoryDataset)in.readObject();

   10

       in.close();

   14

       in.close();

   11

       assertEquals(e1, e2);

   11 | assertEquals(e1, e2);
   15 | assertEquals(d1, d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   e1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.entity.TickLabelEntity | org.jfree.data.statistics.DefaultStatisticalCategoryDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.entity.TickLabelEntity of variable e1 does not match with type org.jfree.data.statistics.DefaultStatisticalCategoryDataset of variable d1
   - Make classes org.jfree.chart.entity.TickLabelEntity and org.jfree.data.statistics.DefaultStatisticalCategoryDataset extend a common superclass

   15

       assertEquals(d1, d2);

   Precondition Violations (10)
   Row | Violation
   --- | ---
   1 | Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
   2 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   3 | Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
   4 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   5 | Type org.jfree.chart.entity.TickLabelEntity of variable e1 does not match with type org.jfree.data.statistics.DefaultStatisticalCategoryDataset of variable d1
   6 | Unmatched statement e2=(TickLabelEntity)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 e2=(TickLabelEntity)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 d2=(DefaultStatisticalCategoryDataset)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 d2=(DefaultStatisticalCategoryDataset)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 | Type org.jfree.chart.entity.TickLabelEntity of variable e1 does not match with type org.jfree.data.statistics.DefaultStatisticalCategoryDataset of variable d1