Index: java/net/InetAddress.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v retrieving revision 1.30 diff -u -r1.30 InetAddress.java --- java/net/InetAddress.java 13 Aug 2004 22:17:34 -0000 1.30 +++ java/net/InetAddress.java 30 Sep 2004 15:21:13 -0000 @@ -35,9 +35,11 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ + package java.net; import gnu.classpath.Configuration; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -49,12 +51,12 @@ * constructor. Instead, new instances of this objects are created * using the static methods getLocalHost(), getByName(), and * getAllByName(). - *

- * This class fulfills the function of the C style functions gethostname(), + * + *

This class fulfills the function of the C style functions gethostname(), * gethostbyname(), and gethostbyaddr(). It resolves Internet DNS names - * into their corresponding numeric addresses and vice versa. + * into their corresponding numeric addresses and vice versa.

* - * @author Aaron M. Renn + * @author Aaron M. Renn (arenn@urbanophile.com) * @author Per Bothner * * @specnote This class is not final since JK 1.4 @@ -71,7 +73,7 @@ private static final byte[] loopbackAddress = { 127, 0, 0, 1 }; private static final InetAddress loopback - = new InetAddress (loopbackAddress, "localhost"); + = new Inet4Address(loopbackAddress, "localhost"); private static InetAddress localhost = null; @@ -79,12 +81,10 @@ { // load the shared library needed for name resolution if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary ("javanet"); - } + System.loadLibrary("javanet"); byte[] zeros = { 0, 0, 0, 0 }; - ANY_IF = new InetAddress (zeros, "0.0.0.0"); + ANY_IF = new Inet4Address(zeros, "0.0.0.0"); } /** @@ -119,27 +119,15 @@ * only by static methods in this class. * * @param ipaddr The IP number of this address as an array of bytes - */ - InetAddress(byte[] address) - { - this (address, null); - } - - /** - * Initializes this object's addr instance variable from the passed in - * int array. Note that this constructor is protected and is called - * only by static methods in this class. - * - * @param ipaddr The IP number of this address as an array of bytes * @param hostname The hostname of this IP address. */ - InetAddress(byte[] address, String hostname) + InetAddress(byte[] ipaddr, String hostname) { - addr = address; + addr = ipaddr; hostName = hostname; - if (address != null) - family = getFamily (address); + if (ipaddr != null) + family = getFamily(ipaddr); } /** @@ -304,9 +292,12 @@ */ public String getHostName() { - if (hostName == null) - lookup (null, this, false); + if (hostName != null) + return hostName; + // Lookup hostname and set field. + lookup (null, this, false); + return hostName; } @@ -422,13 +413,13 @@ for ( ; ; ) { - sb.append (addr [i] & 0xff); - i++; + sb.append(addr[i] & 0xff); + i++; - if (i == len) - break; + if (i == len) + break; - sb.append ('.'); + sb.append('.'); } return sb.toString();