DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); data.setValue("Type 3", 45.8); JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true, true); JFreeChart 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 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);
DefaultPieDataset d1 = new DefaultPieDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); DefaultPieDataset 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 = (DefaultPieDataset) 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/junit/JFreeChartTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultPieDatasetTests.java
Method name: void testSerialization2() Method name: void testSerialization()
Number of AST nodes: 15 Number of AST nodes: 15
1
DefaultPieDataset data = new DefaultPieDataset();
1
DefaultPieDataset d1 = new DefaultPieDataset();
2
        data.setValue("Type 1", 54.5);
2
        d1.setValue("C1", new Double(234.2));
3
        data.setValue("Type 2", 23.9);
3
        d1.setValue("C2", null);
4
        data.setValue("Type 3", 45.8);
4
        d1.setValue("C3", new Double(345.9));
5
        JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true,
5
        
6
                true);
6
d1.setValue("C4", new Double(452.7));
7
        JFreeChart c2 = null;
7
        DefaultPieDataset d2 = null;
8
        try {
8
        try {
9
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
9
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
10
            ObjectOutput out = new ObjectOutputStream(buffer);
10
            ObjectOutput out = new ObjectOutputStream(buffer);
11
            out.writeObject(c1);
11
            out.writeObject(d1);
12
            out.close();
12
            out.close();
13
            ObjectInput in = new ObjectInputStream(
13
            ObjectInput in = new ObjectInputStream(
14
new ByteArrayInputStream(
14
                new ByteArrayInputStream(
15
                    buffer.toByteArray())
15
buffer.toByteArray())
16
);
16
            );
17
            c2 = (JFreeChart) in.readObject();
17
            d2 = (DefaultPieDataset) in.readObject();
18
            in.close();
18
            in.close();
19
        }
19
        }
20
        catch (Exception e) {
20
        catch (Exception e) {
21
            e.printStackTrace();
21
            System.out.println(e.toString());
22
        }
22
        }
23
        assertEquals(c1, c2);
23
        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 comparisons103
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)20.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultPieDataset data = new DefaultPieDataset();
    1
    DefaultPieDataset data = new DefaultPieDataset();
    1
    DefaultPieDataset d1 = new DefaultPieDataset();
    Differences
    Expression1Expression2Difference
    datad1VARIABLE_NAME_MISMATCH
    1
    DefaultPieDataset d1 = new DefaultPieDataset();
                                                                                  
    2
    d1.setValue("C1", new Double(234.2));
    Preondition Violations
    Unmatched statement d1.setValue("C1",new Double(234.2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    d1.setValue("C1", new Double(234.2));
    2
    data.setValue("Type 1", 54.5);
    2
    data.setValue("Type 1", 54.5);
    Preondition Violations
    Unmatched statement data.setValue("Type 1",54.5); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
    3
    data.setValue("Type 2", 23.9);
    3
    data.setValue("Type 2", 23.9);
    3
    d1.setValue("C2", null);
    Differences
    Expression1Expression2Difference
    "Type 2""C2"LITERAL_VALUE_MISMATCH
    23.9nullTYPE_COMPATIBLE_REPLACEMENT
    datad1VARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression data cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    d1.setValue("C2", null);
                                                                                  
    4
    d1.setValue("C3", new Double(345.9));
    Preondition Violations
    Unmatched statement d1.setValue("C3",new Double(345.9)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    d1.setValue("C3", new Double(345.9));
    4
    data.setValue("Type 3", 45.8);
    4
    data.setValue("Type 3", 45.8);
    Preondition Violations
    Unmatched statement data.setValue("Type 3",45.8); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
                                                                                  
    5
    d1.setValue("C4", new Double(452.7));
    Preondition Violations
    Unmatched statement d1.setValue("C4",new Double(452.7)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    d1.setValue("C4", new Double(452.7));
    5
    JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true, true);
    5
    JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true, true);
    Preondition Violations
    Unmatched statement JFreeChart c1=ChartFactory.createPieChart3D("Test",data,true,true,true); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                          
                                                              
    6
    DefaultPieDataset d2 = null;
    6
    JFreeChart c2 = null;
                                                
    7
    try
    7
    try
    7
    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
    7
    try
    8
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    8
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    9
    ObjectOutput out = new ObjectOutputStream(buffer);
    9
    ObjectOutput out = new ObjectOutputStream(buffer);
    10
    out.writeObject(c1);
    10
    out.writeObject(c1);
    10
    out.writeObject(d1);
    Differences
    Expression1Expression2Difference
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.JFreeChartorg.jfree.data.general.DefaultPieDatasetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultPieDataset of variable d1
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultPieDataset extend a common superclass
    10
    out.writeObject(d1);
    11
    out.close();
    11
    out.close();
    12
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    12
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
                                                                                        
    13
    d2 = (DefaultPieDataset)in.readObject();
    Preondition Violations
    Unmatched statement d2=(DefaultPieDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement d2=(DefaultPieDataset)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
    13
    d2 = (DefaultPieDataset)in.readObject();
    13
    c2 = (JFreeChart)in.readObject();
    13
    c2 = (JFreeChart)in.readObject();
    Preondition Violations
    Unmatched statement c2=(JFreeChart)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement c2=(JFreeChart)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
                                                                          
    14
    in.close();
    14
    in.close();
    15
    assertEquals(c1, c2);
    15
    assertEquals(c1, c2);
    15
    assertEquals(d1, d2);
    Differences
    Expression1Expression2Difference
    c1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.JFreeChartorg.jfree.data.general.DefaultPieDatasetVARIABLE_TYPE_MISMATCH
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.JFreeChartorg.jfree.data.general.DefaultPieDatasetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultPieDataset of variable d1
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultPieDataset extend a common superclass
    Type org.jfree.chart.JFreeChart of variable c2 does not match with type org.jfree.data.general.DefaultPieDataset of variable d2
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultPieDataset extend a common superclass
    15
    assertEquals(d1, d2);
    Precondition Violations (29)
    Row Violation
    1Unmatched statement d1.setValue("C1",new Double(234.2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement data.setValue("Type 1",54.5); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression data cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement d1.setValue("C3",new Double(345.9)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement data.setValue("Type 3",45.8); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement d1.setValue("C4",new Double(452.7)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement JFreeChart c1=ChartFactory.createPieChart3D("Test",data,true,true,true); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    12Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    13Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    17Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    18Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultPieDataset of variable d1
    21Unmatched statement d2=(DefaultPieDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Unmatched statement d2=(DefaultPieDataset)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
    23Unmatched statement c2=(JFreeChart)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    24Unmatched statement c2=(JFreeChart)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
    25Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultPieDataset of variable d1
    28Type org.jfree.chart.JFreeChart of variable c2 does not match with type org.jfree.data.general.DefaultPieDataset of variable d2
    29Clone fragment #1 returns variables data, in , while Clone fragment #2 returns variables d1, in