Index: D:/Eclipse3.2/workspace/luni/src/main/java/java/net/InetAddress.java =================================================================== --- D:/Eclipse3.2/workspace/luni/src/main/java/java/net/InetAddress.java (revision 376167) +++ D:/Eclipse3.2/workspace/luni/src/main/java/java/net/InetAddress.java (working copy) @@ -42,9 +42,11 @@ final static byte[] localhost_bytes = { 127, 0, 0, 1 }; static InetAddress ANY = new Inet4Address(any_bytes); + + private static final String LOCALHOSTNAME = "localhost"; final static InetAddress LOOPBACK = new Inet4Address(localhost_bytes, - "localhost"); + LOCALHOSTNAME); private static final long serialVersionUID = 3286316764910316507L; @@ -276,7 +278,7 @@ } } hostName = getHostByAddrImpl(ipaddress).hostName; - if (hostName.equals("localhost") && ipaddress.length == 4 + if (hostName.equals(LOCALHOSTNAME) && ipaddress.length == 4 && address != 0x7f000001) { return hostName = inetNtoaImpl(address); } @@ -291,6 +293,9 @@ if (security != null && isHostName(hostName)) security.checkConnect(hostName, -1); } catch (SecurityException e) { + if(this == LOOPBACK){ + return LOCALHOSTNAME; + } return Inet6Util.createIPAddrStringFromByteArray(ipaddress); } return hostName;