Commit d1aa4795 by Guilhem Lavaux Committed by Michael Koch

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.

From-SVN: r72047
parent bca48dc6
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> 2003-10-02 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (insets): New * gnu/java/awt/peer/gtk/GtkComponentPeer.java (insets): New
......
...@@ -68,7 +68,7 @@ public class InetSocketAddress extends SocketAddress ...@@ -68,7 +68,7 @@ public class InetSocketAddress extends SocketAddress
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (port < 0 || port > 65535) if (port < 0 || port > 65535)
throw new IllegalArgumentException(); throw new IllegalArgumentException ("Bad port number: " + port);
if (addr == null) if (addr == null)
addr = InetAddress.ANY_IF; addr = InetAddress.ANY_IF;
...@@ -102,9 +102,11 @@ public class InetSocketAddress extends SocketAddress ...@@ -102,9 +102,11 @@ public class InetSocketAddress extends SocketAddress
public InetSocketAddress(String hostname, int port) public InetSocketAddress(String hostname, int port)
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (port < 0 || port > 65535 if (hostname == null)
|| hostname == null) throw new IllegalArgumentException ("Null host name value");
throw new IllegalArgumentException();
if (port < 0 || port > 65535)
throw new IllegalArgumentException ("Bad port number: " + port);
this.port = port; this.port = port;
this.hostname = hostname; this.hostname = hostname;
...@@ -130,8 +132,14 @@ public class InetSocketAddress extends SocketAddress ...@@ -130,8 +132,14 @@ public class InetSocketAddress extends SocketAddress
if (obj instanceof InetSocketAddress) if (obj instanceof InetSocketAddress)
{ {
InetSocketAddress a = (InetSocketAddress) obj; InetSocketAddress sa = (InetSocketAddress) obj;
return addr.equals(a.addr) && a.port == port;
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; return false;
...@@ -183,6 +191,6 @@ public class InetSocketAddress extends SocketAddress ...@@ -183,6 +191,6 @@ public class InetSocketAddress extends SocketAddress
*/ */
public String toString() public String toString()
{ {
return addr + ":" + port; return (addr == null ? hostname : addr.getHostName()) + ":" + port;
} }
} }
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
import gnu.classpath.Configuration;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;
...@@ -52,6 +53,14 @@ import java.util.Vector; ...@@ -52,6 +53,14 @@ import java.util.Vector;
*/ */
public final class NetworkInterface public final class NetworkInterface
{ {
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary ("javanet");
}
}
private String name; private String name;
private Vector inetAddresses; private Vector inetAddresses;
...@@ -185,14 +194,12 @@ public final class NetworkInterface ...@@ -185,14 +194,12 @@ public final class NetworkInterface
public static Enumeration getNetworkInterfaces () public static Enumeration getNetworkInterfaces ()
throws SocketException throws SocketException
{ {
Vector networkInterfaces = getRealNetworkInterfaces (); Vector networkInterfaces = getRealNetworkInterfaces();
Enumeration tmp = networkInterfaces.elements ();
if (tmp.hasMoreElements ())
return tmp;
if (networkInterfaces.isEmpty())
return null; return null;
return networkInterfaces.elements();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment