[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath: Fixes for NIO Pipe implementation

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Sun Mar 21 12:06:02 2004


PatchSet 4550 
Date: 2004/03/21 19:41:32
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: Fixes for NIO Pipe implementation

2004-03-21  Dalibor Topic <robilad@kaffe.org>

        Resynced with GNU Classpath.

        2004-03-20  Michael Koch  <konqueror@gmx.de>

        * gnu/java/nio/PipeImpl.java
        (SourceChannelImpl): Made final.
        (read): Implemented.
        (SinkChannelImpl): Made final.
        (write): Implemented.

Members: 
	ChangeLog:1.2128->1.2129 
	libraries/javalib/gnu/java/nio/PipeImpl.java:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2128 kaffe/ChangeLog:1.2129
--- kaffe/ChangeLog:1.2128	Sun Mar 21 19:27:00 2004
+++ kaffe/ChangeLog	Sun Mar 21 19:41:32 2004
@@ -2,6 +2,18 @@
 
 	Resynced with GNU Classpath.
 
+	2004-03-20  Michael Koch  <konqueror@gmx.de>
+
+        * gnu/java/nio/PipeImpl.java
+        (SourceChannelImpl): Made final.
+        (read): Implemented.
+        (SinkChannelImpl): Made final.
+        (write): Implemented.
+
+2004-03-21  Dalibor Topic <robilad@kaffe.org>
+
+	Resynced with GNU Classpath.
+
 	2004-03-19  Michael Koch  <konqueror@gmx.de>
 
         * java/net/HttpURLConnection.java:
Index: kaffe/libraries/javalib/gnu/java/nio/PipeImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/PipeImpl.java:1.3 kaffe/libraries/javalib/gnu/java/nio/PipeImpl.java:1.4
--- kaffe/libraries/javalib/gnu/java/nio/PipeImpl.java:1.3	Thu Jan  8 17:04:20 2004
+++ kaffe/libraries/javalib/gnu/java/nio/PipeImpl.java	Sun Mar 21 19:41:34 2004
@@ -1,5 +1,5 @@
 /* PipeImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -44,7 +44,7 @@
 
 class PipeImpl extends Pipe
 {
-  public final class SourceChannelImpl extends Pipe.SourceChannel
+  public static final class SourceChannelImpl extends Pipe.SourceChannel
   {
     private int native_fd;
     
@@ -79,10 +79,22 @@
       return read (srcs, 0, srcs.length);
     }
 
-    public final long read (ByteBuffer[] srcs, int offset, int len)
+    public synchronized final long read (ByteBuffer[] srcs, int offset, int len)
       throws IOException
     {
-      throw new Error ("Not implemented");
+      if (offset < 0
+	  || offset > srcs.length
+	  || len < 0
+	  || len > srcs.length - offset)
+	throw new IndexOutOfBoundsException();
+
+      long bytesRead = 0;
+      
+      for (int index = 0; index < len; index++)
+	bytesRead += read (srcs [offset + index]);
+
+      return bytesRead;
+
     }
 
     public final int getNativeFD()
@@ -91,7 +103,7 @@
     }
   }
 
-  public final class SinkChannelImpl extends Pipe.SinkChannel
+  public static final class SinkChannelImpl extends Pipe.SinkChannel
   {
     private int native_fd;
     
@@ -120,16 +132,27 @@
       throw new Error ("Not implemented");
     }
 
-    public final long write (ByteBuffer[] dsts)
+    public final long write (ByteBuffer[] srcs)
       throws IOException
     {
-      return write (dsts, 0, dsts.length);
+      return write (srcs, 0, srcs.length);
     }
 
-    public final long write (ByteBuffer[] dsts, int offset, int len)
+    public synchronized final long write (ByteBuffer[] srcs, int offset, int len)
       throws IOException
     {
-      throw new Error ("Not implemented");
+      if (offset < 0
+	  || offset > srcs.length
+	  || len < 0
+	  || len > srcs.length - offset)
+	throw new IndexOutOfBoundsException();
+
+      long bytesWritten = 0;
+      
+      for (int index = 0; index < len; index++)
+	bytesWritten += write (srcs [offset + index]);
+
+      return bytesWritten;
     }
 
     public final int getNativeFD()