362-2-6

GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp); LabelBlock 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 = (LabelBlock) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2);
StrokeMap m1 = new StrokeMap(); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); StrokeMap 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 = (StrokeMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2);

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

1

    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, ↵

2

                    Color.blue);↵

3

            LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", ↵

4

                    Font.PLAIN, 12), gp);↵

5

            LabelBlock b↵

1

    StrokeMap m1 = new StrokeMap();↵

2

            m1.put("K1", new BasicStroke(1.1f));↵

3

            m1.put("K2", new BasicStroke(2.2f));↵

6

    2 = null;↵

4

            StrokeMap m2 = null;↵

7

            try {↵

5

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(b1);↵

8

                out.writeObject(m1);↵

11

                out.close();↵

9

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

10

                ObjectInput in = new ObjectInputStream(↵

13

                        new ByteArrayInputStream(↵

11

    new ByteArrayInputStream(↵

14

    buffer.toByteArray()));↵

12

                        buffer.toByteArray()));↵

15

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

13

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

16

                in.close();↵

14

                in.close();↵

17

            }↵

15

            }↵

18

            catch (Exception e) {↵

16

            catch (Exception e) {↵

19

                e.printStackTrace();↵

17

                e.printStackTrace();↵

20

            }↵

18

            }↵

21

            assertEquals(b1, b2);

19

            assertEquals(m1, m2);

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 | 84

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 4
   Number of unmapped statements in the second code fragment | 5
   Time elapsed for statement mapping (ms) | 2.2
   Clone type | Type 3

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

   1

       StrokeMap m1 = new StrokeMap();

   1

       GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue);

   2

       m1.put("K1", new BasicStroke(1.1f));

   2

       LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp);

   3

       m1.put("K2", new BasicStroke(2.2f));

   3

       LabelBlock b2 = null;

   4

       StrokeMap m2 = null;

   4

       try

   5

       try

   5

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   6

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   6

       ObjectOutput out = new ObjectOutputStream(buffer);

   7

       ObjectOutput out = new ObjectOutputStream(buffer);

   7

       out.writeObject(b1);

   7 | out.writeObject(b1);
   8 | out.writeObject(m1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | m1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.block.LabelBlock | org.jfree.chart.StrokeMap | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.block.LabelBlock of variable b1 does not match with type org.jfree.chart.StrokeMap of variable m1
   - Make classes org.jfree.chart.block.LabelBlock and org.jfree.chart.StrokeMap extend a common superclass

   8

       out.writeObject(m1);

   8

       out.close();

   9

       out.close();

   9

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

   10

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

   10

       b2 = (LabelBlock)in.readObject();

   10 | b2 = (LabelBlock)in.readObject();

   Preondition Violations
   Unmatched statement b2=(LabelBlock)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched statement b2=(LabelBlock)in.readObject(); 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

   11 | m2 = (StrokeMap)in.readObject();

   Preondition Violations
   Unmatched statement m2=(StrokeMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched statement m2=(StrokeMap)in.readObject(); 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

   11

       m2 = (StrokeMap)in.readObject();

   11

       in.close();

   12

       in.close();

   12

       assertEquals(b1, b2);

   12 | assertEquals(b1, b2);
   13 | assertEquals(m1, m2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | m1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.block.LabelBlock | org.jfree.chart.StrokeMap | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.block.LabelBlock of variable b1 does not match with type org.jfree.chart.StrokeMap of variable m1
   - Make classes org.jfree.chart.block.LabelBlock and org.jfree.chart.StrokeMap extend a common superclass

   13

       assertEquals(m1, m2);

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Type org.jfree.chart.block.LabelBlock of variable b1 does not match with type org.jfree.chart.StrokeMap of variable m1
   2 | Unmatched statement b2=(LabelBlock)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement b2=(LabelBlock)in.readObject(); 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
   4 | Unmatched statement m2=(StrokeMap)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   5 | Unmatched statement m2=(StrokeMap)in.readObject(); 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
   6 | Type org.jfree.chart.block.LabelBlock of variable b1 does not match with type org.jfree.chart.StrokeMap of variable m1