PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (StandardEntityCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);
CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker 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 = (CategoryMarker) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } boolean b = m1.equals(m2); assertTrue(b);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CategoryMarkerTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 13 Number of AST nodes: 12
1
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
1
CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 
2
                2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
2
                2.0f, Color.white, 3.0f, 4.0f, 
3
                "ToolTip", "URL");
4
        StandardEntityCollection c1 = new StandardEntityCollection();
5
        c1.add(e1);
6
        StandardEntityCollection c
3
Color.yellow), 
4
                new BasicStroke(1.1f));
7
2 = null;
5
        CategoryMarker m2 = null;
8
        try {
6
        try {
9
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
10
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            ObjectOutput out = new ObjectOutputStream(buffer);
11
            out.writeObject(c1);
9
            out.writeObject(m1);
12
            out.close();
10
            out.close();
13
            ObjectInput in = new ObjectInputStream(
11
            ObjectInput in = new ObjectInputStream(
14
new ByteArrayInputStream(
12
                    new ByteArrayInputStream(
15
                    buffer.toByteArray()));
13
buffer.toByteArray()));
16
            c2 = (StandardEntityCollection) in.readObject();
14
            m2 = (CategoryMarker) in.readObject();
17
            in.close();
15
            in.close();
18
        }
16
        }
19
        catch (Exception e) {
17
        catch (Exception e) {
20
            e.printStackTrace();
18
            fail(e.toString());
21
        }
19
        }
22
        assertEquals(c1, c2
20
        boolean b = m1.equals(m2);
23
);
21
        assertTrue(b);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are in different classes having the same super class
Number of node comparisons84
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)12.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                                                                          
    1
    CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f));
    Preondition Violations
    Unmatched statement CategoryMarker m1=new CategoryMarker("A",new GradientPaint(1.0f,2.0f,Color.white,3.0f,4.0f,Color.yellow),new BasicStroke(1.1f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f));
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    1
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL");
    Preondition Violations
    Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                                                                  
                                                        
    2
    CategoryMarker m2 = null;
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    2
    StandardEntityCollection c1 = new StandardEntityCollection();
    Preondition Violations
    Unmatched statement StandardEntityCollection c1=new StandardEntityCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                
    3
    c1.add(e1);
    3
    c1.add(e1);
    Preondition Violations
    Unmatched statement c1.add(e1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                
    4
    StandardEntityCollection c2 = null;
                                                                            
    5
    try
    5
    try
    3
    try
    Differences
    Expression1Expression2Difference
    printStackTracefailMETHOD_INVOCATION_NAME_MISMATCH
    e.printStackTrace()fail(e.toString())TYPE_COMPATIBLE_REPLACEMENT
    e.printStackTrace()fail(e.toString())ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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
    6
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    7
    ObjectOutput out = new ObjectOutputStream(buffer);
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    8
    out.writeObject(c1);
    8
    out.writeObject(c1);
    6
    out.writeObject(m1);
    Differences
    Expression1Expression2Difference
    c1m1VARIABLE_NAME_MISMATCH
    org.jfree.chart.entity.StandardEntityCollectionorg.jfree.chart.plot.CategoryMarkerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.entity.StandardEntityCollection of variable c1 does not match with type org.jfree.chart.plot.CategoryMarker of variable m1
    • Make classes org.jfree.chart.entity.StandardEntityCollection and org.jfree.chart.plot.CategoryMarker extend a common superclass
    6
    out.writeObject(m1);
    9
    out.close();
    7
    out.close();
    10
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
                                                                                
    9
    m2 = (CategoryMarker)in.readObject();
    Preondition Violations
    Unmatched statement m2=(CategoryMarker)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=(CategoryMarker)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
    m2 = (CategoryMarker)in.readObject();
    11
    c2 = (StandardEntityCollection)in.readObject();
    11
    c2 = (StandardEntityCollection)in.readObject();
    Preondition Violations
    Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement c2=(StandardEntityCollection)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
                                                                                                      
    12
    in.close();
    10
    in.close();
                                                            
    11
    boolean b = m1.equals(m2);
    13
    assertEquals(c1, c2);
    13
    assertEquals(c1, c2);
    12
    assertTrue(b);
    Differences
    Expression1Expression2Difference
    assertEqualsassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(c1,c2)assertTrue(b)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(b) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(b) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
    12
    assertTrue(b);
    Precondition Violations (25)
    Row Violation
    1Unmatched statement CategoryMarker m1=new CategoryMarker("A",new GradientPaint(1.0f,2.0f,Color.white,3.0f,4.0f,Color.yellow),new BasicStroke(1.1f)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement PieSectionEntity e1=new PieSectionEntity(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new DefaultPieDataset(),0,1,"Key","ToolTip","URL"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement StandardEntityCollection c1=new StandardEntityCollection(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement c1.add(e1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    8Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    9Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    12Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    13Type org.jfree.chart.entity.StandardEntityCollection of variable c1 does not match with type org.jfree.chart.plot.CategoryMarker of variable m1
    14Unmatched statement m2=(CategoryMarker)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement m2=(CategoryMarker)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
    16Unmatched statement c2=(StandardEntityCollection)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement c2=(StandardEntityCollection)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
    18Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertTrue(b) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    21Expression assertTrue(b) is a void method call, and thus it cannot be parameterized
    22Expression assertEquals(c1,c2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression assertTrue(b) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression assertEquals(c1,c2) is a void method call, and thus it cannot be parameterized
    25Expression assertTrue(b) is a void method call, and thus it cannot be parameterized