if ( !Modifier.isPublic( methods[i].getModifiers() ) ) { continue; } if ( !methods[i].getName().equals( name ) ) { continue; } Class[] params = methods[i].getParameterTypes(); if ( params.length != parameterTypes.length ) { continue; } eq = true; for ( int j = 0; j < params.length; ++j ) { if ( !params[j].equals( parameterTypes[j] ) ) { eq = false; break; } } if ( eq ) { return i; }
for ( int i = 0; i < conss.length; ++i ) { if ( !Modifier.isPublic( conss[i].getModifiers() ) ) { continue; } Class[] params = conss[i].getParameterTypes(); if ( params.length != parameterTypes.length ) { continue; } eq = true; for ( int j = 0; j < params.length; ++j ) { if ( !params[j].equals( parameterTypes[j] ) ) { eq = false; break; } } if ( eq ) { return i; } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java
Method name: int getIndex(String, Class[]) Method name: int getIndex(Class[])
Number of AST nodes: 14 Number of AST nodes: 13
1
for ( int i = 0; i < conss.length; ++i ) {
1
if ( !Modifier.isPublic( methods[i].getModifiers() ) ) {
2
			if ( !Modifier.isPublic( conss[i].getModifiers() ) ) {
2
				continue;
3
				continue;
3
			}
4
			}
4
			if ( !methods[i].getName().equals( name ) ) {
5
			
5
				continue;
6
			}
7
			Class[] params = methods[i].getParameterTypes();
6
Class[] params = conss[i].getParameterTypes();
8
			if ( params.length != parameterTypes.length ) {
7
			if ( params.length != parameterTypes.length ) {
9
				continue;
8
				continue;
10
			}
9
			}
11
			eq = true;
10
			eq = true;
12
			for ( int j = 0; j < params.length; ++j ) {
11
			for ( int j = 0; j < params.length; ++j ) {
13
				if ( !params[j].equals( parameterTypes[j] ) ) {
12
				if ( !params[j].equals( parameterTypes[j] ) ) {
14
					eq = false;
13
					eq = false;
15
					break;
14
					break;
16
				}
15
				}
17
			}
16
			}
18
			if ( eq ) {
17
			if ( eq ) {
19
				return i;
18
				return i;
20
			}
19
			}
20
		}
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)1.2
Clones locationClones are declared in the same class
Number of node comparisons40
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    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.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    if (!Modifier.isPublic(methods[i].getModifiers()))
    4
    if (!Modifier.isPublic(methods[i].getModifiers()))
    4
    if (!Modifier.isPublic(conss[i].getModifiers()))
    Differences
    Expression1Expression2Difference
    methodsconssVARIABLE_NAME_MISMATCH
    java.lang.reflect.Method[]java.lang.reflect.Constructor[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.reflect.Method[] of variable methods does not match with type java.lang.reflect.Constructor[] of variable conss
    • Make classes java.lang.reflect.Method[] and java.lang.reflect.Constructor[] extend a common superclass
    4
    if (!Modifier.isPublic(conss[i].getModifiers()))
    5
    continue;
    5
    continue;
    5
    continue;
    Preondition Violations
    Statement continue; without innermost loop
    Statement continue; without innermost loop
    5
    continue;
                                                                                                  
    6
    Class[] params = conss[i].getParameterTypes();
    Preondition Violations
    Unmatched statement Class[] params=conss[i].getParameterTypes(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    Class[] params = conss[i].getParameterTypes();
    6
    if (!methods[i].getName().equals(name))
    6
    if (!methods[i].getName().equals(name))
    14
    if (eq)
    Differences
    Expression1Expression2Difference
    !methods[i].getName().equals(name)eqTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression eq cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    if (eq)
    7
    continue;
    7
    continue;
    Preondition Violations
    Unmatched continue;
                            
                              
    15
    return i;
    Preondition Violations
    Unmatched return i;
    15
    return i;
    8
    Class[] params = methods[i].getParameterTypes();
    8
    Class[] params = methods[i].getParameterTypes();
    Preondition Violations
    Unmatched statement Class[] params=methods[i].getParameterTypes(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                      
    9
    if (params.length != parameterTypes.length)
    7
    if (params.length != parameterTypes.length)
    10
    continue;
    10
    continue;
    8
    continue;
    Preondition Violations
    Statement continue; without innermost loop
    Statement continue; without innermost loop
    8
    continue;
    11
    eq = true;
    9
    eq = true;
    12
    for (int j = 0; j < params.length; ++j)
    10
    for (int j = 0; j < params.length; ++j)
    13
    if (!params[j].equals(parameterTypes[j]))
    11
    if (!params[j].equals(parameterTypes[j]))
    14
    eq = false;
    12
    eq = false;
    15
    break;
    13
    break;
    Precondition Violations (11)
    Row Violation
    1Type java.lang.reflect.Method[] of variable methods does not match with type java.lang.reflect.Constructor[] of variable conss
    2Statement continue; without innermost loop
    3Statement continue; without innermost loop
    4Unmatched statement Class[] params=conss[i].getParameterTypes(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression eq cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched continue;
    7Unmatched return i;
    8Unmatched statement Class[] params=methods[i].getParameterTypes(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Statement continue; without innermost loop
    10Statement continue; without innermost loop
    11Clone fragment #1 returns variables eq , while Clone fragment #2 returns variables