if (constructors == null) { constructors = new ArrayList<Constructor>(4); } if (!Ruby.isSecurityRestricted()) { try { ctor.setAccessible(true); } catch(SecurityException e) {} } constructors.add(ctor); haveLocalConstructor |= javaClass == ctor.getDeclaringClass();
if (methods == null) { methods = new ArrayList<Method>(4); } if (!Ruby.isSecurityRestricted()) { try { method.setAccessible(true); } catch(SecurityException e) {} } methods.add(method); haveLocalMethod |= javaClass == method.getDeclaringClass();
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: void addConstructor(Constructor, Class) Method name: void addMethod(Method, Class)
Number of AST nodes: 7 Number of AST nodes: 7
1
if (constructors == null) {
1
if (methods == null) {
2
                constructors = new ArrayList<Constructor>(4);
2
                methods = new ArrayList<Method>(4);
3
            }
3
            }
4
            if (!Ruby.isSecurityRestricted()) {
4
            if (!Ruby.isSecurityRestricted()) {
5
                try {
5
                try {
6
                    ctor.setAccessible(true);
6
                    method.setAccessible(true);
7
                } catch(SecurityException e) {}
7
                } catch(SecurityException e) {}
8
            }
8
            }
9
            constructors.add(ctor);
9
            methods.add(method);
10
            haveLocalConstructor |= javaClass == ctor.getDeclaringClass();
10
            haveLocalMethod |= javaClass == method.getDeclaringClass();
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.4
Clones locationClones are in the same java file
Number of node comparisons13
  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)1.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (constructors == null)
    1
    if (constructors == null)
    1
    if (methods == null)
    Differences
    Expression1Expression2Difference
    constructorsmethodsVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List<java.lang.reflect.Constructor> of variable constructors does not match with type java.util.List<java.lang.reflect.Method> of variable methods
    • Make classes java.util.List and java.util.List extend a common superclass
    1
    if (methods == null)
                                                                            
    2
    methods = new ArrayList<Method>(4);
    2
    constructors = new ArrayList<Constructor>(4);
                                                                                                
    3
    if (!Ruby.isSecurityRestricted())
    3
    if (!Ruby.isSecurityRestricted())
    4
    try
    4
    try
    5
    ctor.setAccessible(true);
    5
    ctor.setAccessible(true);
    5
    method.setAccessible(true);
    Differences
    Expression1Expression2Difference
    ctormethodVARIABLE_NAME_MISMATCH
    java.lang.reflect.Constructorjava.lang.reflect.MethodSUBCLASS_TYPE_MISMATCH
    5
    method.setAccessible(true);
                                                  
    6
    methods.add(method);
    6
    constructors.add(ctor);
                                                        
                                                                                                                            
    7
    haveLocalMethod |= javaClass == method.getDeclaringClass();
    7
    haveLocalConstructor |= javaClass == ctor.getDeclaringClass();
                                                                                                                                  
    Precondition Violations (1)
    Row Violation
    1Type java.util.List<java.lang.reflect.Constructor> of variable constructors does not match with type java.util.List<java.lang.reflect.Method> of variable methods