aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-02-18 07:26:20 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-02-18 07:26:20 +0000
commit69c107efe49360359ac10ab2172fafaf0a665deb (patch)
tree9d984f276c26345880ee577e8d68261a6c8ee2d3
parentc7adfa01929ceb5978fa6cfe768eec7a9b75a24b (diff)
downloadgcc-69c107efe49360359ac10ab2172fafaf0a665deb.zip
gcc-69c107efe49360359ac10ab2172fafaf0a665deb.tar.gz
gcc-69c107efe49360359ac10ab2172fafaf0a665deb.tar.bz2
2003-02-18 Michael Koch <konqueror@gmx.de>
* java/nio/channels/FileChannel.java (toString): New implementation, added documentation. (map): Added exception documentation. (size): Added exception documentation. (write): New methods, documentation work. (read): New methods, documentation work. (implCloseChannel): Rewrote exception documentation. (force): Throws IOException, added documentation. (lock): New methods. (tryLock): New methods. (position): New methods. (transferTo): New method. (transferFrom): New method. (truncate): New method. * java/nio/channels/spi/SelectorProvider.java (provider): Implemented. * Makefile.am (ordinary_java_source_files): Added the following files: gnu/java/nio/DatagramChannelImpl.java gnu/java/nio/FileChannelImpl.java gnu/java/nio/PipeImpl.java gnu/java/nio/SelectionKeyImpl.java gnu/java/nio/SelectorImpl.java gnu/java/nio/SelectorProviderImpl.java gnu/java/nio/ServerSocketChannelImpl.java gnu/java/nio/SocketChannelImpl.java java/nio/channels/FileLock.java (nat_java_source_files): Added the following files: gnu/java/nio/natFileChannelImpl.cc gnu/java/nio/natSelectorImpl.cc gnu/java/nio/natSocketChannelImpl.cc * Makefile.in: Regenerated. From-SVN: r63028
-rw-r--r--libjava/ChangeLog35
-rw-r--r--libjava/Makefile.am12
-rw-r--r--libjava/Makefile.in28
-rw-r--r--libjava/java/nio/channels/FileChannel.java243
-rw-r--r--libjava/java/nio/channels/spi/SelectorProvider.java8
5 files changed, 316 insertions, 10 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index a4e1719..db93486 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,38 @@
+2003-02-18 Michael Koch <konqueror@gmx.de>
+
+ * java/nio/channels/FileChannel.java
+ (toString): New implementation, added documentation.
+ (map): Added exception documentation.
+ (size): Added exception documentation.
+ (write): New methods, documentation work.
+ (read): New methods, documentation work.
+ (implCloseChannel): Rewrote exception documentation.
+ (force): Throws IOException, added documentation.
+ (lock): New methods.
+ (tryLock): New methods.
+ (position): New methods.
+ (transferTo): New method.
+ (transferFrom): New method.
+ (truncate): New method.
+ * java/nio/channels/spi/SelectorProvider.java
+ (provider): Implemented.
+ * Makefile.am
+ (ordinary_java_source_files): Added the following files:
+ gnu/java/nio/DatagramChannelImpl.java
+ gnu/java/nio/FileChannelImpl.java
+ gnu/java/nio/PipeImpl.java
+ gnu/java/nio/SelectionKeyImpl.java
+ gnu/java/nio/SelectorImpl.java
+ gnu/java/nio/SelectorProviderImpl.java
+ gnu/java/nio/ServerSocketChannelImpl.java
+ gnu/java/nio/SocketChannelImpl.java
+ java/nio/channels/FileLock.java
+ (nat_java_source_files): Added the following files:
+ gnu/java/nio/natFileChannelImpl.cc
+ gnu/java/nio/natSelectorImpl.cc
+ gnu/java/nio/natSocketChannelImpl.cc
+ * Makefile.in: Regenerated.
+
2003-02-17 Tom Tromey <tromey@redhat.com>
* java/awt/image/ColorModel.java: Re-merged with Classpath.
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index 7fe068d..c68042b 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -2064,11 +2064,19 @@ gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
gnu/java/nio/ByteBufferImpl.java \
gnu/java/nio/CharBufferImpl.java \
+gnu/java/nio/DatagramChannelImpl.java \
gnu/java/nio/DoubleBufferImpl.java \
+gnu/java/nio/FileChannelImpl.java \
gnu/java/nio/FloatBufferImpl.java \
gnu/java/nio/IntBufferImpl.java \
gnu/java/nio/LongBufferImpl.java \
+gnu/java/nio/PipeImpl.java \
+gnu/java/nio/SelectionKeyImpl.java \
+gnu/java/nio/SelectorImpl.java \
+gnu/java/nio/SelectorProviderImpl.java \
+gnu/java/nio/ServerSocketChannelImpl.java \
gnu/java/nio/ShortBufferImpl.java \
+gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/charset/ISO_8859_1.java \
gnu/java/nio/charset/Provider.java \
gnu/java/nio/charset/US_ASCII.java \
@@ -2196,6 +2204,7 @@ java/nio/channels/ClosedSelectorException.java \
java/nio/channels/ConnectionPendingException.java \
java/nio/channels/DatagramChannel.java \
java/nio/channels/FileChannel.java \
+java/nio/channels/FileLock.java \
java/nio/channels/FileLockInterruptionException.java \
java/nio/channels/GatheringByteChannel.java \
java/nio/channels/IllegalBlockingModeException.java \
@@ -2477,10 +2486,13 @@ gnu/gcj/runtime/natVMClassLoader.cc \
gnu/java/nio/natByteBufferImpl.cc \
gnu/java/nio/natCharBufferImpl.cc \
gnu/java/nio/natDoubleBufferImpl.cc \
+gnu/java/nio/natFileChannelImpl.cc \
gnu/java/nio/natFloatBufferImpl.cc \
gnu/java/nio/natIntBufferImpl.cc \
gnu/java/nio/natLongBufferImpl.cc \
+gnu/java/nio/natSelectorImpl.cc \
gnu/java/nio/natShortBufferImpl.cc \
+gnu/java/nio/natSocketChannelImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index b90de93..7b7b1b8 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -1824,11 +1824,19 @@ gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
gnu/java/nio/ByteBufferImpl.java \
gnu/java/nio/CharBufferImpl.java \
+gnu/java/nio/DatagramChannelImpl.java \
gnu/java/nio/DoubleBufferImpl.java \
+gnu/java/nio/FileChannelImpl.java \
gnu/java/nio/FloatBufferImpl.java \
gnu/java/nio/IntBufferImpl.java \
gnu/java/nio/LongBufferImpl.java \
+gnu/java/nio/PipeImpl.java \
+gnu/java/nio/SelectionKeyImpl.java \
+gnu/java/nio/SelectorImpl.java \
+gnu/java/nio/SelectorProviderImpl.java \
+gnu/java/nio/ServerSocketChannelImpl.java \
gnu/java/nio/ShortBufferImpl.java \
+gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/charset/ISO_8859_1.java \
gnu/java/nio/charset/Provider.java \
gnu/java/nio/charset/US_ASCII.java \
@@ -1956,6 +1964,7 @@ java/nio/channels/ClosedSelectorException.java \
java/nio/channels/ConnectionPendingException.java \
java/nio/channels/DatagramChannel.java \
java/nio/channels/FileChannel.java \
+java/nio/channels/FileLock.java \
java/nio/channels/FileLockInterruptionException.java \
java/nio/channels/GatheringByteChannel.java \
java/nio/channels/IllegalBlockingModeException.java \
@@ -2236,10 +2245,13 @@ gnu/gcj/runtime/natVMClassLoader.cc \
gnu/java/nio/natByteBufferImpl.cc \
gnu/java/nio/natCharBufferImpl.cc \
gnu/java/nio/natDoubleBufferImpl.cc \
+gnu/java/nio/natFileChannelImpl.cc \
gnu/java/nio/natFloatBufferImpl.cc \
gnu/java/nio/natIntBufferImpl.cc \
gnu/java/nio/natLongBufferImpl.cc \
+gnu/java/nio/natSelectorImpl.cc \
gnu/java/nio/natShortBufferImpl.cc \
+gnu/java/nio/natSocketChannelImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
@@ -2413,9 +2425,11 @@ gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \
gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \
gnu/gcj/runtime/natVMClassLoader.lo gnu/java/nio/natByteBufferImpl.lo \
gnu/java/nio/natCharBufferImpl.lo gnu/java/nio/natDoubleBufferImpl.lo \
+gnu/java/nio/natFileChannelImpl.lo \
gnu/java/nio/natFloatBufferImpl.lo gnu/java/nio/natIntBufferImpl.lo \
gnu/java/nio/natLongBufferImpl.lo \
-gnu/java/nio/natShortBufferImpl.lo \
+gnu/java/nio/natSelectorImpl.lo \
+gnu/java/nio/natShortBufferImpl.lo gnu/java/nio/natSocketChannelImpl.lo \
java/io/natFile.lo java/io/natFileDescriptor.lo \
java/io/natObjectInputStream.lo \
java/io/natObjectOutputStream.lo java/io/natVMObjectStreamClass.lo \
@@ -2877,10 +2891,16 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/locale/LocaleInformation_zh_TW.P \
.deps/gnu/java/math/MPN.P .deps/gnu/java/nio/ByteBufferImpl.P \
.deps/gnu/java/nio/CharBufferImpl.P \
+.deps/gnu/java/nio/DatagramChannelImpl.P \
.deps/gnu/java/nio/DoubleBufferImpl.P \
+.deps/gnu/java/nio/FileChannelImpl.P \
.deps/gnu/java/nio/FloatBufferImpl.P .deps/gnu/java/nio/IntBufferImpl.P \
-.deps/gnu/java/nio/LongBufferImpl.P \
+.deps/gnu/java/nio/LongBufferImpl.P .deps/gnu/java/nio/PipeImpl.P \
+.deps/gnu/java/nio/SelectionKeyImpl.P .deps/gnu/java/nio/SelectorImpl.P \
+.deps/gnu/java/nio/SelectorProviderImpl.P \
+.deps/gnu/java/nio/ServerSocketChannelImpl.P \
.deps/gnu/java/nio/ShortBufferImpl.P \
+.deps/gnu/java/nio/SocketChannelImpl.P \
.deps/gnu/java/nio/charset/ISO_8859_1.P \
.deps/gnu/java/nio/charset/Provider.P \
.deps/gnu/java/nio/charset/US_ASCII.P \
@@ -2893,10 +2913,13 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/nio/natByteBufferImpl.P \
.deps/gnu/java/nio/natCharBufferImpl.P \
.deps/gnu/java/nio/natDoubleBufferImpl.P \
+.deps/gnu/java/nio/natFileChannelImpl.P \
.deps/gnu/java/nio/natFloatBufferImpl.P \
.deps/gnu/java/nio/natIntBufferImpl.P \
.deps/gnu/java/nio/natLongBufferImpl.P \
+.deps/gnu/java/nio/natSelectorImpl.P \
.deps/gnu/java/nio/natShortBufferImpl.P \
+.deps/gnu/java/nio/natSocketChannelImpl.P \
.deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \
.deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \
.deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \
@@ -3397,6 +3420,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/nio/channels/ConnectionPendingException.P \
.deps/java/nio/channels/DatagramChannel.P \
.deps/java/nio/channels/FileChannel.P \
+.deps/java/nio/channels/FileLock.P \
.deps/java/nio/channels/FileLockInterruptionException.P \
.deps/java/nio/channels/GatheringByteChannel.P \
.deps/java/nio/channels/IllegalBlockingModeException.P \
diff --git a/libjava/java/nio/channels/FileChannel.java b/libjava/java/nio/channels/FileChannel.java
index 8970b98..3fa0f35 100644
--- a/libjava/java/nio/channels/FileChannel.java
+++ b/libjava/java/nio/channels/FileChannel.java
@@ -65,9 +65,17 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
m = a;
}
+ /**
+ * Returns a string representation of the <code>MapMode</code> object.
+ */
public String toString()
{
- return "" + m;
+ if (this == READ_ONLY)
+ return "READ_ONLY";
+ else if (this == READ_WRITE)
+ return "READ_WRITE";
+
+ return "PRIVATE";
}
}
@@ -81,20 +89,28 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
/**
* Maps the file into the memory.
*
- * @exception IOException If an error occurs.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If mode is READ_ONLY but this channel was
+ * not opened for reading.
+ * @exception NonWritableChannelException If mode is READ_WRITE or PRIVATE but this
+ * channel was not opened for writing.
*/
public abstract MappedByteBuffer map(MapMode mode, long position, long size)
throws IOException;
/**
* Return the size of the file thus far
+ *
+ * @exception ClosedChannelException If this channel is closed.
*/
public abstract long size() throws IOException;
/**
* Writes data to the channel.
*
- * @exception IOException If an error occurs.
+ * @exception IOException If an I/O error occurs.
*/
public long write (ByteBuffer[] srcs) throws IOException
{
@@ -110,26 +126,243 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
/**
* Writes data to the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract int write (ByteBuffer src) throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If position is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
+ */
+ public abstract int write (ByteBuffer srcs, long position) throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception IOException If an I/O error occurs.
*/
public abstract long write(ByteBuffer[] srcs, int offset, int length)
throws IOException;
/**
* Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException;
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
+ */
+ public final long read (ByteBuffer[] dsts) throws IOException
+ {
+ long result = 0;
+
+ for (int i = 0; i < dsts.length; i++)
+ {
+ read (dsts [i]);
+ }
+
+ return result;
+ }
+
+ /**
+ * Reads data from the channel.
+ *
+ * @exception IOException If an I/O error occurs.
*/
public abstract int read(ByteBuffer dst) throws IOException;
/**
+ * Reads data from the channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If position is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading.
+ */
+ public abstract int read(ByteBuffer dst, long position) throws IOException;
+
+ /**
* Closes the channel.
*
* This is called from @see close.
*
- * @exception IOException If an error occurs.
+ * @exception IOException If an I/O error occurs.
*/
protected abstract void implCloseChannel() throws IOException;
/**
* msync with the disk
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract void force(boolean metaData) throws IOException;
+
+ /**
+ * Creates a file lock for the whole assoziated file.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception FileLockInterruptionException If the invoking thread is
+ * interrupted while blocked in this method.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If shared is true and this channel
+ * was not opened for reading.
+ * @exception NonWritableChannelException If shared is false and this channel
+ * was not opened for writing.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public final FileLock lock () throws IOException
+ {
+ return lock (0, Long.MAX_VALUE, false);
+ }
+
+ /**
+ * Creates a file lock for a region of the assoziated file.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception FileLockInterruptionException If the invoking thread is
+ * interrupted while blocked in this method.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ * @exception NonReadableChannelException If shared is true and this channel
+ * was not opened for reading.
+ * @exception NonWritableChannelException If shared is false and this channel
+ * was not opened for writing.
+ */
+ public abstract FileLock lock (long position, long size, boolean shared)
+ throws IOException;
+
+ /**
+ * Tries to aqquire alock on the whole assoziated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public final FileLock tryLock () throws IOException
+ {
+ return tryLock (0, Long.MAX_VALUE, false);
+ }
+
+ /**
+ * Tries to aqquire a lock on a region of the assoziated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception OverlappingFileLockException If a lock that overlaps the
+ * requested region is already held by this Java virtual machine, or if
+ * another thread is already blocked in this method and is attempting to lock
+ * an overlapping region.
+ */
+ public abstract FileLock tryLock (long position, long size, boolean shared)
+ throws IOException;
+
+ /**
+ * Returns the current position on the file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract long position () throws IOException;
+
+ /**
+ * Sets the position of the channel on the assoziated file.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If newPosition is negative.
+ * @exception IOException If an I/O error occurs.
+ */
+ public abstract FileChannel position (long newPosition) throws IOException;
+
+ /**
+ * Transfers bytes from this channel's file to the given writable byte
+ * channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If this channel was not opened for
+ * reading.
+ * @exception NonWritableChannelException If the target channel was not
+ * opened for writing.
+ */
+ public abstract long transferTo (long position, long count,
+ WritableByteChannel target)
+ throws IOException;
+
+ /**
+ * Transfers bytes from the given readable channel into this channel.
+ *
+ * @exception AsynchronousCloseException If another thread closes this channel
+ * while the transfer is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the transfer is in progress, thereby closing both
+ * channels and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If the preconditions on the parameters
+ * do not hold.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonReadableChannelException If the source channel was not
+ * opened for reading.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
+ */
+ public abstract long transferFrom (ReadableByteChannel src, long position,
+ long count) throws IOException;
+
+ /**
+ * Truncates the channel's file at <code>size</code>.
+ *
+ * @exception ClosedChannelException If this channel is closed.
+ * @exception IllegalArgumentException If size is negative.
+ * @exception IOException If an I/O error occurs.
+ * @exception NonWritableChannelException If this channel was not opened for
+ * writing.
*/
- public abstract void force(boolean metaData);
+ public abstract FileChannel truncate (long size) throws IOException;
}
diff --git a/libjava/java/nio/channels/spi/SelectorProvider.java b/libjava/java/nio/channels/spi/SelectorProvider.java
index 157a341..1d4ccfa 100644
--- a/libjava/java/nio/channels/spi/SelectorProvider.java
+++ b/libjava/java/nio/channels/spi/SelectorProvider.java
@@ -37,7 +37,7 @@ exception statement from your version. */
package java.nio.channels.spi;
-/* import gnu.java.nio.channels.SelectorProviderImpl; */
+import gnu.java.nio.SelectorProviderImpl;
import java.io.IOException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
@@ -97,8 +97,10 @@ public abstract class SelectorProvider
*/
public static SelectorProvider provider ()
{
-/* if (pr == null) */
-/* pr = new SelectorProviderImpl (); */
+ if (pr == null)
+ {
+ pr = new SelectorProviderImpl ();
+ }
return pr;
}