DefaultPieDataset d1 = new DefaultPieDataset(); d1.setValue("V1", new Integer(1)); d1.setValue("V2", null); d1.setValue("V3", new Integer(3)); DefaultPieDataset d2 = null; try { d2 = (DefaultPieDataset) 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/DefaultPieDatasetTests.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
DefaultPieDataset d1 = new DefaultPieDataset();
2
        d1.setValue
1
KeyedObjects ko1 = new KeyedObjects();
3
("V1", new Integer(1));
2
        ko1.addObject("V1", new Integer(1));
4
        d1.setValue("V2", null);
3
        ko1.addObject("V2", null);
5
        d1.setValue("V3", new Integer(3));
4
        ko1.addObject("V3", new Integer(3));
6
        DefaultPieDataset d2 = null;
5
        KeyedObjects ko2 = null;
7
        try {
6
        try {
8
            d2 = (DefaultPieDataset) d1.clone();
7
            ko2 = (KeyedObjects) ko1.clone();
9
        }
8
        }
10
        catch (CloneNotSupportedException e) {
9
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
10
            System.err.println("Failed to clone.");
12
        }
11
        }
13
        assertTrue(d1 != d2);
12
        assertTrue(ko1 != ko2);
14
        assertTrue(d1.getClass() == d2.getClass());
13
        assertTrue(ko1.getClass() == ko2.getClass());
15
        assertTrue(d1.equals(d2));
14
        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)44.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultPieDataset d1 = new DefaultPieDataset();
    1
    DefaultPieDataset d1 = new DefaultPieDataset();
    1
    KeyedObjects ko1 = new KeyedObjects();
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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("V1", new Integer(1));
    2
    d1.setValue("V1", new Integer(1));
    2
    ko1.addObject("V1", new Integer(1));
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d1.setValue("V1",new Integer(1)) 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("V1",new Integer(1)) 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(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    2
    ko1.addObject("V1", new Integer(1));
    3
    d1.setValue("V2", null);
    3
    d1.setValue("V2", null);
    3
    ko1.addObject("V2", null);
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d1.setValue("V2",null) 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("V2",null) 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(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    3
    ko1.addObject("V2", null);
    4
    d1.setValue("V3", new Integer(3));
    4
    d1.setValue("V3", new Integer(3));
    4
    ko1.addObject("V3", new Integer(3));
    Differences
    Expression1Expression2Difference
    setValueaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression d1.setValue("V3",new Integer(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 d1.setValue("V3",new Integer(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 d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    4
    ko1.addObject("V3", new Integer(3));
    5
    DefaultPieDataset d2 = null;
    5
    DefaultPieDataset d2 = null;
    5
    KeyedObjects ko2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    5
    KeyedObjects ko2 = null;
    6
    try
    6
    try
    7
    d2 = (DefaultPieDataset)d1.clone();
    7
    d2 = (DefaultPieDataset)d1.clone();
    7
    ko2 = (KeyedObjects)ko1.clone();
    Differences
    Expression1Expression2Difference
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DefaultPieDataset)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.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.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.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d2ko2VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.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.DefaultPieDatasetorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    d1ko1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.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 (22)
    Row Violation
    1Expression new DefaultPieDataset() 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
    3Expression d1.setValue("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression d1.setValue("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    6Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    7Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    8Expression d1.setValue("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression ko1.addObject("V2",null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression d1.setValue("V2",null) is a void method call, and thus it cannot be parameterized
    11Expression ko1.addObject("V2",null) is a void method call, and thus it cannot be parameterized
    12Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    13Expression d1.setValue("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression d1.setValue("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    16Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    17Expression d1 cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void setValue(Comparable#RAW, java.lang.Number) , public void addObject(Comparable#RAW, java.lang.Object)
    18Expression (DefaultPieDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression 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)
    21Expression 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)
    22Expression 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)