if ( importedObjects != null ) for(int i=0; i<importedObjects.size(); i++) { Object object = importedObjects.elementAt(i); Class clas = object.getClass(); Method method = Reflect.resolveJavaMethod( getClassManager(), clas, name, sig, false/*onlyStatic*/ ); if ( method != null ) return new BshMethod( method, object ); } // Try static imports if ( importedStatic!= null ) for(int i=0; i<importedStatic.size(); i++) { Class clas = (Class)importedStatic.elementAt(i); Method method = Reflect.resolveJavaMethod( getClassManager(), clas, name, sig, true/*onlyStatic*/ ); if ( method != null ) return new BshMethod( method, null/*object*/ ); } return null;
if ( importedObjects != null ) for(int i=0; i<importedObjects.size(); i++) { Object object = importedObjects.elementAt(i); Class clas = object.getClass(); Field field = Reflect.resolveJavaField( clas, name, false/*onlyStatic*/ ); if ( field != null ) return new Variable( name, field.getType(), new LHS( object, field ) ); } // Try static imports if ( importedStatic!= null ) for(int i=0; i<importedStatic.size(); i++) { Class clas = (Class)importedStatic.elementAt(i); Field field = Reflect.resolveJavaField( clas, name, true/*onlyStatic*/ ); if ( field != null ) return new Variable( name, field.getType(), new LHS( field ) ); } return null;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/NameSpace.java File path: /jEdit-4.2/src/bsh/NameSpace.java
Method name: BshMethod getImportedMethod(String, Class[]) Method name: Variable getImportedVar(String)
Number of AST nodes: 14 Number of AST nodes: 14
1
if ( importedObjects != null )
1
if ( importedObjects != null )
2
		for(int i=0; i<importedObjects.size(); i++)
2
		for(int i=0; i<importedObjects.size(); i++)
3
		{
3
		{
4
			Object object = importedObjects.elementAt(i);
4
			Object object = importedObjects.elementAt(i);
5
			Class clas = object.getClass();
5
			Class clas = object.getClass();
6
			Method method = Reflect.resolveJavaMethod( 
6
			Field field = Reflect.resolveJavaField( 
7
				getClassManager(), clas, name, sig, false/*onlyStatic*/ );
7
				clas, name, false/*onlyStatic*/ );
8
			if ( method != null )
8
			if ( field != null )
9
				return new BshMethod( method, object
9
				return new Variable( 
10
 );
10
					name, field.getType(), new LHS( object, field ) );
11
		}
11
		}
12
		// Try static imports
12
		// Try static imports
13
		if ( importedStatic!= null )
13
		if ( importedStatic!= null )
14
		for(int i=0; i<importedStatic.size(); i++)
14
		for(int i=0; i<importedStatic.size(); i++)
15
		{
15
		{
16
			Class clas = (Class)importedStatic.elementAt(i);
16
			Class clas = (Class)importedStatic.elementAt(i);
17
			Method method = Reflect.resolveJavaMethod( 
17
			Field field = Reflect.resolveJavaField( 
18
				getClassManager(), clas, name, sig, true/*onlyStatic*/ );
18
				clas, name, true/*onlyStatic*/ );
19
			if ( method != null )
19
			if ( field != null )
20
				return new BshMethod( method, null/*object*/ );
20
				return new Variable( name, field.getType(), new LHS( field ) );
21
		}
21
		}
22
		return null;
22
		return null;
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.5
Clones locationClones are declared in the same class
Number of node comparisons45
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    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.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (importedObjects != null)
    1
    if (importedObjects != null)
    2
    for (int i = 0; i < importedObjects.size(); i++)
    2
    for (int i = 0; i < importedObjects.size(); i++)
    3
    Object object = importedObjects.elementAt(i);
    3
    Object object = importedObjects.elementAt(i);
    4
    Class clas = object.getClass();
    4
    Class clas = object.getClass();
    5
    Method method = Reflect.resolveJavaMethod(getClassManager(), clas, name, sig, false);
    5
    Method method = Reflect.resolveJavaMethod(getClassManager(), clas, name, sig, false);
    5
    Field field = Reflect.resolveJavaField(clas, name, false);
    Differences
    Expression1Expression2Difference
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    methodfieldVARIABLE_NAME_MISMATCH
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    resolveJavaMethodresolveJavaFieldMETHOD_INVOCATION_NAME_MISMATCH
    Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,false)Reflect.resolveJavaField(clas,name,false)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaField(clas,name,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaField(clas,name,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    Field field = Reflect.resolveJavaField(clas, name, false);
    6
    if (method != null)
    6
    if (method != null)
    6
    if (field != null)
    Differences
    Expression1Expression2Difference
    methodfieldVARIABLE_NAME_MISMATCH
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    6
    if (field != null)
                                                                                                                                          
    7
    return new Variable(name, field.getType(), new LHS(object, field));
    Preondition Violations
    Unmatched statement return new Variable(name,field.getType(),new LHS(object,field)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new Variable(name,field.getType(),new LHS(object,field));
    7
    return new Variable(name, field.getType(), new LHS(object, field));
    7
    return new BshMethod(method, object);
    7
    return new BshMethod(method, object);
    Preondition Violations
    Unmatched statement return new BshMethod(method,object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new BshMethod(method,object);
                                                                                  
    8
    if (importedStatic != null)
    8
    if (importedStatic != null)
    9
    for (int i = 0; i < importedStatic.size(); i++)
    9
    for (int i = 0; i < importedStatic.size(); i++)
    10
    Class clas = (Class)importedStatic.elementAt(i);
    10
    Class clas = (Class)importedStatic.elementAt(i);
    11
    Method method = Reflect.resolveJavaMethod(getClassManager(), clas, name, sig, true);
    11
    Method method = Reflect.resolveJavaMethod(getClassManager(), clas, name, sig, true);
    11
    Field field = Reflect.resolveJavaField(clas, name, true);
    Differences
    Expression1Expression2Difference
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    methodfieldVARIABLE_NAME_MISMATCH
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    resolveJavaMethodresolveJavaFieldMETHOD_INVOCATION_NAME_MISMATCH
    Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,true)Reflect.resolveJavaField(clas,name,true)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaField(clas,name,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Reflect.resolveJavaField(clas,name,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    Field field = Reflect.resolveJavaField(clas, name, true);
    12
    if (method != null)
    12
    if (method != null)
    12
    if (field != null)
    Differences
    Expression1Expression2Difference
    methodfieldVARIABLE_NAME_MISMATCH
    java.lang.reflect.Methodjava.lang.reflect.FieldSUBCLASS_TYPE_MISMATCH
    12
    if (field != null)
                                                                                                                              
    13
    return new Variable(name, field.getType(), new LHS(field));
    Preondition Violations
    Unmatched statement return new Variable(name,field.getType(),new LHS(field)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new Variable(name,field.getType(),new LHS(field));
    13
    return new Variable(name, field.getType(), new LHS(field));
    13
    return new BshMethod(method, null);
    13
    return new BshMethod(method, null);
    Preondition Violations
    Unmatched statement return new BshMethod(method,null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new BshMethod(method,null);
                                                                                
    14
    return null;
    14
    return null;
    Precondition Violations (17)
    Row Violation
    1Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression Reflect.resolveJavaField(clas,name,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression Reflect.resolveJavaField(clas,name,false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement return new Variable(name,field.getType(),new LHS(object,field)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched return new Variable(name,field.getType(),new LHS(object,field));
    7Unmatched statement return new BshMethod(method,object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched return new BshMethod(method,object);
    9Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression Reflect.resolveJavaField(clas,name,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression Reflect.resolveJavaMethod(getClassManager(),clas,name,sig,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression Reflect.resolveJavaField(clas,name,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Unmatched statement return new Variable(name,field.getType(),new LHS(field)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched return new Variable(name,field.getType(),new LHS(field));
    15Unmatched statement return new BshMethod(method,null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched return new BshMethod(method,null);
    17Clone fragment #1 returns variables object, method, method , while Clone fragment #2 returns variables object, field, field