I'm checking this in.

I've had this patch in my tree for a while.
I believe it fixes PR 29256.

Tom

2006-12-15  Tom Tromey  <[EMAIL PROTECTED]>

        PR classpath/29526:
        * gnu/java/nio/ChannelInputStream.java (read): New overload.
        (read): Mask return result.

Index: gnu/java/nio/ChannelInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/ChannelInputStream.java,v
retrieving revision 1.3
diff -u -r1.3 ChannelInputStream.java
--- gnu/java/nio/ChannelInputStream.java        2 Jul 2005 20:32:13 -0000       
1.3
+++ gnu/java/nio/ChannelInputStream.java        15 Dec 2006 19:03:53 -0000
@@ -59,6 +59,16 @@
     this.ch = ch;
   }
 
+  public int read(byte[] buf, int off, int len) throws IOException
+  {
+    if (ch instanceof SelectableChannel
+        && (! ((SelectableChannel) ch).isBlocking()))
+      throw new IllegalBlockingModeException();
+
+    ByteBuffer b = ByteBuffer.wrap(buf, off, len);
+    return ch.read(b);
+  }
+
   public int read() throws IOException
   {
     if (ch instanceof SelectableChannel
@@ -74,6 +84,6 @@
     if (result == 0)
       throw new IOException("Could not read from channel");
 
-     return buffer.get(0);
+    return buffer.get(0) & 0xff;
   }
 }

Reply via email to