269-10-18

XYDataItem i1 = new XYDataItem(1.0, 1.1); XYDataItem i2 = null; try { i2 = (XYDataItem) i1.clone(); } catch (CloneNotSupportedException e) { System.err.println("XYDataItemTests.testCloning: failed to clone."); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2));
IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = null; try { r2 = (IntervalBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2));

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

1

    XYDataItem i1 = new XYDataItem(1.0, 1.1);↵

2

            XYDataItem i↵

1

    IntervalBarRenderer r1 = new IntervalBarRenderer();↵

3

    2 = null;↵

2

            IntervalBarRenderer r2 = null;↵

4

            try {↵

3

            try {↵

5

                i2 = (XYDataItem) i1.clone();↵

4

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

6

            }↵

5

            }↵

7

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

8

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

7

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

9

            }↵

8

            }↵

10

            assertTrue(i1 != i2);↵

9

            assertTrue(r1 != r2);↵

11

            assertTrue(i1.getClass() == i2.getClass());↵

10

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

12

            assertTrue(i1.equals(i2));

11

            assertTrue(r1.equals(r2));

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 3
   Number of unmapped statements in the first code fragment | 4
   Number of unmapped statements in the second code fragment | 4
   Time elapsed for statement mapping (ms) | 25.4
   Clone type | Type 2

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

   1

       IntervalBarRenderer r1 = new IntervalBarRenderer();

   1

       XYDataItem i1 = new XYDataItem(1.0, 1.1);

   2

       IntervalBarRenderer r2 = null;

   2

       XYDataItem i2 = null;

   3

       try

   3 | try
   3 | try

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

   3

       try

   4 | r2 = (IntervalBarRenderer)r1.clone();

   Preondition Violations
   Unmatched statement r2=(IntervalBarRenderer)r1.clone(); 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

   4

       r2 = (IntervalBarRenderer)r1.clone();

   4

       i2 = (XYDataItem)i1.clone();

   4 | i2 = (XYDataItem)i1.clone();

   Preondition Violations
   Unmatched statement i2=(XYDataItem)i1.clone(); 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

   5

       assertTrue(r1 != r2);

   5

       assertTrue(i1 != i2);

   5 | assertTrue(i1 != i2);
   7 | assertTrue(r1.equals(r2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1 != i2 | r1.equals(r2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(r1.equals(r2));

   6

       assertTrue(i1.getClass() == i2.getClass());

   7

       assertTrue(i1.equals(i2));

   7 | assertTrue(i1.equals(i2));
   6 | assertTrue(r1.getClass() == r2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1.equals(i2) | r1.getClass() == r2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   6

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

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement r2=(IntervalBarRenderer)r1.clone(); 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
   2 | Unmatched statement i2=(XYDataItem)i1.clone(); 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