153-3-7

DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("V1", new Integer(1)); d1.setValue("V2", null); d1.setValue("V3", new Integer(3)); DefaultKeyedValuesDataset d2 = null; try { d2 = (DefaultKeyedValuesDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));
DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.addSeries(createSeries1()); DefaultTableXYDataset d2 = null; try { d2 = (DefaultTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultKeyedValuesDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/TableXYDatasetTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 10 |  | Number of AST nodes: 8

1

    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();↵

1

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();↵

2

            d1.setValue("V1", new Integer(1));↵

2

            d1.↵

3

            d1.setValue("V2", null);↵

4

            d1.setValue("V3", new Integer(3));↵

3

    addSeries(createSeries1());↵

5

            DefaultKeyedValuesDataset d2 = null;↵

4

            DefaultTableXYDataset d2 = null;↵

6

            try {↵

5

            try {↵

7

                d2 = (DefaultKeyedValuesDataset) d1.clone();↵

6

                d2 = (DefaultTableXYDataset) d1.clone();↵

8

            }↵

7

            }↵

9

            catch (CloneNotSupportedException e) {↵

8

            catch (CloneNotSupportedException e) {↵

10

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

9

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

11

            }↵

10

            }↵

12

            assertTrue(d1 != d2);↵

11

            assertTrue(d1 != d2);↵

13

            assertTrue(d1.getClass() == d2.getClass());↵

12

            assertTrue(d1.getClass() == d2.getClass());↵

14

            assertTrue(d1.equals(d2));

13

            assertTrue(d1.equals(d2));

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

1. {Non-refactorable}

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

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

   1

       DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();

   1 | DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();
   1 | DefaultTableXYDataset d1 = new DefaultTableXYDataset();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH

   1

       DefaultTableXYDataset d1 = new DefaultTableXYDataset();

   2

       d1.setValue("V1", new Integer(1));

   2 | d1.setValue("V1", new Integer(1));
   2 | d1.addSeries(createSeries1());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setValue | addSeries | METHOD_INVOCATION_NAME_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   d1.setValue("V1",new Integer(1)) | d1.addSeries(createSeries1()) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression d1.setValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.addSeries(createSeries1()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   Expression d1.addSeries(createSeries1()) is a void method call, and thus it cannot be parameterized
   Expression d1.setValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.addSeries(createSeries1()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   Expression d1.addSeries(createSeries1()) is a void method call, and thus it cannot be parameterized

   2

       d1.addSeries(createSeries1());

   3

       d1.setValue("V2", null);

   4

       d1.setValue("V3", new Integer(3));

   4 | d1.setValue("V3", new Integer(3));

   Preondition Violations
   Unmatched statement d1.setValue("V3",new Integer(3)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   5

       DefaultKeyedValuesDataset d2 = null;

   5 | DefaultKeyedValuesDataset d2 = null;
   3 | DefaultTableXYDataset d2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH

   3

       DefaultTableXYDataset d2 = null;

   6

       try

   4

       try

   7

       d2 = (DefaultKeyedValuesDataset)d1.clone();

   7 | d2 = (DefaultKeyedValuesDataset)d1.clone();
   5 | d2 = (DefaultTableXYDataset)d1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (DefaultKeyedValuesDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (DefaultTableXYDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   5

       d2 = (DefaultTableXYDataset)d1.clone();

   8

       assertTrue(d1 != d2);

   8 | assertTrue(d1 != d2);
   6 | assertTrue(d1 != d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.general.DefaultKeyedValuesDataset | org.jfree.data.xy.DefaultTableXYDataset | SUBCLASS_TYPE_MISMATCH

   6

       assertTrue(d1 != d2);

   9

       assertTrue(d1.getClass() == d2.getClass());

   9 | assertTrue(d1.getClass() == d2.getClass());
   8 | assertTrue(d1.equals(d2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1.getClass() == d2.getClass() | d1.equals(d2) | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression d1.getClass() == d2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   8

       assertTrue(d1.equals(d2));

   10

       assertTrue(d1.equals(d2));

   10 | assertTrue(d1.equals(d2));
   7 | assertTrue(d1.getClass() == d2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   d1.equals(d2) | d1.getClass() == d2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.getClass() == d2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   7

       assertTrue(d1.getClass() == d2.getClass());

   Precondition Violations (16)
   Row | Violation
   --- | ---
   1 | Expression d1.setValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression d1.addSeries(createSeries1()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   4 | Expression d1.addSeries(createSeries1()) is a void method call, and thus it cannot be parameterized
   5 | Expression d1.setValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression d1.addSeries(createSeries1()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   8 | Expression d1.addSeries(createSeries1()) is a void method call, and thus it cannot be parameterized
   9 | Unmatched statement d1.setValue("V3",new Integer(3)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   10 | Expression (DefaultKeyedValuesDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression (DefaultTableXYDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression d1.getClass() == d2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   14 | Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   15 | Expression d1.getClass() == d2.getClass() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   16 | Clone fragment #1 returns variables d1 , while Clone fragment #2 returns variables