DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); DefaultKeyedValue v2 = null; try { v2 = (DefaultKeyedValue) v1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // confirm that the clone is independent of the original v2.setValue(new Double(12.3)); assertFalse(v1.equals(v2));
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/junit/DefaultKeyedValueTests.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: 9 Number of AST nodes: 10
1
DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
2
        DefaultKeyedValue v
1
KeyedObjects ko1 = new KeyedObjects();
2
        ko1.addObject("V1", new Integer(1));
3
        ko1.addObject("V2", null);
4
        ko1.addObject("V3", new Integer(3));
3
2 = null;
5
        KeyedObjects ko2 = null;
4
        try {
6
        try {
5
            v2 = (DefaultKeyedValue) v1.clone();
7
            ko2 = (KeyedObjects) ko1.clone();
6
        }
8
        }
7
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
8
            System.err.println("Failed to clone.");
10
            System.err.println("Failed to clone.");
9
        }
11
        }
10
        assertTrue(v1 != v2);
12
        assertTrue(ko1 != ko2);
11
        assertTrue(v1.getClass() == v2.getClass());
13
        assertTrue(ko1.getClass() == ko2.getClass());
12
        assertTrue(v1.equals(v2));
14
        assertTrue(ko1.equals(
13
        
14
        // confirm that the clone is independent of the original
15
        v2.setValue(new Double(12.3));
16
        assertFalse(v1.equals(v2));
15
ko2));
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons44
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)19.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    5
    KeyedObjects ko2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v1ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    new DefaultKeyedValue("Test",new Double(45.5))nullTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    KeyedObjects ko2 = null;
    2
    DefaultKeyedValue v2 = null;
    2
    DefaultKeyedValue v2 = null;
    1
    KeyedObjects ko1 = new KeyedObjects();
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v2ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    nullnew KeyedObjects()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    KeyedObjects ko1 = new KeyedObjects();
                                                                                
    2
    ko1.addObject("V1", new Integer(1));
    Preondition Violations
    Unmatched statement ko1.addObject("V1",new Integer(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    ko1.addObject("V1", new Integer(1));
                                                            
    3
    ko1.addObject("V2", null);
    Preondition Violations
    Unmatched statement ko1.addObject("V2",null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    ko1.addObject("V2", null);
    3
    try
    6
    try
    4
    v2 = (DefaultKeyedValue)v1.clone();
    4
    v2 = (DefaultKeyedValue)v1.clone();
    7
    ko2 = (KeyedObjects)ko1.clone();
    Differences
    Expression1Expression2Difference
    v2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    ko2 = (KeyedObjects)ko1.clone();
    5
    assertTrue(v1 != v2);
    5
    assertTrue(v1 != v2);
    8
    assertTrue(ko1 != ko2);
    Differences
    Expression1Expression2Difference
    v1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    assertTrue(ko1 != ko2);
    6
    assertTrue(v1.getClass() == v2.getClass());
    6
    assertTrue(v1.getClass() == v2.getClass());
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    Differences
    Expression1Expression2Difference
    v1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.KeyedObjects> getClass()
    Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2 cannot be unified with expression ko2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.KeyedObjects> getClass()
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    7
    assertTrue(v1.equals(v2));
    7
    assertTrue(v1.equals(v2));
    10
    assertTrue(ko1.equals(ko2));
    Differences
    Expression1Expression2Difference
    v2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2 cannot be unified with expression ko2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression v2 cannot be unified with expression ko2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertTrue(ko1.equals(ko2));
    8
    v2.setValue(new Double(12.3));
    8
    v2.setValue(new Double(12.3));
    4
    ko1.addObject("V3", new Integer(3));
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    v2ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    v2.setValue(new Double(12.3))ko1.addObject("V3",new Integer(3))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2.setValue(new Double(12.3)) 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 v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public synchronized void setValue(java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2.setValue(new Double(12.3)) 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
    assertFalse(v1.equals(v2));
    9
    assertFalse(v1.equals(v2));
    Preondition Violations
    Unmatched statement assertFalse(v1.equals(v2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                
    Precondition Violations (40)
    Row Violation
    1Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement ko1.addObject("V1",new Integer(1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement ko1.addObject("V2",null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression v1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.KeyedObjects> getClass()
    18Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression v2 cannot be unified with expression ko2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.KeyedObjects> getClass()
    21Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression ko2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression v2 cannot be unified with expression ko2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    24Expression v2 cannot be unified with expression ko2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    25Expression v1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression v1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    28Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression v2.setValue(new Double(12.3)) is a void method call, and thus it cannot be parameterized
    31Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    32Expression v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    34Expression v2 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public synchronized void setValue(java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    35Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    36Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    37Expression v2.setValue(new Double(12.3)) is a void method call, and thus it cannot be parameterized
    38Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    39Unmatched statement assertFalse(v1.equals(v2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    40Clone fragment #1 returns variables v1, v2 , while Clone fragment #2 returns variables