try { return javaClass.getDeclaredFields(); } catch (SecurityException e) { return getFields(javaClass); }
try { return javaClass.getFields(); } catch (SecurityException e) { return new Field[] {}; }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/javasupport/JavaClass.java File path: /jruby-1.4.0/src/org/jruby/javasupport/JavaClass.java
Method name: Field[] getDeclaredFields(Class) Method name: Field[] getFields(Class)
Number of AST nodes: 2 Number of AST nodes: 2
1
try {
1
try {
2
            return javaClass.getDeclaredFields();
2
            return javaClass.getFields();
3
        } catch (SecurityException e) {
3
        } catch (SecurityException e) {
4
            return getFields(javaClass);
4
            return new Field[] {};
5
        }
5
        }
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.2
Clones locationClones are declared in the same class
Number of node comparisons4
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    try
    1
    try
    1
    try
    Differences
    Expression1Expression2Difference
    getFields(javaClass)new Field[]{}TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression getFields(javaClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    try
    2
    return javaClass.getDeclaredFields();
    2
    return javaClass.getDeclaredFields();
    2
    return javaClass.getFields();
    Differences
    Expression1Expression2Difference
    getDeclaredFieldsgetFieldsMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Class<>java.lang.Class<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression javaClass.getDeclaredFields() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression javaClass.getFields() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Type java.lang.Class<> of variable javaClass does not match with type java.lang.Class<> of variable javaClass
    • Make classes java.lang.Class<> and java.lang.Class<> extend a common superclass
    2
    return javaClass.getFields();
    Precondition Violations (4)
    Row Violation
    1Expression getFields(javaClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression javaClass.getDeclaredFields() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3Expression javaClass.getFields() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    4Type java.lang.Class<> of variable javaClass does not match with type java.lang.Class<> of variable javaClass