String[] intfs = classFile.getInterfaces(); for ( int i = 0; i < intfs.length; i++ ) { if ( FieldHandled.class.getName().equals( intfs[i] ) ) { return true; } } return false;
final Class[] exceptions = method.getExceptionTypes(); for ( int i = 0; i < exceptions.length; i++ ) { if ( SQLException.class.isAssignableFrom( exceptions[i] ) ) { return true; } } return false;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/buildtime/JavassistInstrumenter.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/test/java/org/hibernate/dialect/Mocks.java
Method name: boolean isInstrumented() Method name: boolean canThrowSQLException(Method)
Number of AST nodes: 5 Number of AST nodes: 5
1
String[] intfs = classFile.getInterfaces();
1
final Class[] exceptions = method.getExceptionTypes();
2
			for ( int i = 0; i < intfs.length; i++ ) {
2
		for ( int i = 0; i < exceptions.length; i++ ) {
3
				if ( FieldHandled.class.getName().equals( intfs[i] ) ) {
3
			if ( SQLException.class.isAssignableFrom( exceptions[i] ) ) {
4
					return true;
4
				return true;
5
				}
5
			}
6
			}
6
		}
7
			return false;
7
		return false;
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.3
Clones locationClones are in different classes
Number of node comparisons6
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                  
    1
    final Class[] exceptions = method.getExceptionTypes();
    1
    String[] intfs = classFile.getInterfaces();
                                                                                            
    2
    for (int i = 0; i < intfs.length; i++)
    2
    for (int i = 0; i < intfs.length; i++)
    2
    for (int i = 0; i < exceptions.length; i++)
    Differences
    Expression1Expression2Difference
    intfsexceptionsVARIABLE_NAME_MISMATCH
    java.lang.String[]java.lang.Class[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable intfs.length does not match with type int of variable exceptions.length
    • Make classes java.lang.String[] and java.lang.Class[] extend a common superclass
    2
    for (int i = 0; i < exceptions.length; i++)
                                                                                                                      
    3
    if (SQLException.class.isAssignableFrom(exceptions[i]))
    Preondition Violations
    Unmatched statement if(SQLException.class.isAssignableFrom(exceptions[i])) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    if (SQLException.class.isAssignableFrom(exceptions[i]))
                                  
    4
    return true;
    Preondition Violations
    Unmatched return true;
    4
    return true;
    3
    if (FieldHandled.class.getName().equals(intfs[i]))
    3
    if (FieldHandled.class.getName().equals(intfs[i]))
    Preondition Violations
    Unmatched statement if(FieldHandled.class.getName().equals(intfs[i])) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                            
    4
    return true;
    4
    return true;
    Preondition Violations
    Unmatched return true;
                                  
    5
    return false;
    5
    return false;
    Precondition Violations (5)
    Row Violation
    1Type int of variable intfs.length does not match with type int of variable exceptions.length
    2Unmatched statement if(SQLException.class.isAssignableFrom(exceptions[i])) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched return true;
    4Unmatched statement if(FieldHandled.class.getName().equals(intfs[i])) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched return true;