39-1-5

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);
DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DialTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); // test a custom instance a1 = new DialTextAnnotation("A1"); a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DialTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2);

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

1

    StandardDialScale s1 = new StandardDialScale();↵

2

            StandardDialScale s↵

1

    DialTextAnnotation a1 = new DialTextAnnotation("A1");↵

3

    2 = null;↵

2

            DialTextAnnotation a2 = null;↵

4

            try {↵

3

            try {↵

5

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

6

                ObjectOutput out = new ObjectOutputStream(buffer);↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

7

                out.writeObject(s1);↵

6

                out.writeObject(a1);↵

8

                out.close();↵

7

                out.close();↵

9

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

10

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

9

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

11

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

10

                a2 = (DialTextAnnotation) in.readObject();↵

12

                in.close();↵

11

                in.close();↵

13

            }↵

12

            }↵

14

            catch (Exception e) {↵

13

            catch (Exception e) {↵

15

                e.printStackTrace();↵

14

                e.printStackTrace();↵

16

            }↵

15

            }↵

17

            assertEquals(s1, s2);↵

16

            assertEquals(a1, a2);↵

18

            ↵

17

            ↵

19

            // try a customised instance↵

18

            // test a custom instance↵

20

            s1 = new StandardDialScale();↵

19

            a1 = new ↵

21

            s1.setExtent(123.4);↵

20

    DialTextAnnotation("A1");↵

22

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

21

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

23

                    4.0f, Color.white));↵

22

                    Color.blue));↵

24

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

23

            ↵

25

            s2 = null;↵

24

    a2 = null;↵

26

            try {↵

25

            try {↵

27

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

26

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

28

                ObjectOutput out = new ObjectOutputStream(buffer);↵

27

                ObjectOutput out = new ObjectOutputStream(buffer);↵

29

                out.writeObject(s1);↵

28

                out.writeObject(a1);↵

30

                out.close();↵

29

                out.close();↵

31

                ObjectInput in = new ObjectInputStream(↵

30

                ObjectInput in = new ObjectInputStream(↵

32

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

31

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

33

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

32

                a2 = (DialTextAnnotation) in.readObject();↵

34

                in.close();↵

33

                in.close();↵

35

            }↵

34

            }↵

36

            catch (Exception e) {↵

35

            catch (Exception e) {↵

37

                e.printStackTrace();↵

36

                e.printStackTrace();↵

38

            }↵

37

            }↵

39

            assertEquals(s1, s2);

38

            assertEquals(a1, a2);

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

1. {Non-refactorable}

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

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

   1

       StandardDialScale s1 = new StandardDialScale();

   1 | StandardDialScale s1 = new StandardDialScale();
   1 | DialTextAnnotation a1 = new DialTextAnnotation("A1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH
   new StandardDialScale() | new DialTextAnnotation("A1") | ARGUMENT_NUMBER_MISMATCH

   1

       DialTextAnnotation a1 = new DialTextAnnotation("A1");

   2

       StandardDialScale s2 = null;

   2 | StandardDialScale s2 = null;
   2 | DialTextAnnotation a2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | a2 | VARIABLE_NAME_MISMATCH

   2

       DialTextAnnotation a2 = 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(s1);

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH

   6

       out.writeObject(a1);

   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

       s2 = (StandardDialScale)in.readObject();

   9 | s2 = (StandardDialScale)in.readObject();
   9 | a2 = (DialTextAnnotation)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | a2 | VARIABLE_NAME_MISMATCH

   9

       a2 = (DialTextAnnotation)in.readObject();

   10

       in.close();

   10

       in.close();

   11

       assertEquals(s1, s2);

   11 | assertEquals(s1, s2);
   11 | assertEquals(a1, a2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH
   s2 | a2 | VARIABLE_NAME_MISMATCH

   11

       assertEquals(a1, a2);

   12

       s1 = new StandardDialScale();

   12 | s1 = new StandardDialScale();
   12 | a1 = new DialTextAnnotation("A1");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH
   new StandardDialScale() | new DialTextAnnotation("A1") | ARGUMENT_NUMBER_MISMATCH

   12

       a1 = new DialTextAnnotation("A1");

   13

       s1.setExtent(123.4);

   14

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

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setMajorTickPaint | setPaint | METHOD_INVOCATION_NAME_MISMATCH
   white | blue | VARIABLE_NAME_MISMATCH
   s1 | a1 | VARIABLE_NAME_MISMATCH

   Preondition Violations
   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 a1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) 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)) is a void method call, and thus it cannot be parameterized
   Expression a1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized

   13

       a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));

   15

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

   16

       s2 = null;

   16 | s2 = null;
   14 | a2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | a2 | VARIABLE_NAME_MISMATCH

   14

       a2 = null;

   17

       try

   15

       try

   18

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   16

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   19

       ObjectOutput out = new ObjectOutputStream(buffer);

   17

       ObjectOutput out = new ObjectOutputStream(buffer);

   20

       out.writeObject(s1);

   20 | out.writeObject(s1);
   18 | out.writeObject(a1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH

   18

       out.writeObject(a1);

   21

       out.close();

   19

       out.close();

   22

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

   20

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

   23

       s2 = (StandardDialScale)in.readObject();

   23 | s2 = (StandardDialScale)in.readObject();
   21 | a2 = (DialTextAnnotation)in.readObject();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s2 | a2 | VARIABLE_NAME_MISMATCH

   21

       a2 = (DialTextAnnotation)in.readObject();

   24

       in.close();

   22

       in.close();

   25

       assertEquals(s1, s2);

   25 | assertEquals(s1, s2);
   23 | assertEquals(a1, a2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   s1 | a1 | VARIABLE_NAME_MISMATCH
   s2 | a2 | VARIABLE_NAME_MISMATCH

   23

       assertEquals(a1, a2);

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | 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
   2 | Expression a1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | 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
   4 | Expression a1.setPaint(new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.blue)) is a void method call, and thus it cannot be parameterized
   5 | Clone fragment #1 returns variables s1 , while Clone fragment #2 returns variables