218-5-7

XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = null; try { s2 = (XYSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2));
DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); DefaultHighLowDataset d2 = null; try { d2 = (DefaultHighLowDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } 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/xy/junit/XYSeriesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultHighLowDatasetTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    XYSeries s1 = new XYSeries("Series");↵

1

    DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series↵

2

     1",↵

2

            s1.add(1.0, 1.1);↵

3

             ↵

3

            XYSeries s↵

4

           new Date[] {new Date(123L)}, new double[] {1.2},↵

5

                    new double[] {3.4}, new double[] {5.6}, new double[] {7.8},↵

6

                    new double[] {99.9});↵

4

    2 = null;↵

7

            DefaultHighLowDataset d2 = null;↵

5

            try {↵

8

            try {↵

6

                s2 = (XYSeries) s1.clone();↵

9

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

7

            }↵

10

            }↵

8

            catch (CloneNotSupportedException e) {↵

11

            catch (CloneNotSupportedException e) {↵

9

                e.printStackTrace();↵

12

                e.printStackTrace();↵

10

            }↵

13

            }↵

11

            assertTrue(s1 != s2);↵

14

            assertTrue(d1 != d2);↵

12

            assertTrue(s1.getClass() == s2.getClass());↵

15

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

13

            assertTrue(s1.equals(s2));

16

            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.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) | 12.2
   Clone type | Type 3

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

   1

       DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9});

   1

       XYSeries s1 = new XYSeries("Series");

   2

       DefaultHighLowDataset d2 = null;

   2

       s1.add(1.0, 1.1);

   2 | s1.add(1.0, 1.1);
   6 | assertTrue(d1.getClass() == d2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   add | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   s1.add(1.0,1.1) | assertTrue(d1.getClass() == d2.getClass()) | ARGUMENT_NUMBER_MISMATCH
   s1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized

   6

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

   3

       XYSeries s2 = null;

   4

       try

   3

       try

   4 | d2 = (DefaultHighLowDataset)d1.clone();

   Preondition Violations
   Unmatched statement d2=(DefaultHighLowDataset)d1.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

       d2 = (DefaultHighLowDataset)d1.clone();

   5

       s2 = (XYSeries)s1.clone();

   5 | s2 = (XYSeries)s1.clone();

   Preondition Violations
   Unmatched statement s2=(XYSeries)s1.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(s1 != s2);

   7

       assertTrue(s1.getClass() == s2.getClass());

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

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

   7

       assertTrue(d1.equals(d2));

   8

       assertTrue(s1.equals(s2));

   8 | assertTrue(s1.equals(s2));
   5 | assertTrue(d1 != d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1.equals(s2) | d1 != d2 | TYPE_COMPATIBLE_REPLACEMENT

   5

       assertTrue(d1 != d2);

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
   2 | Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   3 | Expression s1.add(1.0,1.1) is a void method call, and thus it cannot be parameterized
   4 | Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   5 | Unmatched statement d2=(DefaultHighLowDataset)d1.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 | Unmatched statement s2=(XYSeries)s1.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