153-7-10

DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.addSeries(createSeries1()); DefaultTableXYDataset d2 = null; try { d2 = (DefaultTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));
TickLabelEntity e1 = new TickLabelEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); TickLabelEntity e2 = null; try { e2 = (TickLabelEntity) e1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/TableXYDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/TickLabelEntityTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();↵

2

            d1.addSeries(createSeries1()↵

1

    TickLabelEntity e1 = new TickLabelEntity(↵

2

                new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"↵

3

    );↵

3

            ); ↵

4

            DefaultTableXYDataset d2 = null;↵

4

            TickLabelEntity e2 = null;↵

5

            try {↵

5

            try {↵

6

                d2 = (DefaultTableXYDataset) d1.clone();↵

6

                e2 = (TickLabelEntity) e1.clone();↵

7

            }↵

7

            }↵

8

            catch (CloneNotSupportedException e) {↵

8

            catch (CloneNotSupportedException e) {↵

9

                System.err.println("Failed to clone.");↵

9

                System.err.println("Failed to clone.");↵

10

            }↵

10

            }↵

11

            assertTrue(d1 != d2);↵

11

            assertTrue(e1 != e2);↵

12

            assertTrue(d1.getClass() == d2.getClass());↵

12

            assertTrue(e1.getClass() == e2.getClass());↵

13

            assertTrue(d1.equals(d2));

13

            assertTrue(e1.equals(e2));

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.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 26

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 1.5
   Clone type | Type 3

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

   1

       DefaultTableXYDataset d1 = new DefaultTableXYDataset();

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | e1 | VARIABLE_NAME_MISMATCH
   new DefaultTableXYDataset() | new TickLabelEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),"ToolTip","URL") | ARGUMENT_NUMBER_MISMATCH

   1

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

   2

       d1.addSeries(createSeries1());

   2 | d1.addSeries(createSeries1());

   Preondition Violations
   Unmatched statement d1.addSeries(createSeries1()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   3

       DefaultTableXYDataset d2 = null;

   3 | DefaultTableXYDataset d2 = null;
   2 | TickLabelEntity e2 = null;

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

   2

       TickLabelEntity e2 = null;

   4

       try

   3

       try

   5

       d2 = (DefaultTableXYDataset)d1.clone();

   5 | d2 = (DefaultTableXYDataset)d1.clone();
   4 | e2 = (TickLabelEntity)e1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d2 | e2 | VARIABLE_NAME_MISMATCH
   d1 | e1 | VARIABLE_NAME_MISMATCH

   4

       e2 = (TickLabelEntity)e1.clone();

   6

       assertTrue(d1 != d2);

   6 | assertTrue(d1 != d2);
   5 | assertTrue(e1 != e2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | e1 | VARIABLE_NAME_MISMATCH
   d2 | e2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(e1 != e2);

   7

       assertTrue(d1.getClass() == d2.getClass());

   7 | assertTrue(d1.getClass() == d2.getClass());
   6 | assertTrue(e1.getClass() == e2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1 | e1 | VARIABLE_NAME_MISMATCH
   d2 | e2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(e1.getClass() == e2.getClass());

   8

       assertTrue(d1.equals(d2));

   8 | assertTrue(d1.equals(d2));
   7 | assertTrue(e1.equals(e2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d2 | e2 | VARIABLE_NAME_MISMATCH
   d1 | e1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(e1.equals(e2));

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement d1.addSeries(createSeries1()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Clone fragment #1 returns variables d1 , while Clone fragment #2 returns variables