Bug 30109 - InetAddress.getHostName() does not resolve host names
Summary: InetAddress.getHostName() does not resolve host names
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-07 13:33 UTC by Renaud Saint-Gratien
Modified: 2016-10-03 22:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test case (206 bytes, text/plain)
2006-12-07 13:34 UTC, Renaud Saint-Gratien
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Renaud Saint-Gratien 2006-12-07 13:33:02 UTC
InetAddress.getHostName() does not resolve host names, which differs from the
Sun's JDK behaviour.  Consider the following test case:

import java.net.InetAddress;
public class Test {
    public static void main(String[] argv) throws Exception {
        String resolved = InetAddress.getByName("127.0.0.1").getHostName();
        System.out.println("127.0.0.1 hostname: expected=localhost, actual=" + resolved);
    }
}

With Sun's JDK:

$ java -version
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
$ javac Test.java
$ java -cp . Test
127.0.0.1 hostname: expected=localhost, actual=localhost

With GCJ 4.2 (snapshot of 20061128):

$ gcj -v
Using built-in specs.
Reading specs from /opt/gcc-4.2/lib/gcc/sparc-sun-solaris2.8/4.2.0/../../../libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
Target: sparc-sun-solaris2.8
Configured with: ../gcc-4.2-20061128/configure --prefix=/opt/gcc-4.2 --disable-nls
Thread model: posix
gcc version 4.2.0 20061128 (prerelease)
$ gcj -L/opt/gcc-4.2/lib -lstdc++ -L/usr/local/lib -o Test --main=Test Test.class
$ ./Test
127.0.0.1 hostname: expected=localhost, actual=127.0.0.1

Same results with gcj 4.0.2.
Comment 1 Renaud Saint-Gratien 2006-12-07 13:34:48 UTC
Created attachment 12765 [details]
Test case
Comment 2 Andrew Pinski 2016-09-30 22:51:40 UTC
Closing as won't fix as libgcj (and the java front-end) has been removed from the trunk.
Comment 3 Andrew John Hughes 2016-10-03 22:11:27 UTC
Seems to have been fixed:

$ java PR30109
127.0.0.1 hostname: expected=localhost, actual=localhost.localdomain
$ cacao PR30109
127.0.0.1 hostname: expected=localhost, actual=localhost.localdomain
$ gij PR30109
127.0.0.1 hostname: expected=localhost, actual=localhost.localdomain