if ( clazz==null || clazz==Object.class ) {
throw new PropertyNotFoundException("field not found: " + name);
}
Field field;
try {
field = clazz.getDeclaredField(name);
}
catch (NoSuchFieldException nsfe) {
field = getField( clazz, clazz.getSuperclass(), name );
}
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
return field;
if ( clazz==null || clazz==Object.class ) {
throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName());
}
Field field;
try {
field = clazz.getDeclaredField(name);
}
catch (NoSuchFieldException nsfe) {
field = getField( root, clazz.getSuperclass(), name );
}
if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);
return field;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
|
Method name: Field getField(Class, String)
|
|
Method name: Field getField(Class, Class, String)
|
Number of AST nodes: 8
|
|
Number of AST nodes: 8
|
|
1 | if ( clazz==null || clazz==Object.class ) {↵ | | 1 | if ( clazz==null || clazz==Object.class ) {↵
|
2 | throw new PropertyNotFoundException("field not found: " + name); ↵ | | 2 | throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); ↵
|
3 | }↵ | | 3 | }↵
|
4 | Field field;↵ | | 4 | Field field;↵
|
5 | try {↵ | | 5 | try {↵
|
6 | field = clazz.getDeclaredField(name);↵ | | 6 | field = clazz.getDeclaredField(name);↵
|
7 | }↵ | | 7 | }↵
|
8 | catch (NoSuchFieldException nsfe) {↵ | | 8 | catch (NoSuchFieldException nsfe) {↵
|
9 | field = getField( clazz, clazz.getSuperclass(), name );↵ | | 9 | field = getField( root, clazz.getSuperclass(), name );↵
|
10 | }↵ | | 10 | }↵
|
11 | if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);↵ | | 11 | if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true);↵
|
12 | return field; | | 12 | return field;
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 31 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 1.2 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | if (clazz == null || clazz == Object.class) | | 1 | if (clazz == null || clazz == Object.class) |
2 | throw new PropertyNotFoundException("field not found: " + name); | | 2 | throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); |
3 | Field field; | | 3 | Field field; |
4 | try | | 4 | try |
5 | field = clazz.getDeclaredField(name); | | 5 | field = clazz.getDeclaredField(name); |
6 | if (!ReflectHelper.isPublic(clazz, field)) | | 6 | if (!ReflectHelper.isPublic(clazz, field)) |
7 | field.setAccessible(true); | | 7 | field.setAccessible(true); |
8 | return field; | | 8 | return field; |
Precondition Violations (0)
Row |
Violation |