137-1-2

DialBackground b1 = new DialBackground(); DialBackground 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 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2); // test a customised instance b1 = new DialBackground(); b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); 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 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2);
StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); // try a customised instance s1 = new StandardDialScale(); s1.setExtent(123.4); s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); s1.setMajorTickStroke(new BasicStroke(2.0f)); s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialBackgroundTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 24 |  | Number of AST nodes: 25

1

    DialBackground b1 = new DialBackground();↵

1

    StandardDialScale s1 = new StandardDialScale();↵

2

            DialBackground b2 = null;↵

2

            StandardDialScale s2 = 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(b1);↵

6

                out.writeObject(s1);↵

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

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

10

                s2 = (StandardDialScale) in.readObject();↵

11

                in.close();↵

11

                in.close();↵

12

            }↵

12

            }↵

13

            catch (Exception e) {↵

13

            catch (Exception e) {↵

14

                e.printStackTrace();↵

14

                e.printStackTrace();↵

15

            }↵

15

            }↵

16

            assertEquals(b1, b2);↵

16

            assertEquals(s1, s2);↵

17

            ↵

17

            ↵

18

            // test a customised instance↵

18

            // try a customised instance↵

19

            b1 = new DialBackground(↵

19

            s1 = new StandardDialScale();↵

20

    );↵

20

            s1.setExtent(123.4);↵

21

            b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,↵

21

            s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, ↵

22

                    Color.green));↵

22

                    4.0f, Color.white));↵

23

            b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(↵

23

            s1.set↵

24

                    GradientPaintTransformType.CENTER_VERTICAL));↵

24

    MajorTickStroke(new BasicStroke(2.0f));↵

25

            b2 = null;↵

25

            s2 = null;↵

26

            try {↵

26

            try {↵

27

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

27

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

28

                ObjectOutput out = new ObjectOutputStream(buffer);↵

28

                ObjectOutput out = new ObjectOutputStream(buffer);↵

29

                out.writeObject(b1);↵

29

                out.writeObject(s1);↵

30

                out.close();↵

30

                out.close();↵

31

                ObjectInput in = new ObjectInputStream(↵

31

                ObjectInput in = new ObjectInputStream(↵

32

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

32

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

33

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

33

                s2 = (StandardDialScale) in.readObject();↵

34

                in.close();↵

34

                in.close();↵

35

            }↵

35

            }↵

36

            catch (Exception e) {↵

36

            catch (Exception e) {↵

37

                e.printStackTrace();↵

37

                e.printStackTrace();↵

38

            }↵

38

            }↵

39

            assertEquals(b1, b2);

39

            assertEquals(s1, s2);

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

1. {Non-refactorable}

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

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

   1

       DialBackground b1 = new DialBackground();

   1 | DialBackground b1 = new DialBackground();
   1 | StandardDialScale s1 = new StandardDialScale();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   1

       StandardDialScale s1 = new StandardDialScale();

   2

       DialBackground b2 = null;

   2 | DialBackground b2 = null;
   2 | StandardDialScale s2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   b2 | s2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   2

       StandardDialScale s2 = 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(b1);

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   6

       out.writeObject(s1);

   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

       b2 = (DialBackground)in.readObject();

   9 | b2 = (DialBackground)in.readObject();
   9 | s2 = (StandardDialScale)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b2 | s2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   9

       s2 = (StandardDialScale)in.readObject();

   10

       in.close();

   10

       in.close();

   11

       assertEquals(b1, b2);

   11 | assertEquals(b1, b2);
   11 | assertEquals(s1, s2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   b2 | s2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   11

       assertEquals(s1, s2);

   12

       b1 = new DialBackground();

   12 | b1 = new DialBackground();
   12 | s1 = new StandardDialScale();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   12

       s1 = new StandardDialScale();

   13

       s1.setExtent(123.4);

   13

       b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));

   13 | b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green));
   14 | s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setPaint | setMajorTickPaint | METHOD_INVOCATION_NAME_MISMATCH
   green | white | VARIABLE_NAME_MISMATCH
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized
   Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized

   14

       s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white));

   14

       b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));

   14 | b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
   25 | assertEquals(s1, s2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setGradientPaintTransformer | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) | assertEquals(s1,s2) | ARGUMENT_NUMBER_MISMATCH
   b1 |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(s1,s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(s1,s2) is a void method call, and thus it cannot be parameterized
   Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(s1,s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(s1,s2) is a void method call, and thus it cannot be parameterized

   25

       assertEquals(s1, s2);

   15

       b2 = null;

   15 | b2 = null;
   16 | s2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b2 | s2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   16

       s2 = null;

   16

       try

   17

       try

   17

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   18

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   18

       ObjectOutput out = new ObjectOutputStream(buffer);

   19

       ObjectOutput out = new ObjectOutputStream(buffer);

   19

       out.writeObject(b1);

   19 | out.writeObject(b1);
   20 | out.writeObject(s1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b1 | s1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   20

       out.writeObject(s1);

   20

       out.close();

   21

       out.close();

   21

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

   22

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

   22

       b2 = (DialBackground)in.readObject();

   22 | b2 = (DialBackground)in.readObject();
   23 | s2 = (StandardDialScale)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   b2 | s2 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.plot.dial.DialBackground | org.jfree.chart.plot.dial.StandardDialScale | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted

   23

       s2 = (StandardDialScale)in.readObject();

   23

       in.close();

   24

       in.close();

   24

       assertEquals(b1, b2);

   24 | assertEquals(b1, b2);
   15 | s1.setMajorTickStroke(new BasicStroke(2.0f));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertEquals | setMajorTickStroke | METHOD_INVOCATION_NAME_MISMATCH
   assertEquals(b1,b2) | s1.setMajorTickStroke(new BasicStroke(2.0f)) | ARGUMENT_NUMBER_MISMATCH
   | s1 | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) 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 s1.setMajorTickStroke(new BasicStroke(2.0f)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) is a void method call, and thus it cannot be parameterized

   15

       s1.setMajorTickStroke(new BasicStroke(2.0f));

   Precondition Violations (25)
   Row | Violation
   --- | ---
   1 | Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression b1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.green)) is a void method call, and thus it cannot be parameterized
   6 | Expression s1.setMajorTickPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.white)) is a void method call, and thus it cannot be parameterized
   7 | Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   8 | Expression assertEquals(s1,s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) is a void method call, and thus it cannot be parameterized
   10 | Expression assertEquals(s1,s2) is a void method call, and thus it cannot be parameterized
   11 | Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   12 | Expression assertEquals(s1,s2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   13 | Expression b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)) is a void method call, and thus it cannot be parameterized
   14 | Expression assertEquals(s1,s2) is a void method call, and thus it cannot be parameterized
   15 | Expression (DialBackground)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   16 | Expression (StandardDialScale)in.readObject() cannot be parameterized, because it has dependencies to/from statements that will be extracted
   17 | Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   18 | Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   19 | Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   20 | Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) is a void method call, and thus it cannot be parameterized
   21 | Expression assertEquals(b1,b2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   22 | Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   23 | Expression assertEquals(b1,b2) is a void method call, and thus it cannot be parameterized
   24 | Expression s1.setMajorTickStroke(new BasicStroke(2.0f)) is a void method call, and thus it cannot be parameterized
   25 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables s1