try {
field = clas.getField(fieldName);
ReflectManager.RMSetAccessible( field );
return field;
} catch ( NoSuchFieldException e ) { }
try {
field = clas.getDeclaredField(fieldName);
ReflectManager.RMSetAccessible( field );
return field;
// Not found, fall through to next class
} catch(NoSuchFieldException e) { }
clas = clas.getSuperclass();
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/Reflect.java
|
|
File path: /jEdit-4.2/src/bsh/Reflect.java
|
Method name: Field findAccessibleField(Class, String)
|
|
Method name: Field findAccessibleField(Class, String)
|
Number of AST nodes: 4
|
|
Number of AST nodes: 5
|
|
1 | try {↵ | | 1 | try {↵
|
2 | field = clas.getField(fieldName);↵ | | 2 | field = clas.getDeclaredField(fieldName);↵
|
3 | ReflectManager.RMSetAccessible( field );↵ | | 3 | ReflectManager.RMSetAccessible( field );↵
|
4 | return field;↵ | | 4 | return field;↵
|
|
| | | 5 | // Not found, fall through to next class↵
|
|
5 | } catch ( NoSuchFieldException e ) { } | | 6 | } catch(NoSuchFieldException e) { }↵
|
|
| | | 7 | clas = clas.getSuperclass();
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in the same method |
Number of node comparisons | 16 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 1.1 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
2 | try | | 7 | try |
3 | field = clas.getField(fieldName); | | 8 | field = clas.getDeclaredField(fieldName); |
4 | ReflectManager.RMSetAccessible(field); | | 9 | ReflectManager.RMSetAccessible(field); |
5 | | | 10 | |
| | | 11 | clas = clas.getSuperclass(); |
Precondition Violations (3)
Row |
Violation |
1 | Expression clas.getField(fieldName) is a method call throwing exception(s) that should be caught by a try block that will be extracted |
2 | Expression clas.getDeclaredField(fieldName) is a method call throwing exception(s) that should be caught by a try block that will be extracted |
3 | Unmatched statement clas=clas.getSuperclass(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |