CustomPieURLGenerator g1 = new CustomPieURLGenerator(); Map m1 = new HashMap(); m1.put("A", "http://www.jfree.org/"); g1.addURLs(m1); CustomPieURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (CustomPieURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2);
DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.addSeries(createSeries2()); DefaultTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/urls/junit/CustomPieURLGeneratorTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/TableXYDatasetTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 14 Number of AST nodes: 12
1
CustomPieURLGenerator g1 = new CustomPieURLGenerator();
2
        Map m1 = new HashMap();
1
DefaultTableXYDataset d1 = new DefaultTableXYDataset();
3
        m1.put("A", "http://www.jfree.org/");
2
        d1.
4
        g1.addURLs(m1);
5
        CustomPieURLGenerator g
3
addSeries(createSeries2());
6
2 = null;
4
        DefaultTableXYDataset d2 = null;
7
        try {
5
        try {
8
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
6
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9
            ObjectOutput out = new ObjectOutputStream(buffer);
7
            ObjectOutput out = new ObjectOutputStream(buffer);
10
            out.writeObject(g1);
8
            out.writeObject(d1);
11
            out.close();
9
            out.close();
12
            ObjectInput in = new ObjectInputStream(
10
            ObjectInput in = new ObjectInputStream(
13
                    new ByteArrayInputStream(buffer.toByteArray())
11
                new ByteArrayInputStream(buffer.toByteArray())
14
);
12
            );
15
            g2 = (CustomPieURLGenerator) in.readObject();
13
            d2 = (DefaultTableXYDataset) in.readObject();
16
            in.close();
14
            in.close();
17
        }
15
        }
18
        catch (Exception e) {
16
        catch (Exception e) {
19
            e.printStackTrace();
17
            System.out.println(e.toString());
20
        }
18
        }
21
        assertEquals(g1, g2);
19
        assertEquals(d1, d2);
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 comparisons84
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)37.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    CustomPieURLGenerator g1 = new CustomPieURLGenerator();
    1
    CustomPieURLGenerator g1 = new CustomPieURLGenerator();
    1
    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    g1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new CustomPieURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new DefaultTableXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
                                                                      
    2
    d1.addSeries(createSeries2());
    Preondition Violations
    Unmatched statement d1.addSeries(createSeries2()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    d1.addSeries(createSeries2());
    2
    Map m1 = new HashMap();
    2
    Map m1 = new HashMap();
    Preondition Violations
    Unmatched statement Map m1=new HashMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                    
    3
    m1.put("A", "http://www.jfree.org/");
    3
    m1.put("A", "http://www.jfree.org/");
    Preondition Violations
    Unmatched statement m1.put("A","http://www.jfree.org/"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                  
    4
    g1.addURLs(m1);
    4
    g1.addURLs(m1);
    Preondition Violations
    Unmatched statement g1.addURLs(m1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                        
    5
    CustomPieURLGenerator g2 = null;
    5
    CustomPieURLGenerator g2 = null;
    3
    DefaultTableXYDataset d2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    g2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    3
    DefaultTableXYDataset d2 = null;
    6
    try
    6
    try
    4
    try
    Differences
    Expression1Expression2Difference
    printStackTraceprintlnMETHOD_INVOCATION_NAME_MISMATCH
    eSystem.outAST_TYPE_MISMATCH
    e.printStackTrace()System.out.println(e.toString())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression e.printStackTrace() 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() is a void method call, and thus it cannot be parameterized
    Expression System.out.println(e.toString()) 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 System.out.println(e.toString()) 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.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    4
    try
    7
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    8
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    9
    out.writeObject(g1);
    9
    out.writeObject(g1);
    7
    out.writeObject(d1);
    Differences
    Expression1Expression2Difference
    g1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression g1 cannot be unified with expression d1 , 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
    7
    out.writeObject(d1);
    10
    out.close();
    8
    out.close();
    11
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    12
    g2 = (CustomPieURLGenerator)in.readObject();
    12
    g2 = (CustomPieURLGenerator)in.readObject();
    10
    d2 = (DefaultTableXYDataset)in.readObject();
    Differences
    Expression1Expression2Difference
    g2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (CustomPieURLGenerator)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (DefaultTableXYDataset)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    d2 = (DefaultTableXYDataset)in.readObject();
    13
    in.close();
    11
    in.close();
    14
    assertEquals(g1, g2);
    14
    assertEquals(g1, g2);
    12
    assertEquals(d1, d2);
    Differences
    Expression1Expression2Difference
    g1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    g2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.urls.CustomPieURLGeneratororg.jfree.data.xy.DefaultTableXYDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression g1 cannot be unified with expression d1 , 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 g2 cannot be unified with expression d2 , 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)
    12
    assertEquals(d1, d2);
    Precondition Violations (20)
    Row Violation
    1Expression new CustomPieURLGenerator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new DefaultTableXYDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement d1.addSeries(createSeries2()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement Map m1=new HashMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement m1.put("A","http://www.jfree.org/"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement g1.addURLs(m1); cannot be moved before or after the extracted code, 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 System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    10Expression System.out.println(e.toString()) 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 e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    15Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    16Expression g1 cannot be unified with expression d1 , 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 (CustomPieURLGenerator)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression (DefaultTableXYDataset)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression g1 cannot be unified with expression d1 , 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 g2 cannot be unified with expression d2 , 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)