JDK-6782026 : Strange behaviour with locale sh_Cyrl_RS
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-12-08
  • Updated: 2011-02-16
  • Resolved: 2008-12-09
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
1.6.0

ADDITIONAL OS VERSION INFORMATION :
Windows XP and other

A DESCRIPTION OF THE PROBLEM :
Locale.getAvaillabelLocales has Locale sh_Cyrl_RS.
Creating a Locale with
new Locale("sh", "Cyrl", "RS") and calling toString() shows
sh_CYRL_RS

(country in uppercase letters);

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
for (int iLoop =0; iLoop < availlableLocales.length; iLoop++){
			Locale actLocale = availlableLocales[iLoop];
			assertEquals(actLocale, LocaleProvider.resolveLocale(actLocale.toString()));
		}

// class localeprovider, needed for difficulties with IBM-JDK
	private LocaleProvider() {
	}
	
	public static Locale resolveLocale(String language) {
		Locale resultLocale = null;
		if (language != null && language.length()>0 ) {
			int underScore = language.indexOf("_");
			if (underScore == -1) {
				resultLocale = new Locale (language.toLowerCase(),"");
			}
			else {
				String lang = language.substring(0, underScore);
				String country = language.substring(underScore+1);
				String variant = "";
				if ((underScore=country.indexOf('_')) > -1) {
					variant = country.substring(underScore+1);
					country = country.substring(0, underScore);
					
				}
				resultLocale = new Locale(lang, country, variant);
			}
			if (resultLocale==null) {
				resultLocale = Locale.ENGLISH;
			}
		}
		return resultLocale;
	}




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
sh_Cyrl_RS
ACTUAL -
sh_CYRL_RS

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
look above
---------- END SOURCE ----------

Comments
EVALUATION locale element CR, transfer to Jiri.
09-12-2008