IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( StandardXYToolTipGenerator.getTimeSeriesInstance() ); XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); XYPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); p2 = (XYPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2);
Stroke s = new BasicStroke(1.23f); LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); g1.setOutlineStroke(s); LegendGraphic 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 = (LegendGraphic) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(g1.equals(g2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/XYPlotTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendGraphicTests.java
Method name: void testSerialization2() Method name: void testSerialization()
Number of AST nodes: 14 Number of AST nodes: 13
1
IntervalXYDataset data1 = createDataset1();
2
        XYItemRenderer renderer
1
Stroke s = new BasicStroke(1.23f);
3
1 = new XYBarRenderer(0.20);
2
        LegendGraphic g1 = new 
4
        renderer1.setToolTipGenerator(
5
            StandardXYToolTipGenerator.getTimeSeriesInstance()
6
        );
7
        XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1);
8
        XYPlot p
3
LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black);
4
        g1.setOutlineStroke(s);
9
2 = null;
5
        LegendGraphic g2 = null;
10
        try {
6
        try {
11
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
12
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            ObjectOutput out = new ObjectOutputStream(buffer);
13
            out.writeObject(p1);
9
            out.writeObject(g1);
14
            out.close();
10
            out.close();
15
            ObjectInput in = new ObjectInputStream(
11
            ObjectInput in = new ObjectInputStream(
16
                new ByteArrayInputStream(buffer.toByteArray())
12
                new ByteArrayInputStream(buffer.toByteArray())
17
            );
13
            );
18
            p2 = (XYPlot) in.readObject();
14
            g2 = (LegendGraphic) in.readObject();
19
            in.close();
15
            in.close();
20
        }
16
        }
21
        catch (Exception e) {
17
        catch (Exception e) {
22
            fail(e.toString());
18
            System.out.println(e.toString());
23
        }
19
        }
24
        assertEquals(p1, p2);
20
        assertTrue(g1.equals(g2));
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 comparisons89
  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 fragment2
    Time elapsed for statement mapping (ms)87.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                          
    1
    Stroke s = new BasicStroke(1.23f);
    1
    IntervalXYDataset data1 = createDataset1();
                                                                                            
    2
    XYItemRenderer renderer1 = new XYBarRenderer(0.20);
    2
    XYItemRenderer renderer1 = new XYBarRenderer(0.20);
    Preondition Violations
    Unmatched statement XYItemRenderer renderer1=new XYBarRenderer(0.20); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                            
    3
    renderer1.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    3
    renderer1.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    Preondition Violations
    Unmatched statement renderer1.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                              
    4
    XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1);
    4
    XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1);
    2
    LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    p1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    new XYPlot(data1,new DateAxis("Date"),null,renderer1)new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new XYPlot(data1,new DateAxis("Date"),null,renderer1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new XYPlot(data1,new DateAxis("Date"),null,renderer1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black);
                                                        
    3
    g1.setOutlineStroke(s);
    Preondition Violations
    Unmatched statement g1.setOutlineStroke(s); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    g1.setOutlineStroke(s);
    5
    XYPlot p2 = null;
    5
    XYPlot p2 = null;
    4
    LegendGraphic g2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    p2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    4
    LegendGraphic g2 = null;
    6
    try
    6
    try
    5
    try
    Differences
    Expression1Expression2Difference
    failprintlnMETHOD_INVOCATION_NAME_MISMATCH
    fail(e.toString())System.out.println(e.toString())TYPE_COMPATIBLE_REPLACEMENT
    System.outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression fail(e.toString()) 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 fail(e.toString()) 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 fail(e.toString()) 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 fail(e.toString()) 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
    5
    try
    7
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    8
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    ObjectOutput out = new ObjectOutputStream(buffer);
    9
    out.writeObject(p1);
    9
    out.writeObject(p1);
    8
    out.writeObject(g1);
    Differences
    Expression1Expression2Difference
    p1g1VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression p1 cannot be unified with expression g1 , 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
    8
    out.writeObject(g1);
    10
    out.close();
    9
    out.close();
    11
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    10
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    12
    p2 = (XYPlot)in.readObject();
    12
    p2 = (XYPlot)in.readObject();
    11
    g2 = (LegendGraphic)in.readObject();
    Differences
    Expression1Expression2Difference
    p2g2VARIABLE_NAME_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.plot.XYPlotorg.jfree.chart.title.LegendGraphicSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (XYPlot)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (LegendGraphic)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    g2 = (LegendGraphic)in.readObject();
    13
    in.close();
    12
    in.close();
    14
    assertEquals(p1, p2);
    14
    assertEquals(p1, p2);
    13
    assertTrue(g1.equals(g2));
    Differences
    Expression1Expression2Difference
    assertEqualsassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(p1,p2)assertTrue(g1.equals(g2))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized
    13
    assertTrue(g1.equals(g2));
    Precondition Violations (27)
    Row Violation
    1Unmatched statement XYItemRenderer renderer1=new XYBarRenderer(0.20); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement renderer1.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression new XYPlot(data1,new DateAxis("Date"),null,renderer1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression new XYPlot(data1,new DateAxis("Date"),null,renderer1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new LegendGraphic(new Rectangle2D.Double(1.0,2.0,3.0,4.0),Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Unmatched statement g1.setOutlineStroke(s); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    11Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    12Expression fail(e.toString()) 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 fail(e.toString()) 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 p1 cannot be unified with expression g1 , 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 (XYPlot)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression (LegendGraphic)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
    22Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized
    23Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression assertTrue(g1.equals(g2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
    26Expression assertTrue(g1.equals(g2)) is a void method call, and thus it cannot be parameterized
    27Clone fragment #1 returns variables , while Clone fragment #2 returns variables g1