FastClass fastClass; BulkBean bulkBean; try { fastClass = FastClass.create( clazz ); bulkBean = BulkBean.create( clazz, getterNames, setterNames, types ); if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) { if ( fastClass == null ) { bulkBean = null; } else { //test out the optimizer: Object instance = fastClass.newInstance(); bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) ); } } } catch( Throwable t ) { fastClass = null; bulkBean = null; String message = "reflection optimizer disabled for: " + clazz.getName() + " [" + StringHelper.unqualify( t.getClass().getName() ) + ": " + t.getMessage(); if (t instanceof BulkBeanException ) { int index = ( (BulkBeanException) t ).getIndex(); if (index >= 0) { message += " (property " + setterNames[index] + ")"; } } log.debug( message ); } if ( fastClass != null && bulkBean != null ) { return new ReflectionOptimizerImpl( new InstantiationOptimizerAdapter( fastClass ), new AccessOptimizerAdapter( bulkBean, clazz ) ); } else { return null; }
FastClass fastClass; BulkAccessor bulkAccessor; try { fastClass = FastClass.create( clazz ); bulkAccessor = BulkAccessor.create( clazz, getterNames, setterNames, types ); if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) { if ( fastClass == null ) { bulkAccessor = null; } else { //test out the optimizer: Object instance = fastClass.newInstance(); bulkAccessor.setPropertyValues( instance, bulkAccessor.getPropertyValues( instance ) ); } } } catch ( Throwable t ) { fastClass = null; bulkAccessor = null; String message = "reflection optimizer disabled for: " + clazz.getName() + " [" + StringHelper.unqualify( t.getClass().getName() ) + ": " + t.getMessage(); if ( t instanceof BulkAccessorException ) { int index = ( ( BulkAccessorException ) t ).getIndex(); if ( index >= 0 ) { message += " (property " + setterNames[index] + ")"; } } log.debug( message ); } if ( fastClass != null && bulkAccessor != null ) { return new ReflectionOptimizerImpl( new InstantiationOptimizerAdapter( fastClass ), new AccessOptimizerAdapter( bulkAccessor, clazz ) ); } else { return null; }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java
Method name: ReflectionOptimizer getReflectionOptimizer(Class, String[], String[], Class[]) Method name: ReflectionOptimizer getReflectionOptimizer(Class, String[], String[], Class[])
Number of AST nodes: 13 Number of AST nodes: 13
1
FastClass fastClass;
1
FastClass fastClass;
2
		BulkBean bulkBean;
2
		BulkAccessor bulkAccessor;
3
		try {
3
		try {
4
			fastClass = FastClass.create( clazz );
4
			fastClass = FastClass.create( clazz );
5
			bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );
5
			bulkAccessor = BulkAccessor.create( clazz, getterNames, setterNames, types );
6
			if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
6
			if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
7
				if ( fastClass == null ) {
7
				if ( fastClass == null ) {
8
					bulkBean = null;
8
					bulkAccessor = null;
9
				}
9
				}
10
				else {
10
				else {
11
					//test out the optimizer:
11
					//test out the optimizer:
12
					Object instance = fastClass.newInstance();
12
					Object instance = fastClass.newInstance();
13
					bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );
13
					bulkAccessor.setPropertyValues( instance, bulkAccessor.getPropertyValues( instance ) );
14
				}
14
				}
15
			}
15
			}
16
		}
16
		}
17
		catch( Throwable t ) {
17
		catch ( Throwable t ) {
18
			fastClass = null;
18
			fastClass = null;
19
			bulkBean = null;
19
			bulkAccessor = null;
20
			String message = "reflection optimizer disabled for: " +
20
			String message = "reflection optimizer disabled for: " +
21
			                 clazz.getName() +
21
			                 clazz.getName() +
22
			                 " [" +
22
			                 " [" +
23
			                 StringHelper.unqualify( t.getClass().getName() ) +
23
			                 StringHelper.unqualify( t.getClass().getName() ) +
24
			                 ": " +
24
			                 ": " +
25
			                 t.getMessage();
25
			                 t.getMessage();
26
			if (t instanceof BulkBeanException ) {
26
			if ( t instanceof BulkAccessorException ) {
27
				int index = ( (BulkBeanException) t ).getIndex();
27
				int index = ( ( BulkAccessorException ) t ).getIndex();
28
				if (index >= 0) {
28
				if ( index >= 0 ) {
29
					message += " (property " + setterNames[index] + ")";
29
					message += " (property " + setterNames[index] + ")";
30
				}
30
				}
31
			}
31
			}
32
			log.debug( message );
32
			log.debug( message );
33
		}
33
		}
34
		if ( fastClass != null && bulkBean != null ) {
34
		if ( fastClass != null && bulkAccessor != null ) {
35
			return new ReflectionOptimizerImpl(
35
			return new ReflectionOptimizerImpl(
36
					new InstantiationOptimizerAdapter( fastClass ),
36
					new InstantiationOptimizerAdapter( fastClass ),
37
			        new AccessOptimizerAdapter( bulkBean, clazz )
37
			        new AccessOptimizerAdapter( bulkAccessor, clazz )
38
			);
38
			);
39
		}
39
		}
40
		else {
40
		else {
41
			return null;
41
			return null;
42
		}
42
		}
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.5
Clones locationClones are in different classes
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                              
    4
    fastClass = FastClass.create(clazz);
    4
    fastClass = FastClass.create(clazz);
                                                                              
                                                                                                                                                      
    5
    bulkAccessor = BulkAccessor.create(clazz, getterNames, setterNames, types);
    5
    bulkBean = BulkBean.create(clazz, getterNames, setterNames, types);
                                                                                                                                      
    6
    if (!clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers()))
    6
    if (!clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers()))
    7
    if (fastClass == null)
    7
    if (fastClass == null)
    7
    if (fastClass == null)
    Differences
    Expression1Expression2Difference
    net.sf.cglib.reflect.FastClassorg.hibernate.bytecode.javassist.FastClassVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sf.cglib.reflect.FastClass of variable fastClass does not match with type org.hibernate.bytecode.javassist.FastClass of variable fastClass
    • Make classes net.sf.cglib.reflect.FastClass and org.hibernate.bytecode.javassist.FastClass extend a common superclass
    7
    if (fastClass == null)
                                              
    8
    bulkAccessor = null;
    8
    bulkBean = null;
                                      
    else
    else
    9
    Object instance = fastClass.newInstance();
    9
    Object instance = fastClass.newInstance();
    9
    Object instance = fastClass.newInstance();
    Differences
    Expression1Expression2Difference
    net.sf.cglib.reflect.FastClassorg.hibernate.bytecode.javassist.FastClassVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sf.cglib.reflect.FastClass of variable fastClass does not match with type org.hibernate.bytecode.javassist.FastClass of variable fastClass
    • Make classes net.sf.cglib.reflect.FastClass and org.hibernate.bytecode.javassist.FastClass extend a common superclass
    9
    Object instance = fastClass.newInstance();
    10
    bulkBean.setPropertyValues(instance, bulkBean.getPropertyValues(instance));
    10
    bulkBean.setPropertyValues(instance, bulkBean.getPropertyValues(instance));
    10
    bulkAccessor.setPropertyValues(instance, bulkAccessor.getPropertyValues(instance));
    Differences
    Expression1Expression2Difference
    bulkBeanbulkAccessorVARIABLE_NAME_MISMATCH
    net.sf.cglib.beans.BulkBeanorg.hibernate.bytecode.javassist.BulkAccessorVARIABLE_TYPE_MISMATCH
    bulkBeanbulkAccessorVARIABLE_NAME_MISMATCH
    net.sf.cglib.beans.BulkBeanorg.hibernate.bytecode.javassist.BulkAccessorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sf.cglib.beans.BulkBean of variable bulkBean does not match with type org.hibernate.bytecode.javassist.BulkAccessor of variable bulkAccessor
    • Make classes net.sf.cglib.beans.BulkBean and org.hibernate.bytecode.javassist.BulkAccessor extend a common superclass
    Type net.sf.cglib.beans.BulkBean of variable bulkBean does not match with type org.hibernate.bytecode.javassist.BulkAccessor of variable bulkAccessor
    • Make classes net.sf.cglib.beans.BulkBean and org.hibernate.bytecode.javassist.BulkAccessor extend a common superclass
    10
    bulkAccessor.setPropertyValues(instance, bulkAccessor.getPropertyValues(instance));
    Precondition Violations (4)
    Row Violation
    1Type net.sf.cglib.reflect.FastClass of variable fastClass does not match with type org.hibernate.bytecode.javassist.FastClass of variable fastClass
    2Type net.sf.cglib.reflect.FastClass of variable fastClass does not match with type org.hibernate.bytecode.javassist.FastClass of variable fastClass
    3Type net.sf.cglib.beans.BulkBean of variable bulkBean does not match with type org.hibernate.bytecode.javassist.BulkAccessor of variable bulkAccessor
    4Type net.sf.cglib.beans.BulkBean of variable bulkBean does not match with type org.hibernate.bytecode.javassist.BulkAccessor of variable bulkAccessor