[Patch] java.net.InetAddress - partly merged

Michael Koch konqueror@gmx.de
Mon Oct 18 12:38:00 GMT 2004


Hi list,


I just commited the attached patch to megre java.net more with GNU
classpath again.


Michael


2004-10-18  Michael Koch  <konqueror@gmx.de>

	* java/net/Inet4Address.java: Merged file header and javadocs.
	* java/net/Inet6Address.java: Likewise.
	* java/net/InetAddress.java
	(getCanonicalHostName): Create Inet4Address object instead of
	InetAddress and add comment regarding IPv6.
	(toString): Simplified.

-------------- next part --------------
Index: java/net/Inet4Address.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Inet4Address.java,v
retrieving revision 1.9
diff -u -r1.9 Inet4Address.java
--- java/net/Inet4Address.java	9 Sep 2004 19:44:05 -0000	1.9
+++ java/net/Inet4Address.java	18 Oct 2004 12:35:57 -0000
@@ -1,5 +1,5 @@
-/* Inet4Address.java
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Inet4Address.java --
+   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,23 +35,20 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
 import java.io.ObjectStreamException;
 import java.util.Arrays;
 
-
-/**
- * @author Michael Koch
- * @date August 3, 2002.
- */
-
 /*
  * Written using on-line Java Platform 1.4 API Specification and
  * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt),
  * RFC 1918 (http://www.ietf.org/rfc/rfc1918.txt),
  * RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt)
- * Status: Believed complete and correct.
+ *
+ * @author Michael Koch
+ * @status Believed complete and correct.
  */
 public final class Inet4Address extends InetAddress
 {
@@ -67,12 +64,14 @@
   {
     return new InetAddress(addr, hostName);
   }
-
+  
   /**
-   * Creates a Inet4Address
+   * Initializes this object's addr instance variable from the passed in
+   * byte array.  Note that this constructor is protected and is called
+   * only by static methods in this class.
    *
-   * @param addr The IP address
-   * @param host The Hostname
+   * @param addr The IP number of this address as an array of bytes
+   * @param hostname The hostname of this IP address.
    */
   Inet4Address(byte[] addr, String host)
   {
Index: java/net/Inet6Address.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Inet6Address.java,v
retrieving revision 1.7
diff -u -r1.7 Inet6Address.java
--- java/net/Inet6Address.java	20 Apr 2004 13:05:09 -0000	1.7
+++ java/net/Inet6Address.java	18 Oct 2004 12:35:57 -0000
@@ -1,5 +1,5 @@
-/* Inet6Address.java
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Inet6Address.java --
+   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,20 +35,17 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
 import java.util.Arrays;
 
-
-/**
- * @author Michael Koch
- * @date August 3, 2002.
- */
-
 /*
  * Written using on-line Java Platform 1.4 API Specification and
  * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
- * Status: Believed complete and correct.
+ * 
+ * @author Michael Koch
+ * @status Believed complete and correct.
  */
 public final class Inet6Address extends InetAddress
 {
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.31
diff -u -r1.31 InetAddress.java
--- java/net/InetAddress.java	30 Sep 2004 15:22:08 -0000	1.31
+++ java/net/InetAddress.java	18 Oct 2004 12:35:57 -0000
@@ -313,7 +313,7 @@
       {
         try
 	  {
-            sm.checkConnect (hostName, -1);
+            sm.checkConnect(hostName, -1);
 	  }
 	catch (SecurityException e)
 	  {
@@ -322,7 +322,8 @@
       }
 
     // Try to find the FDQN now
-    InetAddress address = new InetAddress (getAddress(), null);
+    // FIXME: This does not work with IPv6.
+    InetAddress address = new Inet4Address(getAddress(), null);
     return address.getHostName();
   }
 
@@ -487,14 +488,8 @@
    */
   public String toString()
   {
-    String host;
     String address = getHostAddress();
-
-    if (hostName != null)
-      host = hostName;
-    else
-      host = address;
-
+    String host = (hostName != null) ? hostName : address;
     return host + "/" + address;
   }
 


More information about the Java-patches mailing list