This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: FYI: Patch: java.net: socket stuff
On Wed, Nov 26, 2003 at 07:57:27AM -0600, Mohan Embar wrote:
>
> I ran a few tests with this on the i686-pc-linux-gnu native compiler.
> Just let me know and I'll commit it....
I have finished my work on java.net.Socket and java.net.ServerSocket.
The other socket classes will be finished tomorrow.
> + /**
> + * SocketException text which is used in several places.
> + */
> + private static final String SOCKET_CLOSED = "socket is closed";
Please add a constant before all other stuff in the class (like class
variables).
> /**
> @@ -342,5 +347,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> // XXX: JDK 1.4.1 API documentation says that if bindpoint is null the
> @@ -416,5 +421,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (! (endpoint instanceof InetSocketAddress))
> @@ -612,5 +617,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (!isConnected())
> @@ -630,5 +635,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (!isConnected())
> @@ -650,5 +655,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().setOption(SocketOptions.TCP_NODELAY, new Boolean(on));
> @@ -670,5 +675,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object on = getImpl().getOption(SocketOptions.TCP_NODELAY);
> @@ -700,5 +705,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (on == true)
> @@ -737,5 +742,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object linger = getImpl().getOption(SocketOptions.SO_LINGER);
> @@ -760,5 +765,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().sendUrgentData (data);
> @@ -777,5 +782,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().setOption(SocketOptions.SO_OOBINLINE, new Boolean(on));
> @@ -794,5 +799,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object buf = getImpl().getOption(SocketOptions.SO_OOBINLINE);
> @@ -824,5 +829,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (timeout < 0)
> @@ -852,5 +857,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object timeout = getImpl().getOption(SocketOptions.SO_TIMEOUT);
> @@ -876,5 +881,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (size <= 0)
> @@ -898,5 +903,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF);
> @@ -923,5 +928,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (size <= 0)
> @@ -945,5 +950,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF);
> @@ -968,5 +973,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().setOption(SocketOptions.SO_KEEPALIVE, new Boolean(on));
> @@ -986,5 +991,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object buf = getImpl().getOption(SocketOptions.SO_KEEPALIVE);
> @@ -1004,5 +1009,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().close();
> @@ -1079,5 +1084,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().shutdownInput();
> @@ -1095,5 +1100,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> getImpl().shutdownOutput();
> @@ -1125,5 +1130,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object reuseaddr = getImpl().getOption (SocketOptions.SO_REUSEADDR);
> @@ -1163,5 +1168,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> Object obj = getImpl().getOption(SocketOptions.IP_TOS);
> @@ -1188,5 +1193,5 @@
> {
> if (isClosed())
> - throw new SocketException("socket is closed");
> + throw new SocketException(SOCKET_CLOSED);
>
> if (tc < 0 || tc > 255)
Sigh, okay.
Note that java.net.ServerSocket, java.net.DatagramSocket and
java.net.MulticastSocket have this exceptions too.
Michael