[Patch] java.net.InetAddress

Michael Koch konqueror@gmx.de
Wed Nov 17 07:24:00 GMT 2004


Hi list,


I just commited the attached patch to fix IPv6 handling fo canonical
hostnames. I added some testcases to mauve for this too.


Michael


2004-11-17  Michael Koch  <konqueror@gmx.de>

	* java/net/InetAddress.java (getCanonicalHostName):
	Support IPv6 addresses.

-------------- next part --------------
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.33
diff -u -r1.33 InetAddress.java
--- java/net/InetAddress.java	16 Nov 2004 15:33:49 -0000	1.33
+++ java/net/InetAddress.java	17 Nov 2004 07:09:35 -0000
@@ -322,8 +322,14 @@
       }
 
     // Try to find the FDQN now
-    // FIXME: This does not work with IPv6.
-    InetAddress address = new Inet4Address(getAddress(), null);
+    InetAddress address;
+    byte[] ipaddr = getAddress();
+
+    if (ipaddr.length == 16)
+      address = new Inet6Address(getAddress(), null);
+    else
+      address = new Inet4Address(getAddress(), null);
+
     return address.getHostName();
   }
 


More information about the Java-patches mailing list