if ( cg == null ) { try { Class clas = Class.forName( "bsh.ClassGeneratorImpl" ); cg = (ClassGenerator)clas.newInstance(); } catch ( Exception e ) { throw new Unavailable("ClassGenerator unavailable: "+e); } } return cg;
if ( rfm == null ) { Class clas; try { clas = Class.forName( "bsh.reflect.ReflectManagerImpl" ); rfm = (ReflectManager)clas.newInstance(); } catch ( Exception e ) { throw new Unavailable("Reflect Manager unavailable: "+e); } } return rfm;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/ClassGenerator.java File path: /jEdit-4.2/src/bsh/ReflectManager.java
Method name: ClassGenerator getClassGenerator() Method name: ReflectManager getReflectManager()
Number of AST nodes: 5 Number of AST nodes: 6
1
if ( cg == null ) 
1
if ( rfm == null ) 
2
		{
2
		{
3
			
3
			Class clas;
4
try {
4
			try {
5
				Class clas = Class.forName( "bsh.ClassGeneratorImpl" );
5
				clas = Class.forName( "bsh.reflect.ReflectManagerImpl" );
6
				cg = (ClassGenerator)clas.newInstance();
6
				rfm = (ReflectManager)clas.newInstance();
7
			} catch ( Exception e ) {
7
			} catch ( Exception e ) {
8
				throw new Unavailable("ClassGenerator unavailable: "+e);
8
				throw new Unavailable("Reflect Manager unavailable: "+e);
9
			}
9
			}
10
		}
10
		}
11
	
11
	
12
		return cg;
12
		return rfm;
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 comparisons12
  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 fragment4
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (cg == null)
    1
    if (cg == null)
    1
    if (rfm == null)
    Differences
    Expression1Expression2Difference
    cgrfmVARIABLE_NAME_MISMATCH
    bsh.ClassGeneratorbsh.ReflectManagerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type bsh.ClassGenerator of variable cg does not match with type bsh.ReflectManager of variable rfm
    • Make classes bsh.ClassGenerator and bsh.ReflectManager extend a common superclass
    1
    if (rfm == null)
                                
    2
    Class clas;
    2
    try
    2
    try
    3
    try
    Differences
    Expression1Expression2Difference
    "ClassGenerator unavailable: ""Reflect Manager unavailable: "LITERAL_VALUE_MISMATCH
    3
    try
    3
    Class clas = Class.forName("bsh.ClassGeneratorImpl");
    3
    Class clas = Class.forName("bsh.ClassGeneratorImpl");
    Preondition Violations
    Unmatched statement Class clas=Class.forName("bsh.ClassGeneratorImpl"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                
                                                                                                                    
    4
    clas = Class.forName("bsh.reflect.ReflectManagerImpl");
    Preondition Violations
    Unmatched statement clas=Class.forName("bsh.reflect.ReflectManagerImpl"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4
    clas = Class.forName("bsh.reflect.ReflectManagerImpl");
    4
    cg = (ClassGenerator)clas.newInstance();
    4
    cg = (ClassGenerator)clas.newInstance();
    Preondition Violations
    Unmatched statement cg=(ClassGenerator)clas.newInstance(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                      
                                                                                        
    5
    rfm = (ReflectManager)clas.newInstance();
    Preondition Violations
    Unmatched statement rfm=(ReflectManager)clas.newInstance(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5
    rfm = (ReflectManager)clas.newInstance();
    5
    return cg;
    5
    return cg;
    Preondition Violations
    Unmatched return cg;
                              
                                
    6
    return rfm;
    Preondition Violations
    Unmatched return rfm;
    6
    return rfm;
    Precondition Violations (7)
    Row Violation
    1Type bsh.ClassGenerator of variable cg does not match with type bsh.ReflectManager of variable rfm
    2Unmatched statement Class clas=Class.forName("bsh.ClassGeneratorImpl"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3Unmatched statement clas=Class.forName("bsh.reflect.ReflectManagerImpl"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4Unmatched statement cg=(ClassGenerator)clas.newInstance(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5Unmatched statement rfm=(ReflectManager)clas.newInstance(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    6Unmatched return cg;
    7Unmatched return rfm;