269-4-13

XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = null; try { a2 = (XYTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2));
DateTitle t1 = new DateTitle(); DateTitle t2 = null; try { t2 = (DateTitle) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("DateTitleTests.testCloning: failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2));

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

1

    XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0);↵

2

            XYTextAnnotation a↵

1

    DateTitle t1 = new DateTitle();↵

3

    2 = null;↵

2

            DateTitle t2 = null;↵

4

            try {↵

3

            try {↵

5

                a2 = (XYTextAnnotation) a1.clone();↵

4

                t2 = (DateTitle) t1.clone();↵

6

            }↵

5

            }↵

7

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

8

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

7

                System.err.println("DateTitleTests.testCloning: failed to clone.");↵

9

            }↵

8

            }↵

10

            assertTrue(a1 != a2);↵

9

            assertTrue(t1 != t2);↵

11

            assertTrue(a1.getClass() == a2.getClass());↵

10

            assertTrue(t1.getClass() == t2.getClass());↵

12

            assertTrue(a1.equals(a2));

11

            assertTrue(t1.equals(t2));

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

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

       XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0);

   1 | XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0);
   1 | DateTitle t1 = new DateTitle();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | t1 | VARIABLE_NAME_MISMATCH
   new XYTextAnnotation("Text",10.0,20.0) | new DateTitle() | ARGUMENT_NUMBER_MISMATCH

   1

       DateTitle t1 = new DateTitle();

   2

       XYTextAnnotation a2 = null;

   2 | XYTextAnnotation a2 = null;
   2 | DateTitle t2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | t2 | VARIABLE_NAME_MISMATCH

   2

       DateTitle t2 = null;

   3

       try

   3 | try
   3 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   "Failed to clone." | "DateTitleTests.testCloning: failed to clone." | LITERAL_VALUE_MISMATCH

   3

       try

   4

       a2 = (XYTextAnnotation)a1.clone();

   4 | a2 = (XYTextAnnotation)a1.clone();
   4 | t2 = (DateTitle)t1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | t2 | VARIABLE_NAME_MISMATCH
   a1 | t1 | VARIABLE_NAME_MISMATCH

   4

       t2 = (DateTitle)t1.clone();

   5

       assertTrue(a1 != a2);

   5 | assertTrue(a1 != a2);
   5 | assertTrue(t1 != t2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | t1 | VARIABLE_NAME_MISMATCH
   a2 | t2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(t1 != t2);

   6

       assertTrue(a1.getClass() == a2.getClass());

   6 | assertTrue(a1.getClass() == a2.getClass());
   6 | assertTrue(t1.getClass() == t2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | t1 | VARIABLE_NAME_MISMATCH
   a2 | t2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(t1.getClass() == t2.getClass());

   7

       assertTrue(a1.equals(a2));

   7 | assertTrue(a1.equals(a2));
   7 | assertTrue(t1.equals(t2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | t2 | VARIABLE_NAME_MISMATCH
   a1 | t1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(t1.equals(t2));

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