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 converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding()); runtime.setConverter(converterc); converterc.index = ClassIndex.CONVERTER; converterc.kindOf = new RubyModule.KindOf() { @Override public boolean isKindOf(IRubyObject obj, RubyModule type) { return obj instanceof RubyConverter; } }; converterc.defineAnnotatedMethods(RubyConverter.class); return converterc;
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/RubyConverter.java
Method name: RubyClass createEncodingClass(Ruby) Method name: RubyClass createConverterClass(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 converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding());
2
        runtime.setEncoding(encodingc);
2
        runtime.setConverter(converterc);
3
        encodingc.index = ClassIndex.ENCODING;
3
        converterc.index = ClassIndex.CONVERTER;
4
        encodingc.kindOf = new RubyModule.KindOf() {
4
        converterc.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 RubyConverter;
8
            }
8
            }
9
        };
9
        };
10
        encodingc.getSingletonClass().undefineMethod("allocate");
10
        
11
        encodingc.defineAnnotatedMethods(RubyEncoding.class);
11
converterc.defineAnnotatedMethods(RubyConverter.class);
12
        return encodingc;
12
        return converterc;
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 converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding());
    Differences
    Expression1Expression2Difference
    encodingcconvertercVARIABLE_NAME_MISMATCH
    defineClassdefineClassUnderMETHOD_INVOCATION_NAME_MISMATCH
    runtime.defineClass("Encoding",runtime.getObject(),ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR)runtime.defineClassUnder("Converter",runtime.getClass("Data"),CONVERTER_ALLOCATOR,runtime.getEncoding())ARGUMENT_NUMBER_MISMATCH
    1
    RubyClass converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding());
    2
    runtime.setEncoding(encodingc);
    2
    runtime.setEncoding(encodingc);
    2
    runtime.setConverter(converterc);
    Differences
    Expression1Expression2Difference
    setEncodingsetConverterMETHOD_INVOCATION_NAME_MISMATCH
    encodingcconvertercVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression runtime.setEncoding(encodingc) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.setConverter(converterc) 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.setConverter(converterc) is a void method call, and thus it cannot be parameterized
    2
    runtime.setConverter(converterc);
    3
    encodingc.index = ClassIndex.ENCODING;
    3
    encodingc.index = ClassIndex.ENCODING;
    3
    converterc.index = ClassIndex.CONVERTER;
    Differences
    Expression1Expression2Difference
    encodingcconvertercVARIABLE_NAME_MISMATCH
    ENCODINGCONVERTERVARIABLE_NAME_MISMATCH
    3
    converterc.index = ClassIndex.CONVERTER;
    4
    encodingc.kindOf = new RubyModule.KindOf() {...};
    4
    encodingc.kindOf = new RubyModule.KindOf() {...};
    4
    converterc.kindOf = new RubyModule.KindOf() {...};
    Differences
    Expression1Expression2Difference
    encodingcconvertercVARIABLE_NAME_MISMATCH
    org.jruby.RubyEncodingorg.jruby.RubyConverterSUBCLASS_TYPE_MISMATCH
    4
    converterc.kindOf = new RubyModule.KindOf() {...};
    5
    encodingc.getSingletonClass().undefineMethod("allocate");
                                                                                                                            
    6
    encodingc.defineAnnotatedMethods(RubyEncoding.class);
    6
    encodingc.defineAnnotatedMethods(RubyEncoding.class);
    5
    converterc.defineAnnotatedMethods(RubyConverter.class);
    Differences
    Expression1Expression2Difference
    encodingcconvertercVARIABLE_NAME_MISMATCH
    5
    converterc.defineAnnotatedMethods(RubyConverter.class);
    7
    return encodingc;
    7
    return encodingc;
    6
    return converterc;
    Differences
    Expression1Expression2Difference
    encodingcconvertercVARIABLE_NAME_MISMATCH
    6
    return converterc;
    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.setConverter(converterc) 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.setConverter(converterc) is a void method call, and thus it cannot be parameterized
    5Clone fragment #1 returns variables encodingc , while Clone fragment #2 returns variables