aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2002-08-21 18:54:07 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2002-08-21 18:54:07 +0000
commit35da8ccf6837638fc2f830a9a3086adc3c839842 (patch)
treec71c35641b332594b685388180f0a5230bfc5e16 /libjava
parent660df24919f1856d78d79440633d80dc8eb67dbe (diff)
* Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Added SocketAddress.java, InetSocketAddress.java. * java/net/PortUnreachableException.java: Merged with Classpath. * java/net/SocketTimeoutException.java: Likewise. * java/net/URISyntaxException.java: Likewise. * java/net/SocketAddress.java: New class from Classpath. * java/net/InetSocketAddress.java: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56494 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog11
-rw-r--r--libjava/Makefile.am2
-rw-r--r--libjava/Makefile.in12
-rw-r--r--libjava/java/net/InetSocketAddress.java128
-rw-r--r--libjava/java/net/PortUnreachableException.java22
-rw-r--r--libjava/java/net/SocketAddress.java54
-rw-r--r--libjava/java/net/SocketTimeoutException.java21
-rw-r--r--libjava/java/net/URISyntaxException.java108
8 files changed, 291 insertions, 67 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 3f1d5699457..2d8e5931f72 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,14 @@
+2002-08-21 Tom Tromey <tromey@redhat.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (ordinary_java_source_files): Added
+ SocketAddress.java, InetSocketAddress.java.
+ * java/net/PortUnreachableException.java: Merged with Classpath.
+ * java/net/SocketTimeoutException.java: Likewise.
+ * java/net/URISyntaxException.java: Likewise.
+ * java/net/SocketAddress.java: New class from Classpath.
+ * java/net/InetSocketAddress.java: Likewise.
+
2003-08-21 Michael Koch <konqueror@gmx.de>
* java/net/Authenticator.java: updated JDK 1.4
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index 15719b2b7d9..89fff76cbfb 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -1886,6 +1886,7 @@ java/net/DatagramSocketImpl.java \
java/net/FileNameMap.java \
java/net/HttpURLConnection.java \
java/net/InetAddress.java \
+java/net/InetSocketAddress.java \
java/net/JarURLConnection.java \
java/net/MalformedURLException.java \
java/net/MulticastSocket.java \
@@ -1898,6 +1899,7 @@ java/net/PortUnreachableException.java \
java/net/ProtocolException.java \
java/net/ServerSocket.java \
java/net/Socket.java \
+java/net/SocketAddress.java \
java/net/SocketException.java \
java/net/SocketImpl.java \
java/net/SocketImplFactory.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 7a8c7f42933..d165075518e 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -1648,6 +1648,7 @@ java/net/DatagramSocketImpl.java \
java/net/FileNameMap.java \
java/net/HttpURLConnection.java \
java/net/InetAddress.java \
+java/net/InetSocketAddress.java \
java/net/JarURLConnection.java \
java/net/MalformedURLException.java \
java/net/MulticastSocket.java \
@@ -1660,6 +1661,7 @@ java/net/PortUnreachableException.java \
java/net/ProtocolException.java \
java/net/ServerSocket.java \
java/net/Socket.java \
+java/net/SocketAddress.java \
java/net/SocketException.java \
java/net/SocketImpl.java \
java/net/SocketImplFactory.java \
@@ -2858,7 +2860,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/net/ContentHandlerFactory.P .deps/java/net/DatagramPacket.P \
.deps/java/net/DatagramSocket.P .deps/java/net/DatagramSocketImpl.P \
.deps/java/net/FileNameMap.P .deps/java/net/HttpURLConnection.P \
-.deps/java/net/InetAddress.P .deps/java/net/JarURLConnection.P \
+.deps/java/net/InetAddress.P .deps/java/net/InetSocketAddress.P \
+.deps/java/net/JarURLConnection.P \
.deps/java/net/MalformedURLException.P .deps/java/net/MulticastSocket.P \
.deps/java/net/NetPermission.P .deps/java/net/NoRouteToHostException.P \
.deps/java/net/PasswordAuthentication.P \
@@ -2866,9 +2869,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/net/PlainSocketImpl.P \
.deps/java/net/PortUnreachableException.P \
.deps/java/net/ProtocolException.P .deps/java/net/ServerSocket.P \
-.deps/java/net/Socket.P .deps/java/net/SocketException.P \
-.deps/java/net/SocketImpl.P .deps/java/net/SocketImplFactory.P \
-.deps/java/net/SocketOptions.P .deps/java/net/SocketPermission.P \
+.deps/java/net/Socket.P .deps/java/net/SocketAddress.P \
+.deps/java/net/SocketException.P .deps/java/net/SocketImpl.P \
+.deps/java/net/SocketImplFactory.P .deps/java/net/SocketOptions.P \
+.deps/java/net/SocketPermission.P \
.deps/java/net/SocketTimeoutException.P \
.deps/java/net/URISyntaxException.P .deps/java/net/URL.P \
.deps/java/net/URLClassLoader.P .deps/java/net/URLConnection.P \
diff --git a/libjava/java/net/InetSocketAddress.java b/libjava/java/net/InetSocketAddress.java
new file mode 100644
index 00000000000..c542b800225
--- /dev/null
+++ b/libjava/java/net/InetSocketAddress.java
@@ -0,0 +1,128 @@
+/* InetSocketAddress.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+/**
+ * InetSocketAddress instances represent socket addresses
+ * in the java.nio package. They encapsulate a InetAddress and
+ * a port number.
+ */
+
+public class InetSocketAddress extends SocketAddress
+{
+ InetAddress addr;
+ int port;
+
+ public InetSocketAddress(InetAddress addr, int port)
+ {
+ this.addr = addr;
+ this.port = port;
+ }
+
+ public InetSocketAddress(int port)
+ {
+ this.port = port;
+ try {
+ this.addr = InetAddress.getLocalHost();
+ } catch (Exception e) {
+ }
+ }
+
+
+ public InetSocketAddress(String hostname, int port)
+ {
+ this.port = port;
+ try {
+ this.addr = InetAddress.getByName(hostname);
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Test if obj is a InetSocketAddress and
+ * has the same address & port
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof InetSocketAddress)
+ {
+ InetSocketAddress a = (InetSocketAddress) obj;
+ return addr.equals(a.addr) && a.port == port;
+ }
+ return false;
+ }
+
+ public InetAddress getAddress()
+ {
+ return addr;
+ }
+
+ public String getHostName()
+ {
+ return addr.getHostName();
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * TODO: see what sun does here.
+ */
+ public int hashCode()
+ {
+ return port + addr.hashCode();
+ }
+
+ /**
+ * TODO: see what sun does here.
+ */
+ public boolean isUnresolved()
+ {
+ return addr == null;
+ }
+
+ /**
+ * TODO: see what sun does here.
+ */
+ public String toString()
+ {
+ return "SA:"+addr+":"+port;
+ }
+}
diff --git a/libjava/java/net/PortUnreachableException.java b/libjava/java/net/PortUnreachableException.java
index b31bcbcd6a3..b6abfe95a92 100644
--- a/libjava/java/net/PortUnreachableException.java
+++ b/libjava/java/net/PortUnreachableException.java
@@ -1,4 +1,4 @@
-/* PortUnreachableException.java
+/* PortUnreachableException.java -- received an ICMP port unreachable datagram
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,19 +37,22 @@ exception statement from your version. */
package java.net;
-import java.io.IOException;
-
/**
- * This exception indicates that a URL passed to an object was not in a
- * valid format.
+ * This exception signals that an ICMP port unreachable datagram has been
+ * received.
*
- * @author Michael Koch <konqueror@gmx.de>
+ * @author Eric Blake <ebb9@email.byu.edu>
* @since 1.4
- * @status should be completely JDK 1.4 compatible
+ * @status updated to 1.4
*/
-public class PortUnreachableException extends IOException
+public class PortUnreachableException extends SocketException
{
/**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = 8462541992376507323L;
+
+ /**
* Create a new instance without a descriptive error message.
*/
public PortUnreachableException()
@@ -66,3 +69,4 @@ public class PortUnreachableException extends IOException
super(message);
}
} // class PortUnreachableException
+
diff --git a/libjava/java/net/SocketAddress.java b/libjava/java/net/SocketAddress.java
new file mode 100644
index 00000000000..d37020b8e71
--- /dev/null
+++ b/libjava/java/net/SocketAddress.java
@@ -0,0 +1,54 @@
+/* SocketAddress.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.net;
+
+import java.io.*;
+
+/**
+ * Abstract base class for InetSocketAddress.
+ * InetSocketAddress is to my knowledge the only derived
+ * class. [Ronald]
+ */
+
+public abstract class SocketAddress implements Serializable
+{
+ public SocketAddress()
+ {
+ }
+}
+
diff --git a/libjava/java/net/SocketTimeoutException.java b/libjava/java/net/SocketTimeoutException.java
index 3c341b30ccb..e3895518d19 100644
--- a/libjava/java/net/SocketTimeoutException.java
+++ b/libjava/java/net/SocketTimeoutException.java
@@ -1,4 +1,4 @@
-/* SocketTimeoutException.java
+/* SocketTimeoutException.java -- the socket timed out
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,20 +37,23 @@ exception statement from your version. */
package java.net;
-import java.io.IOException;
+import java.io.InterruptedIOException;
/**
- * This exception indicates that a generic error occurred related to an
- * operation on a socket. Check the descriptive message (if any) for
- * details on the nature of this error
+ * This exception signals that a socket read or accept timed out.
*
- * @author Michael Koch <konqueror@gmx.de>
+ * @author Eric Blake <ebb9@email.byu.edu>
* @since 1.4
- * @status should be completele JDK 1.4 compatible
+ * @status updated to 1.4
*/
-public class SocketTimeoutException extends IOException
+public class SocketTimeoutException extends InterruptedIOException
{
/**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = -8846654841826352300L;
+
+ /**
* Create a new instance without a descriptive error message.
*/
public SocketTimeoutException()
diff --git a/libjava/java/net/URISyntaxException.java b/libjava/java/net/URISyntaxException.java
index 2ca799e11fc..cf725665e88 100644
--- a/libjava/java/net/URISyntaxException.java
+++ b/libjava/java/net/URISyntaxException.java
@@ -1,4 +1,4 @@
-/* URISyntaxException.java
+/* URISyntaxException.java -- a string could not be parsed as a URI
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -38,59 +38,70 @@ exception statement from your version. */
package java.net;
/**
- * This exception indicates that a generic error occurred related to an
- * operation on a socket. Check the descriptive message (if any) for
- * details on the nature of this error
+ * This exception is thrown when a String cannot be parsed as a URI.
*
- * @author Michael Koch <konqueror@gmx.de>
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see URI
* @since 1.4
- * @status Should be completely JDK 1.4 compatible
+ * @status updated to 1.4
*/
public class URISyntaxException extends Exception
{
- private String input;
- private String reason;
- private int index;
-
/**
- * @param input Input that cause the exception
- * @param reason Reason of the exception
- * @param index Position of the index or -1 if unknown
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = 2137979680897488891L;
+
+ /**
+ * The failed input.
*
- * @exception NullPointerException
- * @exception IllegalArgumentException
+ * @serial the bad URI
*/
- public URISyntaxException(String input, String reason, int index)
- {
- if (input == null || reason == null)
- throw new NullPointerException();
-
- if (index < -1)
- throw new IllegalArgumentException();
+ private final String input;
- this.input = input;
- this.reason = reason;
- this.index = index;
+ /**
+ * The index of failure.
+ *
+ * @serial the location of the problem
+ */
+ private final int index;
+
+ /**
+ * Create an exception from the invalid string, with the index set to -1.
+ *
+ * @param input the bad URI
+ * @param msg the descriptive error message
+ * @throws NullPointerException if input or msg are null
+ */
+ public URISyntaxException(String input, String msg)
+ {
+ this(input, msg, -1);
}
/**
- * @param input Input that cause the exception
- * @param reason Reason of the exception
+ * Create an exception from the invalid string, with the index of the
+ * point of failure.
*
- * @exception NullPointerException
+ * @param input the bad URI
+ * @param msg the descriptive error message
+ * @param index the index of the parse error, or -1
+ * @throws NullPointerException if input or msg are null
+ * @throws IllegalArgumentException if index &lt; -1
*/
- public URISyntaxException(String input, String reason)
+ public URISyntaxException(String input, String msg, int index)
{
- if (input == null || reason == null)
- throw new NullPointerException();
-
- this.input = input;
- this.reason = reason;
- this.index = -1;
+ // The toString() hack checks for null.
+ super(msg.toString());
+ this.input = input.toString();
+ this.index = index;
+ if (index < -1)
+ throw new IllegalArgumentException();
}
/**
- * @return Returns the input that caused this exception
+ * Returns the bad input string.
+ *
+ * @return the bad URI, guaranteed non-null
*/
public String getInput()
{
@@ -98,15 +109,19 @@ public class URISyntaxException extends Exception
}
/**
- * @return Returns the reason of this exception
+ * Returns the reason for the failure.
+ *
+ * @return the message, guaranteed non-null
*/
public String getReason()
{
- return reason;
+ return super.getMessage();
}
/**
- * @return Returns the index/position of this exception or -1 if unknown
+ * Returns the index of the failure, or -1.
+ *
+ * @return the index of failure
*/
public int getIndex()
{
@@ -114,12 +129,15 @@ public class URISyntaxException extends Exception
}
/**
- * This function returns an error message including input and reason.
- *
- * @return Returns a exception message
+ * Returns a message describing the parse error, as if by
+ * <code>getReason() + (getIndex() &gt;= 0 ? " at index " + getIndex() : "")
+ * + ": " + getInput()</code>.
+ *
+ * @return the message string
*/
public String getMessage()
{
- return input + ":" + reason;
+ return super.getMessage() + (index >= 0 ? " at index " + index : "")
+ + ": " + input;
}
-} // class URISyntaxException
+}