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);
DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); d1.addValue(new Double(234.2), "Row1", "Col1"); d1.addValue(null, "Row1", "Col2"); d1.addValue(new Double(345.9), "Row2", "Col1"); d1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2DDataset 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 = (DefaultKeyedValues2DDataset) 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/DefaultKeyedValues2DDatasetTests.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
DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
2
        data.setValue("Type 1", 54.5);
2
        d1.addValue(new Double(234.2), "Row1", "Col1");
3
        data.setValue("Type 2", 23.9);
3
        d1.addValue(null, "Row1", "Col2");
4
        data.setValue("Type 3", 45.8);
4
        d1.addValue(new Double(345.9), "Row2", "Col1");
5
        JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true,
5
        
6
                true);
6
d1.addValue(new Double(452.7), "Row2", "Col2");
7
        JFreeChart c2 = null;
7
        DefaultKeyedValues2DDataset 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 = (DefaultKeyedValues2DDataset) 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 comparisons93
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)67.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultPieDataset data = new DefaultPieDataset();
    1
    DefaultPieDataset data = new DefaultPieDataset();
    1
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    Differences
    Expression1Expression2Difference
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    datad1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    2
    data.setValue("Type 1", 54.5);
    2
    data.setValue("Type 1", 54.5);
    2
    d1.addValue(new Double(234.2), "Row1", "Col1");
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    datad1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    data.setValue("Type 1",54.5)d1.addValue(new Double(234.2),"Row1","Col1")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression data.setValue("Type 1",54.5) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(new Double(234.2),"Row1","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 1",54.5) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(new Double(234.2),"Row1","Col1") is a void method call, and thus it cannot be parameterized
    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
    Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    Expression data.setValue("Type 1",54.5) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(new Double(234.2),"Row1","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 1",54.5) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(new Double(234.2),"Row1","Col1") is a void method call, and thus it cannot be parameterized
    2
    d1.addValue(new Double(234.2), "Row1", "Col1");
    3
    data.setValue("Type 2", 23.9);
    3
    data.setValue("Type 2", 23.9);
    3
    d1.addValue(null, "Row1", "Col2");
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    datad1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    data.setValue("Type 2",23.9)d1.addValue(null,"Row1","Col2")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression data.setValue("Type 2",23.9) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(null,"Row1","Col2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 2",23.9) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(null,"Row1","Col2") is a void method call, and thus it cannot be parameterized
    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
    Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    Expression data.setValue("Type 2",23.9) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(null,"Row1","Col2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 2",23.9) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(null,"Row1","Col2") is a void method call, and thus it cannot be parameterized
    3
    d1.addValue(null, "Row1", "Col2");
    4
    data.setValue("Type 3", 45.8);
    4
    data.setValue("Type 3", 45.8);
    4
    d1.addValue(new Double(345.9), "Row2", "Col1");
    Differences
    Expression1Expression2Difference
    setValueaddValueMETHOD_INVOCATION_NAME_MISMATCH
    datad1VARIABLE_NAME_MISMATCH
    org.jfree.data.general.DefaultPieDatasetorg.jfree.data.general.DefaultKeyedValues2DDatasetSUBCLASS_TYPE_MISMATCH
    data.setValue("Type 3",45.8)d1.addValue(new Double(345.9),"Row2","Col1")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression data.setValue("Type 3",45.8) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(new Double(345.9),"Row2","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 3",45.8) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(new Double(345.9),"Row2","Col1") is a void method call, and thus it cannot be parameterized
    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
    Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    Expression data.setValue("Type 3",45.8) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.addValue(new Double(345.9),"Row2","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.setValue("Type 3",45.8) is a void method call, and thus it cannot be parameterized
    Expression d1.addValue(new Double(345.9),"Row2","Col1") is a void method call, and thus it cannot be parameterized
    4
    d1.addValue(new Double(345.9), "Row2", "Col1");
                                                                                                    
    5
    d1.addValue(new Double(452.7), "Row2", "Col2");
    Preondition Violations
    Unmatched statement d1.addValue(new Double(452.7),"Row2","Col2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    d1.addValue(new Double(452.7), "Row2", "Col2");
    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
    DefaultKeyedValues2DDataset 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.DefaultKeyedValues2DDatasetVARIABLE_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.DefaultKeyedValues2DDataset of variable d1
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultKeyedValues2DDataset 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 = (DefaultKeyedValues2DDataset)in.readObject();
    Preondition Violations
    Unmatched statement d2=(DefaultKeyedValues2DDataset)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=(DefaultKeyedValues2DDataset)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 = (DefaultKeyedValues2DDataset)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.DefaultKeyedValues2DDatasetVARIABLE_TYPE_MISMATCH
    c2d2VARIABLE_NAME_MISMATCH
    org.jfree.chart.JFreeChartorg.jfree.data.general.DefaultKeyedValues2DDatasetVARIABLE_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.DefaultKeyedValues2DDataset of variable d1
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultKeyedValues2DDataset extend a common superclass
    Type org.jfree.chart.JFreeChart of variable c2 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d2
    • Make classes org.jfree.chart.JFreeChart and org.jfree.data.general.DefaultKeyedValues2DDataset extend a common superclass
    15
    assertEquals(d1, d2);
    Precondition Violations (57)
    Row Violation
    1Expression new DefaultPieDataset() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression data.setValue("Type 1",54.5) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression d1.addValue(new Double(234.2),"Row1","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression data.setValue("Type 1",54.5) is a void method call, and thus it cannot be parameterized
    5Expression d1.addValue(new Double(234.2),"Row1","Col1") is a void method call, and thus it cannot be parameterized
    6Expression data cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    9Expression data.setValue("Type 1",54.5) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression d1.addValue(new Double(234.2),"Row1","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression data.setValue("Type 1",54.5) is a void method call, and thus it cannot be parameterized
    12Expression d1.addValue(new Double(234.2),"Row1","Col1") is a void method call, and thus it cannot be parameterized
    13Expression data.setValue("Type 2",23.9) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression d1.addValue(null,"Row1","Col2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression data.setValue("Type 2",23.9) is a void method call, and thus it cannot be parameterized
    16Expression d1.addValue(null,"Row1","Col2") is a void method call, and thus it cannot be parameterized
    17Expression data cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    20Expression data.setValue("Type 2",23.9) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression d1.addValue(null,"Row1","Col2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression data.setValue("Type 2",23.9) is a void method call, and thus it cannot be parameterized
    23Expression d1.addValue(null,"Row1","Col2") is a void method call, and thus it cannot be parameterized
    24Expression data.setValue("Type 3",45.8) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression d1.addValue(new Double(345.9),"Row2","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression data.setValue("Type 3",45.8) is a void method call, and thus it cannot be parameterized
    27Expression d1.addValue(new Double(345.9),"Row2","Col1") is a void method call, and thus it cannot be parameterized
    28Expression data cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression data cannot be unified with expression d1 , because common superclass org.jfree.data.general.AbstractDataset does not declare member(s) public void setValue(Comparable#RAW, double) , public void addValue(java.lang.Number, Comparable#RAW, Comparable#RAW)
    31Expression data.setValue("Type 3",45.8) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    32Expression d1.addValue(new Double(345.9),"Row2","Col1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33Expression data.setValue("Type 3",45.8) is a void method call, and thus it cannot be parameterized
    34Expression d1.addValue(new Double(345.9),"Row2","Col1") is a void method call, and thus it cannot be parameterized
    35Unmatched statement d1.addValue(new Double(452.7),"Row2","Col2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    36Unmatched 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
    37Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    38Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    39Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    40Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    41Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    42Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    43Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    44Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    45Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    46Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    47Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    48Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d1
    49Unmatched statement d2=(DefaultKeyedValues2DDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    50Unmatched statement d2=(DefaultKeyedValues2DDataset)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
    51Unmatched 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
    52Unmatched 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
    53Expression c1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    54Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    55Type org.jfree.chart.JFreeChart of variable c1 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d1
    56Type org.jfree.chart.JFreeChart of variable c2 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d2
    57Clone fragment #1 returns variables data, in , while Clone fragment #2 returns variables d1, in