229-5-55

LineAndShapeRenderer r1 = new LineAndShapeRenderer(); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2));
LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = null; try { f2 = (LogFormat) f1.clone(); } catch (Exception e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2));

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

1

    LineAndShapeRenderer r1 = new LineAndShapeRenderer();↵

1

    L↵

2

            LineAndShapeRenderer r↵

2

    ogFormat f1 = new LogFormat(10.0, "10", true);↵

3

    2 = null;↵

3

            LogFormat f2 = null;↵

4

            try {↵

4

            try {↵

5

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

5

                f2 = (LogFormat) f1.clone();↵

6

            }↵

6

            }↵

7

            catch (CloneNotSupportedException e) {↵

7

            catch (Exception e) {↵

8

                e.printStackTrace();↵

8

                e.printStackTrace();↵

9

            }↵

9

            }↵

10

            assertTrue(r1 != r2);↵

10

            assertTrue(f1 != f2);↵

11

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

11

            assertTrue(f1.getClass() == f2.getClass());↵

12

            assertTrue(r1.equals(r2));↵

12

            assertTrue(f1.equals(↵

13

            assertTrue(checkIndependence(r1, r2));

13

    f2));

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.1
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 | 4
   Number of unmapped statements in the first code fragment | 4
   Number of unmapped statements in the second code fragment | 3
   Time elapsed for statement mapping (ms) | 4.5
   Clone type | Type 3

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

   1

       LogFormat f1 = new LogFormat(10.0, "10", true);

   1

       LineAndShapeRenderer r1 = new LineAndShapeRenderer();

   2

       LogFormat f2 = null;

   2

       LineAndShapeRenderer r2 = null;

   3

       try

   3 | try
   3 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.CloneNotSupportedException | java.lang.Exception | SUBCLASS_TYPE_MISMATCH
   java.lang.CloneNotSupportedException | java.lang.Exception | SUBCLASS_TYPE_MISMATCH
   java.lang.CloneNotSupportedException | java.lang.Exception | SUBCLASS_TYPE_MISMATCH

   3

       try

   4

       f2 = (LogFormat)f1.clone();

   4

       r2 = (LineAndShapeRenderer)r1.clone();

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

   Preondition Violations
   Unmatched statement r2=(LineAndShapeRenderer)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

   5

       assertTrue(r1 != r2);

   6

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

   6 | assertTrue(r1.getClass() == r2.getClass());
   7 | assertTrue(f1.equals(f2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1.getClass() == r2.getClass() | f1.equals(f2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(f1.equals(f2));

   7

       assertTrue(r1.equals(r2));

   7 | assertTrue(r1.equals(r2));
   6 | assertTrue(f1.getClass() == f2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1.equals(r2) | f1.getClass() == f2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   6

       assertTrue(f1.getClass() == f2.getClass());

   8

       assertTrue(checkIndependence(r1, r2));

   8 | assertTrue(checkIndependence(r1, r2));
   5 | assertTrue(f1 != f2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   checkIndependence(r1,r2) | f1 != f2 | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations

   Expression checkIndependence(r1,r2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   - Inline private method checkIndependence

   5

       assertTrue(f1 != f2);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement r2=(LineAndShapeRenderer)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 | Expression checkIndependence(r1,r2) cannot be parameterized, because it has dependencies to/from statements that will be extracted