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));
SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true); b1.setItemCount(99); SimpleHistogramBin b2 = null; try { b2 = (SimpleHistogramBin) b1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check that clone is independent of the original b2.setItemCount(111); assertFalse(b1.equals(b2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjectsTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/SimpleHistogramBinTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 10 Number of AST nodes: 10
1
KeyedObjects ko1 = new KeyedObjects();
2
        ko1.addObject("V1", new Integer(1));
3
        ko1.addObject("V2", null);
4
        ko1.addObject("V3", new Integer(3));
5
        KeyedObjects ko
1
SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);
2
        b1.setItemCount(99);
6
2 = null;
3
        SimpleHistogramBin b2 = null;
7
        try {
4
        try {
8
            ko2 = (KeyedObjects) ko1.clone();
5
            b2 = (SimpleHistogramBin) b1.clone();
9
        }
6
        }
10
        catch (CloneNotSupportedException e) {
7
        catch (CloneNotSupportedException e) {
11
            System.err.println("Failed to clone.");
8
            System.err.println("Failed to clone.");
12
        }
9
        }
13
        assertTrue(ko1 != ko2);
10
        assertTrue(b1 != b2);
14
        assertTrue(ko1.getClass() == ko2.getClass());
11
        assertTrue(b1.getClass() == b2.getClass());
15
        assertTrue(ko
12
        assertTrue(b1.equals(b2));
13
        
14
        // check that clone is independent of the original
15
        b2.setItemCount(111);
16
1.equals(ko2));
16
        assertFalse(b1.equals(b2));
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 comparisons52
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)23.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    KeyedObjects ko1 = new KeyedObjects();
    1
    KeyedObjects ko1 = new KeyedObjects();
    1
    SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);
    Differences
    Expression1Expression2Difference
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    new KeyedObjects()new SimpleHistogramBin(1.1,2.2,false,true)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new SimpleHistogramBin(1.1,2.2,false,true) 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
    Expression new SimpleHistogramBin(1.1,2.2,false,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);
    2
    ko1.addObject("V1", new Integer(1));
    2
    ko1.addObject("V1", new Integer(1));
    2
    b1.setItemCount(99);
    Differences
    Expression1Expression2Difference
    addObjectsetItemCountMETHOD_INVOCATION_NAME_MISMATCH
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko1.addObject("V1",new Integer(1))b1.setItemCount(99)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b1.setItemCount(99) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    Expression b1.setItemCount(99) is a void method call, and thus it cannot be parameterized
    Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addObject(Comparable#RAW, java.lang.Object) , public void setItemCount(int)
    Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b1.setItemCount(99) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    Expression b1.setItemCount(99) is a void method call, and thus it cannot be parameterized
    2
    b1.setItemCount(99);
    3
    ko1.addObject("V2", null);
    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
                                                            
    4
    ko1.addObject("V3", new Integer(3));
    4
    ko1.addObject("V3", new Integer(3));
    9
    b2.setItemCount(111);
    Differences
    Expression1Expression2Difference
    addObjectsetItemCountMETHOD_INVOCATION_NAME_MISMATCH
    ko1b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko1.addObject("V3",new Integer(3))b2.setItemCount(111)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b2.setItemCount(111) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    Expression b2.setItemCount(111) is a void method call, and thus it cannot be parameterized
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addObject(Comparable#RAW, java.lang.Object) , public void setItemCount(int)
    Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression b2.setItemCount(111) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    Expression b2.setItemCount(111) is a void method call, and thus it cannot be parameterized
    9
    b2.setItemCount(111);
    5
    KeyedObjects ko2 = null;
    5
    KeyedObjects ko2 = null;
    3
    SimpleHistogramBin b2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    3
    SimpleHistogramBin b2 = null;
    6
    try
    4
    try
    7
    ko2 = (KeyedObjects)ko1.clone();
    7
    ko2 = (KeyedObjects)ko1.clone();
    5
    b2 = (SimpleHistogramBin)b1.clone();
    Differences
    Expression1Expression2Difference
    ko2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (SimpleHistogramBin)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    b2 = (SimpleHistogramBin)b1.clone();
    8
    assertTrue(ko1 != ko2);
    8
    assertTrue(ko1 != ko2);
    6
    assertTrue(b1 != b2);
    Differences
    Expression1Expression2Difference
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(b1 != b2);
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    9
    assertTrue(ko1.getClass() == ko2.getClass());
    7
    assertTrue(b1.getClass() == b2.getClass());
    Differences
    Expression1Expression2Difference
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.KeyedObjects> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    Expression ko2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.KeyedObjects> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    7
    assertTrue(b1.getClass() == b2.getClass());
    10
    assertTrue(ko1.equals(ko2));
    10
    assertTrue(ko1.equals(ko2));
    8
    assertTrue(b1.equals(b2));
    Differences
    Expression1Expression2Difference
    ko2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    ko1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.KeyedObjectsorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression ko2 cannot be unified with expression b2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    Expression ko2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    8
    assertTrue(b1.equals(b2));
                                                                  
    10
    assertFalse(b1.equals(b2));
    Preondition Violations
    Unmatched statement assertFalse(b1.equals(b2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    assertFalse(b1.equals(b2));
    Precondition Violations (34)
    Row Violation
    1Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new SimpleHistogramBin(1.1,2.2,false,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new KeyedObjects() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new SimpleHistogramBin(1.1,2.2,false,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression b1.setItemCount(99) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    8Expression b1.setItemCount(99) is a void method call, and thus it cannot be parameterized
    9Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addObject(Comparable#RAW, java.lang.Object) , public void setItemCount(int)
    10Expression ko1.addObject("V1",new Integer(1)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression b1.setItemCount(99) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression ko1.addObject("V1",new Integer(1)) is a void method call, and thus it cannot be parameterized
    13Expression b1.setItemCount(99) is a void method call, and thus it cannot be parameterized
    14Unmatched 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
    15Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression b2.setItemCount(111) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    18Expression b2.setItemCount(111) is a void method call, and thus it cannot be parameterized
    19Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression b2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression ko1 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addObject(Comparable#RAW, java.lang.Object) , public void setItemCount(int)
    22Expression ko1.addObject("V3",new Integer(3)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression b2.setItemCount(111) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression ko1.addObject("V3",new Integer(3)) is a void method call, and thus it cannot be parameterized
    25Expression b2.setItemCount(111) is a void method call, and thus it cannot be parameterized
    26Expression (KeyedObjects)ko1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Expression (SimpleHistogramBin)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.KeyedObjects> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    29Expression ko2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.KeyedObjects> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    30Expression ko2 cannot be unified with expression b2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object)
    31Expression ko2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    32Expression ko1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    33Unmatched statement assertFalse(b1.equals(b2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    34Clone fragment #1 returns variables ko1 , while Clone fragment #2 returns variables b1, b2