JRubyMethod anno = md.getAnnotation(JRubyMethod.class); if (anno != null && out != null) { boolean isStatic = md.getModifiers().contains(Modifier.STATIC); String qualifiedName = getActualQualifiedName(md.getDeclaringType()); boolean hasContext = false; boolean hasBlock = false; for (ParameterDeclaration pd : md.getParameters()) { hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext"); hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block"); } int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock); String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName( md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), true, anno.frame()); String implClass = anno.meta() ? "metaClass" : "cls"; out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");"); out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");"); generateMethodAddCalls(md, anno); }
JRubyMethod anno = md.getAnnotation(JRubyMethod.class); if (anno != null && out != null) { boolean isStatic = md.getModifiers().contains(Modifier.STATIC); String qualifiedName = getActualQualifiedName(md.getDeclaringType()); boolean hasContext = false; boolean hasBlock = false; for (ParameterDeclaration pd : md.getParameters()) { hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext"); hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block"); } int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock); String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName( md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), false, anno.frame()); String implClass = anno.meta() ? "metaClass" : "cls"; out.println(" javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");"); out.println(" populateMethod(javaMethod, " + getArityValue(anno, actualRequired) + ", \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");"); generateMethodAddCalls(md, anno); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/anno/AnnotationBinder.java File path: /jruby-1.4.0/src/org/jruby/anno/AnnotationBinder.java
Method name: void processMethodDeclarationMulti(MethodDeclaration) Method name: void processMethodDeclaration(MethodDeclaration)
Number of AST nodes: 15 Number of AST nodes: 15
1
JRubyMethod anno = md.getAnnotation(JRubyMethod.class);
1
JRubyMethod anno = md.getAnnotation(JRubyMethod.class);
2
                if (anno != null && out != null) {
2
                if (anno != null && out != null) {
3
                    boolean isStatic = md.getModifiers().contains(Modifier.STATIC);
3
                    boolean isStatic = md.getModifiers().contains(Modifier.STATIC);
4
                    String qualifiedName = getActualQualifiedName(md.getDeclaringType());
4
                    String qualifiedName = getActualQualifiedName(md.getDeclaringType());
5
                    boolean hasContext = false;
5
                    boolean hasContext = false;
6
                    boolean hasBlock = false;
6
                    boolean hasBlock = false;
7
                    for (ParameterDeclaration pd : md.getParameters()) {
7
                    for (ParameterDeclaration pd : md.getParameters()) {
8
                        hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext");
8
                        hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext");
9
                        hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block");
9
                        hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block");
10
                    }
10
                    }
11
                    int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock);
11
                    int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock);
12
                    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(
12
                    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(
13
                            md.getSimpleName(),
13
                            md.getSimpleName(),
14
                            qualifiedName,
14
                            qualifiedName,
15
                            isStatic,
15
                            isStatic,
16
                            actualRequired,
16
                            actualRequired,
17
                            anno.optional(),
17
                            anno.optional(),
18
                            true,
18
                            false,
19
                            anno.frame());
19
                            anno.frame());
20
                    String implClass = anno.meta() ? "metaClass" : "cls";
20
                    String implClass = anno.meta() ? "metaClass" : "cls";
21
                    out.println("        javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
21
                    out.println("        javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
22
                    out.println("        populateMethod(javaMethod, " +
22
                    out.println("        populateMethod(javaMethod, " +
23
                            "-1, \"" +
23
                            getArityValue(anno, actualRequired) + ", \"" +
24
                            md.getSimpleName() + "\", " +
24
                            md.getSimpleName() + "\", " +
25
                            isStatic + ", " +
25
                            isStatic + ", " +
26
                            "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
26
                            "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
27
                    generateMethodAddCalls(md, anno);
27
                    generateMethodAddCalls(md, anno);
28
                }
28
                }
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 comparisons131
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)9.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    JRubyMethod anno = md.getAnnotation(JRubyMethod.class);
    1
    JRubyMethod anno = md.getAnnotation(JRubyMethod.class);
    2
    if (anno != null && out != null)
    2
    if (anno != null && out != null)
    3
    boolean isStatic = md.getModifiers().contains(Modifier.STATIC);
    3
    boolean isStatic = md.getModifiers().contains(Modifier.STATIC);
    4
    String qualifiedName = getActualQualifiedName(md.getDeclaringType());
    4
    String qualifiedName = getActualQualifiedName(md.getDeclaringType());
    5
    boolean hasContext = false;
    5
    boolean hasContext = false;
    6
    boolean hasBlock = false;
    Differences
    Expression1Expression2Difference
    hasContexthasBlockVARIABLE_NAME_MISMATCH
    6
    boolean hasBlock = false;
    6
    boolean hasBlock = false;
    6
    boolean hasBlock = false;
    5
    boolean hasContext = false;
    Differences
    Expression1Expression2Difference
    hasBlockhasContextVARIABLE_NAME_MISMATCH
    5
    boolean hasContext = false;
    7
    for (ParameterDeclaration pd : md.getParameters())
    7
    for (ParameterDeclaration pd : md.getParameters())
    8
    hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext");
    8
    hasContext |= pd.getType().toString().equals("org.jruby.runtime.ThreadContext");
    9
    hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block");
    9
    hasBlock |= pd.getType().toString().equals("org.jruby.runtime.Block");
    10
    int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock);
    10
    int actualRequired = calculateActualRequired(md.getParameters().size(), anno.optional(), anno.rest(), isStatic, hasContext, hasBlock);
    11
    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), true, anno.frame());
    11
    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), true, anno.frame());
    11
    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), false, anno.frame());
    Differences
    Expression1Expression2Difference
    truefalseLITERAL_VALUE_MISMATCH
    11
    String annotatedBindingName = CodegenUtils.getAnnotatedBindingClassName(md.getSimpleName(), qualifiedName, isStatic, actualRequired, anno.optional(), false, anno.frame());
    12
    String implClass = anno.meta() ? "metaClass" : "cls";
    12
    String implClass = anno.meta() ? "metaClass" : "cls";
    13
    out.println("        javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
    13
    out.println("        javaMethod = new " + annotatedBindingName + "(" + implClass + ", Visibility." + anno.visibility() + ");");
    14
    out.println("        populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
    14
    out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
    15
    generateMethodAddCalls(md, anno);
    Differences
    Expression1Expression2Difference
    printlngenerateMethodAddCallsMETHOD_INVOCATION_NAME_MISMATCH
    out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");")generateMethodAddCalls(md,anno)ARGUMENT_NUMBER_MISMATCH
    outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    15
    generateMethodAddCalls(md, anno);
    15
    generateMethodAddCalls(md, anno);
    15
    generateMethodAddCalls(md, anno);
    14
    out.println(" populateMethod(javaMethod, " + getArityValue(anno, actualRequired) + ", \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
    Differences
    Expression1Expression2Difference
    generateMethodAddCallsprintlnMETHOD_INVOCATION_NAME_MISMATCH
    generateMethodAddCalls(md,anno)out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");")ARGUMENT_NUMBER_MISMATCH
    outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    14
    out.println("        populateMethod(javaMethod, " + getArityValue(anno, actualRequired) + ", \"" + md.getSimpleName() + "\", " + isStatic + ", " + "CallConfiguration." + getCallConfigNameByAnno(anno) + ");");
    Precondition Violations (16)
    Row Violation
    1Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    4Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    5Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression out.println(" populateMethod(javaMethod, " + "-1, \"" + md.getSimpleName() + "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    8Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    9Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    12Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized
    13Expression generateMethodAddCalls(md,anno) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression generateMethodAddCalls(md,anno) is a void method call, and thus it cannot be parameterized
    16Expression out.println(" populateMethod(javaMethod, " + getArityValue(anno,actualRequired) + ", \""+ md.getSimpleName()+ "\", "+ isStatic+ ", "+ "CallConfiguration."+ getCallConfigNameByAnno(anno)+ ");") is a void method call, and thus it cannot be parameterized