249-1-3

CategoryAxis a1 = new CategoryAxis("Test"); a1.setAxisLinePaint(Color.red); CategoryAxis a2 = null; try { a2 = (CategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2));
XYItemEntity e1 = new XYItemEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL" ); XYItemEntity e2 = null; try { e2 = (XYItemEntity) 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/chart/axis/junit/AxisTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/XYItemEntityTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    CategoryAxis a1 = new CategoryAxis("Test");↵

2

            a1.setAxisLinePaint(Color.red↵

1

    XYItemEntity e1 = new XYItemEntity(↵

2

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

3

                new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"↵

3

    );↵

4

            ); ↵

4

            CategoryAxis a2 = null;↵

5

            XYItemEntity e2 = null;↵

6

            ↵

5

            try {↵

7

            try {↵

6

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

8

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

7

            }↵

9

            }↵

8

            catch (CloneNotSupportedException e) {↵

10

            catch (CloneNotSupportedException e) {↵

9

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

11

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

10

            }↵

12

            }↵

11

            assertTrue(a1 != a2);↵

13

            assertTrue(e1 != e2);↵

12

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

14

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

13

            assertTrue(a1.equals(a2));

15

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

1. {Non-refactorable}

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

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

   1

       XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL");

   1

       CategoryAxis a1 = new CategoryAxis("Test");

   2

       XYItemEntity e2 = null;

   2

       a1.setAxisLinePaint(Color.red);

   3

       CategoryAxis a2 = null;

   4

       try

   3

       try

   4 | e2 = (XYItemEntity)e1.clone();

   Preondition Violations
   Unmatched statement e2=(XYItemEntity)e1.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

       e2 = (XYItemEntity)e1.clone();

   5

       a2 = (CategoryAxis)a1.clone();

   5 | a2 = (CategoryAxis)a1.clone();

   Preondition Violations
   Unmatched statement a2=(CategoryAxis)a1.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

   6

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

   6

       assertTrue(a1 != a2);

   7

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

   7 | assertTrue(a1.getClass() == a2.getClass());
   7 | assertTrue(e1.equals(e2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1.getClass() == a2.getClass() | e1.equals(e2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(e1.equals(e2));

   8

       assertTrue(a1.equals(a2));

   8 | assertTrue(a1.equals(a2));
   5 | assertTrue(e1 != e2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1.equals(a2) | e1 != e2 | TYPE_COMPATIBLE_REPLACEMENT

   5

       assertTrue(e1 != e2);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement e2=(XYItemEntity)e1.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 a2=(CategoryAxis)a1.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