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);
KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); KeyedObjects ko2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2 = (KeyedObjects) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko1, ko2);
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/junit/KeyedObjectsTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 12 Number of AST nodes: 14
1
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
2
        t1.getContainer().add(new TextTitle("T1")
1
KeyedObjects ko1 = new KeyedObjects();
2
        ko1.addObject("Key 1", "Object 1");
3
        ko1.addObject("Key 2", null);
3
);
4
        ko1.addObject("Key 3", "Object 2");
4
        CompositeTitle t2 = null;
5
        KeyedObjects ko2 = null;
5
        try {
6
        try {
6
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
7
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            ObjectOutput out = new ObjectOutputStream(buffer);
8
            out.writeObject(t1);
9
            out.writeObject(ko1);
9
            out.close();
10
            out.close();
10
            ObjectInput in = new ObjectInputStream(
11
            ObjectInput in = new ObjectInputStream(
11
                new ByteArrayInputStream(buffer.toByteArray())
12
                    new ByteArrayInputStream(buffer.toByteArray())
12
            );
13
);
13
            t2 = (CompositeTitle) in.readObject();
14
            ko2 = (KeyedObjects) in.readObject();
14
            in.close();
15
            in.close();
15
        }
16
        }
16
        catch (Exception e) {
17
        catch (Exception e) {
17
            System.out.println(e.toString());
18
            e.printStackTrace();
18
        }
19
        }
19
        assertEquals(t1, t2);
20
        assertEquals(ko1, ko2);
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 comparisons88
  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 fragment5
    Time elapsed for statement mapping (ms)25.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                  
    1
    KeyedObjects ko1 = new KeyedObjects();
    Preondition Violations
    Unmatched statement KeyedObjects ko1=new KeyedObjects(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    KeyedObjects ko1 = new KeyedObjects();
    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
    ko1.addObject("Key 1", "Object 1");
    Differences
    Expression1Expression2Difference
    addaddObjectMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.chart.block.BlockContainerorg.jfree.data.KeyedObjectsSUBCLASS_TYPE_MISMATCH
    t1.getContainer()ko1TYPE_COMPATIBLE_REPLACEMENT
    t1.getContainer().add(new TextTitle("T1"))ko1.addObject("Key 1","Object 1")ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression t1.getContainer().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("Key 1","Object 1") 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 ko1.addObject("Key 1","Object 1") is a void method call, and thus it cannot be parameterized
    Expression t1.getContainer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression t1.getContainer() cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.block.Block) , public void addObject(Comparable#RAW, java.lang.Object)
    Expression t1.getContainer().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ko1.addObject("Key 1","Object 1") 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 ko1.addObject("Key 1","Object 1") is a void method call, and thus it cannot be parameterized
    2
    ko1.addObject("Key 1", "Object 1");
                                                                  
    3
    ko1.addObject("Key 2", null);
    Preondition Violations
    Unmatched statement ko1.addObject("Key 2",null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    ko1.addObject("Key 2", null);
    3
    CompositeTitle t2 = null;
                                                        
                                                                              
    4
    ko1.addObject("Key 3", "Object 2");
    Preondition Violations
    Unmatched statement ko1.addObject("Key 3","Object 2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    ko1.addObject("Key 3", "Object 2");
                                                      
    5
    KeyedObjects ko2 = null;
    4
    try
    4
    try
    6
    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
    6
    try
    5
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    7
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    6
    ObjectOutput out = new ObjectOutputStream(buffer);
    8
    ObjectOutput out = new ObjectOutputStream(buffer);
    7
    out.writeObject(t1);
    7
    out.writeObject(t1);
    9
    out.writeObject(ko1);
    Differences
    Expression1Expression2Difference
    t1ko1VARIABLE_NAME_MISMATCH
    org.jfree.chart.title.CompositeTitleorg.jfree.data.KeyedObjectsVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.KeyedObjects of variable ko1
    • Make classes org.jfree.chart.title.CompositeTitle and org.jfree.data.KeyedObjects extend a common superclass
    9
    out.writeObject(ko1);
    8
    out.close();
    10
    out.close();
    9
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    11
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    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
                                                                                  
                                                                                
    12
    ko2 = (KeyedObjects)in.readObject();
    Preondition Violations
    Unmatched statement ko2=(KeyedObjects)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement ko2=(KeyedObjects)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
    ko2 = (KeyedObjects)in.readObject();
    11
    in.close();
    13
    in.close();
    12
    assertEquals(t1, t2);
    12
    assertEquals(t1, t2);
    14
    assertEquals(ko1, ko2);
    Differences
    Expression1Expression2Difference
    t1ko1VARIABLE_NAME_MISMATCH
    org.jfree.chart.title.CompositeTitleorg.jfree.data.KeyedObjectsVARIABLE_TYPE_MISMATCH
    t2ko2VARIABLE_NAME_MISMATCH
    org.jfree.chart.title.CompositeTitleorg.jfree.data.KeyedObjectsVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.KeyedObjects of variable ko1
    • Make classes org.jfree.chart.title.CompositeTitle and org.jfree.data.KeyedObjects extend a common superclass
    Type org.jfree.chart.title.CompositeTitle of variable t2 does not match with type org.jfree.data.KeyedObjects of variable ko2
    • Make classes org.jfree.chart.title.CompositeTitle and org.jfree.data.KeyedObjects extend a common superclass
    14
    assertEquals(ko1, ko2);
    Precondition Violations (31)
    Row Violation
    1Unmatched statement KeyedObjects ko1=new KeyedObjects(); 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().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression ko1.addObject("Key 1","Object 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression t1.getContainer().add(new TextTitle("T1")) is a void method call, and thus it cannot be parameterized
    6Expression ko1.addObject("Key 1","Object 1") is a void method call, and thus it cannot be parameterized
    7Expression t1.getContainer() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression ko1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression t1.getContainer() cannot be unified with expression ko1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void add(org.jfree.chart.block.Block) , public void addObject(Comparable#RAW, java.lang.Object)
    10Expression t1.getContainer().add(new TextTitle("T1")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression ko1.addObject("Key 1","Object 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression t1.getContainer().add(new TextTitle("T1")) is a void method call, and thus it cannot be parameterized
    13Expression ko1.addObject("Key 1","Object 1") is a void method call, and thus it cannot be parameterized
    14Unmatched statement ko1.addObject("Key 2",null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement ko1.addObject("Key 3","Object 2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    19Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    20Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    24Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    25Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.KeyedObjects of variable ko1
    26Unmatched 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
    27Unmatched 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
    28Unmatched statement ko2=(KeyedObjects)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29Unmatched statement ko2=(KeyedObjects)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
    30Type org.jfree.chart.title.CompositeTitle of variable t1 does not match with type org.jfree.data.KeyedObjects of variable ko1
    31Type org.jfree.chart.title.CompositeTitle of variable t2 does not match with type org.jfree.data.KeyedObjects of variable ko2