CompositeTitle t1 = new CompositeTitle(new BlockContainer()); t1.getContainer().add(new TextTitle("T1")); CompositeTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (CompositeTitle) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(t1, t2);
TimeTableXYDataset d1 = new TimeTableXYDataset(); d1.add(new Year(1999), 123.4, "S1"); TimeTableXYDataset 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 = (TimeTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(d1.equals(d2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/CompositeTitleTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/TimeTableXYDatasetTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 12 Number of AST nodes: 12
1
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
1
TimeTableXYDataset d1 = new TimeTableXYDataset();
2
        t1.getContainer().add(new TextTitle("T1"));
2
        d1.add(new Year(1999), 123.4, "S1");
3
        CompositeTitle t2 = null;
3
        TimeTableXYDataset d2 = null;
4
        try {
4
        try {
5
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
5
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
6
            ObjectOutput out = new ObjectOutputStream(buffer);
6
            ObjectOutput out = new ObjectOutputStream(buffer);
7
            out.writeObject(t1);
7
            out.writeObject(d1);
8
            out.close();
8
            out.close();
9
            ObjectInput in = new ObjectInputStream(
9
            ObjectInput in = new ObjectInputStream(
10
                new ByteArrayInputStream(
10
new ByteArrayInputStream(
11
buffer.toByteArray())
11
                    buffer.toByteArray())
12
            );
12
);
13
            t2 = (CompositeTitle) in.readObject();
13
            d2 = (TimeTableXYDataset) in.readObject();
14
            in.close();
14
            in.close();
15
        }
15
        }
16
        catch (Exception e) {
16
        catch (Exception e) {
17
            System.out.println(e.toString());
17
            e.printStackTrace();
18
        }
18
        }
19
        assertEquals(t1, t2);
19
        assertTrue(d1.equals(d2));
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons80
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)32.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                        
    1
    TimeTableXYDataset d1 = new TimeTableXYDataset();
    Preondition Violations
    Unmatched statement TimeTableXYDataset d1=new TimeTableXYDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    TimeTableXYDataset d1 = new TimeTableXYDataset();
    1
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    1
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    Preondition Violations
    Unmatched statement CompositeTitle t1=new CompositeTitle(new BlockContainer()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                
    2
    t1.getContainer().add(new TextTitle("T1"));
    2
    t1.getContainer().add(new TextTitle("T1"));
    2
    d1.add(new Year(1999), 123.4, "S1");
    Differences
    Expression1Expression2Difference
    org.jfree.chart.block.BlockContainerorg.jfree.data.time.TimeTableXYDatasetSUBCLASS_TYPE_MISMATCH
    t1.getContainer()d1TYPE_COMPATIBLE_REPLACEMENT
    t1.getContainer().add(new TextTitle("T1"))d1.add(new Year(1999),123.4,"S1")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression t1.getContainer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression t1.getContainer() cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.block.Block) , public void add(org.jfree.data.time.TimePeriod, double, java.lang.String)
    Expression t1.getContainer().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression d1.add(new Year(1999),123.4,"S1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression t1.getContainer().add(new TextTitle("T1")) is a void method call, and thus it cannot be parameterized
    Expression d1.add(new Year(1999),123.4,"S1") is a void method call, and thus it cannot be parameterized
    2
    d1.add(new Year(1999), 123.4, "S1");
                                                                
    3
    TimeTableXYDataset d2 = null;
    3
    CompositeTitle t2 = null;
                                                        
    4
    try
    4
    try
    4
    try
    Differences
    Expression1Expression2Difference
    printlnprintStackTraceMETHOD_INVOCATION_NAME_MISMATCH
    System.outeAST_TYPE_MISMATCH
    System.out.println(e.toString())e.printStackTrace()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    4
    try
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    out.writeObject(t1);
    7
    out.writeObject(t1);
    7
    out.writeObject(d1);
    Differences
    Expression1Expression2Difference
    t1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.title.CompositeTitleorg.jfree.data.time.TimeTableXYDatasetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.time.TimeTableXYDataset of variable d1
    • Make classes org.jfree.chart.title.CompositeTitle and org.jfree.data.time.TimeTableXYDataset extend a common superclass
    7
    out.writeObject(d1);
    8
    out.close();
    8
    out.close();
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
                                                                                          
    10
    d2 = (TimeTableXYDataset)in.readObject();
    Preondition Violations
    Unmatched statement d2=(TimeTableXYDataset)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=(TimeTableXYDataset)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
    d2 = (TimeTableXYDataset)in.readObject();
    10
    t2 = (CompositeTitle)in.readObject();
    10
    t2 = (CompositeTitle)in.readObject();
    Preondition Violations
    Unmatched statement t2=(CompositeTitle)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement t2=(CompositeTitle)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
    in.close();
    11
    in.close();
    12
    assertEquals(t1, t2);
    12
    assertEquals(t1, t2);
    12
    assertTrue(d1.equals(d2));
    Differences
    Expression1Expression2Difference
    assertEqualsassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(t1,t2)assertTrue(d1.equals(d2))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(t1,t2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(t1,t2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(t1,t2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(t1,t2) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
    12
    assertTrue(d1.equals(d2));
    Precondition Violations (31)
    Row Violation
    1Unmatched statement TimeTableXYDataset d1=new TimeTableXYDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement CompositeTitle t1=new CompositeTitle(new BlockContainer()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Expression t1.getContainer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression d1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression t1.getContainer() cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.block.Block) , public void add(org.jfree.data.time.TimePeriod, double, java.lang.String)
    6Expression t1.getContainer().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression d1.add(new Year(1999),123.4,"S1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression t1.getContainer().add(new TextTitle("T1")) is a void method call, and thus it cannot be parameterized
    9Expression d1.add(new Year(1999),123.4,"S1") is a void method call, and thus it cannot be parameterized
    10Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    13Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    14Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    18Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    19Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.time.TimeTableXYDataset of variable d1
    20Unmatched statement d2=(TimeTableXYDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement d2=(TimeTableXYDataset)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
    22Unmatched statement t2=(CompositeTitle)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    23Unmatched statement t2=(CompositeTitle)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
    24Expression assertEquals(t1,t2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression assertEquals(t1,t2) is a void method call, and thus it cannot be parameterized
    27Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized
    28Expression assertEquals(t1,t2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression assertTrue(d1.equals(d2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression assertEquals(t1,t2) is a void method call, and thus it cannot be parameterized
    31Expression assertTrue(d1.equals(d2)) is a void method call, and thus it cannot be parameterized