182-2-4

DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = null; try { i2 = (DialValueIndicator) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); i1.addChangeListener(l1); assertTrue(i1.hasListener(l1)); assertFalse(i2.hasListener(l1));
ArcDialFrame f1 = new ArcDialFrame(); ArcDialFrame f2 = null; try { f2 = (ArcDialFrame) f1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); f1.addChangeListener(l1); assertTrue(f1.hasListener(l1)); assertFalse(f2.hasListener(l1));

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

1

    DialValueIndicator i1 = new DialValueIndicator(0);↵

1

    ArcDialFrame f1 = new ArcDialFrame();↵

2

            DialValueIndicator i2 = null;↵

2

            ArcDialFrame f2 = null;↵

3

            try {↵

3

            try {↵

4

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

4

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

5

            }↵

5

            }↵

6

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

7

                e.printStackTrace();↵

7

                e.printStackTrace();↵

8

            }↵

8

            }↵

9

            assertTrue(i1 != i2);↵

9

            assertTrue(f1 != f2);↵

10

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

10

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

11

            assertTrue(i1.equals(i2));↵

11

            assertTrue(f1.equals(f2));↵

12

            ↵

12

            ↵

13

            // check that the listener lists are independent↵

13

            // check that the listener lists are independent↵

14

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

14

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

15

            i1.addChangeListener(l1);↵

15

            f1.addChangeListener(l1);↵

16

            assertTrue(i1.hasListener(l1));↵

16

            assertTrue(f1.hasListener(l1));↵

17

            assertFalse(i2.hasListener(l1));

17

            assertFalse(f2.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.3
   Clone type | Type 2

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

   1

       DialValueIndicator i1 = new DialValueIndicator(0);

   1 | DialValueIndicator i1 = new DialValueIndicator(0);
   1 | ArcDialFrame f1 = new ArcDialFrame();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   i1 | f1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   new DialValueIndicator(0) | new ArcDialFrame() | ARGUMENT_NUMBER_MISMATCH

   1

       ArcDialFrame f1 = new ArcDialFrame();

   2

       DialValueIndicator i2 = null;

   2 | DialValueIndicator i2 = null;
   2 | ArcDialFrame f2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   i2 | f2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   2

       ArcDialFrame f2 = null;

   3

       try

   3

       try

   4

       i2 = (DialValueIndicator)i1.clone();

   4 | i2 = (DialValueIndicator)i1.clone();
   4 | f2 = (ArcDialFrame)f1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i2 | f2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   i1 | f1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (DialValueIndicator)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (ArcDialFrame)f1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   4

       f2 = (ArcDialFrame)f1.clone();

   5

       assertTrue(i1 != i2);

   5 | assertTrue(i1 != i2);
   5 | assertTrue(f1 != f2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1 | f1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   i2 | f2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   5

       assertTrue(f1 != f2);

   6

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

   6 | assertTrue(i1.getClass() == i2.getClass());
   10 | assertTrue(f1.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1.getClass() == i2.getClass() | f1.hasListener(l1) | TYPE_COMPATIBLE_REPLACEMENT

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

   10

       assertTrue(f1.hasListener(l1));

   7

       assertTrue(i1.equals(i2));

   7 | assertTrue(i1.equals(i2));
   7 | assertTrue(f1.equals(f2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i2 | f2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH
   i1 | f1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   7

       assertTrue(f1.equals(f2));

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   9

       i1.addChangeListener(l1);

   9 | i1.addChangeListener(l1);
   9 | f1.addChangeListener(l1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1 | f1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   9

       f1.addChangeListener(l1);

   10

       assertTrue(i1.hasListener(l1));

   10 | assertTrue(i1.hasListener(l1));
   6 | assertTrue(f1.getClass() == f2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i1.hasListener(l1) | f1.getClass() == f2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

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

   6

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

   11

       assertFalse(i2.hasListener(l1));

   11 | assertFalse(i2.hasListener(l1));
   11 | assertFalse(f2.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   i2 | f2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialValueIndicator | org.jfree.chart.plot.dial.ArcDialFrame | SUBCLASS_TYPE_MISMATCH

   11

       assertFalse(f2.hasListener(l1));

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression (DialValueIndicator)i1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression (ArcDialFrame)f1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression i1.getClass() == i2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression f1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression i1.hasListener(l1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression f1.getClass() == f2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted