RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR); runtime.setHash(hashc); hashc.index = ClassIndex.HASH; hashc.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyHash; } }; hashc.includeModule(runtime.getEnumerable()); hashc.defineAnnotatedMethods(RubyHash.class); return hashc;
RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR); runtime.setArray(arrayc); arrayc.index = ClassIndex.ARRAY; arrayc.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyArray; } }; arrayc.includeModule(runtime.getEnumerable()); arrayc.defineAnnotatedMethods(RubyArray.class); return arrayc;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyHash.java File path: /jruby-1.4.0/src/org/jruby/RubyArray.java
Method name: RubyClass createHashClass(Ruby) Method name: RubyClass createArrayClass(Ruby)
Number of AST nodes: 7 Number of AST nodes: 7
1
RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
1
RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
2
        runtime.setHash(hashc);
2
        runtime.setArray(arrayc);
3
        hashc.index = ClassIndex.HASH;
3
        arrayc.index = ClassIndex.ARRAY;
4
        hashc.kindOf = new RubyModule.KindOf() {
4
        arrayc.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 RubyHash;
7
                return obj instanceof RubyArray;
8
            }
8
            }
9
        };
9
        };
10
        hashc.includeModule(runtime.getEnumerable());
10
        arrayc.includeModule(runtime.getEnumerable());
11
        hashc.defineAnnotatedMethods(RubyHash.class);
11
        arrayc.defineAnnotatedMethods(RubyArray.class);
12
        return hashc;
12
        return arrayc;
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 comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
    1
    RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
    1
    RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    "Hash""Array"LITERAL_VALUE_MISMATCH
    HASH_ALLOCATORARRAY_ALLOCATORVARIABLE_NAME_MISMATCH
    1
    RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
    2
    runtime.setHash(hashc);
    2
    runtime.setHash(hashc);
    2
    runtime.setArray(arrayc);
    Differences
    Expression1Expression2Difference
    setHashsetArrayMETHOD_INVOCATION_NAME_MISMATCH
    hashcarraycVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression runtime.setHash(hashc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.setArray(arrayc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.setHash(hashc) is a void method call, and thus it cannot be parameterized
    Expression runtime.setArray(arrayc) is a void method call, and thus it cannot be parameterized
    2
    runtime.setArray(arrayc);
    3
    hashc.index = ClassIndex.HASH;
    3
    hashc.index = ClassIndex.HASH;
    3
    arrayc.index = ClassIndex.ARRAY;
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    HASHARRAYVARIABLE_NAME_MISMATCH
    3
    arrayc.index = ClassIndex.ARRAY;
    4
    hashc.kindOf = new RubyModule.KindOf() {...};
    4
    hashc.kindOf = new RubyModule.KindOf() {...};
    4
    arrayc.kindOf = new RubyModule.KindOf() {...};
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    org.jruby.RubyHashorg.jruby.RubyArraySUBCLASS_TYPE_MISMATCH
    4
    arrayc.kindOf = new RubyModule.KindOf() {...};
    5
    hashc.includeModule(runtime.getEnumerable());
    5
    hashc.includeModule(runtime.getEnumerable());
    5
    arrayc.includeModule(runtime.getEnumerable());
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    5
    arrayc.includeModule(runtime.getEnumerable());
    6
    hashc.defineAnnotatedMethods(RubyHash.class);
    6
    hashc.defineAnnotatedMethods(RubyHash.class);
    6
    arrayc.defineAnnotatedMethods(RubyArray.class);
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    6
    arrayc.defineAnnotatedMethods(RubyArray.class);
    7
    return hashc;
    7
    return hashc;
    7
    return arrayc;
    Differences
    Expression1Expression2Difference
    hashcarraycVARIABLE_NAME_MISMATCH
    7
    return arrayc;
    Precondition Violations (4)
    Row Violation
    1Expression runtime.setHash(hashc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression runtime.setArray(arrayc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression runtime.setHash(hashc) is a void method call, and thus it cannot be parameterized
    4Expression runtime.setArray(arrayc) is a void method call, and thus it cannot be parameterized