2003-10-02 Guilhem Lavaux <guilhem@kaffe.org>
authorGuilhem Lavaux <guilhem@kaffe.org>
Thu, 2 Oct 2003 19:29:31 +0000 (19:29 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Thu, 2 Oct 2003 19:29:31 +0000 (19:29 +0000)
* 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

libjava/ChangeLog
libjava/java/net/InetSocketAddress.java
libjava/java/net/NetworkInterface.java

index a5184f5a956ab784484a885f86421fed1cc902ec..ce16a0a2029ede583b9d1d0c4baafb6754227e36 100644 (file)
@@ -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
index c720fbcfe61875b943d51a6122add1cb15157e83..3f6eb09456bf0155a9602407c7e51770a701342b 100644 (file)
@@ -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;
   }
 }
index c3eb7108002a577211b18b6eab6ba31bc783cf3f..f6d37489836460624652f07cf263f0ca22c21370 100644 (file)
@@ -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 ();
-
-    Enumeration tmp = networkInterfaces.elements ();
+    Vector networkInterfaces = getRealNetworkInterfaces();
 
-    if (tmp.hasMoreElements ())
-      return tmp;
+    if (networkInterfaces.isEmpty())
+      return null;
 
-    return null;
+    return networkInterfaces.elements();
   }
 
   /**