153-3-4

DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("V1", new Integer(1)); d1.setValue("V2", null); d1.setValue("V3", new Integer(3)); DefaultKeyedValuesDataset d2 = null; try { d2 = (DefaultKeyedValuesDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2));
KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("V1", new Integer(1)); ko1.addObject("V2", null); ko1.addObject("V3", new Integer(3)); KeyedObjects ko2 = null; try { ko2 = (KeyedObjects) ko1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2));

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

1

    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();↵

1

    KeyedObjects ko1 = new ↵

2

            d1.setValue↵

2

    KeyedObjects();↵

3

    ("V1", new Integer(1));↵

3

            ko1.addObject("V1", new Integer(1));↵

4

            d1.setValue("V2", null);↵

4

            ko1.addObject("V2", null);↵

5

            d1.setValue("V3", new Integer(3));↵

5

            ko1.addObject("V3", new Integer(3));↵

6

            DefaultKeyedValuesDataset d2 = null;↵

6

            KeyedObjects ko2 = null;↵

7

            try {↵

7

            try {↵

8

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

8

                ko2 = (KeyedObjects) ko1.clone();↵

9

            }↵

9

            }↵

10

            catch (CloneNotSupportedException e) {↵

10

            catch (CloneNotSupportedException e) {↵

11

                System.err.println("Failed to clone.");↵

11

                System.err.println("Failed to clone.");↵

12

            }↵

12

            }↵

13

            assertTrue(d1 != d2);↵

13

            assertTrue(ko1 != ko2);↵

14

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

14

            assertTrue(ko1.getClass() == ko2.getClass());↵

15

            assertTrue(d1.equals(d2));

15

            assertTrue(ko1.equals(ko2));

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

1. {Non-refactorable}

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

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

   1

       KeyedObjects ko1 = new KeyedObjects();

   1

       DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();

   5

       KeyedObjects ko2 = null;

   2

       d1.setValue("V1", new Integer(1));

   2 | d1.setValue("V1", new Integer(1));
   10 | assertTrue(ko1.equals(ko2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setValue | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   d1.setValue("V1",new Integer(1)) | assertTrue(ko1.equals(ko2)) | ARGUMENT_NUMBER_MISMATCH
   d1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(ko1.equals(ko2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1.equals(ko2)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1.equals(ko2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1.equals(ko2)) is a void method call, and thus it cannot be parameterized

   10

       assertTrue(ko1.equals(ko2));

   3

       d1.setValue("V2", null);

   3 | d1.setValue("V2", null);
   9 | assertTrue(ko1.getClass() == ko2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setValue | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   d1.setValue("V2",null) | assertTrue(ko1.getClass() == ko2.getClass()) | ARGUMENT_NUMBER_MISMATCH
   d1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression d1.setValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V2",null) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1.getClass() == ko2.getClass()) is a void method call, and thus it cannot be parameterized
   Expression d1.setValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V2",null) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1.getClass() == ko2.getClass()) is a void method call, and thus it cannot be parameterized

   9

       assertTrue(ko1.getClass() == ko2.getClass());

   4

       d1.setValue("V3", new Integer(3));

   4 | d1.setValue("V3", new Integer(3));
   8 | assertTrue(ko1 != ko2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setValue | assertTrue | METHOD_INVOCATION_NAME_MISMATCH
   d1.setValue("V3",new Integer(3)) | assertTrue(ko1 != ko2) | ARGUMENT_NUMBER_MISMATCH
   d1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression d1.setValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1 != ko2) is a void method call, and thus it cannot be parameterized
   Expression d1.setValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression d1.setValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(ko1 != ko2) is a void method call, and thus it cannot be parameterized

   8

       assertTrue(ko1 != ko2);

   5

       DefaultKeyedValuesDataset d2 = null;

   6

       try

   6

       try

   7 | ko2 = (KeyedObjects)ko1.clone();

   Preondition Violations
   Unmatched statement ko2=(KeyedObjects)ko1.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

       ko2 = (KeyedObjects)ko1.clone();

   7

       d2 = (DefaultKeyedValuesDataset)d1.clone();

   7 | d2 = (DefaultKeyedValuesDataset)d1.clone();

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

   8

       assertTrue(d1 != d2);

   8 | assertTrue(d1 != d2);
   4 | ko1.addObject("V3", new Integer(3));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | addObject | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(d1 != d2) | ko1.addObject("V3",new Integer(3)) | ARGUMENT_NUMBER_MISMATCH
   | ko1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1 != d2) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1 != d2) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized

   4

       ko1.addObject("V3", new Integer(3));

   9

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

   9 | assertTrue(d1.getClass() == d2.getClass());
   3 | ko1.addObject("V2", null);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | addObject | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(d1.getClass() == d2.getClass()) | ko1.addObject("V2",null) | ARGUMENT_NUMBER_MISMATCH
   | ko1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized

   3

       ko1.addObject("V2", null);

   10

       assertTrue(d1.equals(d2));

   10 | assertTrue(d1.equals(d2));
   2 | ko1.addObject("V1", new Integer(1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | addObject | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(d1.equals(d2)) | ko1.addObject("V1",new Integer(1)) | ARGUMENT_NUMBER_MISMATCH
   | ko1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
   Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized

   2

       ko1.addObject("V1", new Integer(1));

   Precondition Violations (39)
   Row | Violation
   --- | ---
   1 | Expression assertTrue(ko1.equals(ko2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   3 | Expression assertTrue(ko1.equals(ko2)) is a void method call, and thus it cannot be parameterized
   4 | Expression assertTrue(ko1.equals(ko2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   6 | Expression assertTrue(ko1.equals(ko2)) is a void method call, and thus it cannot be parameterized
   7 | Expression d1.setValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression d1.setValue("V2",null) is a void method call, and thus it cannot be parameterized
   9 | Expression assertTrue(ko1.getClass() == ko2.getClass()) is a void method call, and thus it cannot be parameterized
   10 | Expression d1.setValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression d1.setValue("V2",null) is a void method call, and thus it cannot be parameterized
   12 | Expression assertTrue(ko1.getClass() == ko2.getClass()) is a void method call, and thus it cannot be parameterized
   13 | Expression d1.setValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   14 | Expression d1.setValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   15 | Expression assertTrue(ko1 != ko2) is a void method call, and thus it cannot be parameterized
   16 | Expression d1.setValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   17 | Expression d1.setValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   18 | Expression assertTrue(ko1 != ko2) is a void method call, and thus it cannot be parameterized
   19 | Unmatched statement ko2=(KeyedObjects)ko1.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
   20 | Unmatched statement d2=(DefaultKeyedValuesDataset)d1.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   21 | Unmatched statement d2=(DefaultKeyedValuesDataset)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
   22 | Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   23 | Expression assertTrue(d1 != d2) is a void method call, and thus it cannot be parameterized
   24 | Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   25 | Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   26 | Expression assertTrue(d1 != d2) is a void method call, and thus it cannot be parameterized
   27 | Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
   28 | Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   29 | Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   30 | Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
   31 | Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   32 | Expression assertTrue(d1.getClass() == d2.getClass()) is a void method call, and thus it cannot be parameterized
   33 | Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
   34 | Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   35 | Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
   36 | Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
   37 | Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   38 | Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
   39 | Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized