Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation( 10.0, 20.0, 100.0, 200.0, stroke, Color.blue ); XYLineAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (XYLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2);
MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (MatrixSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYLineAnnotationTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/MatrixSeriesCollectionTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 12 Number of AST nodes: 14
1
Stroke stroke = new BasicStroke(2.0f);
2
        XYLineAnnota
1
MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
2
        s1.update(0, 0, 1.1);
3
tion a1 = new XYLineAnnotation(
3
        MatrixSeriesCollection c1 = new MatrixSeriesCollection(
4
  
4
);
5
          10.0, 20.0, 100.0, 200.0, stroke, Color.blue
5
        
6
        );
7
        XYLineAnnota
6
c1.addSeries(s1);
8
tion a2 = null;
7
        MatrixSeriesCollection c2 = null;
9
        try {
8
        try {
10
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
11
            ObjectOutput out = new ObjectOutputStream(buffer);
10
            ObjectOutput out = new ObjectOutputStream(buffer);
12
            out.writeObject(a1);
11
            out.writeObject(c1);
13
            out.close();
12
            out.close();
14
            ObjectInput in = new ObjectInputStream(
13
            ObjectInput in = new ObjectInputStream(
15
                new ByteArrayInputStream(buffer.toByteArray())
14
                    new ByteArrayInputStream(buffer.toByteArray())
16
            );
15
);
17
            a2 = (XYLineAnnotation) in.readObject();
16
            c2 = (MatrixSeriesCollection) in.readObject();
18
            in.close();
17
            in.close();
19
        }
18
        }
20
        catch (Exception e) {
19
        catch (Exception e) {
21
            System.out.println(e.toString());
20
            e.printStackTrace();
22
        }
21
        }
23
        assertEquals(a1, a2);
22
        assertEquals(c1, c2);
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons82
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)37.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                        
    1
    MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
    Preondition Violations
    Unmatched statement MatrixSeries s1=new MatrixSeries("Series",2,3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    MatrixSeries s1 = new MatrixSeries("Series", 2, 3);
    1
    Stroke stroke = new BasicStroke(2.0f);
                                                                                  
                                                
    2
    s1.update(0, 0, 1.1);
    2
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
    2
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue);
    3
    MatrixSeriesCollection c1 = new MatrixSeriesCollection();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    a1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue)new MatrixSeriesCollection()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new MatrixSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new MatrixSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    MatrixSeriesCollection c1 = new MatrixSeriesCollection();
                                            
    4
    c1.addSeries(s1);
    Preondition Violations
    Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    c1.addSeries(s1);
    3
    XYLineAnnotation a2 = null;
    3
    XYLineAnnotation a2 = null;
    5
    MatrixSeriesCollection c2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    a2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    5
    MatrixSeriesCollection c2 = null;
    4
    try
    4
    try
    6
    try
    Differences
    Expression1Expression2Difference
    printlnprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    System.outeAST_TYPE_MISMATCH
    System.out.println(e.toString())e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression System.out.println(e.toString()) 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 System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() 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 System.out.println(e.toString()) 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 System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    6
    try
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    7
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    8
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    out.writeObject(a1);
    7
    out.writeObject(a1);
    9
    out.writeObject(c1);
    Differences
    Expression1Expression2Difference
    a1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a1 cannot be unified with expression c1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public abstract void writeObject(java.lang.Object) throws java.io.IOException
    9
    out.writeObject(c1);
    8
    out.close();
    10
    out.close();
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    11
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    10
    a2 = (XYLineAnnotation)in.readObject();
    10
    a2 = (XYLineAnnotation)in.readObject();
    12
    c2 = (MatrixSeriesCollection)in.readObject();
    Differences
    Expression1Expression2Difference
    a2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYLineAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (MatrixSeriesCollection)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    c2 = (MatrixSeriesCollection)in.readObject();
    11
    in.close();
    13
    in.close();
    12
    assertEquals(a1, a2);
    12
    assertEquals(a1, a2);
    14
    assertEquals(c1, c2);
    Differences
    Expression1Expression2Difference
    a1c1VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    a2c2VARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYLineAnnotationorg.jfree.data.xy.MatrixSeriesCollectionSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression a1 cannot be unified with expression c1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public static void assertEquals(java.lang.Object, java.lang.Object)
    Expression a2 cannot be unified with expression c2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public static void assertEquals(java.lang.Object, java.lang.Object)
    14
    assertEquals(c1, c2);
    Precondition Violations (21)
    Row Violation
    1Unmatched statement MatrixSeries s1=new MatrixSeries("Series",2,3); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new MatrixSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new XYLineAnnotation(10.0,20.0,100.0,200.0,stroke,Color.blue) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new MatrixSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    10Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    11Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    15Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    16Expression a1 cannot be unified with expression c1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public abstract void writeObject(java.lang.Object) throws java.io.IOException
    17Expression (XYLineAnnotation)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression (MatrixSeriesCollection)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression a1 cannot be unified with expression c1 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public static void assertEquals(java.lang.Object, java.lang.Object)
    20Expression a2 cannot be unified with expression c2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public static void assertEquals(java.lang.Object, java.lang.Object)
    21Clone fragment #1 returns variables , while Clone fragment #2 returns variables c1