JDK-6512101 : NetworkInterface#getDisplayName() method returns wrong encoding for Japanese OS
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-01-11
  • Updated: 2013-06-26
  • Resolved: 2012-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b69Fixed
Description
FULL PRODUCT VERSION :
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode)

and

java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Japanese Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Intel(R) PRO/1000 MT Network Connection -  Packet Scheduler Miniport

A DESCRIPTION OF THE PROBLEM :
Under Japanese Windows environment, NetworkInterface#getDisplayName() method returns wrong encoded string of "Packet Scheduler Miniport" in Japanese. So, I can not read it.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run following class under Japanese Windows
//exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.
//act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
//exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.

ACTUAL -
The following wrong encoded characters ate displayed for the "Packet Scheduler Miniport" in Japanese.
//act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*
Run following class under Japanese Windows
//exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.
//act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g

*/
package displaynametest;
import java.net.*;
import java.util.Enumeration;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		try {
			NetworkInterface aninterface = null;
			for (Enumeration <NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
				aninterface = e.nextElement();
				String displayName = aninterface.getDisplayName();
				System.out.println( "//act: " + displayName);
				System.out.println( "//exp: " + new String(displayName.getBytes("ISO-8859-1"),"MS932"));
			}
		} catch (SocketException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Convert the return string like following in user application.
new String(aninterface.getDisplayName().getBytes("ISO-8859-1"),"MS932"))

Comments
Added 'noreg-hard' label. Requires Windows machine configured with network interfaces that contain Japanese (or other) characters.
11-12-2012