RubyIO io = (RubyIO)self; Ruby runtime = context.getRuntime(); try { io.getOpenFile().checkWritable(context.getRuntime()); } catch (PipeException pe) { throw runtime.newErrnoEPIPEError(); } catch (IOException ex) { throw runtime.newIOErrorFromException(ex); } catch (BadDescriptorException ex) { throw runtime.newErrnoEBADFError(); } catch (InvalidValueException e) { throw runtime.newErrnoEINVALError(); } return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getOutStream());
RubyIO io = (RubyIO)self; Ruby runtime = context.getRuntime(); try { io.getOpenFile().checkReadable(context.getRuntime()); } catch (PipeException pe) { throw runtime.newErrnoEPIPEError(); } catch (IOException ex) { throw runtime.newIOErrorFromException(ex); } catch (BadDescriptorException ex) { throw runtime.newErrnoEBADFError(); } catch (InvalidValueException e) { throw runtime.newErrnoEINVALError(); } return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getInStream());
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/java/addons/IOJavaAddons.java File path: /jruby-1.4.0/src/org/jruby/java/addons/IOJavaAddons.java
Method name: IRubyObject to_outputstream(ThreadContext, IRubyObject) Method name: IRubyObject to_inputstream(ThreadContext, IRubyObject)
Number of AST nodes: 5 Number of AST nodes: 5
1
RubyIO io = (RubyIO)self;
1
RubyIO io = (RubyIO)self;
2
        Ruby runtime = context.getRuntime();
2
        Ruby runtime = context.getRuntime();
3
        try {
3
        try {
4
            io.getOpenFile().checkWritable(context.getRuntime());
4
            io.getOpenFile().checkReadable(context.getRuntime());
5
        } catch (PipeException pe) {
5
        } catch (PipeException pe) {
6
            throw runtime.newErrnoEPIPEError();
6
            throw runtime.newErrnoEPIPEError();
7
        } catch (IOException ex) {
7
        } catch (IOException ex) {
8
            throw runtime.newIOErrorFromException(ex);
8
            throw runtime.newIOErrorFromException(ex);
9
        } catch (BadDescriptorException ex) {
9
        } catch (BadDescriptorException ex) {
10
            throw runtime.newErrnoEBADFError();
10
            throw runtime.newErrnoEBADFError();
11
        } catch (InvalidValueException e) {
11
        } catch (InvalidValueException e) {
12
            throw runtime.newErrnoEINVALError();
12
            throw runtime.newErrnoEINVALError();
13
        }
13
        }
14
        
14
        
15
        return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getOutStream());
15
        return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getInStream());
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.3
Clones locationClones are declared in the same class
Number of node comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    RubyIO io = (RubyIO)self;
    1
    RubyIO io = (RubyIO)self;
    2
    Ruby runtime = context.getRuntime();
    2
    Ruby runtime = context.getRuntime();
    3
    try
    3
    try
    4
    io.getOpenFile().checkWritable(context.getRuntime());
    4
    io.getOpenFile().checkWritable(context.getRuntime());
    4
    io.getOpenFile().checkReadable(context.getRuntime());
    Differences
    Expression1Expression2Difference
    checkWritablecheckReadableMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression io.getOpenFile().checkWritable(context.getRuntime()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression io.getOpenFile().checkReadable(context.getRuntime()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression io.getOpenFile().checkWritable(context.getRuntime()) is a void method call, and thus it cannot be parameterized
    Expression io.getOpenFile().checkReadable(context.getRuntime()) is a void method call, and thus it cannot be parameterized
    4
    io.getOpenFile().checkReadable(context.getRuntime());
    5
    return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getOutStream());
    5
    return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getOutStream());
    5
    return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getInStream());
    Differences
    Expression1Expression2Difference
    getOutStreamgetInStreamMETHOD_INVOCATION_NAME_MISMATCH
    java.io.OutputStreamjava.io.InputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression io.getOutStream() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression io.getInStream() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.io.OutputStream of variable io.getOutStream() does not match with type java.io.InputStream of variable io.getInStream()
    • Make classes java.io.OutputStream and java.io.InputStream extend a common superclass
    5
    return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), io.getInStream());
    Precondition Violations (7)
    Row Violation
    1Expression io.getOpenFile().checkWritable(context.getRuntime()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression io.getOpenFile().checkReadable(context.getRuntime()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression io.getOpenFile().checkWritable(context.getRuntime()) is a void method call, and thus it cannot be parameterized
    4Expression io.getOpenFile().checkReadable(context.getRuntime()) is a void method call, and thus it cannot be parameterized
    5Expression io.getOutStream() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression io.getInStream() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Type java.io.OutputStream of variable io.getOutStream() does not match with type java.io.InputStream of variable io.getInStream()