super(runtime, runtime.getIO()); if (inputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = new OpenFile(); try { openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(inputStream), getNewFileno(), new FileDescriptor()))); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(OpenFile.READABLE); registerDescriptor(openFile.getMainStream().getDescriptor());
super(runtime, runtime.getIO()); // We only want IO objects with valid streams (better to error now). if (outputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = new OpenFile(); try { openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(outputStream), getNewFileno(), new FileDescriptor()))); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND); registerDescriptor(openFile.getMainStream().getDescriptor());
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyIO.java File path: /jruby-1.4.0/src/org/jruby/RubyIO.java
Method name: void RubyIO(Ruby, InputStream) Method name: void RubyIO(Ruby, OutputStream)
Number of AST nodes: 8 Number of AST nodes: 8
1
super(runtime, runtime.getIO());
1
super(runtime, runtime.getIO());
2
        
2
        
3
        if (in
3
        // We only want IO objects with valid streams (better to error now). 
4
putStream == null) {
4
        if (outputStream == null) {
5
            throw runtime.newRuntimeError("Opening null stream");
5
            throw runtime.newRuntimeError("Opening null stream");
6
        }
6
        }
7
        
7
        
8
        openFile = new OpenFile();
8
        openFile = new OpenFile();
9
        
9
        
10
        try {
10
        try {
11
            openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(inputStream), getNewFileno(), new FileDescriptor())));
11
            openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(outputStream), getNewFileno(), new FileDescriptor())));
12
        } catch (InvalidValueException e) {
12
        } catch (InvalidValueException e) {
13
            throw getRuntime().newErrnoEINVALError();
13
            throw getRuntime().newErrnoEINVALError();
14
        }
14
        }
15
        
15
        
16
        openFile.setMode(OpenFile.READABLE);
16
        openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
17
        
17
        
18
        registerDescriptor(openFile.getMainStream().getDescriptor());
18
        registerDescriptor(openFile.getMainStream().getDescriptor());
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 comparisons23
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    super(runtime, runtime.getIO());
    1
    super(runtime, runtime.getIO());
    2
    if (inputStream == null)
    2
    if (inputStream == null)
    2
    if (outputStream == null)
    Differences
    Expression1Expression2Difference
    inputStreamoutputStreamVARIABLE_NAME_MISMATCH
    java.io.InputStreamjava.io.OutputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.InputStream of variable inputStream does not match with type java.io.OutputStream of variable outputStream
    • Make classes java.io.InputStream and java.io.OutputStream extend a common superclass
    2
    if (outputStream == null)
    3
    throw runtime.newRuntimeError("Opening null stream");
    3
    throw runtime.newRuntimeError("Opening null stream");
    4
    openFile = new OpenFile();
    4
    openFile = new OpenFile();
    5
    try
    5
    try
    6
    openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(inputStream), getNewFileno(), new FileDescriptor())));
    6
    openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(inputStream), getNewFileno(), new FileDescriptor())));
    6
    openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(outputStream), getNewFileno(), new FileDescriptor())));
    Differences
    Expression1Expression2Difference
    java.nio.channels.ReadableByteChanneljava.nio.channels.WritableByteChannelVARIABLE_TYPE_MISMATCH
    inputStreamoutputStreamVARIABLE_NAME_MISMATCH
    java.io.InputStreamjava.io.OutputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.nio.channels.ReadableByteChannel of variable Channels.newChannel(inputStream) does not match with type java.nio.channels.WritableByteChannel of variable Channels.newChannel(outputStream)
    • Make classes java.nio.channels.ReadableByteChannel and java.nio.channels.WritableByteChannel extend a common superclass
    Type java.io.InputStream of variable inputStream does not match with type java.io.OutputStream of variable outputStream
    • Make classes java.io.InputStream and java.io.OutputStream extend a common superclass
    6
    openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(outputStream), getNewFileno(), new FileDescriptor())));
    7
    openFile.setMode(OpenFile.READABLE);
    7
    openFile.setMode(OpenFile.READABLE);
    7
    openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
    Differences
    Expression1Expression2Difference
    OpenFile.READABLEOpenFile.WRITABLE | OpenFile.APPENDTYPE_COMPATIBLE_REPLACEMENT
    7
    openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
    8
    registerDescriptor(openFile.getMainStream().getDescriptor());
    8
    registerDescriptor(openFile.getMainStream().getDescriptor());
    Precondition Violations (3)
    Row Violation
    1Type java.io.InputStream of variable inputStream does not match with type java.io.OutputStream of variable outputStream
    2Type java.nio.channels.ReadableByteChannel of variable Channels.newChannel(inputStream) does not match with type java.nio.channels.WritableByteChannel of variable Channels.newChannel(outputStream)
    3Type java.io.InputStream of variable inputStream does not match with type java.io.OutputStream of variable outputStream