218-2-10

VectorSeries s1 = new VectorSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); VectorSeries s2 = null; try { s2 = (VectorSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2));
OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCItem item2 = null; try { item2 = (OHLCItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/VectorSeriesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/time/ohlc/junit/OHLCItemTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    VectorSeries s1 = new VectorSeries("s1");↵

2

            s1.add(1.0, 0.5, 1.5, 2.0);↵

1

    OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0);↵

3

            VectorSeries s2 = null;↵

2

            OHLCItem item2 = null;↵

4

            try {↵

3

            try {↵

5

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

4

                item2 = (OHLCItem) item1.clone();↵

6

            }↵

5

            }↵

7

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

8

                e.printStackTrace();↵

7

                e.printStackTrace();↵

9

            }↵

8

            }↵

10

            assertTrue(s1 != s2);↵

9

            assertTrue(item1 != item2);↵

11

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

10

            assertTrue(item1.getClass() == item2.getClass());↵

12

            assertTrue(s1.equals(s2));

11

            assertTrue(item1.equals(item2));

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

1. {Non-refactorable}

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

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

   1

       VectorSeries s1 = new VectorSeries("s1");

   1 | VectorSeries s1 = new VectorSeries("s1");
   1 | OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | item1 | VARIABLE_NAME_MISMATCH
   new VectorSeries("s1") | new OHLCItem(new Year(2006),2.0,4.0,1.0,3.0) | ARGUMENT_NUMBER_MISMATCH

   1

       OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0);

   2

       s1.add(1.0, 0.5, 1.5, 2.0);

   3

       VectorSeries s2 = null;

   3 | VectorSeries s2 = null;
   2 | OHLCItem item2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | item2 | VARIABLE_NAME_MISMATCH

   2

       OHLCItem item2 = null;

   4

       try

   3

       try

   5

       s2 = (VectorSeries)s1.clone();

   5 | s2 = (VectorSeries)s1.clone();
   4 | item2 = (OHLCItem)item1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | item2 | VARIABLE_NAME_MISMATCH
   s1 | item1 | VARIABLE_NAME_MISMATCH

   4

       item2 = (OHLCItem)item1.clone();

   6

       assertTrue(s1 != s2);

   6 | assertTrue(s1 != s2);
   5 | assertTrue(item1 != item2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | item1 | VARIABLE_NAME_MISMATCH
   s2 | item2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(item1 != item2);

   7

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

   7 | assertTrue(s1.getClass() == s2.getClass());
   6 | assertTrue(item1.getClass() == item2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | item1 | VARIABLE_NAME_MISMATCH
   s2 | item2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(item1.getClass() == item2.getClass());

   8

       assertTrue(s1.equals(s2));

   8 | assertTrue(s1.equals(s2));
   7 | assertTrue(item1.equals(item2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | item2 | VARIABLE_NAME_MISMATCH
   s1 | item1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(item1.equals(item2));

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variables s1 , while Clone fragment #2 returns variables