if (index<0) { throw new ArrayIndexOutOfBoundsException("negative index"); } Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN; if ( old==UNKNOWN ) { write(); return list.remove(index); } else { queueOperation( new Remove(index, old) ); return old; }
if (index<0) { throw new ArrayIndexOutOfBoundsException("negative index"); } Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN; if ( old==UNKNOWN ) { write(); return list.set(index, value); } else { queueOperation( new Set(index, value, old) ); return old; }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentList.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentList.java
Method name: Object remove(int) Method name: Object set(int, Object)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (index<0) {
1
if (index<0) {
2
			throw new ArrayIndexOutOfBoundsException("negative index");
2
			throw new ArrayIndexOutOfBoundsException("negative index");
3
		}
3
		}
4
		Object old = isPutQueueEnabled() ?
4
		Object old = isPutQueueEnabled() ?
5
				readElementByIndex( new Integer(index) ) : UNKNOWN;
5
 readElementByIndex( new Integer(index) ) : UNKNOWN;
6
		if ( old==UNKNOWN ) {
6
		if ( old==UNKNOWN ) {
7
			write();
7
			write();
8
			return list.remove(index);
8
			return list.set(index, value);
9
		}
9
		}
10
		else {
10
		else {
11
			queueOperation( new Remove(index, old) );
11
			queueOperation( new Set(index, value, old) );
12
			return old;
12
			return old;
13
		}
13
		}
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.4
Clones locationClones are declared in the same class
Number of node comparisons41
  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)2.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (index < 0)
    1
    if (index < 0)
    2
    throw new ArrayIndexOutOfBoundsException("negative index");
    2
    throw new ArrayIndexOutOfBoundsException("negative index");
    3
    Object old = isPutQueueEnabled() ? readElementByIndex(new Integer(index)) : UNKNOWN;
    3
    Object old = isPutQueueEnabled() ? readElementByIndex(new Integer(index)) : UNKNOWN;
    4
    if (old == UNKNOWN)
    4
    if (old == UNKNOWN)
    5
    write();
    5
    write();
    6
    return list.remove(index);
    6
    return list.remove(index);
    6
    return list.set(index, value);
    Differences
    Expression1Expression2Difference
    removesetMETHOD_INVOCATION_NAME_MISMATCH
    list.remove(index)list.set(index,value)ARGUMENT_NUMBER_MISMATCH
    6
    return list.set(index, value);
    else
    else
                                                                                            
    7
    queueOperation(new Set(index, value, old));
    Preondition Violations
    Unmatched statement queueOperation(new Set(index,value,old)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    queueOperation(new Set(index, value, old));
    7
    queueOperation(new Remove(index, old));
    7
    queueOperation(new Remove(index, old));
    Preondition Violations
    Unmatched statement queueOperation(new Remove(index,old)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                      
    8
    return old;
    8
    return old;
    Precondition Violations (2)
    Row Violation
    1Unmatched statement queueOperation(new Set(index,value,old)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement queueOperation(new Remove(index,old)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted