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));
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/DefaultKeyedValueTests.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: 9 Number of AST nodes: 10
1
DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
2
        DefaultKeyedValue v
1
SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);
2
        b1.setItemCount(99);
3
2 = null;
3
        SimpleHistogramBin b2 = null;
4
        try {
4
        try {
5
            v2 = (DefaultKeyedValue) v1.clone();
5
            b2 = (SimpleHistogramBin) b1.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(v1 != v2);
10
        assertTrue(b1 != b2);
11
        assertTrue(v1.getClass() == v2.getClass());
11
        assertTrue(b1.getClass() == b2.getClass());
12
        assertTrue(v1.equals(v2));
12
        assertTrue(b1.equals(b2));
13
        
13
        
14
        // confirm that the clone is independent of the original
14
        // check that clone is independent of the original
15
        v2.setValue(new Double(12.3));
15
        b2.setItemCount(111);
16
        assertFalse(v1.equals(v2));
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 comparisons41
  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 fragment2
    Time elapsed for statement mapping (ms)15.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    1
    SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    new DefaultKeyedValue("Test",new Double(45.5))new SimpleHistogramBin(1.1,2.2,false,true)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new DefaultKeyedValue("Test",new Double(45.5)) 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 DefaultKeyedValue("Test",new Double(45.5)) 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
    b1.setItemCount(99);
    Preondition Violations
    Unmatched statement b1.setItemCount(99); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    b1.setItemCount(99);
    2
    DefaultKeyedValue v2 = null;
    2
    DefaultKeyedValue v2 = null;
    3
    SimpleHistogramBin b2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    3
    SimpleHistogramBin b2 = null;
    3
    try
    4
    try
    4
    v2 = (DefaultKeyedValue)v1.clone();
    4
    v2 = (DefaultKeyedValue)v1.clone();
    5
    b2 = (SimpleHistogramBin)b1.clone();
    Differences
    Expression1Expression2Difference
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (DefaultKeyedValue)v1.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();
    5
    assertTrue(v1 != v2);
    5
    assertTrue(v1 != v2);
    6
    assertTrue(b1 != b2);
    Differences
    Expression1Expression2Difference
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(b1 != b2);
    6
    assertTrue(v1.getClass() == v2.getClass());
    6
    assertTrue(v1.getClass() == v2.getClass());
    7
    assertTrue(b1.getClass() == b2.getClass());
    Differences
    Expression1Expression2Difference
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v1 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.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    Expression v2 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.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    7
    assertTrue(b1.getClass() == b2.getClass());
    7
    assertTrue(v1.equals(v2));
    7
    assertTrue(v1.equals(v2));
    8
    assertTrue(b1.equals(b2));
    Differences
    Expression1Expression2Difference
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 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 v2 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 v1 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));
    8
    v2.setValue(new Double(12.3));
    8
    v2.setValue(new Double(12.3));
    Preondition Violations
    Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
                                                    
    9
    b2.setItemCount(111);
    Preondition Violations
    Unmatched statement b2.setItemCount(111); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    b2.setItemCount(111);
    9
    assertFalse(v1.equals(v2));
    9
    assertFalse(v1.equals(v2));
    10
    assertFalse(b1.equals(b2));
    Differences
    Expression1Expression2Difference
    v2b2VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    v1b1VARIABLE_NAME_MISMATCH
    org.jfree.data.DefaultKeyedValueorg.jfree.data.statistics.SimpleHistogramBinSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression v2 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 v2 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 v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    10
    assertFalse(b1.equals(b2));
    Precondition Violations (18)
    Row Violation
    1Expression new DefaultKeyedValue("Test",new Double(45.5)) 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 DefaultKeyedValue("Test",new Double(45.5)) 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
    5Unmatched statement b1.setItemCount(99); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression (SimpleHistogramBin)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression v1 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.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    9Expression v2 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.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass()
    10Expression v2 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)
    11Expression v2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    12Expression v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    13Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement b2.setItemCount(111); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Expression v2 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)
    16Expression v2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    17Expression v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object)
    18Clone fragment #1 returns variable v2 with type org.jfree.data.DefaultKeyedValue , while Clone fragment #2 returns variable b2 with type org.jfree.data.statistics.SimpleHistogramBin