This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.nio.PipeImpl
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 11 Mar 2004 09:50:14 +0100
- Subject: FYI: Patch: gnu.java.nio.PipeImpl
Hi list,
I just commited the attached patch to improve gnu.java.nio.PipeImpl. Its
not working yet because of missing native stuff.
Michael
2004-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/PipeImpl.java
(SourceChannelImpl): Made final.
(read): Implemented.
(SinkChannelImpl): Made final.
(write): Implemented.
Index: gnu/java/nio/PipeImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/PipeImpl.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 PipeImpl.java
--- gnu/java/nio/PipeImpl.java 12 Oct 2003 13:39:07 -0000 1.2
+++ gnu/java/nio/PipeImpl.java 11 Mar 2004 08:48:39 -0000
@@ -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()