synchronized (requireLocks) { requireLock = requireLocks.get(requireName); if (requireLock == null) { requireLock = new Object(); requireLocks.put(requireName, requireLock); } }
synchronized (arities) { result = arities.get(value); if (result == null) { result = new Arity(value); arities.put(value, result); } }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/runtime/load/LoadService.java File path: /jruby-1.4.0/src/org/jruby/runtime/Arity.java
Method name: boolean lockAndRequire(String) Method name: Arity newArity(int)
Number of AST nodes: 5 Number of AST nodes: 5
1
synchronized (requireLocks) {
1
synchronized (arities) {
2
                requireLock = requireLocks.get(requireName);
2
            
3
    
3
result = arities.get(value);
4
            if (requireLock == null) {
4
            if (result == null) {
5
                    requireLock = new Object();
5
                result = new Arity(value);
6
                    requireLocks.put(requireName, requireLock);
6
                arities.put(value, result);
7
                }
7
            
8
    
8
}
9
        }
9
        }
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 in different classes
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    if (requireLock == null)
    5
    if (requireLock == null)
    4
    if (result == null)
    Differences
    Expression1Expression2Difference
    requireLockresultVARIABLE_NAME_MISMATCH
    java.lang.Objectorg.jruby.runtime.ArityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable requireLock does not match with type org.jruby.runtime.Arity of variable result
    • Make classes java.lang.Object and org.jruby.runtime.Arity extend a common superclass
    4
    if (result == null)
                                                          
    5
    result = new Arity(value);
    Preondition Violations
    Unmatched statement result=new Arity(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    result = new Arity(value);
                                                              
    6
    arities.put(value, result);
    6
    requireLock = new Object();
    6
    requireLock = new Object();
    Preondition Violations
    Unmatched statement requireLock=new Object(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    7
    requireLocks.put(requireName, requireLock);
                                                                                              
    Precondition Violations (3)
    Row Violation
    1Type java.lang.Object of variable requireLock does not match with type org.jruby.runtime.Arity of variable result
    2Unmatched statement result=new Arity(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement requireLock=new Object(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted