182-1-3

DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { a2 = (DialTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); a1.addChangeListener(l1); assertTrue(a1.hasListener(l1)); assertFalse(a2.hasListener(l1));
StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { r2 = (StandardDialRange) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); r1.addChangeListener(l1); assertTrue(r1.hasListener(l1)); assertFalse(r2.hasListener(l1));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialRangeTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    DialTextAnnotation a1 = new DialTextAnnotation("A1");↵

2

            DialTextAnnotation a↵

1

    StandardDialRange r1 = new StandardDialRange();↵

3

    2 = null;↵

2

            StandardDialRange r2 = null;↵

4

            try {↵

3

            try {↵

5

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

4

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

6

            }↵

5

            }↵

7

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

8

                e.printStackTrace();↵

7

                e.printStackTrace();↵

9

            }↵

8

            }↵

10

            assertTrue(a1 != a2);↵

9

            assertTrue(r1 != r2);↵

11

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

10

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

12

            assertTrue(a1.equals(a2));↵

11

            assertTrue(r1.equals(r2));↵

13

            ↵

12

            ↵

14

            // check that the listener lists are independent↵

13

            // check that the listener lists are independent↵

15

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

14

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

16

            a1.addChangeListener(l1);↵

15

            r1.addChangeListener(l1);↵

17

            assertTrue(a1.hasListener(l1));↵

16

            assertTrue(r1.hasListener(l1));↵

18

            assertFalse(a2.hasListener(l1));

17

            assertFalse(r2.hasListener(l1));

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 11
   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) | 3.1
   Clone type | Type 2

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

   1

       DialTextAnnotation a1 = new DialTextAnnotation("A1");

   1 | DialTextAnnotation a1 = new DialTextAnnotation("A1");
   1 | StandardDialRange r1 = new StandardDialRange();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   new DialTextAnnotation("A1") | new StandardDialRange() | ARGUMENT_NUMBER_MISMATCH

   1

       StandardDialRange r1 = new StandardDialRange();

   2

       DialTextAnnotation a2 = null;

   2 | DialTextAnnotation a2 = null;
   2 | StandardDialRange r2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   2

       StandardDialRange r2 = null;

   3

       try

   3

       try

   4

       a2 = (DialTextAnnotation)a1.clone();

   4 | a2 = (DialTextAnnotation)a1.clone();
   4 | r2 = (StandardDialRange)r1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (StandardDialRange)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   4

       r2 = (StandardDialRange)r1.clone();

   5

       assertTrue(a1 != a2);

   5 | assertTrue(a1 != a2);
   5 | assertTrue(r1 != r2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   5

       assertTrue(r1 != r2);

   6

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

   6 | assertTrue(a1.getClass() == a2.getClass());
   10 | assertTrue(r1.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1.getClass() == a2.getClass() | r1.hasListener(l1) | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression a1.getClass() == a2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   10

       assertTrue(r1.hasListener(l1));

   7

       assertTrue(a1.equals(a2));

   7 | assertTrue(a1.equals(a2));
   7 | assertTrue(r1.equals(r2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   7

       assertTrue(r1.equals(r2));

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   9

       a1.addChangeListener(l1);

   9 | a1.addChangeListener(l1);
   9 | r1.addChangeListener(l1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1 | r1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   9

       r1.addChangeListener(l1);

   10

       assertTrue(a1.hasListener(l1));

   10 | assertTrue(a1.hasListener(l1));
   6 | assertTrue(r1.getClass() == r2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a1.hasListener(l1) | r1.getClass() == r2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression a1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression r1.getClass() == r2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   6

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

   11

       assertFalse(a2.hasListener(l1));

   11 | assertFalse(a2.hasListener(l1));
   11 | assertFalse(r2.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   a2 | r2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialTextAnnotation | org.jfree.chart.plot.dial.StandardDialRange | SUBCLASS_TYPE_MISMATCH

   11

       assertFalse(r2.hasListener(l1));

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression (StandardDialRange)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression a1.getClass() == a2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression r1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression a1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression r1.getClass() == r2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted