173-207-208

if (buffer == null) { buffer = new Buffer(100); } buffer.write(b);
if (buffer == null) { buffer = new Buffer(100); } return buffer.read();

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/resource/URIConverter.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/ecore/resource/URIConverter.java
Method name: `void write(int)` |  | Method name: `int read()`
Number of AST nodes: 3 |  | Number of AST nodes: 3

1

    if (buffer == null)↵

1

    if (buffer == null)↵

2

          {↵

2

          {↵

3

            buffer = new Buffer(100);↵

3

            buffer = new Buffer(100);↵

4

          }↵

4

          }↵

5

          ↵

5

          ↵

6

          buffer.write(b);

6

          return buffer.read();

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.2
Clones location | Clones are in the same java file
Number of node comparisons | 5

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 2
   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) | 1.5
   Clone type | Type 2

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

   1

       if (buffer == null)

   1 | if (buffer == null)
   1 | if (buffer == null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.eclipse.emf.ecore.resource.URIConverter.WriteableOutputStream.Buffer | org.eclipse.emf.ecore.resource.URIConverter.ReadableInputStream.Buffer | SUBCLASS_TYPE_MISMATCH

   1

       if (buffer == null)

   2

       buffer = new Buffer(100);

   2 | buffer = new Buffer(100);
   2 | buffer = new Buffer(100);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.eclipse.emf.ecore.resource.URIConverter.WriteableOutputStream.Buffer | org.eclipse.emf.ecore.resource.URIConverter.ReadableInputStream.Buffer | SUBCLASS_TYPE_MISMATCH
   org.eclipse.emf.ecore.resource.URIConverter.WriteableOutputStream.Buffer | org.eclipse.emf.ecore.resource.URIConverter.ReadableInputStream.Buffer | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression new Buffer(100) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression new Buffer(100) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   2

       buffer = new Buffer(100);

   3 | return buffer.read();

   Preondition Violations
   Unmatched statement return buffer.read(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
   Unmatched return buffer.read();

   3

       return buffer.read();

   3

       buffer.write(b);

   3 | buffer.write(b);

   Preondition Violations
   Unmatched statement buffer.write(b); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Expression new Buffer(100) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression new Buffer(100) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement return buffer.read(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
   4 | Unmatched return buffer.read();
   5 | Unmatched statement buffer.write(b); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted