StrokeMap m1 = new StrokeMap(); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); StrokeMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (StrokeMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2);
XYIntervalSeries s1 = new XYIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); XYIntervalSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (XYIntervalSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2);
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/xy/junit/XYIntervalSeriesTests.java
Method name: void testSerialization2() Method name: void testSerialization()
Number of AST nodes: 13 Number of AST nodes: 12
1
StrokeMap m1 = new StrokeMap();
1
XYIntervalSeries s1 = new XYIntervalSeries("s1");
2
        m1.put("K1", new BasicStroke(1.1f));
2
        s1.
3
        m1.put("K2", new BasicStroke(2.2f));
4
        StrokeMap m2 = null;
3
add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
4
        XYIntervalSeries s2 = null;
5
        
5
        try {
6
        try {
6
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            out.writeObject(m1);
9
            out.writeObject(s1);
9
            out.close();
10
            out.close();
10
            ObjectInput in = new ObjectInputStream(
11
            ObjectInput in = new ObjectInputStream(
11
new ByteArrayInputStream(
12
                    new ByteArrayInputStream(
12
                    buffer.toByteArray()));
13
buffer.toByteArray()));
13
            m2 = (StrokeMap) in.readObject();
14
            s2 = (XYIntervalSeries) in.readObject();
14
            in.close();
15
            in.close();
15
        }
16
        }
16
        catch (Exception e) {
17
        catch (Exception e) {
17
            e.printStackTrace();
18
            e.printStackTrace();
18
        }
19
        }
19
        assertEquals(m1, m2);
20
        assertEquals(s1, s2);
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons84
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)11.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                        
    1
    XYIntervalSeries s1 = new XYIntervalSeries("s1");
    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
    s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    Preondition Violations
    Unmatched statement s1.add(1.0,0.5,1.5,2.0,1.9,2.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    2
    m1.put("K1", new BasicStroke(1.1f));
    2
    m1.put("K1", new BasicStroke(1.1f));
    Preondition Violations
    Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                
                                                            
    3
    XYIntervalSeries s2 = null;
    3
    m1.put("K2", new BasicStroke(2.2f));
    3
    m1.put("K2", new BasicStroke(2.2f));
    Preondition Violations
    Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                
    4
    StrokeMap m2 = null;
                                              
    5
    try
    4
    try
    6
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    7
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    8
    out.writeObject(m1);
    8
    out.writeObject(m1);
    7
    out.writeObject(s1);
    Differences
    Expression1Expression2Difference
    m1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.xy.XYIntervalSeriesVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s1
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.xy.XYIntervalSeries extend a common superclass
    7
    out.writeObject(s1);
    9
    out.close();
    8
    out.close();
    10
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
                                                                                      
    10
    s2 = (XYIntervalSeries)in.readObject();
    Preondition Violations
    Unmatched statement s2=(XYIntervalSeries)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement s2=(XYIntervalSeries)in.readObject(); 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
    10
    s2 = (XYIntervalSeries)in.readObject();
    11
    m2 = (StrokeMap)in.readObject();
    11
    m2 = (StrokeMap)in.readObject();
    Preondition Violations
    Unmatched statement m2=(StrokeMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement m2=(StrokeMap)in.readObject(); 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
                                                                        
    12
    in.close();
    11
    in.close();
    13
    assertEquals(m1, m2);
    13
    assertEquals(m1, m2);
    12
    assertEquals(s1, s2);
    Differences
    Expression1Expression2Difference
    m1s1VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.xy.XYIntervalSeriesVARIABLE_TYPE_MISMATCH
    m2s2VARIABLE_NAME_MISMATCH
    org.jfree.chart.StrokeMaporg.jfree.data.xy.XYIntervalSeriesVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s1
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.xy.XYIntervalSeries extend a common superclass
    Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s2
    • Make classes org.jfree.chart.StrokeMap and org.jfree.data.xy.XYIntervalSeries extend a common superclass
    12
    assertEquals(s1, s2);
    Precondition Violations (11)
    Row Violation
    1Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s1.add(1.0,0.5,1.5,2.0,1.9,2.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s1
    6Unmatched statement s2=(XYIntervalSeries)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s2=(XYIntervalSeries)in.readObject(); 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
    8Unmatched statement m2=(StrokeMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement m2=(StrokeMap)in.readObject(); 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
    10Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s1
    11Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.xy.XYIntervalSeries of variable s2