if (!(original instanceof RubyTime)) { throw getRuntime().newTypeError("Expecting an instance of class Time"); } RubyTime originalTime = (RubyTime) original; // We can just use dt, since it is immutable dt = originalTime.dt; usec = originalTime.usec; return this;
if (!(original instanceof RubyFileStat)) { throw getRuntime().newTypeError("wrong argument class"); } RubyFileStat originalFileStat = (RubyFileStat) original; file = originalFileStat.file; stat = originalFileStat.stat; return this;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyTime.java File path: /jruby-1.4.0/src/org/jruby/RubyFileStat.java
Method name: IRubyObject initialize_copy(IRubyObject) Method name: IRubyObject initialize_copy(IRubyObject)
Number of AST nodes: 6 Number of AST nodes: 6
1
if (!(original instanceof RubyTime)) {
1
if (!(original instanceof RubyFileStat)) {
2
            throw getRuntime().newTypeError("Expecting an instance of class Time");
2
            throw getRuntime().newTypeError("wrong argument class");
3
        }
3
        }
4
        
4
        
5
        RubyTime originalTime = (RubyTime) original;
5
        RubyFileStat originalFileStat = (RubyFileStat) original;
6
        
6
        
7
        // We can just use dt, since it is immutable
7
        
8
        dt = originalTime.dt;
8
file = originalFileStat.file;
9
        usec = originalTime.usec;
9
        stat = originalFileStat.stat;
10
        
10
        
11
        return this;
11
        return this;
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 in different classes having the same super class
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!(original instanceof RubyTime))
    1
    if (!(original instanceof RubyTime))
    1
    if (!(original instanceof RubyFileStat))
    Differences
    Expression1Expression2Difference
    org.jruby.RubyTimeorg.jruby.RubyFileStatSUBCLASS_TYPE_MISMATCH
    1
    if (!(original instanceof RubyFileStat))
    2
    throw getRuntime().newTypeError("Expecting an instance of class Time");
    2
    throw getRuntime().newTypeError("Expecting an instance of class Time");
    2
    throw getRuntime().newTypeError("wrong argument class");
    Differences
    Expression1Expression2Difference
    "Expecting an instance of class Time""wrong argument class"LITERAL_VALUE_MISMATCH
    2
    throw getRuntime().newTypeError("wrong argument class");
    3
    RubyTime originalTime = (RubyTime)original;
    3
    RubyTime originalTime = (RubyTime)original;
    3
    RubyFileStat originalFileStat = (RubyFileStat)original;
    Differences
    Expression1Expression2Difference
    org.jruby.RubyTimeorg.jruby.RubyFileStatSUBCLASS_TYPE_MISMATCH
    originalTimeoriginalFileStatVARIABLE_NAME_MISMATCH
    org.jruby.RubyTimeorg.jruby.RubyFileStatSUBCLASS_TYPE_MISMATCH
    org.jruby.RubyTimeorg.jruby.RubyFileStatSUBCLASS_TYPE_MISMATCH
    3
    RubyFileStat originalFileStat = (RubyFileStat)original;
                                                                
    4
    file = originalFileStat.file;
    4
    dt = originalTime.dt;
                                                
                                                                
    5
    stat = originalFileStat.stat;
    5
    usec = originalTime.usec;
                                                        
    6
    return this;
    6
    return this;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variable originalTime with type org.jruby.RubyTime , while Clone fragment #2 returns variable originalFileStat with type org.jruby.RubyFileStat