This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[Patch] java.net and java.nio fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 20 Nov 2002 17:22:10 +0100
- Subject: [Patch] java.net and java.nio fixes
Hello list,
I commited the attached patch. Mainly it fixes
java.net.ServerSocket.bind() and add some documentation thingies.
Michael
--
Homepage: http://www.worldforge.org/
GPG-key: http://konqueror.dyndns.org/~mkoch/michael.gpg
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1548
diff -b -u -r1.1548 ChangeLog
--- ChangeLog 20 Nov 2002 15:19:17 -0000 1.1548
+++ ChangeLog 20 Nov 2002 16:17:56 -0000
@@ -1,3 +1,21 @@
+2002-11-20 Michael Koch <konqueror@gmx.de>
+
+ * java/io/FileInputStream.java
+ (getChannel): New method.
+ * java/io/FileOutputStream.java
+ (getChannel): New method.
+ * java/net/ServerSocket.java
+ (bind): Removed duplicate code and called another bind method instead.
+ * java/nio/channels/SelectionKey.java
+ (isValid): Removed wrong exception documentation.
+ * java/nio/channels/ServerSocketChannel.java
+ (accept): Added exception documentation.
+ (open): Fixed typo, added exception documentation.
+ * java/nio/channels/spi/AbstractSelectableChannel.java
+ (implCloseChannel): Added exception documentation.
+ (add): Reformated.
+ (register): Added exception documentation.
+
2002-11-20 Andreas Jaeger <aj@suse.de>
* configure: Regenerated with new libtool.m4.
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileInputStream.java,v
retrieving revision 1.7
diff -b -u -r1.7 FileInputStream.java
--- java/io/FileInputStream.java 25 Mar 2002 02:01:29 -0000 1.7
+++ java/io/FileInputStream.java 20 Nov 2002 16:17:57 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2001 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation
This file is part of libgcj.
@@ -8,6 +8,8 @@
package java.io;
+import java.nio.channels.FileChannel;
+
/**
* @author Warren Levy <warrenl@cygnus.com>
* @date October 28, 1998.
@@ -23,6 +25,8 @@
/* Contains the file descriptor for referencing the actual file. */
private FileDescriptor fd;
+ private FileChannel ch;
+
public FileInputStream(String name) throws FileNotFoundException
{
SecurityManager s = System.getSecurityManager();
@@ -91,5 +95,10 @@
long startPos = fd.getFilePointer();
long endPos = fd.seek(n, FileDescriptor.CUR, true);
return endPos - startPos;
+ }
+
+ public FileChannel getChannel ()
+ {
+ return ch;
}
}
Index: java/io/FileOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileOutputStream.java,v
retrieving revision 1.4
diff -b -u -r1.4 FileOutputStream.java
--- java/io/FileOutputStream.java 12 Jul 2001 15:37:43 -0000 1.4
+++ java/io/FileOutputStream.java 20 Nov 2002 16:17:57 -0000
@@ -10,6 +10,8 @@
package java.io;
+import java.nio.channels.FileChannel;
+
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date September 24, 1998
@@ -93,4 +95,9 @@
// Instance variables.
private FileDescriptor fd;
+
+ public FileChannel getChannel ()
+ {
+ return null;
+ }
}
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.17
diff -b -u -r1.17 ServerSocket.java
--- java/net/ServerSocket.java 18 Nov 2002 13:22:51 -0000 1.17
+++ java/net/ServerSocket.java 20 Nov 2002 16:17:57 -0000
@@ -151,6 +151,7 @@
throws IOException
{
this();
+
if (impl == null)
throw new IOException("Cannot initialize Socket implementation");
@@ -181,19 +182,7 @@
public void bind (SocketAddress endpoint)
throws IOException
{
- if (impl == null)
- throw new IOException ("Cannot initialize Socket implementation");
-
- if (! (endpoint instanceof InetSocketAddress))
- throw new IllegalArgumentException ("Address type not supported");
-
- InetSocketAddress tmp = (InetSocketAddress) endpoint;
-
- SecurityManager s = System.getSecurityManager ();
- if (s != null)
- s.checkListen (tmp.getPort ());
-
- impl.bind (tmp.getAddress (), tmp.getPort ());
+ bind (endpoint, 50);
}
/**
Index: java/nio/channels/SelectionKey.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/SelectionKey.java,v
retrieving revision 1.3
diff -b -u -r1.3 SelectionKey.java
--- java/nio/channels/SelectionKey.java 18 Nov 2002 14:31:39 -0000 1.3
+++ java/nio/channels/SelectionKey.java 20 Nov 2002 16:17:57 -0000
@@ -147,8 +147,6 @@
/**
* Tells whether or not this key is valid.
- *
- * @exception CancelledKeyException If this key has been cancelled
*/
public abstract boolean isValid ();
Index: java/nio/channels/ServerSocketChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ServerSocketChannel.java,v
retrieving revision 1.4
diff -b -u -r1.4 ServerSocketChannel.java
--- java/nio/channels/ServerSocketChannel.java 13 Nov 2002 12:21:25 -0000 1.4
+++ java/nio/channels/ServerSocketChannel.java 20 Nov 2002 16:17:57 -0000
@@ -61,6 +61,17 @@
/**
* Accepts a connection made to this channel's socket.
+ *
+ * @exception IOException If an error occurs
+ * @exception AsynchronousCloseException If another thread closes this
+ * channel while the accept operation is in progress.
+ * @exception ClosedByInterruptException If another thread interrupts the
+ * current thread while the accept operation is in progress, thereby closing
+ * the channel and setting the current thread's interrupt status.
+ * @exception ClosedChannelException If the channel is closed.
+ * @exception NotYetBoundException If the channel's socket is not yet bound.
+ * @exception SecurityException If a security manager has been installed and
+ * it does not permit access to the remote endpoint of the new connection.
*/
public abstract SocketChannel accept ();
@@ -70,7 +81,9 @@
public abstract ServerSocket socket ();
/**
- * Opens a server socker channel.
+ * Opens a server socket channel.
+ *
+ * @exception IOException If an error occurs
*/
public static ServerSocketChannel open () throws IOException
{
Index: java/nio/channels/spi/AbstractSelectableChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractSelectableChannel.java,v
retrieving revision 1.3
diff -b -u -r1.3 AbstractSelectableChannel.java
--- java/nio/channels/spi/AbstractSelectableChannel.java 13 Nov 2002 12:21:25 -0000 1.3
+++ java/nio/channels/spi/AbstractSelectableChannel.java 20 Nov 2002 16:17:58 -0000
@@ -87,6 +87,8 @@
/**
* Closes this channel.
+ *
+ * @exception IOException If an error occurs
*/
protected final void implCloseChannel ()
{
@@ -168,13 +170,17 @@
private void add (SelectionKey key)
{
if (keys == null)
+ {
keys = new LinkedList ();
+ }
keys.add (key);
}
/**
* Registers this channel with the given selector, returning a selection key.
+ *
+ * @exception ClosedChannelException If the channel is already closed.
*/
public final SelectionKey register (Selector selin, int ops, Object att)
throws ClosedChannelException