DefaultKeyedValues2D v1 = new DefaultKeyedValues2D(); v1.setValue(new Integer(1), "V1", "C1"); v1.setValue(null, "V2", "C1"); v1.setValue(new Integer(3), "V3", "C2"); DefaultKeyedValues2D v2 = null; try { v2 = (DefaultKeyedValues2D) v1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // check that clone is independent of the original v2.setValue(new Integer(2), "V2", "C1"); assertFalse(v1.equals(v2));
DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("V1", new Integer(1)); v1.addValue("V2", null); v1.addValue("V3", new Integer(3)); DefaultKeyedValues v2 = null; try { v2 = (DefaultKeyedValues) 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("V1", new Integer(44)); assertFalse(v1.equals(v2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 12 Number of AST nodes: 12
1
DefaultKeyedValues2D v1 = new DefaultKeyedValues2D();
1
DefaultKeyedValues v1 = new DefaultKeyedValues();
2
        v1.setValue(new Integer(1), "V1", "C1");
2
        v1.addValue("V1", new Integer(1));
3
        v1.setValue(null, "V2", "C1");
3
        v1.addValue("V2", null);
4
        v1.setValue(new Integer(3), "V3", "C2");
4
        v1.addValue("V3", new Integer(3));
5
        DefaultKeyedValues2D v2 = null;
5
        DefaultKeyedValues v2 = null;
6
        try {
6
        try {
7
            v2 = (DefaultKeyedValues2D) v1.clone();
7
            v2 = (DefaultKeyedValues) v1.clone();
8
        }
8
        }
9
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
10
            e.printStackTrace();
10
            System.err.println("Failed to clone.");
11
        }
11
        }
12
        assertTrue(v1 != v2);
12
        assertTrue(v1 != v2);
13
        assertTrue(v1.getClass() == v2.getClass());
13
        assertTrue(v1.getClass() == v2.getClass());
14
        assertTrue(v1.equals(v2));
14
        assertTrue(v1.equals(v2));
15
        
15
        
16
        // check that clone is independent of the original
16
        // confirm that the clone is independent of the original
17
        v2.setValue(new Integer(2), "V2", "C1");
17
        v2.setValue("V1", new Integer(44));
18
        assertFalse(v1.equals(v2));
18
        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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons48
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)177.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValues2D v1 = new DefaultKeyedValues2D();
    1
    DefaultKeyedValues2D v1 = new DefaultKeyedValues2D();
    1
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultKeyedValues2D() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultKeyedValues() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    2
    v1.setValue(new Integer(1), "V1", "C1");
    2
    v1.setValue(new Integer(1), "V1", "C1");
    2
    v1.addValue("V1", new Integer(1));
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    v1.setValue(new Integer(1),"V1","C1")v1.addValue("V1",new Integer(1))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression v1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    Expression v1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    2
    v1.addValue("V1", new Integer(1));
    3
    v1.setValue(null, "V2", "C1");
    3
    v1.setValue(null, "V2", "C1");
    3
    v1.addValue("V2", null);
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    v1.setValue(null,"V2","C1")v1.addValue("V2",null)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression v1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V2",null) is a void method call, and thus it cannot be parameterized
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    Expression v1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V2",null) is a void method call, and thus it cannot be parameterized
    3
    v1.addValue("V2", null);
    4
    v1.setValue(new Integer(3), "V3", "C2");
    4
    v1.setValue(new Integer(3), "V3", "C2");
    4
    v1.addValue("V3", new Integer(3));
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    v1.setValue(new Integer(3),"V3","C2")v1.addValue("V3",new Integer(3))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression v1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    Expression v1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.addValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    Expression v1.addValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    4
    v1.addValue("V3", new Integer(3));
    5
    DefaultKeyedValues2D v2 = null;
    5
    DefaultKeyedValues2D v2 = null;
    5
    DefaultKeyedValues v2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    5
    DefaultKeyedValues v2 = null;
    6
    try
    6
    try
    6
    try
    Differences
    Expression1Expression2Difference
    printStackTraceprintlnMETHOD_INVOCATION_NAME_MISMATCH
    eSystem.errAST_TYPE_MISMATCH
    e.printStackTrace()System.err.println("Failed to clone.")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    6
    try
    7
    v2 = (DefaultKeyedValues2D)v1.clone();
    7
    v2 = (DefaultKeyedValues2D)v1.clone();
    7
    v2 = (DefaultKeyedValues)v1.clone();
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DefaultKeyedValues2D)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DefaultKeyedValues)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    v2 = (DefaultKeyedValues)v1.clone();
    8
    assertTrue(v1 != v2);
    8
    assertTrue(v1 != v2);
    8
    assertTrue(v1 != v2);
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    8
    assertTrue(v1 != v2);
    9
    assertTrue(v1.getClass() == v2.getClass());
    9
    assertTrue(v1.getClass() == v2.getClass());
    9
    assertTrue(v1.getClass() == v2.getClass());
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValues2D> getClass() , public final native Class<? extends org.jfree.data.DefaultKeyedValues> getClass()
    Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValues2D> getClass() , public final native Class<? extends org.jfree.data.DefaultKeyedValues> getClass()
    9
    assertTrue(v1.getClass() == v2.getClass());
    10
    assertTrue(v1.equals(v2));
    10
    assertTrue(v1.equals(v2));
    10
    assertTrue(v1.equals(v2));
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 cannot be unified with expression v2 , 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 v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertTrue(v1.equals(v2));
    11
    v2.setValue(new Integer(2), "V2", "C1");
    11
    v2.setValue(new Integer(2), "V2", "C1");
    11
    v2.setValue("V1", new Integer(44));
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    v2.setValue(new Integer(2),"V2","C1")v2.setValue("V1",new Integer(44))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, java.lang.Number)
    Expression v2.setValue(new Integer(2),"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2.setValue("V1",new Integer(44)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v2.setValue(new Integer(2),"V2","C1") is a void method call, and thus it cannot be parameterized
    Expression v2.setValue("V1",new Integer(44)) is a void method call, and thus it cannot be parameterized
    11
    v2.setValue("V1", new Integer(44));
    12
    assertFalse(v1.equals(v2));
    12
    assertFalse(v1.equals(v2));
    12
    assertFalse(v1.equals(v2));
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValues2Dorg.jfree.data.DefaultKeyedValuesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 cannot be unified with expression v2 , 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 v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12
    assertFalse(v1.equals(v2));
    Precondition Violations (51)
    Row Violation
    1Expression new DefaultKeyedValues2D() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultKeyedValues() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression v1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression v1.addValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression v1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    6Expression v1.addValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    7Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    8Expression v1.setValue(new Integer(1),"V1","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression v1.addValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression v1.setValue(new Integer(1),"V1","C1") is a void method call, and thus it cannot be parameterized
    11Expression v1.addValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    12Expression v1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression v1.addValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression v1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    15Expression v1.addValue("V2",null) is a void method call, and thus it cannot be parameterized
    16Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    17Expression v1.setValue(null,"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression v1.addValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression v1.setValue(null,"V2","C1") is a void method call, and thus it cannot be parameterized
    20Expression v1.addValue("V2",null) is a void method call, and thus it cannot be parameterized
    21Expression v1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression v1.addValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression v1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    24Expression v1.addValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    25Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void addValue(Comparable#RAW, java.lang.Number)
    26Expression v1.setValue(new Integer(3),"V3","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression v1.addValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression v1.setValue(new Integer(3),"V3","C2") is a void method call, and thus it cannot be parameterized
    29Expression v1.addValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    30Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    32Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    33Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    34Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    35Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    36Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    37Expression (DefaultKeyedValues2D)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    38Expression (DefaultKeyedValues)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    39Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValues2D> getClass() , public final native Class<? extends org.jfree.data.DefaultKeyedValues> getClass()
    40Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValues2D> getClass() , public final native Class<? extends org.jfree.data.DefaultKeyedValues> getClass()
    41Expression v2 cannot be unified with expression v2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    42Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    43Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    44Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(java.lang.Number, Comparable#RAW, Comparable#RAW) , public void setValue(Comparable#RAW, java.lang.Number)
    45Expression v2.setValue(new Integer(2),"V2","C1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    46Expression v2.setValue("V1",new Integer(44)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    47Expression v2.setValue(new Integer(2),"V2","C1") is a void method call, and thus it cannot be parameterized
    48Expression v2.setValue("V1",new Integer(44)) is a void method call, and thus it cannot be parameterized
    49Expression v2 cannot be unified with expression v2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    50Expression v2 cannot be unified with expression v2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    51Expression v1 cannot be unified with expression v1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)