String className = name.toString(); try { Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className); RubyModule namespace; if (self instanceof RubyModule) { namespace = (RubyModule) self; } else { namespace = self.getMetaClass().getRealClass(); } namespace.defineConstant(cls.getSimpleName(), getMirrorForClass(context.getRuntime(), cls)); return context.getRuntime().getNil(); } catch (Exception e) { if (context.getRuntime().getDebug().isTrue()) { e.printStackTrace(); } throw context.getRuntime().newTypeError("Could not find class " + className + ", exception: " + e); }
String className = name.toString(); try { Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className); RubyModule namespace; if (self instanceof RubyModule) { namespace = (RubyModule) self; } else { namespace = self.getMetaClass().getRealClass(); } namespace.defineConstant(as.toString(), getMirrorForClass(context.getRuntime(), cls)); return context.getRuntime().getNil(); } catch (Exception e) { if (context.getRuntime().getDebug().isTrue()) { e.printStackTrace(); } throw context.getRuntime().newTypeError("Could not find class " + className + ", exception: " + e); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/java/MiniJava.java File path: /jruby-1.4.0/src/org/jruby/java/MiniJava.java
Method name: IRubyObject rb_import(ThreadContext, IRubyObject, IRubyObject) Method name: IRubyObject rb_import(ThreadContext, IRubyObject, IRubyObject, IRubyObject)
Number of AST nodes: 9 Number of AST nodes: 9
1
String className = name.toString();
1
String className = name.toString();
2
        try {
2
        try {
3
            Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className);
3
            Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className);
4
            RubyModule namespace;
4
            RubyModule namespace;
5
            if (self instanceof RubyModule) {
5
            if (self instanceof RubyModule) {
6
                namespace = (RubyModule) self;
6
                namespace = (RubyModule) self;
7
            } else {
7
            } else {
8
                namespace = self.getMetaClass().getRealClass();
8
                namespace = self.getMetaClass().getRealClass();
9
            }
9
            }
10
            namespace.defineConstant(cls.getSimpleName(), getMirrorForClass(context.getRuntime(), cls));
10
            namespace.defineConstant(as.toString(), getMirrorForClass(context.getRuntime(), cls));
11
            return context.getRuntime().getNil();
11
            return context.getRuntime().getNil();
12
        } catch (Exception e) {
12
        } catch (Exception e) {
13
            if (context.getRuntime().getDebug().isTrue()) {
13
            if (context.getRuntime().getDebug().isTrue()) {
14
                e.printStackTrace();
14
                e.printStackTrace();
15
            }
15
            }
16
            throw context.getRuntime().newTypeError("Could not find class " + className + ", exception: " + e);
16
            throw context.getRuntime().newTypeError("Could not find class " + className + ", exception: " + e);
17
        }
17
        }
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.5
Clones locationClones are declared in the same class
Number of node comparisons35
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String className = name.toString();
    1
    String className = name.toString();
    2
    try
    2
    try
    3
    Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className);
    3
    Class cls = findClass(context.getRuntime().getJRubyClassLoader(), className);
    4
    RubyModule namespace;
    4
    RubyModule namespace;
    5
    if (self instanceof RubyModule)
    5
    if (self instanceof RubyModule)
    6
    namespace = (RubyModule)self;
    6
    namespace = (RubyModule)self;
    else
    else
    7
    namespace = self.getMetaClass().getRealClass();
    7
    namespace = self.getMetaClass().getRealClass();
                                                                                                                                                                                  
    8
    namespace.defineConstant(as.toString(), getMirrorForClass(context.getRuntime(), cls));
    8
    namespace.defineConstant(cls.getSimpleName(), getMirrorForClass(context.getRuntime(), cls));
                                                                                                                                                                                              
    9
    return context.getRuntime().getNil();
    9
    return context.getRuntime().getNil();
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables cls, namespace , while Clone fragment #2 returns variables cls, namespace