RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setEncoding(encodingc); encodingc.index = ClassIndex.ENCODING; encodingc.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyEncoding; } }; encodingc.getSingletonClass().undefineMethod("allocate"); encodingc.defineAnnotatedMethods(RubyEncoding.class); return encodingc;
RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator()); runtime.setYielder(yielderc); yielderc.index = ClassIndex.YIELDER; yielderc.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyYielder; } }; yielderc.defineAnnotatedMethods(RubyYielder.class); return yielderc;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyEncoding.java File path: /jruby-1.4.0/src/org/jruby/RubyYielder.java
Method name: RubyClass createEncodingClass(Ruby) Method name: RubyClass createYielderClass(Ruby)
Number of AST nodes: 7 Number of AST nodes: 6
1
RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
1
RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
2
        runtime.setEncoding(encodingc);
2
        runtime.setYielder(yielderc);
3
        encodingc.index = ClassIndex.ENCODING;
3
        yielderc.index = ClassIndex.YIELDER;
4
        encodingc.kindOf = new RubyModule.KindOf() {
4
        yielderc.kindOf = new RubyModule.KindOf() {
5
            @Override
5
            @Override
6
            public boolean isKindOf(IRubyObject obj, RubyModule type) {
6
            public boolean isKindOf(IRubyObject obj, RubyModule type) {
7
                return obj instanceof RubyEncoding;
7
                return obj instanceof RubyYielder;
8
            }
8
            }
9
        };
9
        };
10
        encodingc.getSingletonClass().undefineMethod("allocate");
10
        
11
        encodingc.defineAnnotatedMethods(RubyEncoding.class);
11
yielderc.defineAnnotatedMethods(RubyYielder.class);
12
        return encodingc;
12
        return yielderc;
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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons24
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
    1
    RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
    1
    RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
    Differences
    Expression1Expression2Difference
    encodingcyieldercVARIABLE_NAME_MISMATCH
    defineClassdefineClassUnderMETHOD_INVOCATION_NAME_MISMATCH
    runtime.defineClass("Encoding",runtime.getObject(),ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR)runtime.defineClassUnder("Yielder",runtime.getObject(),YIELDER_ALLOCATOR,runtime.getEnumerator())ARGUMENT_NUMBER_MISMATCH
    1
    RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
    2
    runtime.setEncoding(encodingc);
    2
    runtime.setEncoding(encodingc);
    2
    runtime.setYielder(yielderc);
    Differences
    Expression1Expression2Difference
    setEncodingsetYielderMETHOD_INVOCATION_NAME_MISMATCH
    encodingcyieldercVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression runtime.setEncoding(encodingc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.setYielder(yielderc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.setEncoding(encodingc) is a void method call, and thus it cannot be parameterized
    Expression runtime.setYielder(yielderc) is a void method call, and thus it cannot be parameterized
    2
    runtime.setYielder(yielderc);
    3
    encodingc.index = ClassIndex.ENCODING;
    3
    encodingc.index = ClassIndex.ENCODING;
    3
    yielderc.index = ClassIndex.YIELDER;
    Differences
    Expression1Expression2Difference
    encodingcyieldercVARIABLE_NAME_MISMATCH
    ENCODINGYIELDERVARIABLE_NAME_MISMATCH
    3
    yielderc.index = ClassIndex.YIELDER;
    4
    encodingc.kindOf = new RubyModule.KindOf() {...};
    4
    encodingc.kindOf = new RubyModule.KindOf() {...};
    4
    yielderc.kindOf = new RubyModule.KindOf() {...};
    Differences
    Expression1Expression2Difference
    encodingcyieldercVARIABLE_NAME_MISMATCH
    org.jruby.RubyEncodingorg.jruby.RubyYielderSUBCLASS_TYPE_MISMATCH
    4
    yielderc.kindOf = new RubyModule.KindOf() {...};
    5
    encodingc.getSingletonClass().undefineMethod("allocate");
                                                                                                                            
    6
    encodingc.defineAnnotatedMethods(RubyEncoding.class);
    6
    encodingc.defineAnnotatedMethods(RubyEncoding.class);
    5
    yielderc.defineAnnotatedMethods(RubyYielder.class);
    Differences
    Expression1Expression2Difference
    encodingcyieldercVARIABLE_NAME_MISMATCH
    5
    yielderc.defineAnnotatedMethods(RubyYielder.class);
    7
    return encodingc;
    7
    return encodingc;
    6
    return yielderc;
    Differences
    Expression1Expression2Difference
    encodingcyieldercVARIABLE_NAME_MISMATCH
    6
    return yielderc;
    Precondition Violations (5)
    Row Violation
    1Expression runtime.setEncoding(encodingc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression runtime.setYielder(yielderc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression runtime.setEncoding(encodingc) is a void method call, and thus it cannot be parameterized
    4Expression runtime.setYielder(yielderc) is a void method call, and thus it cannot be parameterized
    5Clone fragment #1 returns variables encodingc , while Clone fragment #2 returns variables