int pid = -1; int flags = 0; if (args.length > 0) { pid = (int)args[0].convertToInteger().getLongValue(); } if (args.length > 1) { flags = (int)args[1].convertToInteger().getLongValue(); } int[] status = new int[1]; pid = runtime.getPosix().waitpid(pid, status, flags); if (pid == -1) { throw runtime.newErrnoECHILDError(); } runtime.getGlobalVariables().set( "$?", RubyProcess.RubyStatus.newProcessStatus(runtime, status[0])); return runtime.newFixnum(pid);
int pid = -1; int flags = 0; if (args.length > 0) { pid = (int)args[0].convertToInteger().getLongValue(); } if (args.length > 1) { flags = (int)args[1].convertToInteger().getLongValue(); } int[] status = new int[1]; pid = runtime.getPosix().waitpid(pid, status, flags); if (pid == -1) { throw runtime.newErrnoECHILDError(); } return runtime.newArray(runtime.newFixnum(pid), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyProcess.java File path: /jruby-1.4.0/src/org/jruby/RubyProcess.java
Method name: IRubyObject waitpid(Ruby, IRubyObject[]) Method name: IRubyObject waitpid2(Ruby, IRubyObject[])
Number of AST nodes: 12 Number of AST nodes: 11
1
int pid = -1;
1
int pid = -1;
2
        int flags = 0;
2
        int flags = 0;
3
        if (args.length > 0) {
3
        if (args.length > 0) {
4
            pid = (int)args[0].convertToInteger().getLongValue();
4
            pid = (int)args[0].convertToInteger().getLongValue();
5
        }
5
        }
6
        if (args.length > 1) {
6
        if (args.length > 1) {
7
            flags = (int)args[1].convertToInteger().getLongValue();
7
            flags = (int)args[1].convertToInteger().getLongValue();
8
        }
8
        }
9
        
9
        
10
        int[] status = new int[1];
10
        int[] status = new int[1];
11
        pid = runtime.getPosix().waitpid(pid, status, flags);
11
        pid = runtime.getPosix().waitpid(pid, status, flags);
12
        
12
        
13
        if (pid == -1) {
13
        if (pid == -1) {
14
            throw runtime.newErrnoECHILDError();
14
            throw runtime.newErrnoECHILDError();
15
        }
15
        }
16
        
16
        
17
        runtime.getGlobalVariables().set(
17
        r
18
                "$?", 
19
                RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
18
eturn runtime.newArray(runtime.newFixnum(pid), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
20
        return runtime.newFixnum(pid);
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.6
Clones locationClones are declared in the same class
Number of node comparisons57
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int pid = -1;
    1
    int pid = -1;
    2
    int flags = 0;
    2
    int flags = 0;
    3
    if (args.length > 0)
    3
    if (args.length > 0)
    4
    pid = (int)args[0].convertToInteger().getLongValue();
    4
    pid = (int)args[0].convertToInteger().getLongValue();
    5
    if (args.length > 1)
    5
    if (args.length > 1)
    6
    flags = (int)args[1].convertToInteger().getLongValue();
    6
    flags = (int)args[1].convertToInteger().getLongValue();
    7
    int[] status = new int[1];
    7
    int[] status = new int[1];
    8
    pid = runtime.getPosix().waitpid(pid, status, flags);
    8
    pid = runtime.getPosix().waitpid(pid, status, flags);
    9
    if (pid == -1)
    9
    if (pid == -1)
    10
    throw runtime.newErrnoECHILDError();
    10
    throw runtime.newErrnoECHILDError();
    11
    runtime.getGlobalVariables().set("$?", RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
                                                                                                                                                                                                                
    12
    return runtime.newFixnum(pid);
    12
    return runtime.newFixnum(pid);
    11
    return runtime.newArray(runtime.newFixnum(pid), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
    Differences
    Expression1Expression2Difference
    newFixnumnewArrayMETHOD_INVOCATION_NAME_MISMATCH
    runtime.newFixnum(pid)runtime.newArray(runtime.newFixnum(pid),RubyProcess.RubyStatus.newProcessStatus(runtime,status[0]))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression runtime.newFixnum(pid) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.newArray(runtime.newFixnum(pid),RubyProcess.RubyStatus.newProcessStatus(runtime,status[0])) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.newFixnum(pid) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.newArray(runtime.newFixnum(pid),RubyProcess.RubyStatus.newProcessStatus(runtime,status[0])) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    return runtime.newArray(runtime.newFixnum(pid), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]));
    Precondition Violations (5)
    Row Violation
    1Expression runtime.newFixnum(pid) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression runtime.newArray(runtime.newFixnum(pid),RubyProcess.RubyStatus.newProcessStatus(runtime,status[0])) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression runtime.newFixnum(pid) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression runtime.newArray(runtime.newFixnum(pid),RubyProcess.RubyStatus.newProcessStatus(runtime,status[0])) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables status , while Clone fragment #2 returns variables