JDK-7029868 : Extending ListResourceBundle has no effect
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-03-22
  • Updated: 2012-03-20
  • Resolved: 2011-05-16
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"

A DESCRIPTION OF THE PROBLEM :
With Java 6 it isn't possible anymore to override ListResourceBundle for other locale definitions.
Overriding classes are never called, so overriding has no effect anymore.
Same behaviour for every language/country.
With Java4 it worked fine.

REGRESSION.  Last worked in version 6

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Implement new class:
package sun.text.resources;

import java.util.ListResourceBundle;

public class LocaleElements_cs_EU extends ListResourceBundle
{
  public LocaleElements_cs_EU()
  {
  }

  public Object[][] getContents()
  {
    return (new Object[][]{new Object[]{"DateTimeElements", new String[]{"2", "4"}}});
  }
}

And start program/server with
"-Duser.language=cs
-Duser.country=EU"

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The new defintion for DateTimeElements should be used if the server settings are
"-Duser.language=cs
-Duser.country=EU"



ACTUAL -
Class was never called.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message and nothing called.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class LocaleElements_cs_EUTest extends FdBaseTestCase
{
  public void testLocaleElements_cs_EU()
  {
    Calendar cal_cs = Calendar.getInstance(new Locale("cs"));
    Calendar cal_cs_EU = Calendar.getInstance(new Locale("cs", "EU"));
    int kalenderWoche1;
    int kalenderWoche2;

      cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(2004, 12, 27).getTime());
    kalenderWoche1 = cal_cs_EU.get(Calendar.WEEK_OF_YEAR);
    cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(2004, 12, 26).getTime());
    kalenderWoche2 = cal_cs_EU.get(Calendar.WEEK_OF_YEAR);
    assertTrue("Wrong", kalenderWoche1 == kalenderWoche2 + 1);

    cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(1995, 1, 1).getTime());
    cal_cs.setTimeInMillis(FdDateSupport.getDate(1995, 1, 1).getTime());
    assertTrue("Wrong", cal_cs_EU.get(Calendar.WEEK_OF_YEAR) == 52);

    cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(2005, 1, 1).getTime());
    assertTrue("Wrong", cal_cs_EU.get(Calendar.WEEK_OF_YEAR) == 53);
    
    cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(1999, 1, 1).getTime());
    assertTrue("Wrong", cal_cs_EU.get(Calendar.WEEK_OF_YEAR) == 53);

    cal_cs_EU.setTimeInMillis(FdDateSupport.getDate(2004, 1, 1).getTime());
    assertTrue("Wrong", cal_cs_EU.get(Calendar.WEEK_OF_YEAR) == 1);
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No workaround yet.

Comments
EVALUATION Localization resources files were refactored in JDK 6. Refer to 5013088.
16-05-2011