1031-1-2

try { SAXParser parser = factory.newSAXParser(); PieDatasetHandler handler = new PieDatasetHandler(); parser.parse(in, handler); result = handler.getDataset(); } catch (SAXException e) { System.out.println(e.getMessage()); } catch (ParserConfigurationException e2) { System.out.println(e2.getMessage()); }
try { SAXParser parser = factory.newSAXParser(); CategoryDatasetHandler handler = new CategoryDatasetHandler(); parser.parse(in, handler); result = handler.getDataset(); } catch (SAXException e) { System.out.println(e.getMessage()); } catch (ParserConfigurationException e2) { System.out.println(e2.getMessage()); }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/xml/DatasetReader.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/xml/DatasetReader.java
Method name: `PieDataset readPieDatasetFromXML(InputStream)` |  | Method name: `CategoryDataset readCategoryDatasetFromXML(InputStream)`
Number of AST nodes: 5 |  | Number of AST nodes: 5

1

    try {↵

1

    try {↵

2

                SAXParser parser = factory.newSAXParser();↵

2

                SAXParser parser = factory.newSAXParser();↵

3

                PieDatasetHandler handler = new PieDatasetHandler();↵

3

                CategoryDatasetHandler handler = new CategoryDatasetHandler();↵

4

                parser.parse(in, handler);↵

4

                parser.parse(in, handler);↵

5

                result = handler.getDataset();↵

5

                result = handler.getDataset();↵

6

            }↵

6

            }↵

7

            catch (SAXException e) {↵

7

            catch (SAXException e) {↵

8

                System.out.println(e.getMessage());↵

8

                System.out.println(e.getMessage());↵

9

            }↵

9

            }↵

10

            catch (ParserConfigurationException e2) {↵

10

            catch (ParserConfigurationException e2) {↵

11

                System.out.println(e2.getMessage());↵

11

                System.out.println(e2.getMessage());↵

12

            }

12

            }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3
Clones location | Clones are declared in the same class
Number of node comparisons | 25

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 4
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 0.7
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   3

       try

   3

       try

   4

       SAXParser parser = factory.newSAXParser();

   4

       SAXParser parser = factory.newSAXParser();

   5

       PieDatasetHandler handler = new PieDatasetHandler();

   5 | PieDatasetHandler handler = new PieDatasetHandler();
   5 | CategoryDatasetHandler handler = new CategoryDatasetHandler();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.xml.PieDatasetHandler | org.jfree.data.xml.CategoryDatasetHandler | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.xml.PieDatasetHandler | org.jfree.data.xml.CategoryDatasetHandler | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.xml.PieDatasetHandler | org.jfree.data.xml.CategoryDatasetHandler | SUBCLASS_TYPE_MISMATCH

   5

       CategoryDatasetHandler handler = new CategoryDatasetHandler();

   6

       parser.parse(in, handler);

   6 | parser.parse(in, handler);
   6 | parser.parse(in, handler);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.xml.PieDatasetHandler | org.jfree.data.xml.CategoryDatasetHandler | SUBCLASS_TYPE_MISMATCH

   6

       parser.parse(in, handler);

   7

       result = handler.getDataset();

   7

       result = handler.getDataset();

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variable handler with type org.jfree.data.xml.PieDatasetHandler , while Clone fragment #2 returns variable handler with type org.jfree.data.xml.CategoryDatasetHandler