for ( int i=0; i<types.length; i++ ) { Object result = processValue( values[i], types[i] ); if (result!=null) { values[i] = result; substituteComponent = true; } }
for ( int i = 0; i < subvalues.length; i++ ) { Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] ); if ( replacement != subvalues[i] ) { substitute = true; subvalues[i] = replacement; } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/event/def/WrapVisitor.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/engine/ForeignKeys.java
Method name: Object processComponent(Object, AbstractComponentType) Method name: Object nullifyTransientReferences(Object, Type)
Number of AST nodes: 5 Number of AST nodes: 5
1
for ( int i=0; i<types.length; i++ ) {
1
for ( int i = 0; i < subvalues.length; i++ ) {
2
				Object result = processValue( values[i], types[i] );
2
					Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
3
				if (result!=null) {
3
					if ( re
4
					values[i] = result
4
placement != subvalues[i] ) {
5
;
5
						substitute = true;
6
					substituteComponent = true;
6
						subvalues[i] = replacement;
7
				}
7
					}
8
			}
8
				}
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
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)93.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    for (int i = 0; i < types.length; i++)
    5
    for (int i = 0; i < types.length; i++)
    16
    for (int i = 0; i < subvalues.length; i++)
    Differences
    Expression1Expression2Difference
    typessubvaluesVARIABLE_NAME_MISMATCH
    org.hibernate.type.Type[]java.lang.Object[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.type.Type[] of variable types does not match with type java.lang.Object[] of variable subvalues
    • Make classes org.hibernate.type.Type[] and java.lang.Object[] extend a common superclass
    16
    for (int i = 0; i < subvalues.length; i++)
    6
    Object result = processValue(values[i], types[i]);
    6
    Object result = processValue(values[i], types[i]);
    17
    Object replacement = nullifyTransientReferences(subvalues[i], subtypes[i]);
    Differences
    Expression1Expression2Difference
    resultreplacementVARIABLE_NAME_MISMATCH
    processValuenullifyTransientReferencesMETHOD_INVOCATION_NAME_MISMATCH
    valuessubvaluesVARIABLE_NAME_MISMATCH
    typessubtypesVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression processValue(values[i],types[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression nullifyTransientReferences(subvalues[i],subtypes[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method nullifyTransientReferences
    Expression values cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17
    Object replacement = nullifyTransientReferences(subvalues[i], subtypes[i]);
    7
    if (result != null)
    7
    if (result != null)
    18
    if (replacement != subvalues[i])
    Differences
    Expression1Expression2Difference
    resultreplacementVARIABLE_NAME_MISMATCH
    nullsubvalues[i]TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression subvalues[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    if (replacement != subvalues[i])
    8
    values[i] = result;
    8
    values[i] = result;
    20
    subvalues[i] = replacement;
    Differences
    Expression1Expression2Difference
    valuessubvaluesVARIABLE_NAME_MISMATCH
    resultreplacementVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression values cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    subvalues[i] = replacement;
    9
    substituteComponent = true;
    9
    substituteComponent = true;
    19
    substitute = true;
    Differences
    Expression1Expression2Difference
    substituteComponentsubstituteVARIABLE_NAME_MISMATCH
    19
    substitute = true;
    Precondition Violations (10)
    Row Violation
    1Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Type org.hibernate.type.Type[] of variable types does not match with type java.lang.Object[] of variable subvalues
    3Expression processValue(values[i],types[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression nullifyTransientReferences(subvalues[i],subtypes[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression values cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression subvalues[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression values cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression subvalues cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Clone fragment #1 returns variables substituteComponent, values , while Clone fragment #2 returns variables substitute, subvalues