39-4-6

LookupPaintScale g1 = new LookupPaintScale(); LookupPaintScale g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (LookupPaintScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); g1.add(new Double(1.5), new GradientPaint(1.1f, 2.2f, Color.red, 3.3f, 4.4f, Color.blue)); g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (LookupPaintScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2);
DefaultWindDataset d1 = new DefaultWindDataset(); DefaultWindDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultWindDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... d1 = createSampleDataset1(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultWindDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultWindDatasetTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 23 |  | Number of AST nodes: 21

1

    LookupPaintScale g1 = new LookupPaintScale();↵

2

            LookupPaintScale g↵

1

    DefaultWindDataset d1 = new DefaultWindDataset();↵

3

    2 = null;↵

2

            DefaultWindDataset d2 = 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(g1);↵

6

                out.writeObject(d1);↵

8

                out.close();↵

7

                out.close();↵

9

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

10

                        new ByteArrayInputStream(↵

9

    new ByteArrayInputStream(↵

11

    buffer.toByteArray()));↵

10

                        buffer.toByteArray()));↵

12

                g2 = (LookupPaintScale) in.readObject();↵

11

                d2 = (DefaultWindDataset) in.readObject();↵

13

                in.close();↵

12

                in.close();↵

14

            }↵

13

            }↵

15

            catch (Exception e) {↵

14

            catch (Exception e) {↵

16

                e.printStackTrace();↵

15

                e.printStackTrace();↵

17

            }↵

16

            }↵

18

            assertEquals(g1, g2);       ↵

17

            assertEquals(d1, d2);↵

19

            ↵

20

            g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, ↵

21

                    Color.red, 3.0f, 4.0f, Color.yellow));↵

22

            g1.add(new Double(1.5), new GradientPaint(1.1f, 2.2f, Color.red, 3.3f, ↵

23

                    4.4f, Color.blue));↵

24

            g2 = null↵

18

            // try a dataset with some content...↵

25

    ;↵

19

            d1 = createSampleDataset1();↵

26

            try {↵

20

            try {↵

27

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

21

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

28

                ObjectOutput out = new ObjectOutputStream(buffer);↵

22

                ObjectOutput out = new ObjectOutputStream(buffer);↵

29

                out.writeObject(g1);↵

23

                out.writeObject(d1);↵

30

                out.close();↵

24

                out.close();↵

31

                ObjectInput in = new ObjectInputStream(↵

25

                ObjectInput in = new ObjectInputStream(↵

32

                        new ByteArrayInputStream(↵

26

    new ByteArrayInputStream(↵

33

    buffer.toByteArray()));↵

27

                        buffer.toByteArray()));↵

34

                g2 = (LookupPaintScale) in.readObject();↵

28

                d2 = (DefaultWindDataset) in.readObject();↵

35

                in.close();↵

29

                in.close();↵

36

            }↵

30

            }↵

37

            catch (Exception e) {↵

31

            catch (Exception e) {↵

38

                e.printStackTrace();↵

32

                e.printStackTrace();↵

39

            }↵

33

            }↵

40

            assertEquals(g1, g2);

34

            assertEquals(d1, d2);

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

1. {Non-refactorable}

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

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

   1

       DefaultWindDataset d1 = new DefaultWindDataset();

   1

       LookupPaintScale g1 = new LookupPaintScale();

   2

       DefaultWindDataset d2 = null;

   2

       LookupPaintScale g2 = 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(g1);

   6 | out.writeObject(g1);
   6 | out.writeObject(d1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   g1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.renderer.LookupPaintScale | org.jfree.data.xy.DefaultWindDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   - Make classes org.jfree.chart.renderer.LookupPaintScale and org.jfree.data.xy.DefaultWindDataset extend a common superclass

   6

       out.writeObject(d1);

   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 | d2 = (DefaultWindDataset)in.readObject();

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

   9

       d2 = (DefaultWindDataset)in.readObject();

   9

       g2 = (LookupPaintScale)in.readObject();

   9 | g2 = (LookupPaintScale)in.readObject();

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

   10

       in.close();

   10

       in.close();

   11

       assertEquals(g1, g2);

   11 | assertEquals(g1, g2);
   11 | assertEquals(d1, d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   g1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.renderer.LookupPaintScale | org.jfree.data.xy.DefaultWindDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   - Make classes org.jfree.chart.renderer.LookupPaintScale and org.jfree.data.xy.DefaultWindDataset extend a common superclass

   11

       assertEquals(d1, d2);

   12 | d1 = createSampleDataset1();

   Preondition Violations
   Unmatched statement d1=createSampleDataset1(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   12

       d1 = createSampleDataset1();

   12

       g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));

   12 | g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));

   Preondition Violations
   Unmatched statement g1=new LookupPaintScale(1.0,2.0,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   13

       g1.add(new Double(1.5), new GradientPaint(1.1f, 2.2f, Color.red, 3.3f, 4.4f, Color.blue));

   14

       g2 = null;

   14 | g2 = null;

   Preondition Violations
   Unmatched statement g2=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   15

       try

   13

       try

   16

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   14

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   17

       ObjectOutput out = new ObjectOutputStream(buffer);

   15

       ObjectOutput out = new ObjectOutputStream(buffer);

   18

       out.writeObject(g1);

   18 | out.writeObject(g1);
   16 | out.writeObject(d1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   g1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.renderer.LookupPaintScale | org.jfree.data.xy.DefaultWindDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   - Make classes org.jfree.chart.renderer.LookupPaintScale and org.jfree.data.xy.DefaultWindDataset extend a common superclass

   16

       out.writeObject(d1);

   19

       out.close();

   17

       out.close();

   20

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

   18

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

   19 | d2 = (DefaultWindDataset)in.readObject();

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

   19

       d2 = (DefaultWindDataset)in.readObject();

   21

       g2 = (LookupPaintScale)in.readObject();

   21 | g2 = (LookupPaintScale)in.readObject();

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

   22

       in.close();

   20

       in.close();

   23

       assertEquals(g1, g2);

   23 | assertEquals(g1, g2);
   21 | assertEquals(d1, d2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   g1 | d1 | VARIABLE_NAME_MISMATCH
   org.jfree.chart.renderer.LookupPaintScale | org.jfree.data.xy.DefaultWindDataset | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   - Make classes org.jfree.chart.renderer.LookupPaintScale and org.jfree.data.xy.DefaultWindDataset extend a common superclass

   21

       assertEquals(d1, d2);

   Precondition Violations (16)
   Row | Violation
   --- | ---
   1 | Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   2 | Unmatched statement d2=(DefaultWindDataset)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 d2=(DefaultWindDataset)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 g2=(LookupPaintScale)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 g2=(LookupPaintScale)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.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   7 | Unmatched statement d1=createSampleDataset1(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   8 | Unmatched statement g1=new LookupPaintScale(1.0,2.0,new GradientPaint(1.0f,2.0f,Color.red,3.0f,4.0f,Color.yellow)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   9 | Unmatched statement g2=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   10 | Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   11 | Unmatched statement d2=(DefaultWindDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   12 | Unmatched statement d2=(DefaultWindDataset)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
   13 | Unmatched statement g2=(LookupPaintScale)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   14 | Unmatched statement g2=(LookupPaintScale)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
   15 | Type org.jfree.chart.renderer.LookupPaintScale of variable g1 does not match with type org.jfree.data.xy.DefaultWindDataset of variable d1
   16 | Clone fragment #1 returns variables in, in , while Clone fragment #2 returns variables in, in