229-1-2

TimeSeries s1 = new TimeSeries("Series"); TimeSeries s2 = null; try { s2 = (TimeSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // test independence s1.add(new Day(1, 1, 2007), 100.0); assertFalse(s1.equals(s2));
StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); StandardPieToolTipGenerator g2 = null; try { g2 = (StandardPieToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); assertTrue(g1.getNumberFormat() != g2.getNumberFormat()); assertTrue(g1.getPercentFormat() != g2.getPercentFormat());

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/TimeSeriesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/labels/junit/StandardPieToolTipGeneratorTests.java
Method name: `void testBug1832432()` |  | Method name: `void testCloning()`
Number of AST nodes: 9 |  | Number of AST nodes: 9

1

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

2

            TimeSeries s↵

1

    StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();↵

3

    2 = null;↵

2

            StandardPieToolTipGenerator g2 = null;↵

4

            try {↵

3

            try {↵

5

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

4

                g2 = (StandardPieToolTipGenerator) g1.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(g1 != g2);↵

11

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

10

            assertTrue(g1.getClass() == g2.getClass());↵

12

            assertTrue(s1.equals(s2));↵

11

            assertTrue(g1.equals(g2));↵

13

            // test independence↵

12

            ↵

14

            s1.add(new Day(1, 1, 2007), 100.0);↵

13

    assertTrue(g1.getNumberFormat() != g2.getNumberFormat());↵

15

            assertFalse(s1.equals(s2));

14

            assertTrue(g1.getPercentFormat() != g2.getPercentFormat());

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

1. {Non-refactorable}

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

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

   1

       StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();

   1

       TimeSeries s1 = new TimeSeries("Series");

   2

       StandardPieToolTipGenerator g2 = null;

   2

       TimeSeries s2 = null;

   3

       try

   3

       try

   4 | g2 = (StandardPieToolTipGenerator)g1.clone();

   Preondition Violations
   Unmatched statement g2=(StandardPieToolTipGenerator)g1.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

       g2 = (StandardPieToolTipGenerator)g1.clone();

   4

       s2 = (TimeSeries)s1.clone();

   4 | s2 = (TimeSeries)s1.clone();

   Preondition Violations
   Unmatched statement s2=(TimeSeries)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

   5

       assertTrue(g1 != g2);

   5

       assertTrue(s1 != s2);

   5 | assertTrue(s1 != s2);
   7 | assertTrue(g1.equals(g2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 != s2 | g1.equals(g2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(g1.equals(g2));

   6

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

   7

       assertTrue(s1.equals(s2));

   7 | assertTrue(s1.equals(s2));
   6 | assertTrue(g1.getClass() == g2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1.equals(s2) | g1.getClass() == g2.getClass() | TYPE_COMPATIBLE_REPLACEMENT

   6

       assertTrue(g1.getClass() == g2.getClass());

   8

       s1.add(new Day(1, 1, 2007), 100.0);

   8 | s1.add(new Day(1, 1, 2007), 100.0);
   8 | assertTrue(g1.getNumberFormat() != g2.getNumberFormat());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   add | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   s1.add(new Day(1,1,2007),100.0) | assertTrue(g1.getNumberFormat() != g2.getNumberFormat()) | ARGUMENT_NUMBER_MISMATCH
   s1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression s1.add(new Day(1,1,2007),100.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression s1.add(new Day(1,1,2007),100.0) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(g1.getNumberFormat() != g2.getNumberFormat()) is a void method call, and thus it cannot be parameterized
   Expression s1.add(new Day(1,1,2007),100.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression s1.add(new Day(1,1,2007),100.0) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(g1.getNumberFormat() != g2.getNumberFormat()) is a void method call, and thus it cannot be parameterized

   8

       assertTrue(g1.getNumberFormat() != g2.getNumberFormat());

   9

       assertFalse(s1.equals(s2));

   9 | assertFalse(s1.equals(s2));
   9 | assertTrue(g1.getPercentFormat() != g2.getPercentFormat());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertFalse | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   s1.equals(s2) | g1.getPercentFormat() != g2.getPercentFormat() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression assertFalse(s1.equals(s2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertFalse(s1.equals(s2)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(g1.getPercentFormat() != g2.getPercentFormat()) is a void method call, and thus it cannot be parameterized
   Expression s1.equals(s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   9

       assertTrue(g1.getPercentFormat() != g2.getPercentFormat());

   Precondition Violations (12)
   Row | Violation
   --- | ---
   1 | Unmatched statement g2=(StandardPieToolTipGenerator)g1.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 s2=(TimeSeries)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
   3 | Expression s1.add(new Day(1,1,2007),100.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression s1.add(new Day(1,1,2007),100.0) is a void method call, and thus it cannot be parameterized
   5 | Expression assertTrue(g1.getNumberFormat() != g2.getNumberFormat()) is a void method call, and thus it cannot be parameterized
   6 | Expression s1.add(new Day(1,1,2007),100.0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression s1.add(new Day(1,1,2007),100.0) is a void method call, and thus it cannot be parameterized
   8 | Expression assertTrue(g1.getNumberFormat() != g2.getNumberFormat()) is a void method call, and thus it cannot be parameterized
   9 | Expression assertFalse(s1.equals(s2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression assertFalse(s1.equals(s2)) is a void method call, and thus it cannot be parameterized
   11 | Expression assertTrue(g1.getPercentFormat() != g2.getPercentFormat()) is a void method call, and thus it cannot be parameterized
   12 | Expression s1.equals(s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted