112-50-98

IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (IntervalMarker) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = m1.equals(m2); assertTrue(b);
EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (EmptyBlock) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(b1, b2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/IntervalMarkerTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/block/junit/EmptyBlockTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 12 |  | Number of AST nodes: 11

1

    IntervalMarker m1 = new IntervalMarker(45.0, 50.0);↵

1

    EmptyBlock b1 = new EmptyBlock(1.0, 2.0);↵

2

            IntervalMarker m2 = null;↵

2

            EmptyBlock b2 = null;↵

3

            try {↵

3

            try {↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

6

                out.writeObject(m1);↵

6

                out.writeObject(b1);↵

7

                out.close();↵

7

                out.close();↵

8

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

9

                        new ByteArrayInputStream(buffer.toByteArray()));↵

9

                        new ByteArrayInputStream(buffer.toByteArray()));↵

10

                m2 = (IntervalMarker) in.readObject();↵

10

                b2 = (EmptyBlock) in.readObject();↵

11

                in.close();↵

11

                in.close();↵

12

            }↵

12

            }↵

13

            catch (Exception e) {↵

13

            catch (Exception e) {↵

14

                e.printStackTrace();↵

14

                fail(e.toString());↵

15

            }↵

15

            }↵

16

            boolean b = m1.equals(m2);↵

16

            ↵

17

            assertTrue(b);

17

    assertEquals(b1, b2);

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.1
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 71

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 11
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 2.0
   Clone type | Type 3

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

   1

       IntervalMarker m1 = new IntervalMarker(45.0, 50.0);

   1 | IntervalMarker m1 = new IntervalMarker(45.0, 50.0);
   1 | EmptyBlock b1 = new EmptyBlock(1.0, 2.0);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | b1 | VARIABLE_NAME_MISMATCH
   45.0 | 1.0 | LITERAL_VALUE_MISMATCH
   50.0 | 2.0 | LITERAL_VALUE_MISMATCH

   1

       EmptyBlock b1 = new EmptyBlock(1.0, 2.0);

   2

       IntervalMarker m2 = null;

   2 | IntervalMarker m2 = null;
   2 | EmptyBlock b2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m2 | b2 | VARIABLE_NAME_MISMATCH

   2

       EmptyBlock b2 = null;

   3

       try

   3 | try
   3 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   printStackTrace | fail | METHOD_INVOCATION_NAME_MISMATCH
   e.printStackTrace() | fail(e.toString()) | ARGUMENT_NUMBER_MISMATCH
   e |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized

   3

       try

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   6

       out.writeObject(m1);

   6 | out.writeObject(m1);
   6 | out.writeObject(b1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m1 | b1 | VARIABLE_NAME_MISMATCH

   6

       out.writeObject(b1);

   7

       out.close();

   7

       out.close();

   8

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   8

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   9

       m2 = (IntervalMarker)in.readObject();

   9 | m2 = (IntervalMarker)in.readObject();
   9 | b2 = (EmptyBlock)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   m2 | b2 | VARIABLE_NAME_MISMATCH

   9

       b2 = (EmptyBlock)in.readObject();

   10

       in.close();

   10

       in.close();

   11

       boolean b = m1.equals(m2);

   11 | boolean b = m1.equals(m2);

   Preondition Violations
   Unmatched statement boolean b=m1.equals(m2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   12

       assertTrue(b);

   12 | assertTrue(b);
   11 | assertEquals(b1, b2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(b) | assertEquals(b1,b2) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized

   11

       assertEquals(b1, b2);

   Precondition Violations (12)
   Row | Violation
   --- | ---
   1 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   2 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   3 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   4 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   5 | Unmatched statement boolean b=m1.equals(m2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
   8 | Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   9 | Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
   11 | Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   12 | Clone fragment #1 returns variables m1, m2 , while Clone fragment #2 returns variables