int index = ++catchIndex; CatchTarget[] stack = catchStack; stack[index] = catchTarget; if (index + 1 == stack.length) { expandCatchIfNecessary(); }
int index = ++parentIndex; RubyModule[] stack = parentStack; stack[index] = currentModule; if (index + 1 == stack.length) { expandParentsIfNecessary(); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/runtime/ThreadContext.java File path: /jruby-1.4.0/src/org/jruby/runtime/ThreadContext.java
Method name: void pushCatch(CatchTarget) Method name: void pushRubyClass(RubyModule)
Number of AST nodes: 5 Number of AST nodes: 5
1
int index = ++catchIndex;
1
int index = ++parentIndex;
2
        CatchTarget[] stack = catchStack;
2
        RubyModule[] stack = parentStack;
3
        stack[index] = catchTarget;
3
        stack[index] = currentModule;
4
        if (index + 1 == stack.length) {
4
        if (index + 1 == stack.length) {
5
            expandCatchIfNecessary();
5
            expandParentsIfNecessary();
6
        }
6
        }
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 comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    int index = ++catchIndex;
    1
    int index = ++catchIndex;
    1
    int index = ++parentIndex;
    Differences
    Expression1Expression2Difference
    catchIndexparentIndexVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression catchIndex is a field being modified, and thus it cannot be parameterized
    Expression parentIndex is a field being modified, and thus it cannot be parameterized
    1
    int index = ++parentIndex;
                                                                        
    2
    RubyModule[] stack = parentStack;
    2
    CatchTarget[] stack = catchStack;
                                                                        
                                                                
    3
    stack[index] = currentModule;
    Preondition Violations
    Unmatched statement stack[index]=currentModule; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    stack[index] = currentModule;
    3
    stack[index] = catchTarget;
    3
    stack[index] = catchTarget;
    Preondition Violations
    Unmatched statement stack[index]=catchTarget; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    4
    if (index + 1 == stack.length)
    4
    if (index + 1 == stack.length)
    4
    if (index + 1 == stack.length)
    Differences
    Expression1Expression2Difference
    org.jruby.RubyKernel.CatchTarget[]org.jruby.RubyModule[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jruby.RubyKernel.CatchTarget[] of variable stack does not match with type org.jruby.RubyModule[] of variable stack
    • Make classes org.jruby.RubyKernel.CatchTarget[] and org.jruby.RubyModule[] extend a common superclass
    4
    if (index + 1 == stack.length)
    5
    expandCatchIfNecessary();
    5
    expandCatchIfNecessary();
    5
    expandParentsIfNecessary();
    Differences
    Expression1Expression2Difference
    expandCatchIfNecessaryexpandParentsIfNecessaryMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression expandCatchIfNecessary() is a void method call, and thus it cannot be parameterized
    Expression expandParentsIfNecessary() is a void method call, and thus it cannot be parameterized
    5
    expandParentsIfNecessary();
    Precondition Violations (7)
    Row Violation
    1Expression catchIndex is a field being modified, and thus it cannot be parameterized
    2Expression parentIndex is a field being modified, and thus it cannot be parameterized
    3Unmatched statement stack[index]=currentModule; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement stack[index]=catchTarget; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Type org.jruby.RubyKernel.CatchTarget[] of variable stack does not match with type org.jruby.RubyModule[] of variable stack
    6Expression expandCatchIfNecessary() is a void method call, and thus it cannot be parameterized
    7Expression expandParentsIfNecessary() is a void method call, and thus it cannot be parameterized