String[] superTypeNames = new String[superTypes.length]; Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>(); for (int i = 0; i < superTypes.length; i++) { superTypeNames[i] = p(superTypes[i]); for (Method method : superTypes[i].getMethods()) { List<Method> methods = simpleToAll.get(method.getName()); if (methods == null) simpleToAll.put(method.getName(), methods = new ArrayList<Method>()); methods.add(method); } } Class newClass = defineImplClass(ruby, name, superTypeNames, simpleToAll); RubyClass rubyCls = populateImplClass(ruby, newClass, simpleToAll); return rubyCls;
String[] superTypeNames = new String[superTypes.length]; Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>(); for (int i = 0; i < superTypes.length; i++) { superTypeNames[i] = p(superTypes[i]); for (Method method : superTypes[i].getMethods()) { List<Method> methods = simpleToAll.get(method.getName()); if (methods == null) simpleToAll.put(method.getName(), methods = new ArrayList<Method>()); methods.add(method); } } Class newClass = defineOldStyleImplClass(ruby, name, superTypeNames, simpleToAll); return newClass;
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: RubyClass createImplClass(Class[], Ruby, String) Method name: Class createOldStyleImplClass(Class[], RubyClass, Ruby, String)
Number of AST nodes: 12 Number of AST nodes: 11
1
String[] superTypeNames = new String[superTypes.length];
1
String[] superTypeNames = new String[superTypes.length];
2
        Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>();
2
        Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>();
3
        for (int i = 0; i < superTypes.length; i++) {
3
        for (int i = 0; i < superTypes.length; i++) {
4
            superTypeNames[i] = p(superTypes[i]);
4
            superTypeNames[i] = p(superTypes[i]);
5
            
5
            
6
            for (Method method : superTypes[i].getMethods()) {
6
            for (Method method : superTypes[i].getMethods()) {
7
                List<Method> methods = simpleToAll.get(method.getName());
7
                List<Method> methods = simpleToAll.get(method.getName());
8
                if (methods == null) simpleToAll.put(method.getName(), methods = new ArrayList<Method>());
8
                if (methods == null) simpleToAll.put(method.getName(), methods = new ArrayList<Method>());
9
                methods.add(method);
9
                methods.add(method);
10
            }
10
            }
11
        }
11
        }
12
        
12
        
13
        Class newClass = defineImplClass(ruby, name, superTypeNames, simpleToAll);
13
        Class newClass = defineOldStyleImplClass(ruby, name, superTypeNames, simpleToAll);
14
        RubyClass rubyCls = populateImplClass(ruby, newClass, simpleToAll);
15
        
14
        
16
        return rubyCls;
15
        return newClass;
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.4
Clones locationClones are declared in the same class
Number of node comparisons31
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)5.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    String[] superTypeNames = new String[superTypes.length];
    1
    String[] superTypeNames = new String[superTypes.length];
    2
    Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>();
    2
    Map<String, List<Method>> simpleToAll = new HashMap<String, List<Method>>();
    3
    for (int i = 0; i < superTypes.length; i++)
    3
    for (int i = 0; i < superTypes.length; i++)
    4
    superTypeNames[i] = p(superTypes[i]);
    4
    superTypeNames[i] = p(superTypes[i]);
    5
    for (Method method : superTypes[i].getMethods())
    5
    for (Method method : superTypes[i].getMethods())
    6
    List<Method> methods = simpleToAll.get(method.getName());
    6
    List<Method> methods = simpleToAll.get(method.getName());
    7
    if (methods == null)
    7
    if (methods == null)
    8
    simpleToAll.put(method.getName(), methods = new ArrayList<Method>());
    8
    simpleToAll.put(method.getName(), methods = new ArrayList<Method>());
    9
    methods.add(method);
    9
    methods.add(method);
    10
    Class newClass = defineImplClass(ruby, name, superTypeNames, simpleToAll);
    10
    Class newClass = defineImplClass(ruby, name, superTypeNames, simpleToAll);
    10
    Class newClass = defineOldStyleImplClass(ruby, name, superTypeNames, simpleToAll);
    Differences
    Expression1Expression2Difference
    defineImplClassdefineOldStyleImplClassMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression defineImplClass(ruby,name,superTypeNames,simpleToAll) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression defineOldStyleImplClass(ruby,name,superTypeNames,simpleToAll) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    Class newClass = defineOldStyleImplClass(ruby, name, superTypeNames, simpleToAll);
                                            
    11
    return newClass;
    11
    RubyClass rubyCls = populateImplClass(ruby, newClass, simpleToAll);
                                                                                                                                          
    12
    return rubyCls;
    12
    return rubyCls;
    Preondition Violations
    Unmatched return rubyCls;
                                          
    Precondition Violations (4)
    Row Violation
    1Expression defineImplClass(ruby,name,superTypeNames,simpleToAll) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression defineOldStyleImplClass(ruby,name,superTypeNames,simpleToAll) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched return rubyCls;
    4Clone fragment #1 returns variables simpleToAll, newClass , while Clone fragment #2 returns variables newClass