423-1-2

PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { c2 = (StandardEntityCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence c1.clear(); assertFalse(c1.equals(c2)); c2.clear(); assertTrue(c1.equals(c2));
XYPlot p1 = new XYPlot(); p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check for independence p1.setQuadrantPaint(1, Color.red); assertFalse(p1.equals(p2)); p2.setQuadrantPaint(1, Color.red); assertTrue(p1.equals(p2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning_QuadrantPaint()`
Number of AST nodes: 13 |  | Number of AST nodes: 12

1

    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, ↵

2

                    2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", ↵

3

                    "ToolTip", "URL");↵

4

            StandardEntityCollection c1 = new StandardEntityCollection();↵

5

            c1.add(e1);↵

6

            StandardEntityCollection c↵

1

    XYPlot p1 = new XYPlot();↵

2

            p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, ↵

3

                    3.0f, 4.0f, Color.blue));↵

7

    2 = null;↵

4

            XYPlot p2 = null;↵

8

            try {↵

5

            try {↵

9

                c2 = (StandardEntityCollection) c1.clone();↵

6

                p2 = (XYPlot) p1.clone();↵

10

            }↵

7

            }↵

11

            catch (CloneNotSupportedException e) {↵

8

            catch (CloneNotSupportedException e) {↵

12

                e.printStackTrace();↵

9

                e.printStackTrace();↵

13

            }↵

10

            }↵

14

            assertTrue(c1 != c2);↵

11

            assertTrue(p1 != p2);↵

15

            assertTrue(c1.getClass() == c2.getClass());↵

12

            assertTrue(p1.getClass() == p2.getClass());↵

16

            assertTrue(c1.equals(c2));↵

13

            assertTrue(p1.equals(p2));↵

17

            ↵

14

            ↵

18

            // check independence↵

15

            // check for independence↵

19

            c1.clear();↵

16

            p1.setQuadrantPaint(1, Color.red);↵

20

            assertFalse(c1.equals(c2));↵

17

            assertFalse(p1.equals(p2));↵

21

            c2.clear();↵

18

            p2.setQuadrantPaint(1, Color.red);↵

22

            assertTrue(c1.equals(c2));

19

            assertTrue(p1.equals(p2));

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

1. {Non-refactorable}

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

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

   1

       XYPlot p1 = new XYPlot();

   1

       PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");

   2

       StandardEntityCollection c1 = new StandardEntityCollection();

   3

       c1.add(e1);

   4

       StandardEntityCollection c2 = null;

   5

       try

   4

       try

   5 | p2 = (XYPlot)p1.clone();

   Preondition Violations
   Unmatched statement p2=(XYPlot)p1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched statement p2=(XYPlot)p1.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

   5

       p2 = (XYPlot)p1.clone();

   6

       c2 = (StandardEntityCollection)c1.clone();

   6 | c2 = (StandardEntityCollection)c1.clone();

   Preondition Violations
   Unmatched statement c2=(StandardEntityCollection)c1.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

   7

       assertTrue(c1 != c2);

   7 | assertTrue(c1 != c2);
   2 | p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | setQuadrantPaint | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(c1 != c2) | p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) | ARGUMENT_NUMBER_MISMATCH
   | p1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(c1 != c2) is a void method call, and thus it cannot be parameterized
   Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(c1 != c2) is a void method call, and thus it cannot be parameterized
   Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized

   2

       p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));

   3

       XYPlot p2 = null;

   8

       assertTrue(c1.getClass() == c2.getClass());

   8 | assertTrue(c1.getClass() == c2.getClass());
   8 | assertTrue(p1.equals(p2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   c1.getClass() == c2.getClass() | p1.equals(p2) | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression p1.equals(p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   8

       assertTrue(p1.equals(p2));

   9

       assertTrue(c1.equals(c2));

   9 | assertTrue(c1.equals(c2));
   7 | assertTrue(p1.getClass() == p2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   c1.equals(c2) | p1.getClass() == p2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(p1.getClass() == p2.getClass());

   10

       c1.clear();

   10 | c1.clear();
   10 | assertFalse(p1.equals(p2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   clear | assertFalse | METHOD_INVOCATION_NAME_MISMATCH
   c1.clear() | assertFalse(p1.equals(p2)) | ARGUMENT_NUMBER_MISMATCH
   c1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression c1.clear() is a void method call, and thus it cannot be parameterized
   Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression c1.clear() is a void method call, and thus it cannot be parameterized
   Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized

   10

       assertFalse(p1.equals(p2));

   11

       assertFalse(c1.equals(c2));

   11 | assertFalse(c1.equals(c2));
   9 | p1.setQuadrantPaint(1, Color.red);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertFalse | setQuadrantPaint | METHOD_INVOCATION_NAME_MISMATCH
   assertFalse(c1.equals(c2)) | p1.setQuadrantPaint(1,Color.red) | ARGUMENT_NUMBER_MISMATCH
   | p1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertFalse(c1.equals(c2)) is a void method call, and thus it cannot be parameterized
   Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
   Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertFalse(c1.equals(c2)) is a void method call, and thus it cannot be parameterized
   Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized

   9

       p1.setQuadrantPaint(1, Color.red);

   12

       c2.clear();

   12 | c2.clear();
   12 | assertTrue(p1.equals(p2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   clear | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   c2.clear() | assertTrue(p1.equals(p2)) | ARGUMENT_NUMBER_MISMATCH
   c2 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression c2.clear() is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression c2.clear() is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized

   12

       assertTrue(p1.equals(p2));

   13

       assertTrue(c1.equals(c2));

   13 | assertTrue(c1.equals(c2));
   6 | assertTrue(p1 != p2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   c1.equals(c2) | p1 != p2 | TYPE_COMPATIBLE_REPLACEMENT

   6

       assertTrue(p1 != p2);

   11

       p2.setQuadrantPaint(1, Color.red);

   Precondition Violations (26)
   Row | Violation
   --- | ---
   1 | Unmatched statement p2=(XYPlot)p1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement p2=(XYPlot)p1.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
   3 | Unmatched statement c2=(StandardEntityCollection)c1.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 | Expression assertTrue(c1 != c2) is a void method call, and thus it cannot be parameterized
   5 | Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
   6 | Expression assertTrue(c1 != c2) is a void method call, and thus it cannot be parameterized
   7 | Expression p1.setQuadrantPaint(3,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
   8 | Expression p1.equals(p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression c1.clear() is a void method call, and thus it cannot be parameterized
   11 | Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   12 | Expression assertFalse(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Expression c1.clear() is a void method call, and thus it cannot be parameterized
   14 | Expression assertFalse(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   15 | Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   16 | Expression assertFalse(c1.equals(c2)) is a void method call, and thus it cannot be parameterized
   17 | Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
   18 | Expression p1.setQuadrantPaint(1,Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   19 | Expression assertFalse(c1.equals(c2)) is a void method call, and thus it cannot be parameterized
   20 | Expression p1.setQuadrantPaint(1,Color.red) is a void method call, and thus it cannot be parameterized
   21 | Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   22 | Expression c2.clear() is a void method call, and thus it cannot be parameterized
   23 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   24 | Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   25 | Expression c2.clear() is a void method call, and thus it cannot be parameterized
   26 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized