DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0)); DefaultKeyedValueDataset d2 = null; try { d2 = (DefaultKeyedValueDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1.equals(d2)); d2.updateValue(new Double(99.9)); assertFalse(d1.equals(d2)); d2.updateValue(new Double(10.0)); assertTrue(d1.equals(d2));
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));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultKeyedValueDatasetTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValueTests.java
Method name: void testCloneIndependence() Method name: void testCloning()
Number of AST nodes: 9 Number of AST nodes: 9
1
DefaultKeyedValueDataset d1 
1
DefaultKeyedValue
2
            = new DefaultKeyedValueDataset("Key", new Double(10.0));
2
 v1 = new DefaultKeyedValue("Test", new Double(45.5));
3
        DefaultKeyedValueDataset d2 = null;
3
        DefaultKeyedValue v2 = null;
4
        try {
4
        try {
5
            d2 = (DefaultKeyedValueDataset) d1.clone();
5
            v2 = (DefaultKeyedValue) v1.clone();
6
        }
6
        }
7
        catch (CloneNotSupportedException e) {
7
        catch (CloneNotSupportedException e) {
8
            System.err.println("Failed to clone.");
8
            System.err.println("Failed to clone.");
9
        }
9
        }
10
        assertTrue(d1.equals(d2));
10
        assertTrue(
11
        d2.updateValue(new Double(99.9
11
v1 != v2);
12
));
12
        assertTrue(v1.getClass() == v2.getClass());
13
        assertFalse(d1.equals(d2));
13
        assertTrue(v1.equals(v2));
14
        d2.update
14
        
15
        // confirm that the clone is independent of the original
15
Value(new Double(10.0));
16
        v2.setValue(new Double(12.3));
16
        assertTrue(d1.equals(d2));
17
        assertFalse(v1.equals(v2));
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 comparisons29
  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 fragment1
    Time elapsed for statement mapping (ms)16.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0));
    1
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0));
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    d1v1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    "Key""Test"LITERAL_VALUE_MISMATCH
    10.045.5LITERAL_VALUE_MISMATCH
    Preondition Violations
    Expression new DefaultKeyedValueDataset("Key",new Double(10.0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    2
    DefaultKeyedValueDataset d2 = null;
    2
    DefaultKeyedValueDataset d2 = null;
    2
    DefaultKeyedValue v2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    d2v2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    2
    DefaultKeyedValue v2 = null;
    3
    try
    3
    try
    4
    d2 = (DefaultKeyedValueDataset)d1.clone();
    4
    d2 = (DefaultKeyedValueDataset)d1.clone();
    4
    v2 = (DefaultKeyedValue)v1.clone();
    Differences
    Expression1Expression2Difference
    d2v2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    d1v1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    Expression (DefaultKeyedValueDataset)d1.clone() 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 (DefaultKeyedValueDataset)d1.clone() cannot be unified with expression (DefaultKeyedValue)v1.clone() , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    4
    v2 = (DefaultKeyedValue)v1.clone();
                                                                                                
    6
    assertTrue(v1.getClass() == v2.getClass());
    Preondition Violations
    Unmatched statement assertTrue(v1.getClass() == v2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    assertTrue(v1.getClass() == v2.getClass());
    5
    assertTrue(d1.equals(d2));
    5
    assertTrue(d1.equals(d2));
    7
    assertTrue(v1.equals(v2));
    Differences
    Expression1Expression2Difference
    d2v2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    d1v1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 cannot be unified with expression v2 , because common superclass type org.jfree.data.KeyedValue cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    7
    assertTrue(v1.equals(v2));
    6
    d2.updateValue(new Double(99.9));
    6
    d2.updateValue(new Double(99.9));
    Preondition Violations
    Unmatched statement d2.updateValue(new Double(99.9)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    7
    assertFalse(d1.equals(d2));
    7
    assertFalse(d1.equals(d2));
    9
    assertFalse(v1.equals(v2));
    Differences
    Expression1Expression2Difference
    d2v2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    d1v1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 cannot be unified with expression v2 , because common superclass type org.jfree.data.KeyedValue cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    9
    assertFalse(v1.equals(v2));
    8
    d2.updateValue(new Double(10.0));
    8
    d2.updateValue(new Double(10.0));
    8
    v2.setValue(new Double(12.3));
    Differences
    Expression1Expression2Difference
    10.012.3LITERAL_VALUE_MISMATCH
    updateValuesetValueMETHOD_INVOCATION_NAME_MISMATCH
    d2v2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValueDatasetorg.jfree.data.DefaultKeyedValueSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2.updateValue(new Double(10.0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d2.updateValue(new Double(10.0)) is a void method call, and thus it cannot be parameterized
    Expression v2.setValue(new Double(12.3)) is a void method call, and thus it cannot be parameterized
    Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public void updateValue(java.lang.Number) , public synchronized void setValue(java.lang.Number)
    8
    v2.setValue(new Double(12.3));
    9
    assertTrue(d1.equals(d2));
    9
    assertTrue(d1.equals(d2));
    5
    assertTrue(v1 != v2);
    Differences
    Expression1Expression2Difference
    d1.equals(d2)v1 != v2TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1 != v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    assertTrue(v1 != v2);
    Precondition Violations (23)
    Row Violation
    1Expression new DefaultKeyedValueDataset("Key",new Double(10.0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    4Expression (DefaultKeyedValueDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression (DefaultKeyedValueDataset)d1.clone() cannot be unified with expression (DefaultKeyedValue)v1.clone() , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    7Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public java.lang.Object clone() throws java.lang.CloneNotSupportedException
    8Unmatched statement assertTrue(v1.getClass() == v2.getClass()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression d2 cannot be unified with expression v2 , because common superclass type org.jfree.data.KeyedValue cannot be passed as an argument to public boolean equals(java.lang.Object)
    10Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    11Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    12Unmatched statement d2.updateValue(new Double(99.9)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Expression d2 cannot be unified with expression v2 , because common superclass type org.jfree.data.KeyedValue cannot be passed as an argument to public boolean equals(java.lang.Object)
    14Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    15Expression d1 cannot be unified with expression v1 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public boolean equals(java.lang.Object)
    16Expression d2.updateValue(new Double(10.0)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression v2.setValue(new Double(12.3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression d2.updateValue(new Double(10.0)) is a void method call, and thus it cannot be parameterized
    19Expression v2.setValue(new Double(12.3)) is a void method call, and thus it cannot be parameterized
    20Expression d2 cannot be unified with expression v2 , because common superclass org.jfree.data.KeyedValue does not declare member(s) public void updateValue(java.lang.Number) , public synchronized void setValue(java.lang.Number)
    21Expression d1.equals(d2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression v1 != v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Clone fragment #1 returns variables d2 , while Clone fragment #2 returns variables v1, v2