if (object instanceof InternalJavaProxy) { InternalJavaProxy internalJavaProxy = (InternalJavaProxy) object; IRubyObject orig = internalJavaProxy.___getInvocationHandler().getOrig(); if (orig != null) { return orig; } }
if (existing instanceof Map) { Map m = (Map) existing; Callback cb = (Callback) m.get(proc); if (cb != null) { return cb; } }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/javasupport/JavaUtil.java File path: /jruby-1.4.0/src/org/jruby/ext/ffi/jffi/CallbackManager.java
Method name: IRubyObject trySimpleConversions(Ruby, Object) Method name: org.jruby.ext.ffi.Pointer getCallback(Ruby, CallbackInfo, RubyObject)
Number of AST nodes: 5 Number of AST nodes: 5
1
if (object instanceof InternalJavaProxy) {
1
if (existing instanceof 
2
            InternalJavaProxy internalJavaProxy = (InternalJavaProxy) object;
3
            IRubyObject orig = internalJavaProxy.___getInvocationHandler().getOrig();
2
Map) {
3
                Map m = (Map) existing;
4
                Callback cb = (Callback) m.get(proc);
4
            if (orig != null) {
5
                if (cb != null) {
5
                return orig;
6
                    return 
7
cb;
6
            }
8
                }
7
        }
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 comparisons9
  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.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    InternalJavaProxy internalJavaProxy = (InternalJavaProxy)object;
                                                                                                                                      
    7
    IRubyObject orig = internalJavaProxy.___getInvocationHandler().getOrig();
                                                                                                                                                        
                                                  
    8
    Map m = (Map)existing;
                                                                              
    9
    Callback cb = (Callback)m.get(proc);
    8
    if (orig != null)
    8
    if (orig != null)
    10
    if (cb != null)
    Differences
    Expression1Expression2Difference
    origcbVARIABLE_NAME_MISMATCH
    org.jruby.runtime.builtin.IRubyObjectorg.jruby.ext.ffi.jffi.CallbackManager.CallbackVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jruby.runtime.builtin.IRubyObject of variable orig does not match with type org.jruby.ext.ffi.jffi.CallbackManager.Callback of variable cb
    • Make classes org.jruby.runtime.builtin.IRubyObject and org.jruby.ext.ffi.jffi.CallbackManager.Callback extend a common superclass
    10
    if (cb != null)
    9
    return orig;
    9
    return orig;
    Preondition Violations
    Unmatched return orig;
                                  
                                
    11
    return cb;
    Preondition Violations
    Unmatched return cb;
    11
    return cb;
    Precondition Violations (3)
    Row Violation
    1Type org.jruby.runtime.builtin.IRubyObject of variable orig does not match with type org.jruby.ext.ffi.jffi.CallbackManager.Callback of variable cb
    2Unmatched return orig;
    3Unmatched return cb;