229-31-32

DeviationRenderer r1 = new DeviationRenderer(); DeviationRenderer r2 = null; try { r2 = (DeviationRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2));
DialPlot p1 = new DialPlot(); DialPlot p2 = null; try { p2 = (DialPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/DeviationRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    DeviationRenderer r1 = new DeviationRenderer();↵

1

    D↵

2

            DeviationRenderer r↵

2

    ialPlot p1 = new DialPlot();↵

3

    2 = null;↵

3

            DialPlot p2 = null;↵

4

            try {↵

4

            try {↵

5

                r2 = (DeviationRenderer) r1.clone();↵

5

                p2 = (DialPlot) p1.clone();↵

6

            }↵

6

            }↵

7

            catch (CloneNotSupportedException e) {↵

7

            catch (CloneNotSupportedException e) {↵

8

                e.printStackTrace();↵

8

                e.printStackTrace();↵

9

            }↵

9

            }↵

10

            assertTrue(r1 != r2);↵

10

            assertTrue(p1 != p2);↵

11

            assertTrue(r1.getClass() == r2.getClass());↵

11

            assertTrue(p1.getClass() == p2.getClass());↵

12

            assertTrue(r1.equals(r2));

12

            assertTrue(p1.equals(p2));

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
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 | 21

1. {Refactorable}

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

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

   1

       DeviationRenderer r1 = new DeviationRenderer();

   1 | DeviationRenderer r1 = new DeviationRenderer();
   1 | DialPlot p1 = new DialPlot();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | p1 | VARIABLE_NAME_MISMATCH

   1

       DialPlot p1 = new DialPlot();

   2

       DeviationRenderer r2 = null;

   2 | DeviationRenderer r2 = null;
   2 | DialPlot p2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | p2 | VARIABLE_NAME_MISMATCH

   2

       DialPlot p2 = null;

   3

       try

   3

       try

   4

       r2 = (DeviationRenderer)r1.clone();

   4 | r2 = (DeviationRenderer)r1.clone();
   4 | p2 = (DialPlot)p1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | p2 | VARIABLE_NAME_MISMATCH
   r1 | p1 | VARIABLE_NAME_MISMATCH

   4

       p2 = (DialPlot)p1.clone();

   5

       assertTrue(r1 != r2);

   5 | assertTrue(r1 != r2);
   5 | assertTrue(p1 != p2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | p1 | VARIABLE_NAME_MISMATCH
   r2 | p2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(p1 != p2);

   6

       assertTrue(r1.getClass() == r2.getClass());

   6 | assertTrue(r1.getClass() == r2.getClass());
   6 | assertTrue(p1.getClass() == p2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | p1 | VARIABLE_NAME_MISMATCH
   r2 | p2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(p1.getClass() == p2.getClass());

   7

       assertTrue(r1.equals(r2));

   7 | assertTrue(r1.equals(r2));
   7 | assertTrue(p1.equals(p2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | p2 | VARIABLE_NAME_MISMATCH
   r1 | p1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(p1.equals(p2));

   Precondition Violations (0)
   Row | Violation
   --- | ---