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
This commit is contained in:
parent
bca48dc625
commit
d1aa479583
@ -1,3 +1,13 @@
|
||||
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
|
||||
|
@ -68,7 +68,7 @@ public class InetSocketAddress extends SocketAddress
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (port < 0 || port > 65535)
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException ("Bad port number: " + port);
|
||||
|
||||
if (addr == null)
|
||||
addr = InetAddress.ANY_IF;
|
||||
@ -102,9 +102,11 @@ public class InetSocketAddress extends SocketAddress
|
||||
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;
|
||||
@ -130,8 +132,14 @@ public class InetSocketAddress extends SocketAddress
|
||||
|
||||
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;
|
||||
@ -183,6 +191,6 @@ public class InetSocketAddress extends SocketAddress
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return addr + ":" + port;
|
||||
return (addr == null ? hostname : addr.getHostName()) + ":" + port;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ exception statement from your version. */
|
||||
|
||||
package java.net;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
@ -52,6 +53,14 @@ import java.util.Vector;
|
||||
*/
|
||||
public final class NetworkInterface
|
||||
{
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary ("javanet");
|
||||
}
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
private Vector inetAddresses;
|
||||
@ -185,14 +194,12 @@ public final class NetworkInterface
|
||||
public static Enumeration getNetworkInterfaces ()
|
||||
throws SocketException
|
||||
{
|
||||
Vector networkInterfaces = getRealNetworkInterfaces ();
|
||||
Vector networkInterfaces = getRealNetworkInterfaces();
|
||||
|
||||
Enumeration tmp = networkInterfaces.elements ();
|
||||
if (networkInterfaces.isEmpty())
|
||||
return null;
|
||||
|
||||
if (tmp.hasMoreElements ())
|
||||
return tmp;
|
||||
|
||||
return null;
|
||||
return networkInterfaces.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user