FULL PRODUCT VERSION : c:>java -version java version "1.6.0_03" Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : c:> ver Microsoft Windows [������ 5.2.3790] A DESCRIPTION OF THE PROBLEM : the InetAddress.getLocalHost() works fine in jre 1.5.0_03, but fails to fetch chinese local host name in jre 1.6.0_03. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : assume the host name is "��������_��������", which have to be a chinese presenting, and the running os is Windows 2003 Standard Edition with SP2 EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - with jre 1.5.0_03, it print like: host : ��������_�������� -42 -48 -50 -60 95 -78 -30 -54 -44 it corretly presents my host name ACTUAL - with jre 1.6.0_03 , it prints like: host : ????_??? 63 63 63 63 95 63 63 63 REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- try { InetAddress localHost = InetAddress.getLocalHost(); String hostName = localHost.getHostName(); System.out.println("host\t: " + hostName); byte[] bytes = hostName.getBytes(); for(byte b : bytes){ System.out.print(b + " "); } System.out.println(); } catch (Exception ex) { ex.printStackTrace(System.out); } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : I am going to use this localhost name to get all local IP addr later, but with "????", it is sure to throw java.net.UnknownHostException. downgrade jre environment to 1.5. Release Regression From : 5.0u3 The above release value was the last known release where this bug was not reproducible. Since then there has been a regression.
|