242-2-6

WindNeedle n1 = new WindNeedle(); WindNeedle n2 = null; try { n2 = (WindNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2));
LineNeedle n1 = new LineNeedle(); LineNeedle n2 = null; try { n2 = (LineNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/WindNeedleTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/LineNeedleTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    WindNeedle n1 = new WindNeedle();↵

1

    LineNeedle n1 = new LineNeedle();↵

2

            WindNeedle n2 = null;↵

2

            LineNeedle n2 = null;↵

3

            try {↵

3

            try {↵

4

                n2 = (WindNeedle) n1.clone();↵

4

                n2 = (LineNeedle) n1.clone();↵

5

            }↵

5

            }↵

6

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

7

                e.printStackTrace();↵

7

                e.printStackTrace();↵

8

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

8

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

9

            }↵

9

            }↵

10

            assertTrue(n1 != n2);↵

10

            assertTrue(n1 != n2);↵

11

            assertTrue(n1.getClass() == n2.getClass());↵

11

            assertTrue(n1.getClass() == n2.getClass());↵

12

            assertTrue(n1.equals(n2));

12

            assertTrue(n1.equals(n2));

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.2
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.0
   Clone type | Type 1

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

   1

       WindNeedle n1 = new WindNeedle();

   1

       LineNeedle n1 = new LineNeedle();

   2

       WindNeedle n2 = null;

   2

       LineNeedle n2 = null;

   3

       try

   3

       try

   4

       n2 = (WindNeedle)n1.clone();

   4

       n2 = (LineNeedle)n1.clone();

   5

       assertTrue(n1 != n2);

   5

       assertTrue(n1 != n2);

   6

       assertTrue(n1.getClass() == n2.getClass());

   6

       assertTrue(n1.getClass() == n2.getClass());

   7

       assertTrue(n1.equals(n2));

   7

       assertTrue(n1.equals(n2));

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