JDK-7079486 : Locale.getDisplayScript() (no args) does not honor default DISPLAY locale
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-08-15
  • Updated: 2011-09-07
  • Resolved: 2011-09-07
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 8
8 b04Fixed
Related Reports
Relates :  
Relates :  
Description
The code snippet below illustrates the issue.

Locale loc = Locale.forLanguageTag("zh-Hans-CN");

// Set default locale to en-US
Locale.setDefault(Locale.US);

System.out.println("Default Locale: en-US");
System.out.println(" langauge: " + loc.getDisplayLanguage());
System.out.println(" script: " + loc.getDisplayScript());

// Set DISPLAY locale to zh-Hans-CN
Locale.setDefault(Category.DISPLAY, loc);

System.out.println("Default DISPLAY Locale: zh-Hans-CN");
System.out.println(" langauge: " + loc.getDisplayLanguage());
System.out.println(" script: " + loc.getDisplayScript());

// Set default locale to zh-Hans-CN
Locale.setDefault(loc);

System.out.println("Default Locale: zh-Hans-CN");
System.out.println(" langauge: " + loc.getDisplayLanguage());
System.out.println(" script: " + loc.getDisplayScript());

This code prints out -

Default Locale: en-US
langauge: Chinese
script: Simplified Han
Default DISPLAY Locale: zh-Hans-CN
langauge: ����
script: Simplified Han
Default Locale: zh-Hans-CN
langauge: ����
script: ��������

Comments
EVALUATION Apparently, the Locale Enhancement fix which introduced Locale.getDisplayScript() and Locale.Category feature which introduced the DISPLAY locale got mixed. The locale used for getDisplayScript() should get the DISPLAY locale for it.
15-08-2011