summaryrefslogtreecommitdiff
path: root/java/net
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-10-24 23:19:47 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-10-24 23:19:47 +0000
commitdecadab307d6855e39a5ffa27967fa9568954b91 (patch)
tree606c093d4c0fc1a1dc5a6144c5b94d6877d50ad3 /java/net
parent54df2ab823c74e470e2ece7c33d8a8f9f7ba6176 (diff)
downloadclasspath-decadab307d6855e39a5ffa27967fa9568954b91.tar.gz
2006-10-25 Robert Schuster <robertschuster@fsfe.org>
Fixes PR29576 * java/net/NetworkInterface.java: (createAnyInterface): New method. (equals): Added if-statement to handle case where netif.name is null. * vm/reference/java/net/VMNetworkInterface.java: (hashCode): Rewritten. (VMNetworkInterface): New constructor.
Diffstat (limited to 'java/net')
-rw-r--r--java/net/NetworkInterface.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/java/net/NetworkInterface.java b/java/net/NetworkInterface.java
index 1d5c409ed..1b52cf3cb 100644
--- a/java/net/NetworkInterface.java
+++ b/java/net/NetworkInterface.java
@@ -67,6 +67,16 @@ public final class NetworkInterface
this.netif = netif;
}
+ /** Creates an NetworkInterface instance which
+ * represents any interface in the system. Its only
+ * address is <code>0.0.0.0/0.0.0.0</code>. This
+ * method is needed by {@link MulticastSocket#getNetworkInterface}
+ */
+ static NetworkInterface createAnyInterface()
+ {
+ return new NetworkInterface(new VMNetworkInterface());
+ }
+
/**
* Returns the name of the network interface
*
@@ -206,6 +216,9 @@ public final class NetworkInterface
return false;
NetworkInterface tmp = (NetworkInterface) obj;
+
+ if (netif.name == null)
+ return tmp.netif.name == null;
return (netif.name.equals(tmp.netif.name)
&& (netif.addresses.equals(tmp.netif.addresses)));
@@ -219,7 +232,12 @@ public final class NetworkInterface
public int hashCode()
{
// FIXME: hash correctly
- return netif.name.hashCode() + netif.addresses.hashCode();
+ int hc = netif.addresses.hashCode();
+
+ if (netif.name != null)
+ hc += netif.name.hashCode();
+
+ return hc;
}
/**