JDK-4088617 : InetAddress.getLocalHost() not returning host-info
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.1.3
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-10-24
  • Updated: 1997-10-24
  • Resolved: 1997-10-24
Related Reports
Duplicate :  
Description

Name: rm29839			Date: 10/24/97


 From a send I posted to advanced-java mailing list:

Hello, 

I've done the background work on this and didnt find very much that
applied.  I have two machines both of which are Solaris 2.5.1 machines. 
Specific architecture is as follows:
  SunOS pandora 5.5.1 Genric_103640-08 sun4u SUNW,Ultra-Enterprise

One of these machines is dual-homed with two lance interfaces.
The other machine is single homed with a fiber interface.

Lastly, I speculate they are both using some form of DHCP boot.

InetAddress.getLocalHost() under JDK 1.1.3 is returning the address for
localhost/127.0.0.1.  This is what is returned by
java.net.InetAddressImpl as provided.  One of the threads I read
indicated that this information was gathered from sysinfo, however
initial tests do not seem to confirm that.  This simple application
returned the name pandora.

  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/systeminfo.h>

  void main() {
    char host[512] ;
    sysinfo( SI_HOSTNAME, host, sizeof(host) ) ;
    printf( "%s\n", host ) ;
  }

Is anyone familiar enough with the workings of InetAddressImpl on
Solaris to tell me what might be causing this to occur.

-- Additionally, source code which causes the failure

import java.net.* ;

public class test {
  public static void main( String[] args ) throws Exception {
    InetAddress addr = InetAddress.getLocalHost() ;
    System.out.println( addr.toString() ) ;
    System.out.println( addr.getHostName() ) ;
    System.out.println( addr.getHostAddress() ) ;
  }
}

-- Results

localhost/127.0.0.1
localhost
127.0.0.1

-- Further information, output from ifconfig

ifconfig -a

lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232
	inet 127.0.0.1 netmask ff000000 
fddi0: flags=1863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST,MULTI_BCAST> mtu 4352
	inet 172.16.64.45 netmask ffffff00 broadcast 172.16.64.255
	ether 0:40:b:40:e9:7f
======================================================================

Comments
WORK AROUND Name: rm29839 Date: 10/24/97 ======================================================================
11-06-2004

EVALUATION This is likely due to the fact that we're currently using gethostname and not sysinfo (as correctly guessed in the bug description). This is a known bug and will be fixed in 1.2. I am closing it as a duplicate. benjamin.renaud@Eng 1997-10-24
24-10-1997