StrokeMap m1 = new StrokeMap(); StrokeMap m2 = null; try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2));
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));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/StrokeMapTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValueTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 10 Number of AST nodes: 9
1
StrokeMap m1 = new StrokeMap();
2
        StrokeMap m
1
DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
3
2 = null;
2
        DefaultKeyedValue v2 = null;
4
        try {
3
        try {
5
            m2 = (StrokeMap) m1.clone();
4
            v2 = (DefaultKeyedValue) v1.clone();
6
        }
5
        }
7
        catch (CloneNotSupportedException e) {
6
        catch (CloneNotSupportedException e) {
8
            e.printStackTrace();
7
            
9
        }
10
        assertTrue(m1.equals(m2));
11
        
12
        m1.put("K1", new BasicStroke(1.1f));
13
        m1.put("K2", new BasicStroke(2.2f
8
System.err.println("Failed to clone.");
9
        }
10
        assertTrue(v1 != v2);
11
        assertTrue(v1.getClass() == v2.getClass());
14
));
12
        assertTrue(v1.equals(v2));
15
        try {
13
        
16
            m2 = (StrokeMap) m1.clone();
14
        
17
        }
18
        catch (CloneNotSupportedException e) {
19
            e.printStackTrace(
15
// confirm that the clone is independent of the original
20
);
16
        v2.setValue(new Double(12.3));
21
        }
22
        assertTrue(m1.equals(m2));
17
        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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons47
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)13.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                  
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    Preondition Violations
    Unmatched statement DefaultKeyedValue v1=new DefaultKeyedValue("Test",new Double(45.5)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));
    1
    StrokeMap m1 = new StrokeMap();
    1
    StrokeMap m1 = new StrokeMap();
    Preondition Violations
    Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                    
                                                              
    2
    DefaultKeyedValue v2 = null;
    2
    StrokeMap m2 = null;
                                              
    3
    try
    3
    try
    3
    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
    3
    try
                                                                            
    4
    v2 = (DefaultKeyedValue)v1.clone();
    Preondition Violations
    Unmatched statement v2=(DefaultKeyedValue)v1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4
    v2 = (DefaultKeyedValue)v1.clone();
    4
    m2 = (StrokeMap)m1.clone();
    4
    m2 = (StrokeMap)m1.clone();
    Preondition Violations
    Unmatched statement m2=(StrokeMap)m1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                            
                                                                                                
    6
    assertTrue(v1.getClass() == v2.getClass());
    5
    assertTrue(m1.equals(m2));
    5
    assertTrue(m1.equals(m2));
    7
    assertTrue(v1.equals(v2));
    Differences
    Expression1Expression2Difference
    m2v2VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.DefaultKeyedValueVARIABLE_TYPE_MISMATCH
    m1v1VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.DefaultKeyedValueVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.DefaultKeyedValue of variable v2
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.DefaultKeyedValue extend a common superclass
    Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.DefaultKeyedValue of variable v1
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.DefaultKeyedValue extend a common superclass
    7
    assertTrue(v1.equals(v2));
    6
    m1.put("K1", new BasicStroke(1.1f));
    6
    m1.put("K1", new BasicStroke(1.1f));
    Preondition Violations
    Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    7
    m1.put("K2", new BasicStroke(2.2f));
    7
    m1.put("K2", new BasicStroke(2.2f));
    Preondition Violations
    Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    10
    assertTrue(m1.equals(m2));
    10
    assertTrue(m1.equals(m2));
    5
    assertTrue(v1 != v2);
    Differences
    Expression1Expression2Difference
    m1.equals(m2)v1 != v2TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression v1 != v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    assertTrue(v1 != v2);
                                                                      
    8
    v2.setValue(new Double(12.3));
    Preondition Violations
    Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8
    v2.setValue(new Double(12.3));
                                                                
    9
    assertFalse(v1.equals(v2));
    Precondition Violations (18)
    Row Violation
    1Unmatched statement DefaultKeyedValue v1=new DefaultKeyedValue("Test",new Double(45.5)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    5Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    6Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    9Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized
    10Unmatched statement v2=(DefaultKeyedValue)v1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11Unmatched statement m2=(StrokeMap)m1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    12Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.DefaultKeyedValue of variable v2
    13Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.DefaultKeyedValue of variable v1
    14Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression v1 != v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted