* Package-private array that ChineseDateFormat needs to be able to
* read.
*/
- String isLeapMonth[]; // Do NOT add =null initializer
+ String[] isLeapMonth;
/**
* Construct a ChineseDateFormatSymbols for the default <code>FORMAT</code> locale.
*/
protected void initializeData(ULocale loc, CalendarData calData) {
super.initializeData(loc, calData);
- // The old way, obsolete:
- //isLeapMonth = calData.getStringArray("isLeapMonth");
- // The new way to fake this for backward compatibility (no longer used to format/parse):
- isLeapMonth = new String[2];
- isLeapMonth[0] = "";
- isLeapMonth[1] = (leapMonthPatterns != null)? leapMonthPatterns[DT_LEAP_MONTH_PATTERN_FORMAT_WIDE].replace("{0}", ""): "";
+ initializeIsLeapMonth();
}
void initializeData(DateFormatSymbols dfs) {
super.initializeData(dfs);
if (dfs instanceof ChineseDateFormatSymbols) {
+ // read-only array, no need to clone
this.isLeapMonth = ((ChineseDateFormatSymbols)dfs).isLeapMonth;
+ } else {
+ initializeIsLeapMonth();
}
}
+
+ private void initializeIsLeapMonth() {
+ // The old way, obsolete:
+ //isLeapMonth = calData.getStringArray("isLeapMonth");
+ // The new way to fake this for backward compatibility (no longer used to format/parse):
+
+ isLeapMonth = new String[2];
+ isLeapMonth[0] = "";
+ isLeapMonth[1] = (leapMonthPatterns != null)? leapMonthPatterns[DT_LEAP_MONTH_PATTERN_FORMAT_WIDE].replace("{0}", ""): "";
+ }
}
// Initialize data from scratch put a clone of this instance into the cache
CalendarData calData = new CalendarData(desiredLocale, type);
initializeData(desiredLocale, calData);
- dfs = (DateFormatSymbols)this.clone();
- DFSCACHE.put(key, dfs);
+ // Do not cache subclass instances
+ if (this.getClass().getName().equals("com.ibm.icu.text.DateFormatSymbols")) {
+ dfs = (DateFormatSymbols)this.clone();
+ DFSCACHE.put(key, dfs);
+ }
} else {
initializeData(dfs);
}