boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(3.0, 4.0, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success);
try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(null, new Double(4.0), "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java
Method name: void testDrawWithNullInfo() Method name: void testDrawWithNullMeanHorizontal()
Number of AST nodes: 10 Number of AST nodes: 9
1
boolean success = false;
2
        try {
1
try {
3
            DefaultStatisticalCategoryDataset dataset
2
            DefaultStatisticalCategoryDataset dataset
4
                    = new DefaultStatisticalCategoryDataset();
3
                    = new DefaultStatisticalCategoryDataset();
5
            dataset.add(1.0, 2.0, "S1", "C1");
4
            dataset.add(1.0, 2.0, "S1", "C1");
6
            dataset.add(3.0, 4.0, "S1", "C2");
5
            dataset.add(null, new Double(4.0), "S1", "C2");
7
            CategoryPlot plot = new CategoryPlot(dataset,
6
            CategoryPlot plot = new CategoryPlot(dataset,
8
                    new CategoryAxis("Category"), new NumberAxis("Value"),
7
                    new CategoryAxis("Category"), new NumberAxis("Value"),
9
                    new StatisticalBarRenderer());
8
                    new StatisticalBarRenderer());
9
            plot.setOrientation(PlotOrientation.HORIZONTAL);
10
            JFreeChart chart = new JFreeChart(plot);
10
            JFreeChart chart = new JFreeChart(plot);
11
            /* BufferedImage image = */ chart.createBufferedImage(300, 200,
11
            /* BufferedImage image = */ chart.createBufferedImage(300, 200,
12
                    null);
12
                    null);
13
            success = true;
13
            success = true;
14
        }
14
        }
15
        catch (NullPointerException e) {
15
        catch (NullPointerException e) {
16
            e.printStackTrace();
16
            e.printStackTrace();
17
            success = false;
17
            success = false;
18
        }
18
        }
19
        assertTrue(success);
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.1
Clones locationClones are declared in the same class
Number of node comparisons72
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)83.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    boolean success = false;
                                                      
    2
    try
    2
    try
    3
    DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset();
    3
    DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset();
    4
    dataset.add(1.0, 2.0, "S1", "C1");
    4
    dataset.add(1.0, 2.0, "S1", "C1");
                                                                                                  
    5
    dataset.add(null, new Double(4.0), "S1", "C2");
    Preondition Violations
    Unmatched statement dataset.add(null,new Double(4.0),"S1","C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement dataset.add(null,new Double(4.0),"S1","C2"); 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
    5
    dataset.add(null, new Double(4.0), "S1", "C2");
    5
    dataset.add(3.0, 4.0, "S1", "C2");
    5
    dataset.add(3.0, 4.0, "S1", "C2");
    7
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    Differences
    Expression1Expression2Difference
    addsetOrientationMETHOD_INVOCATION_NAME_MISMATCH
    datasetplotVARIABLE_NAME_MISMATCH
    org.jfree.data.statistics.DefaultStatisticalCategoryDatasetorg.jfree.chart.plot.CategoryPlotSUBCLASS_TYPE_MISMATCH
    dataset.add(3.0,4.0,"S1","C2")plot.setOrientation(PlotOrientation.HORIZONTAL)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression dataset.add(3.0,4.0,"S1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot.setOrientation(PlotOrientation.HORIZONTAL) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dataset.add(3.0,4.0,"S1","C2") is a void method call, and thus it cannot be parameterized
    Expression plot.setOrientation(PlotOrientation.HORIZONTAL) is a void method call, and thus it cannot be parameterized
    Expression dataset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dataset cannot be unified with expression plot , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(double, double, Comparable#RAW, Comparable#RAW) , public void setOrientation(org.jfree.chart.plot.PlotOrientation)
    Expression dataset.add(3.0,4.0,"S1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression plot.setOrientation(PlotOrientation.HORIZONTAL) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dataset.add(3.0,4.0,"S1","C2") is a void method call, and thus it cannot be parameterized
    Expression plot.setOrientation(PlotOrientation.HORIZONTAL) is a void method call, and thus it cannot be parameterized
    7
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    6
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer());
    6
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer());
    7
    JFreeChart chart = new JFreeChart(plot);
    8
    JFreeChart chart = new JFreeChart(plot);
    8
    chart.createBufferedImage(300, 200, null);
    9
    chart.createBufferedImage(300, 200, null);
    9
    success = true;
    10
    success = true;
    10
    assertTrue(success);
    10
    assertTrue(success);
    Preondition Violations
    Unmatched statement assertTrue(success); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
    Precondition Violations (15)
    Row Violation
    1Unmatched statement dataset.add(null,new Double(4.0),"S1","C2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement dataset.add(null,new Double(4.0),"S1","C2"); 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
    3Expression dataset.add(3.0,4.0,"S1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression plot.setOrientation(PlotOrientation.HORIZONTAL) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression dataset.add(3.0,4.0,"S1","C2") is a void method call, and thus it cannot be parameterized
    6Expression plot.setOrientation(PlotOrientation.HORIZONTAL) is a void method call, and thus it cannot be parameterized
    7Expression dataset cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression plot cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression dataset cannot be unified with expression plot , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(double, double, Comparable#RAW, Comparable#RAW) , public void setOrientation(org.jfree.chart.plot.PlotOrientation)
    10Expression dataset.add(3.0,4.0,"S1","C2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression plot.setOrientation(PlotOrientation.HORIZONTAL) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression dataset.add(3.0,4.0,"S1","C2") is a void method call, and thus it cannot be parameterized
    13Expression plot.setOrientation(PlotOrientation.HORIZONTAL) is a void method call, and thus it cannot be parameterized
    14Unmatched statement assertTrue(success); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Clone fragment #1 returns variables , while Clone fragment #2 returns variables success