RubyClass stringClass = runtime.defineClass("String", runtime.getObject(), STRING_ALLOCATOR); runtime.setString(stringClass); stringClass.index = ClassIndex.STRING; stringClass.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyString; } }; stringClass.includeModule(runtime.getComparable()); if (!runtime.is1_9()) stringClass.includeModule(runtime.getEnumerable()); stringClass.defineAnnotatedMethods(RubyString.class); return stringClass;
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/RubyString.java File path: /jruby-1.4.0/src/org/jruby/RubyArray.java
Method name: RubyClass createStringClass(Ruby) Method name: RubyClass createArrayClass(Ruby)
Number of AST nodes: 9 Number of AST nodes: 7
1
RubyClass stringClass = runtime.defineClass("String", runtime.getObject(), STRING_ALLOCATOR);
1
RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
2
        runtime.setString(stringClass);
2
        runtime.set
3
        stringClass
3
Array(arrayc);
4
.index = ClassIndex.STRING;
4
        arrayc.index = ClassIndex.ARRAY;
5
        stringClass.kindOf = new RubyModule.KindOf() {
5
        arrayc.kindOf = new RubyModule.KindOf() {
6
            @Override
6
            @Override
7
                public boolean isKindOf(IRubyObject obj, RubyModule type) {
7
            public boolean isKindOf(IRubyObject obj, RubyModule type) {
8
                    return obj instanceof RubyString;
8
                return obj instanceof RubyArray;
9
                }
9
            
10
    
10
}
11
        };
11
        };
12
        stringClass.includeModule(runtime.getComparable());
12
        
13
        if (!runtime.is1_9()) stringClass.includeModule(runtime.getEnumerable());
13
arrayc.includeModule(runtime.getEnumerable());
14
        stringClass.defineAnnotatedMethods(RubyString.class);
14
        arrayc.defineAnnotatedMethods(RubyArray.class);
15
        return stringClass;
15
        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 fragment2
    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 stringClass = runtime.defineClass("String", runtime.getObject(), STRING_ALLOCATOR);
    1
    RubyClass stringClass = runtime.defineClass("String", runtime.getObject(), STRING_ALLOCATOR);
    1
    RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
    Differences
    Expression1Expression2Difference
    stringClassarraycVARIABLE_NAME_MISMATCH
    "String""Array"LITERAL_VALUE_MISMATCH
    STRING_ALLOCATORARRAY_ALLOCATORVARIABLE_NAME_MISMATCH
    1
    RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR);
    2
    runtime.setString(stringClass);
    2
    runtime.setString(stringClass);
    2
    runtime.setArray(arrayc);
    Differences
    Expression1Expression2Difference
    setStringsetArrayMETHOD_INVOCATION_NAME_MISMATCH
    stringClassarraycVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression runtime.setString(stringClass) 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.setString(stringClass) 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
    stringClass.index = ClassIndex.STRING;
    3
    stringClass.index = ClassIndex.STRING;
    3
    arrayc.index = ClassIndex.ARRAY;
    Differences
    Expression1Expression2Difference
    stringClassarraycVARIABLE_NAME_MISMATCH
    STRINGARRAYVARIABLE_NAME_MISMATCH
    3
    arrayc.index = ClassIndex.ARRAY;
    4
    stringClass.kindOf = new RubyModule.KindOf() {...};
    4
    stringClass.kindOf = new RubyModule.KindOf() {...};
    4
    arrayc.kindOf = new RubyModule.KindOf() {...};
    Differences
    Expression1Expression2Difference
    stringClassarraycVARIABLE_NAME_MISMATCH
    org.jruby.RubyStringorg.jruby.RubyArraySUBCLASS_TYPE_MISMATCH
    4
    arrayc.kindOf = new RubyModule.KindOf() {...};
    5
    stringClass.includeModule(runtime.getComparable());
    5
    stringClass.includeModule(runtime.getComparable());
    5
    arrayc.includeModule(runtime.getEnumerable());
    Differences
    Expression1Expression2Difference
    getComparablegetEnumerableMETHOD_INVOCATION_NAME_MISMATCH
    stringClassarraycVARIABLE_NAME_MISMATCH
    5
    arrayc.includeModule(runtime.getEnumerable());
    6
    if (!runtime.is1_9())
                                                  
    7
    stringClass.includeModule(runtime.getEnumerable());
                                                                                                                
    8
    stringClass.defineAnnotatedMethods(RubyString.class);
    8
    stringClass.defineAnnotatedMethods(RubyString.class);
    6
    arrayc.defineAnnotatedMethods(RubyArray.class);
    Differences
    Expression1Expression2Difference
    stringClassarraycVARIABLE_NAME_MISMATCH
    6
    arrayc.defineAnnotatedMethods(RubyArray.class);
    9
    return stringClass;
    9
    return stringClass;
    7
    return arrayc;
    Differences
    Expression1Expression2Difference
    stringClassarraycVARIABLE_NAME_MISMATCH
    7
    return arrayc;
    Precondition Violations (5)
    Row Violation
    1Expression runtime.setString(stringClass) 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.setString(stringClass) 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
    5Clone fragment #1 returns variables stringClass , while Clone fragment #2 returns variables