try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(mf1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); mf2 = (MonthDateFormat) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); }
try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultKeyedValues2DDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/MonthDateFormatTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultKeyedValues2DDatasetTests.java
Method name: void testSerialization() Method name: void testSerialization()
Number of AST nodes: 8 Number of AST nodes: 8
1
try {
1
try {
2
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
2
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
3
            ObjectOutput out = new ObjectOutputStream(buffer);
3
            ObjectOutput out = new ObjectOutputStream(buffer);
4
            out.writeObject(mf1);
4
            out.writeObject(d1);
5
            out.close();
5
            out.close();
6
            ObjectInput in = new ObjectInputStream(
6
            ObjectInput in = new ObjectInputStream(
7
                new ByteArrayInputStream(buffer.toByteArray())
7
                new ByteArrayInputStream(buffer.toByteArray())
8
            );
8
            );
9
            mf2 = (MonthDateFormat) in.readObject();
9
            d2 = (DefaultKeyedValues2DDataset) in.readObject();
10
            in.close();
10
            in.close();
11
        }
11
        }
12
        catch (Exception e) {
12
        catch (Exception e) {
13
            fail(e.toString());
13
            System.out.println(e.toString());
14
        }
14
        }
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)11.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    try
    3
    try
    7
    try
    Differences
    Expression1Expression2Difference
    failprintlnMETHOD_INVOCATION_NAME_MISMATCH
    fail(e.toString())System.out.println(e.toString())TYPE_COMPATIBLE_REPLACEMENT
    System.outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression fail(e.toString()) 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 fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression fail(e.toString()) 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 fail(e.toString()) is a void method call, and thus it cannot be parameterized
    Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    7
    try
    4
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    8
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    5
    ObjectOutput out = new ObjectOutputStream(buffer);
    9
    ObjectOutput out = new ObjectOutputStream(buffer);
    6
    out.writeObject(mf1);
    6
    out.writeObject(mf1);
    10
    out.writeObject(d1);
    Differences
    Expression1Expression2Difference
    mf1d1VARIABLE_NAME_MISMATCH
    org.jfree.chart.axis.MonthDateFormatorg.jfree.data.general.DefaultKeyedValues2DDatasetVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.axis.MonthDateFormat of variable mf1 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d1
    • Make classes org.jfree.chart.axis.MonthDateFormat and org.jfree.data.general.DefaultKeyedValues2DDataset extend a common superclass
    10
    out.writeObject(d1);
    7
    out.close();
    11
    out.close();
    8
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    12
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    9
    mf2 = (MonthDateFormat)in.readObject();
    9
    mf2 = (MonthDateFormat)in.readObject();
    Preondition Violations
    Unmatched statement mf2=(MonthDateFormat)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement mf2=(MonthDateFormat)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
    d2 = (DefaultKeyedValues2DDataset)in.readObject();
    Preondition Violations
    Unmatched statement d2=(DefaultKeyedValues2DDataset)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=(DefaultKeyedValues2DDataset)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
    d2 = (DefaultKeyedValues2DDataset)in.readObject();
    10
    in.close();
    14
    in.close();
    Precondition Violations (13)
    Row Violation
    1Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    4Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    5Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression System.out.println(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    8Expression System.out.println(e.toString()) is a void method call, and thus it cannot be parameterized
    9Type org.jfree.chart.axis.MonthDateFormat of variable mf1 does not match with type org.jfree.data.general.DefaultKeyedValues2DDataset of variable d1
    10Unmatched statement mf2=(MonthDateFormat)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement mf2=(MonthDateFormat)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
    12Unmatched statement d2=(DefaultKeyedValues2DDataset)in.readObject(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement d2=(DefaultKeyedValues2DDataset)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