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."); } } }
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."); } } }
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: 6 Number of AST nodes: 6
1
if (this.data.size() > 0) {
1
if (this.data.size() > 0) {
2
            for (int index = start; index <= end; index++) {
2
            for (int index = start; index <= end; index++) {
3
                TimePeriodValue item = (TimePeriodValue) this.data.get(index);
3
                XYDataItem item = (XYDataItem) this.data.get(index);
4
                TimePeriodValue clone = (TimePeriodValue) item.clone();
4
                XYDataItem clone = (XYDataItem) item.clone();
5
                try {
5
                try {
6
                    copy.add(clone);
6
                    copy.add(clone);
7
                }
7
                }
8
                catch (SeriesException e) {
8
                catch (SeriesException e) {
9
                    System.err.println("Failed to add cloned item.");
9
                    System.err.println("Unable to add cloned data item.");
10
                }
10
                }
11
            }
11
            }
12
        }
12
        }
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 comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    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);
    Precondition Violations (7)
    Row Violation
    1Unmatched 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
    2Unmatched 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
    3Unmatched 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
    4Unmatched 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
    5Unmatched 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
    6Type org.jfree.data.time.TimePeriodValue of variable clone does not match with type org.jfree.data.xy.XYDataItem of variable clone
    7Expression 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)