DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); d1.setValue(new Integer(1), "V1", "C1"); d1.setValue(null, "V2", "C1"); d1.setValue(new Integer(3), "V3", "C2"); DefaultKeyedValues2DDataset d2 = null; try { d2 = (DefaultKeyedValues2DDataset) 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/DefaultKeyedValues2DDatasetTests.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
DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
1
KeyedObjects ko1 = new 
2
        d1.setValue(
2
KeyedObjects();
3
new Integer(1), "V1", "C1");
3
        ko1.addObject("V1", new Integer(1)
4
        d1.setValue(null, 
4
);
5
"V2", "C1");
5
        ko1.addObject("V2", null);
6
        d1.setValue(new Integer(3), "V3", "C2");
6
        ko1.addObject("V3", new Integer(3));
7
        DefaultKeyedValues2DDataset d2 = null;
7
        KeyedObjects ko2 = null;
8
        try {
8
        try {
9
            d2 = (DefaultKeyedValues2DDataset) d1.clone();
9
            ko2 = (KeyedObjects) ko1.clone();
10
        }
10
        }
11
        catch (CloneNotSupportedException e) {
11
        catch (CloneNotSupportedException e) {
12
            System.err.println("Failed to clone.");
12
            System.err.println("Failed to clone.");
13
        }
13
        }
14
        assertTrue(d1 != d2);
14
        assertTrue(ko1 != ko2);
15
        assertTrue(d1.getClass() == d2.getClass());
15
        assertTrue(ko1.getClass() == ko2.getClass());
16
        assertTrue(d1.equals(d2));
16
        assertTrue(ko1.equals(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 comparisons36
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)107.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    1
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    1
    KeyedObjects ko1 = new KeyedObjects();
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    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
    d1.setValue(new Integer(1), "V1", "C1");
    2
    d1.setValue(new Integer(1), "V1", "C1");
    2
    ko1.addObject("V1", new Integer(1));
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1.setValue(new Integer(1),"V1","C1")ko1.addObject("V1",new Integer(1))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.setValue(new Integer(1),"V1","C1") 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 d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    Expression d1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.setValue(new Integer(1),"V1","C1") 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));
    3
    d1.setValue(null, "V2", "C1");
    3
    d1.setValue(null, "V2", "C1");
    3
    ko1.addObject("V2", null);
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1.setValue(null,"V2","C1")ko1.addObject("V2",null)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.setValue(null,"V2","C1") 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 d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    Expression d1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.setValue(null,"V2","C1") 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);
    4
    d1.setValue(new Integer(3), "V3", "C2");
    4
    d1.setValue(new Integer(3), "V3", "C2");
    4
    ko1.addObject("V3", new Integer(3));
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1.setValue(new Integer(3),"V3","C2")ko1.addObject("V3",new Integer(3))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression d1.setValue(new Integer(3),"V3","C2") 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 d1.setValue(new Integer(3),"V3","C2") 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 d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    Expression d1.setValue(new Integer(3),"V3","C2") 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 d1.setValue(new Integer(3),"V3","C2") 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));
    5
    DefaultKeyedValues2DDataset d2 = null;
    5
    DefaultKeyedValues2DDataset d2 = null;
    5
    KeyedObjects ko2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    5
    KeyedObjects ko2 = null;
    6
    try
    6
    try
    7
    d2 = (DefaultKeyedValues2DDataset)d1.clone();
    7
    d2 = (DefaultKeyedValues2DDataset)d1.clone();
    7
    ko2 = (KeyedObjects)ko1.clone();
    Differences
    Expression1Expression2Difference
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DefaultKeyedValues2DDataset)d1.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
    7
    ko2 = (KeyedObjects)ko1.clone();
    8
    assertTrue(d1 != d2);
    8
    assertTrue(d1 != d2);
    8
    assertTrue(ko1 != ko2);
    Differences
    Expression1Expression2Difference
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(ko1 != ko2);
    9
    assertTrue(d1.getClass() == d2.getClass());
    9
    assertTrue(d1.getClass() == d2.getClass());
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    Differences
    Expression1Expression2Difference
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    10
    assertTrue(d1.equals(d2));
    10
    assertTrue(d1.equals(d2));
    10
    assertTrue(ko1.equals(ko2));
    Differences
    Expression1Expression2Difference
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultKeyedValues2DDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d2 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 d2 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 d1 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));
    Precondition Violations (33)
    Row Violation
    1Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression d1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression d1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    5Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    6Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    7Expression d1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression d1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    10Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    11Expression d1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression d1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    14Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
    15Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    16Expression d1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression d1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    19Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
    20Expression d1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression d1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    23Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    24Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addObject(Comparable#RAW, java.lang.Object)
    25Expression d1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression d1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    28Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    29Expression (DefaultKeyedValues2DDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression d2 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)
    32Expression d2 cannot be unified with expression ko2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    33Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)