This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.net fixes


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,

I commited the attached patch to trunk to fix little things in 
java.net.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/fH0YWSOgCCdjSDsRAjG5AJ0fkjOz/+/GEh2u6YvzR9DdMrXdvQCghs4W
9GJZ2wYPUeS8u+4NpYbu0AQ=
=flBk
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2212
diff -u -b -B -r1.2212 ChangeLog
--- ChangeLog	2 Oct 2003 15:17:12 -0000	1.2212
+++ ChangeLog	2 Oct 2003 19:26:01 -0000
@@ -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  Michael Koch  <konqueror@gmx.de>
 
 	* java/net/InetAddress.java
Index: java/net/InetSocketAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetSocketAddress.java,v
retrieving revision 1.8
diff -u -b -B -r1.8 InetSocketAddress.java
--- java/net/InetSocketAddress.java	17 Jun 2003 19:11:56 -0000	1.8
+++ java/net/InetSocketAddress.java	2 Oct 2003 19:26:01 -0000
@@ -68,7 +68,7 @@
     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 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 @@
 
     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 String toString()
   {
-    return addr + ":" + port;
+    return (addr == null ? hostname : addr.getHostName()) + ":" + port;
   }
 }
Index: java/net/NetworkInterface.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/NetworkInterface.java,v
retrieving revision 1.7
diff -u -b -B -r1.7 NetworkInterface.java
--- java/net/NetworkInterface.java	26 May 2003 12:58:02 -0000	1.7
+++ java/net/NetworkInterface.java	2 Oct 2003 19:26:01 -0000
@@ -37,6 +37,7 @@
 
 package java.net;
 
+import gnu.classpath.Configuration;
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -52,6 +53,14 @@
  */
 public final class NetworkInterface
 {
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+	System.loadLibrary ("javanet");
+      }
+  }
+
   private String name;
   
   private Vector inetAddresses;
@@ -185,14 +194,12 @@
   public static Enumeration getNetworkInterfaces ()
     throws SocketException
   {
-    Vector networkInterfaces = getRealNetworkInterfaces ();
-
-    Enumeration tmp = networkInterfaces.elements ();
-
-    if (tmp.hasMoreElements ())
-      return tmp;
+    Vector networkInterfaces = getRealNetworkInterfaces();
 
+    if (networkInterfaces.isEmpty())
     return null;
+
+    return networkInterfaces.elements();
   }
 
   /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]