140-1-2

PaintMap m1 = new PaintMap(); PaintMap m2 = null; try { m2 = (PaintMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", Color.red); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); try { m2 = (PaintMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2));
StrokeMap m1 = new StrokeMap(); StrokeMap m2 = null; try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2));

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

1

    PaintMap m1 = new PaintMap();↵

1

    StrokeMap m1 = new StrokeMap();↵

2

            PaintMap m2 = null;↵

2

            StrokeMap m2 = null;↵

3

            try {↵

3

            try {↵

4

                m2 = (PaintMap) m1.clone();↵

4

                m2 = (StrokeMap) m1.clone();↵

5

            }↵

5

            }↵

6

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

7

                e.printStackTrace();↵

7

                e.printStackTrace();↵

8

            }↵

8

            }↵

9

            assertTrue(m1.equals(m2));↵

9

            assertTrue(m1.equals(m2));↵

10

            ↵

10

            ↵

11

            m1.put("K1", Color.red);↵

11

            m1.put("K1", new BasicStroke(1.1f));↵

12

            m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, ↵

12

            m1.put("K2", new ↵

13

                    Color.yellow));↵

13

    BasicStroke(2.2f));↵

14

            try {↵

14

            try {↵

15

                m2 = (PaintMap) m1.clone();↵

15

                m2 = (StrokeMap) m1.clone();↵

16

            }↵

16

            }↵

17

            catch (CloneNotSupportedException e) {↵

17

            catch (CloneNotSupportedException e) {↵

18

                e.printStackTrace();↵

18

                e.printStackTrace();↵

19

            }↵

19

            }↵

20

            assertTrue(m1.equals(m2));

20

            assertTrue(m1.equals(m2));

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.3
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 43

1. {Non-refactorable}

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

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

   1

       StrokeMap m1 = new StrokeMap();

   1

       PaintMap m1 = new PaintMap();

   2

       StrokeMap m2 = null;

   2

       PaintMap m2 = null;

   3

       try

   3

       try

   4 | m2 = (StrokeMap)m1.clone();

   Preondition Violations
   Unmatched statement m2=(StrokeMap)m1.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

       m2 = (StrokeMap)m1.clone();

   4

       m2 = (PaintMap)m1.clone();

   4 | m2 = (PaintMap)m1.clone();

   Preondition Violations
   Unmatched statement m2=(PaintMap)m1.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

       assertTrue(m1.equals(m2));

   5 | assertTrue(m1.equals(m2));
   5 | assertTrue(m1.equals(m2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.PaintMap | org.jfree.chart.StrokeMap | VARIABLE_TYPE_MISMATCH
   org.jfree.chart.PaintMap | org.jfree.chart.StrokeMap | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.PaintMap of variable m2 does not match with type org.jfree.chart.StrokeMap of variable m2
   - Make classes org.jfree.chart.PaintMap and org.jfree.chart.StrokeMap extend a common superclass

   Type org.jfree.chart.PaintMap of variable m1 does not match with type org.jfree.chart.StrokeMap of variable m1
   - Make classes org.jfree.chart.PaintMap and org.jfree.chart.StrokeMap extend a common superclass

   5

       assertTrue(m1.equals(m2));

   6 | m1.put("K1", new BasicStroke(1.1f));

   Preondition Violations
   Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   6

       m1.put("K1", new BasicStroke(1.1f));

   6

       m1.put("K1", Color.red);

   6 | m1.put("K1", Color.red);
   10 | assertTrue(m1.equals(m2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   put | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   m1.put("K1",Color.red) | assertTrue(m1.equals(m2)) | ARGUMENT_NUMBER_MISMATCH
   m1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression m1.put("K1",Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression m1.put("K1",Color.red) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   Expression m1.put("K1",Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression m1.put("K1",Color.red) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized

   10

       assertTrue(m1.equals(m2));

   7

       m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow));

   7 | m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow));

   Preondition Violations
   Unmatched statement m1.put("K2",new GradientPaint(1.0f,2.0f,Color.green,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   8

       try

   8

       try

   9 | m2 = (StrokeMap)m1.clone();

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

   9

       m2 = (StrokeMap)m1.clone();

   9

       m2 = (PaintMap)m1.clone();

   9 | m2 = (PaintMap)m1.clone();

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

   10

       assertTrue(m1.equals(m2));

   10 | assertTrue(m1.equals(m2));
   7 | m1.put("K2", new BasicStroke(2.2f));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | put | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(m1.equals(m2)) | m1.put("K2",new BasicStroke(2.2f)) | ARGUMENT_NUMBER_MISMATCH
   | m1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   Expression m1.put("K2",new BasicStroke(2.2f)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   Expression m1.put("K2",new BasicStroke(2.2f)) is a void method call, and thus it cannot be parameterized

   7

       m1.put("K2", new BasicStroke(2.2f));

   Precondition Violations (24)
   Row | Violation
   --- | ---
   1 | Unmatched statement m2=(StrokeMap)m1.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
   2 | Unmatched statement m2=(PaintMap)m1.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 | Type org.jfree.chart.PaintMap of variable m2 does not match with type org.jfree.chart.StrokeMap of variable m2
   4 | Type org.jfree.chart.PaintMap of variable m1 does not match with type org.jfree.chart.StrokeMap of variable m1
   5 | Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Expression m1.put("K1",Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression m1.put("K1",Color.red) is a void method call, and thus it cannot be parameterized
   9 | Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   10 | Expression m1.put("K1",Color.red) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression m1.put("K1",Color.red) is a void method call, and thus it cannot be parameterized
   13 | Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   14 | Unmatched statement m1.put("K2",new GradientPaint(1.0f,2.0f,Color.green,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   15 | Unmatched statement m2=(StrokeMap)m1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   16 | Unmatched statement m2=(StrokeMap)m1.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
   17 | Unmatched statement m2=(PaintMap)m1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   18 | Unmatched statement m2=(PaintMap)m1.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
   19 | Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   20 | Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   21 | Expression m1.put("K2",new BasicStroke(2.2f)) is a void method call, and thus it cannot be parameterized
   22 | Expression assertTrue(m1.equals(m2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   23 | Expression assertTrue(m1.equals(m2)) is a void method call, and thus it cannot be parameterized
   24 | Expression m1.put("K2",new BasicStroke(2.2f)) is a void method call, and thus it cannot be parameterized