+2003-10-02 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/net/InetSocketAddress.java
+ (InetSocketAddress): Made exception more clear.
+ (equals): Handle case when addr is null.
+ (toString): Likewise.
+ * java/net/NetworkInterface.java
+ (static): Load native library.
+ (getNetworkInterfaces): Rewritten.
+
2003-10-02 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (insets): New
throws IllegalArgumentException
{
if (port < 0 || port > 65535)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException ("Bad port number: " + port);
if (addr == null)
addr = InetAddress.ANY_IF;
public InetSocketAddress(String hostname, int port)
throws IllegalArgumentException
{
- if (port < 0 || port > 65535
- || hostname == null)
- throw new IllegalArgumentException();
+ if (hostname == null)
+ throw new IllegalArgumentException ("Null host name value");
+
+ if (port < 0 || port > 65535)
+ throw new IllegalArgumentException ("Bad port number: " + port);
this.port = port;
this.hostname = hostname;
if (obj instanceof InetSocketAddress)
{
- InetSocketAddress a = (InetSocketAddress) obj;
- return addr.equals(a.addr) && a.port == port;
+ InetSocketAddress sa = (InetSocketAddress) obj;
+
+ if (addr == null && sa.addr != null)
+ return false;
+ else if (addr == null && sa.addr == null)
+ return hostname.equals (sa.hostname) && sa.port == port;
+ else
+ return addr.equals (sa.addr) && sa.port == port;
}
return false;
*/
public String toString()
{
- return addr + ":" + port;
+ return (addr == null ? hostname : addr.getHostName()) + ":" + port;
}
}
package java.net;
+import gnu.classpath.Configuration;
import java.util.Enumeration;
import java.util.Vector;
*/
public final class NetworkInterface
{
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary ("javanet");
+ }
+ }
+
private String name;
private Vector inetAddresses;
public static Enumeration getNetworkInterfaces ()
throws SocketException
{
- Vector networkInterfaces = getRealNetworkInterfaces ();
-
- Enumeration tmp = networkInterfaces.elements ();
+ Vector networkInterfaces = getRealNetworkInterfaces();
- if (tmp.hasMoreElements ())
- return tmp;
+ if (networkInterfaces.isEmpty())
+ return null;
- return null;
+ return networkInterfaces.elements();
}
/**