TimePeriodValues copy = (TimePeriodValues) super.clone(); copy.data = new ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { TimePeriodValue item = (TimePeriodValue) this.data.get(index); TimePeriodValue clone = (TimePeriodValue) item.clone(); try { copy.add(clone); } catch (SeriesException e) { System.err.println("Failed to add cloned item."); } } } return copy;
XYSeries copy = (XYSeries) super.clone(); copy.data = new java.util.ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { XYDataItem item = (XYDataItem) this.data.get(index); XYDataItem clone = (XYDataItem) item.clone(); try { copy.add(clone); } catch (SeriesException e) { System.err.println("Unable to add cloned data item."); } } } return copy;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/TimePeriodValues.java File path: /jfreechart-1.0.10/src/org/jfree/data/xy/XYSeries.java
Method name: TimePeriodValues createCopy(int, int) Method name: XYSeries createCopy(int, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
TimePeriodValues copy = (TimePeriodValues) super.clone();
1
XYSeries copy = (XYSeries) super.clone();
2
        copy.data = new ArrayList();
2
        copy.data = new java.util.ArrayList();
3
        if (this.data.size() > 0) {
3
        if (this.data.size() > 0) {
4
            for (int index = start; index <= end; index++) {
4
            for (int index = start; index <= end; index++) {
5
                TimePeriodValue item = (TimePeriodValue) this.data.get(index);
5
                XYDataItem item = (XYDataItem) this.data.get(index);
6
                TimePeriodValue clone = (TimePeriodValue) item.clone();
6
                XYDataItem clone = (XYDataItem) item.clone();
7
                try {
7
                try {
8
                    copy.add(clone);
8
                    copy.add(clone);
9
                }
9
                }
10
                catch (SeriesException e) {
10
                catch (SeriesException e) {
11
                    System.err.println("Failed to add cloned item.");
11
                    System.err.println("Unable to add cloned data item.");
12
                }
12
                }
13
            }
13
            }
14
        }
14
        }
15
        return copy;
15
        return copy;
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.5
Clones locationClones are in different classes having the same super class
Number of node comparisons19
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)6.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    TimePeriodValues copy = (TimePeriodValues)super.clone();
    1
    TimePeriodValues copy = (TimePeriodValues)super.clone();
    1
    XYSeries copy = (XYSeries)super.clone();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Super method call TimePeriodValues copy=(TimePeriodValues)super.clone(); cannot be extracted from method
    Super method call XYSeries copy=(XYSeries)super.clone(); cannot be extracted from method
    1
    XYSeries copy = (XYSeries)super.clone();
    2
    copy.data = new ArrayList();
    2
    copy.data = new ArrayList();
    2
    copy.data = new java.util.ArrayList();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    ArrayListjava.util.ArrayListTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression copy.data cannot be unified with expression copy.data , because common superclass org.jfree.data.general.Series does not declare member(s) private List#RAW data
    2
    copy.data = new java.util.ArrayList();
    3
    if (this.data.size() > 0)
    3
    if (this.data.size() > 0)
    4
    for (int index = start; index <= end; index++)
    4
    for (int index = start; index <= end; index++)
                                                                                                            
    5
    XYDataItem item = (XYDataItem)this.data.get(index);
    Preondition Violations
    Unmatched statement XYDataItem item=(XYDataItem)this.data.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    XYDataItem item = (XYDataItem)this.data.get(index);
    5
    TimePeriodValue item = (TimePeriodValue)this.data.get(index);
    5
    TimePeriodValue item = (TimePeriodValue)this.data.get(index);
    Preondition Violations
    Unmatched statement TimePeriodValue item=(TimePeriodValue)this.data.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                
                                                                                              
    6
    XYDataItem clone = (XYDataItem)item.clone();
    Preondition Violations
    Unmatched statement XYDataItem clone=(XYDataItem)item.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement XYDataItem clone=(XYDataItem)item.clone(); 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
    XYDataItem clone = (XYDataItem)item.clone();
    6
    TimePeriodValue clone = (TimePeriodValue)item.clone();
    6
    TimePeriodValue clone = (TimePeriodValue)item.clone();
    Preondition Violations
    Unmatched statement TimePeriodValue clone=(TimePeriodValue)item.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                  
    7
    try
    7
    try
    7
    try
    Differences
    Expression1Expression2Difference
    "Failed to add cloned item.""Unable to add cloned data item."LITERAL_VALUE_MISMATCH
    7
    try
    8
    copy.add(clone);
    8
    copy.add(clone);
    8
    copy.add(clone);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.TimePeriodValueorg.jfree.data.xy.XYDataItemVARIABLE_TYPE_MISMATCH
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.time.TimePeriodValue of variable clone does not match with type org.jfree.data.xy.XYDataItem of variable clone
    • Make classes org.jfree.data.time.TimePeriodValue and org.jfree.data.xy.XYDataItem extend a common superclass
    Expression copy cannot be unified with expression copy , because common superclass org.jfree.data.general.Series does not declare member(s) public void add(org.jfree.data.time.TimePeriodValue) , public void add(org.jfree.data.xy.XYDataItem)
    8
    copy.add(clone);
    9
    return copy;
    9
    return copy;
    9
    return copy;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.TimePeriodValuesorg.jfree.data.xy.XYSeriesSUBCLASS_TYPE_MISMATCH
    9
    return copy;
    Precondition Violations (10)
    Row Violation
    1Super method call TimePeriodValues copy=(TimePeriodValues)super.clone(); cannot be extracted from method
    2Super method call XYSeries copy=(XYSeries)super.clone(); cannot be extracted from method
    3Expression copy.data cannot be unified with expression copy.data , because common superclass org.jfree.data.general.Series does not declare member(s) private List#RAW data
    4Unmatched statement XYDataItem item=(XYDataItem)this.data.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement TimePeriodValue item=(TimePeriodValue)this.data.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement XYDataItem clone=(XYDataItem)item.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement XYDataItem clone=(XYDataItem)item.clone(); 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
    8Unmatched statement TimePeriodValue clone=(TimePeriodValue)item.clone(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Type org.jfree.data.time.TimePeriodValue of variable clone does not match with type org.jfree.data.xy.XYDataItem of variable clone
    10Expression copy cannot be unified with expression copy , because common superclass org.jfree.data.general.Series does not declare member(s) public void add(org.jfree.data.time.TimePeriodValue) , public void add(org.jfree.data.xy.XYDataItem)