7117487: Warnings Cleanup: some i18n classes in java.util and sun.util
Reviewed-by: lancea, naoto
--- a/jdk/src/share/classes/java/util/Date.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/java/util/Date.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -770,7 +770,7 @@
*/
@Deprecated
public int getDay() {
- return normalize().getDayOfWeek() - gcal.SUNDAY;
+ return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
}
/**
@@ -1027,7 +1027,7 @@
BaseCalendar.Date date = normalize();
StringBuilder sb = new StringBuilder(28);
int index = date.getDayOfWeek();
- if (index == gcal.SUNDAY) {
+ if (index == BaseCalendar.SUNDAY) {
index = 8;
}
convertToAbbr(sb, wtb[index]).append(' '); // EEE
@@ -1039,7 +1039,7 @@
CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
TimeZone zi = date.getZone();
if (zi != null) {
- sb.append(zi.getDisplayName(date.isDaylightTime(), zi.SHORT, Locale.US)); // zzz
+ sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
} else {
sb.append("GMT");
}
@@ -1237,7 +1237,7 @@
}
GregorianCalendar gc = new GregorianCalendar(tz);
gc.clear();
- gc.set(gc.MILLISECOND, ms);
+ gc.set(GregorianCalendar.MILLISECOND, ms);
gc.set(y, m-1, d, hh, mm, ss);
fastTime = gc.getTimeInMillis();
BaseCalendar cal = getCalendarSystem(fastTime);
--- a/jdk/src/share/classes/java/util/GregorianCalendar.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/java/util/GregorianCalendar.java Sat Dec 03 10:58:19 2011 +0900
@@ -947,7 +947,7 @@
}
if (month >= 0) {
- set(MONTH, (int) (month % 12));
+ set(MONTH, month % 12);
} else {
// month < 0
month %= 12;
@@ -1313,8 +1313,8 @@
}
// the first day of week of the month.
- long monthDay1st = calsys.getDayOfWeekDateOnOrBefore(month1 + 6,
- getFirstDayOfWeek());
+ long monthDay1st = BaseCalendar.getDayOfWeekDateOnOrBefore(month1 + 6,
+ getFirstDayOfWeek());
// if the week has enough days to form a week, the
// week starts from the previous month.
if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) {
@@ -1407,7 +1407,7 @@
return;
}
long fd = getCurrentFixedDate();
- long dowFirst = calsys.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
+ long dowFirst = BaseCalendar.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
fd += amount;
if (fd < dowFirst) {
fd += 7;
@@ -1926,7 +1926,7 @@
* Returns the millisecond offset from the beginning of this
* year. This Calendar object must have been normalized.
*/
- private final long getYearOffsetInMillis() {
+ private long getYearOffsetInMillis() {
long t = (internalGet(DAY_OF_YEAR) - 1) * 24;
t += internalGet(HOUR_OF_DAY);
t *= 60;
@@ -2485,8 +2485,8 @@
if (cdate.isLeapYear()) {
nextJan1++;
}
- long nextJan1st = calsys.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
- getFirstDayOfWeek());
+ long nextJan1st = BaseCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(nextJan1st - nextJan1);
if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
// The first days forms a week in which the date is included.
@@ -2518,8 +2518,8 @@
calForJan1 = gcal;
}
- long nextJan1st = calForJan1.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
- getFirstDayOfWeek());
+ long nextJan1st = BaseCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(nextJan1st - nextJan1);
if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
// The first days forms a week in which the date is included.
@@ -2543,11 +2543,11 @@
* @param fixedDate the fixed date of the last day of the period
* @return the number of weeks of the given period
*/
- private final int getWeekNumber(long fixedDay1, long fixedDate) {
+ private int getWeekNumber(long fixedDay1, long fixedDate) {
// We can always use `gcal' since Julian and Gregorian are the
// same thing for this calculation.
- long fixedDay1st = gcal.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
- getFirstDayOfWeek());
+ long fixedDay1st = Gregorian.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(fixedDay1st - fixedDay1);
assert ndays <= 7;
if (ndays >= getMinimalDaysInFirstWeek()) {
@@ -2818,16 +2818,16 @@
}
} else {
if (isFieldSet(fieldMask, WEEK_OF_MONTH)) {
- long firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
- getFirstDayOfWeek());
+ long firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+ getFirstDayOfWeek());
// If we have enough days in the first week, then
// move to the previous week.
if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
firstDayOfWeek -= 7;
}
if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
- firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
- internalGet(DAY_OF_WEEK));
+ firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+ internalGet(DAY_OF_WEEK));
}
// In lenient mode, we treat days of the previous
// months as a part of the specified
@@ -2850,15 +2850,15 @@
dowim = 1;
}
if (dowim >= 0) {
- fixedDate = cal.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
- dayOfWeek);
+ fixedDate = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
+ dayOfWeek);
} else {
// Go to the first day of the next week of
// the specified week boundary.
int lastDate = monthLength(month, year) + (7 * (dowim + 1));
// Then, get the day of week date on or before the last date.
- fixedDate = cal.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
- dayOfWeek);
+ fixedDate = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
+ dayOfWeek);
}
}
}
@@ -2877,8 +2877,8 @@
fixedDate += internalGet(DAY_OF_YEAR);
fixedDate--;
} else {
- long firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
- getFirstDayOfWeek());
+ long firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+ getFirstDayOfWeek());
// If we have enough days in the first week, then move
// to the previous week.
if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
@@ -2887,8 +2887,8 @@
if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
int dayOfWeek = internalGet(DAY_OF_WEEK);
if (dayOfWeek != getFirstDayOfWeek()) {
- firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
- dayOfWeek);
+ firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+ dayOfWeek);
}
}
fixedDate = firstDayOfWeek + 7 * ((long)internalGet(WEEK_OF_YEAR) - 1);
@@ -2903,7 +2903,7 @@
* in sync). Otherwise, a cloned object is returned after calling
* complete() in lenient mode.
*/
- private final GregorianCalendar getNormalizedCalendar() {
+ private GregorianCalendar getNormalizedCalendar() {
GregorianCalendar gc;
if (isFullyNormalized()) {
gc = this;
@@ -2920,7 +2920,7 @@
* Returns the Julian calendar system instance (singleton). 'jcal'
* and 'jeras' are set upon the return.
*/
- synchronized private static final BaseCalendar getJulianCalendarSystem() {
+ synchronized private static BaseCalendar getJulianCalendarSystem() {
if (jcal == null) {
jcal = (JulianCalendar) CalendarSystem.forName("julian");
jeras = jcal.getEras();
@@ -2958,7 +2958,7 @@
* or Julian).
* @param fixedDate the fixed date representation of the date
*/
- private final long getFixedDateJan1(BaseCalendar.Date date, long fixedDate) {
+ private long getFixedDateJan1(BaseCalendar.Date date, long fixedDate) {
assert date.getNormalizedYear() == gregorianCutoverYear ||
date.getNormalizedYear() == gregorianCutoverYearJulian;
if (gregorianCutoverYear != gregorianCutoverYearJulian) {
@@ -2984,7 +2984,7 @@
* or Julian).
* @param fixedDate the fixed date representation of the date
*/
- private final long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
+ private long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
assert date.getNormalizedYear() == gregorianCutoverYear ||
date.getNormalizedYear() == gregorianCutoverYearJulian;
BaseCalendar.Date gCutover = getGregorianCutoverDate();
@@ -3023,7 +3023,7 @@
*
* @param fd the fixed date
*/
- private final BaseCalendar.Date getCalendarDate(long fd) {
+ private BaseCalendar.Date getCalendarDate(long fd) {
BaseCalendar cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem();
BaseCalendar.Date d = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
cal.getCalendarDateFromFixedDate(d, fd);
@@ -3034,7 +3034,7 @@
* Returns the Gregorian cutover date as a BaseCalendar.Date. The
* date is a Gregorian date.
*/
- private final BaseCalendar.Date getGregorianCutoverDate() {
+ private BaseCalendar.Date getGregorianCutoverDate() {
return getCalendarDate(gregorianCutoverDate);
}
@@ -3042,7 +3042,7 @@
* Returns the day before the Gregorian cutover date as a
* BaseCalendar.Date. The date is a Julian date.
*/
- private final BaseCalendar.Date getLastJulianDate() {
+ private BaseCalendar.Date getLastJulianDate() {
return getCalendarDate(gregorianCutoverDate - 1);
}
@@ -3052,7 +3052,7 @@
*
* @see #isLeapYear(int)
*/
- private final int monthLength(int month, int year) {
+ private int monthLength(int month, int year) {
return isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month];
}
@@ -3062,7 +3062,7 @@
*
* @see #isLeapYear(int)
*/
- private final int monthLength(int month) {
+ private int monthLength(int month) {
int year = internalGet(YEAR);
if (internalGetEra() == BCE) {
year = 1 - year;
@@ -3070,7 +3070,7 @@
return monthLength(month, year);
}
- private final int actualMonthLength() {
+ private int actualMonthLength() {
int year = cdate.getNormalizedYear();
if (year != gregorianCutoverYear && year != gregorianCutoverYearJulian) {
return calsys.getMonthLength(cdate);
@@ -3094,7 +3094,7 @@
* Returns the length (in days) of the specified year. The year
* must be normalized.
*/
- private final int yearLength(int year) {
+ private int yearLength(int year) {
return isLeapYear(year) ? 366 : 365;
}
@@ -3102,7 +3102,7 @@
* Returns the length (in days) of the year provided by
* internalGet(YEAR).
*/
- private final int yearLength() {
+ private int yearLength() {
int year = internalGet(YEAR);
if (internalGetEra() == BCE) {
year = 1 - year;
@@ -3116,7 +3116,7 @@
* 3, we want it to go to Feb 28. Adjustments which might run into this
* problem call this method to retain the proper month.
*/
- private final void pinDayOfMonth() {
+ private void pinDayOfMonth() {
int year = internalGet(YEAR);
int monthLen;
if (year > gregorianCutoverYear || year < gregorianCutoverYearJulian) {
@@ -3135,14 +3135,14 @@
* Returns the fixed date value of this object. The time value and
* calendar fields must be in synch.
*/
- private final long getCurrentFixedDate() {
+ private long getCurrentFixedDate() {
return (calsys == gcal) ? cachedFixedDate : calsys.getFixedDate(cdate);
}
/**
* Returns the new value after 'roll'ing the specified value and amount.
*/
- private static final int getRolledValue(int value, int amount, int min, int max) {
+ private static int getRolledValue(int value, int amount, int min, int max) {
assert value >= min && value <= max;
int range = max - min + 1;
amount %= range;
@@ -3160,7 +3160,7 @@
* Returns the ERA. We need a special method for this because the
* default ERA is CE, but a zero (unset) ERA is BCE.
*/
- private final int internalGetEra() {
+ private int internalGetEra() {
return isSet(ERA) ? internalGet(ERA) : CE;
}
--- a/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -260,8 +260,9 @@
// max value could be one year short. For example, if it's
// Showa 63 January 8, 63 is the actual max value since
// Showa 64 January 8 doesn't exist.
- if (!(lgd.getMonth() == BaseCalendar.JANUARY && lgd.getDayOfMonth() == 1))
+ if (!(lgd.getMonth() == BaseCalendar.JANUARY && lgd.getDayOfMonth() == 1)) {
y--;
+ }
year = Math.min(y, year);
}
LEAST_MAX_VALUES[YEAR] = year; // Max year could be smaller than this value.
@@ -294,7 +295,7 @@
* @param zone the given time zone.
* @param aLocale the given locale.
*/
- public JapaneseImperialCalendar(TimeZone zone, Locale aLocale) {
+ JapaneseImperialCalendar(TimeZone zone, Locale aLocale) {
super(zone, aLocale);
jdate = jcal.newCalendarDate(zone);
setTimeInMillis(System.currentTimeMillis());
@@ -792,8 +793,8 @@
}
// the first day of week of the month.
- long monthDay1st = jcal.getDayOfWeekDateOnOrBefore(month1 + 6,
- getFirstDayOfWeek());
+ long monthDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(month1 + 6,
+ getFirstDayOfWeek());
// if the week has enough days to form a week, the
// week starts from the previous month.
if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) {
@@ -884,7 +885,7 @@
return;
}
long fd = cachedFixedDate;
- long dowFirst = jcal.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
+ long dowFirst = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
fd += amount;
if (fd < dowFirst) {
fd += 7;
@@ -963,8 +964,9 @@
Era era = eras[index];
name = (style == SHORT) ? era.getAbbreviation() : era.getName();
} else {
- if (field == DAY_OF_WEEK)
+ if (field == DAY_OF_WEEK) {
--index;
+ }
name = strings[index];
}
}
@@ -1000,7 +1002,7 @@
private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
ResourceBundle rb = LocaleData.getDateFormatData(locale);
String key = getKey(field, style);
- Map<String,Integer> map = new HashMap<String,Integer>();
+ Map<String,Integer> map = new HashMap<>();
if (key != null) {
String[] strings = rb.getStringArray(key);
if (field == YEAR) {
@@ -1392,8 +1394,8 @@
jcal.normalize(jd);
long jan1 = jcal.getFixedDate(d);
long nextJan1 = jcal.getFixedDate(jd);
- long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
- getFirstDayOfWeek());
+ long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(nextJan1st - nextJan1);
if (ndays >= getMinimalDaysInFirstWeek()) {
nextJan1st -= 7;
@@ -1523,7 +1525,7 @@
* beyond the limit. The given CalendarDate object must have been
* normalized before calling this method.
*/
- private final long getYearOffsetInMillis(CalendarDate date) {
+ private long getYearOffsetInMillis(CalendarDate date) {
long t = (jcal.getDayOfYear(date) - 1) * ONE_DAY;
return t + date.getTimeOfDay() - date.getZoneOffset();
}
@@ -1755,7 +1757,7 @@
d.setMonth(pd.getMonth()).setDayOfMonth(pd.getDayOfMonth());
}
} else {
- d.setMonth(jcal.JANUARY).setDayOfMonth(1);
+ d.setMonth(LocalGregorianCalendar.JANUARY).setDayOfMonth(1);
}
jcal.normalize(d);
prevJan1 = jcal.getFixedDate(d);
@@ -1780,8 +1782,8 @@
if (jdate.isLeapYear()) {
nextJan1++;
}
- long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
- getFirstDayOfWeek());
+ long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(nextJan1st - nextJan1);
if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
// The first days forms a week in which the date is included.
@@ -1793,7 +1795,7 @@
long nextJan1;
if (jdate.getYear() == 1) {
d.addYear(+1);
- d.setMonth(jcal.JANUARY).setDayOfMonth(1);
+ d.setMonth(LocalGregorianCalendar.JANUARY).setDayOfMonth(1);
nextJan1 = jcal.getFixedDate(d);
} else {
int nextEraIndex = getEraIndex(d) + 1;
@@ -1803,8 +1805,8 @@
jcal.normalize(d);
nextJan1 = jcal.getFixedDate(d);
}
- long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
- getFirstDayOfWeek());
+ long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(nextJan1st - nextJan1);
if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
// The first days forms a week in which the date is included.
@@ -1828,11 +1830,11 @@
* @param fixedDate the fixed date of the last day of the period
* @return the number of weeks of the given period
*/
- private final int getWeekNumber(long fixedDay1, long fixedDate) {
+ private int getWeekNumber(long fixedDay1, long fixedDate) {
// We can always use `jcal' since Julian and Gregorian are the
// same thing for this calculation.
- long fixedDay1st = jcal.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
- getFirstDayOfWeek());
+ long fixedDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
+ getFirstDayOfWeek());
int ndays = (int)(fixedDay1st - fixedDay1);
assert ndays <= 7;
if (ndays >= getMinimalDaysInFirstWeek()) {
@@ -2026,10 +2028,12 @@
if (year == MIN_VALUES[YEAR]) {
CalendarDate dx = jcal.getCalendarDate(Long.MIN_VALUE, getZone());
int m = dx.getMonth() - 1;
- if (month < m)
+ if (month < m) {
month = m;
- if (month == m)
+ }
+ if (month == m) {
firstDayOfMonth = dx.getDayOfMonth();
+ }
}
LocalGregorianCalendar.Date date = jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
@@ -2058,16 +2062,16 @@
}
} else {
if (isFieldSet(fieldMask, WEEK_OF_MONTH)) {
- long firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
- getFirstDayOfWeek());
+ long firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+ getFirstDayOfWeek());
// If we have enough days in the first week, then
// move to the previous week.
if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
firstDayOfWeek -= 7;
}
if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
- firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
- internalGet(DAY_OF_WEEK));
+ firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+ internalGet(DAY_OF_WEEK));
}
// In lenient mode, we treat days of the previous
// months as a part of the specified
@@ -2090,15 +2094,15 @@
dowim = 1;
}
if (dowim >= 0) {
- fixedDate = jcal.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
- dayOfWeek);
+ fixedDate = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
+ dayOfWeek);
} else {
// Go to the first day of the next week of
// the specified week boundary.
int lastDate = monthLength(month, year) + (7 * (dowim + 1));
// Then, get the day of week date on or before the last date.
- fixedDate = jcal.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
- dayOfWeek);
+ fixedDate = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
+ dayOfWeek);
}
}
}
@@ -2112,8 +2116,8 @@
fixedDate += internalGet(DAY_OF_YEAR);
fixedDate--;
} else {
- long firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
- getFirstDayOfWeek());
+ long firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+ getFirstDayOfWeek());
// If we have enough days in the first week, then move
// to the previous week.
if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
@@ -2122,8 +2126,8 @@
if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
int dayOfWeek = internalGet(DAY_OF_WEEK);
if (dayOfWeek != getFirstDayOfWeek()) {
- firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
- dayOfWeek);
+ firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+ dayOfWeek);
}
}
fixedDate = firstDayOfWeek + 7 * ((long)internalGet(WEEK_OF_YEAR) - 1);
@@ -2140,7 +2144,7 @@
* calculated. The date has to be in the cut-over year.
* @param fixedDate the fixed date representation of the date
*/
- private final long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) {
+ private long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) {
Era era = date.getEra();
if (date.getEra() != null && date.getYear() == 1) {
for (int eraIndex = getEraIndex(date); eraIndex > 0; eraIndex--) {
@@ -2154,7 +2158,7 @@
}
}
CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE);
- d.setDate(date.getNormalizedYear(), gcal.JANUARY, 1);
+ d.setDate(date.getNormalizedYear(), Gregorian.JANUARY, 1);
return gcal.getFixedDate(d);
}
@@ -2166,7 +2170,7 @@
* calculated. The date must be in the era transition year.
* @param fixedDate the fixed date representation of the date
*/
- private final long getFixedDateMonth1(LocalGregorianCalendar.Date date,
+ private long getFixedDateMonth1(LocalGregorianCalendar.Date date,
long fixedDate) {
int eraIndex = getTransitionEraIndex(date);
if (eraIndex != -1) {
@@ -2187,7 +2191,7 @@
*
* @param fd the fixed date
*/
- private static final LocalGregorianCalendar.Date getCalendarDate(long fd) {
+ private static LocalGregorianCalendar.Date getCalendarDate(long fd) {
LocalGregorianCalendar.Date d = jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
jcal.getCalendarDateFromFixedDate(d, fd);
return d;
@@ -2199,7 +2203,7 @@
*
* @see #isLeapYear(int)
*/
- private final int monthLength(int month, int gregorianYear) {
+ private int monthLength(int month, int gregorianYear) {
return CalendarUtils.isGregorianLeapYear(gregorianYear) ?
GregorianCalendar.LEAP_MONTH_LENGTH[month] : GregorianCalendar.MONTH_LENGTH[month];
}
@@ -2210,13 +2214,13 @@
*
* @see #isLeapYear(int)
*/
- private final int monthLength(int month) {
+ private int monthLength(int month) {
assert jdate.isNormalized();
return jdate.isLeapYear() ?
GregorianCalendar.LEAP_MONTH_LENGTH[month] : GregorianCalendar.MONTH_LENGTH[month];
}
- private final int actualMonthLength() {
+ private int actualMonthLength() {
int length = jcal.getMonthLength(jdate);
int eraIndex = getTransitionEraIndex(jdate);
if (eraIndex == -1) {
@@ -2239,7 +2243,7 @@
* January 3, then the era index for Heisei is returned. If the
* given date is not in any transition month, then -1 is returned.
*/
- private static final int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
+ private static int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
int eraIndex = getEraIndex(date);
CalendarDate transitionDate = eras[eraIndex].getSinceDate();
if (transitionDate.getYear() == date.getNormalizedYear() &&
@@ -2256,7 +2260,7 @@
return -1;
}
- private final boolean isTransitionYear(int normalizedYear) {
+ private boolean isTransitionYear(int normalizedYear) {
for (int i = eras.length - 1; i > 0; i--) {
int transitionYear = eras[i].getSinceDate().getYear();
if (normalizedYear == transitionYear) {
@@ -2269,7 +2273,7 @@
return false;
}
- private static final int getEraIndex(LocalGregorianCalendar.Date date) {
+ private static int getEraIndex(LocalGregorianCalendar.Date date) {
Era era = date.getEra();
for (int i = eras.length - 1; i > 0; i--) {
if (eras[i] == era) {
@@ -2284,7 +2288,7 @@
* in sync). Otherwise, a cloned object is returned after calling
* complete() in lenient mode.
*/
- private final JapaneseImperialCalendar getNormalizedCalendar() {
+ private JapaneseImperialCalendar getNormalizedCalendar() {
JapaneseImperialCalendar jc;
if (isFullyNormalized()) {
jc = this;
@@ -2303,7 +2307,7 @@
* 3, we want it to go to Feb 28. Adjustments which might run into this
* problem call this method to retain the proper month.
*/
- private final void pinDayOfMonth(LocalGregorianCalendar.Date date) {
+ private void pinDayOfMonth(LocalGregorianCalendar.Date date) {
int year = date.getYear();
int dom = date.getDayOfMonth();
if (year != getMinimum(YEAR)) {
@@ -2347,7 +2351,7 @@
/**
* Returns the new value after 'roll'ing the specified value and amount.
*/
- private static final int getRolledValue(int value, int amount, int min, int max) {
+ private static int getRolledValue(int value, int amount, int min, int max) {
assert value >= min && value <= max;
int range = max - min + 1;
amount %= range;
@@ -2365,7 +2369,7 @@
* Returns the ERA. We need a special method for this because the
* default ERA is the current era, but a zero (unset) ERA means before Meiji.
*/
- private final int internalGetEra() {
+ private int internalGetEra() {
return isSet(ERA) ? internalGet(ERA) : eras.length - 1;
}
--- a/jdk/src/share/classes/java/util/ResourceBundle.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/java/util/ResourceBundle.java Sat Dec 03 10:58:19 2011 +0900
@@ -294,7 +294,7 @@
/**
* Queue for reference objects referring to class loaders or bundles.
*/
- private static final ReferenceQueue referenceQueue = new ReferenceQueue();
+ private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
/**
* The parent bundle of this bundle.
@@ -389,12 +389,13 @@
if (parent != null) {
obj = parent.getObject(key);
}
- if (obj == null)
+ if (obj == null) {
throw new MissingResourceException("Can't find resource for bundle "
+this.getClass().getName()
+", key "+key,
this.getClass().getName(),
key);
+ }
}
return obj;
}
@@ -418,7 +419,7 @@
private static ClassLoader getLoader() {
Class[] stack = getClassContext();
/* Magic number 2 identifies our caller's caller */
- Class c = stack[2];
+ Class<?> c = stack[2];
ClassLoader cl = (c == null) ? null : c.getClassLoader();
if (cl == null) {
// When the caller's loader is the boot class loader, cl is null
@@ -488,7 +489,7 @@
* null, but the base name and the locale must have a non-null
* value.
*/
- private static final class CacheKey implements Cloneable {
+ private static class CacheKey implements Cloneable {
// These three are the actual keys for lookup in Map.
private String name;
private Locale locale;
@@ -583,8 +584,7 @@
// treat it as unequal
&& (loader != null)
&& (loader == otherEntry.loaderRef.get());
- } catch (NullPointerException e) {
- } catch (ClassCastException e) {
+ } catch ( NullPointerException | ClassCastException e) {
}
return false;
}
@@ -669,11 +669,11 @@
* garbage collected when nobody else is using them. The ResourceBundle
* class has no reason to keep class loaders alive.
*/
- private static final class LoaderReference extends WeakReference<ClassLoader>
- implements CacheKeyReference {
+ private static class LoaderReference extends WeakReference<ClassLoader>
+ implements CacheKeyReference {
private CacheKey cacheKey;
- LoaderReference(ClassLoader referent, ReferenceQueue q, CacheKey key) {
+ LoaderReference(ClassLoader referent, ReferenceQueue<Object> q, CacheKey key) {
super(referent, q);
cacheKey = key;
}
@@ -687,11 +687,11 @@
* References to bundles are soft references so that they can be garbage
* collected when they have no hard references.
*/
- private static final class BundleReference extends SoftReference<ResourceBundle>
- implements CacheKeyReference {
+ private static class BundleReference extends SoftReference<ResourceBundle>
+ implements CacheKeyReference {
private CacheKey cacheKey;
- BundleReference(ResourceBundle referent, ReferenceQueue q, CacheKey key) {
+ BundleReference(ResourceBundle referent, ReferenceQueue<Object> q, CacheKey key) {
super(referent, q);
cacheKey = key;
}
@@ -1331,8 +1331,8 @@
* Checks if the given <code>List</code> is not null, not empty,
* not having null in its elements.
*/
- private static final boolean checkList(List a) {
- boolean valid = (a != null && a.size() != 0);
+ private static boolean checkList(List<?> a) {
+ boolean valid = (a != null && !a.isEmpty());
if (valid) {
int size = a.size();
for (int i = 0; valid && i < size; i++) {
@@ -1342,12 +1342,12 @@
return valid;
}
- private static final ResourceBundle findBundle(CacheKey cacheKey,
- List<Locale> candidateLocales,
- List<String> formats,
- int index,
- Control control,
- ResourceBundle baseBundle) {
+ private static ResourceBundle findBundle(CacheKey cacheKey,
+ List<Locale> candidateLocales,
+ List<String> formats,
+ int index,
+ Control control,
+ ResourceBundle baseBundle) {
Locale targetLocale = candidateLocales.get(index);
ResourceBundle parent = null;
if (index != candidateLocales.size() - 1) {
@@ -1419,10 +1419,10 @@
return parent;
}
- private static final ResourceBundle loadBundle(CacheKey cacheKey,
- List<String> formats,
- Control control,
- boolean reload) {
+ private static ResourceBundle loadBundle(CacheKey cacheKey,
+ List<String> formats,
+ Control control,
+ boolean reload) {
// Here we actually load the bundle in the order of formats
// specified by the getFormats() value.
@@ -1459,7 +1459,7 @@
return bundle;
}
- private static final boolean isValidBundle(ResourceBundle bundle) {
+ private static boolean isValidBundle(ResourceBundle bundle) {
return bundle != null && bundle != NONEXISTENT_BUNDLE;
}
@@ -1467,7 +1467,7 @@
* Determines whether any of resource bundles in the parent chain,
* including the leaf, have expired.
*/
- private static final boolean hasValidParentChain(ResourceBundle bundle) {
+ private static boolean hasValidParentChain(ResourceBundle bundle) {
long now = System.currentTimeMillis();
while (bundle != null) {
if (bundle.expired) {
@@ -1488,9 +1488,9 @@
/**
* Throw a MissingResourceException with proper message
*/
- private static final void throwMissingResourceException(String baseName,
- Locale locale,
- Throwable cause) {
+ private static void throwMissingResourceException(String baseName,
+ Locale locale,
+ Throwable cause) {
// If the cause is a MissingResourceException, avoid creating
// a long chain. (6355009)
if (cause instanceof MissingResourceException) {
@@ -1513,8 +1513,8 @@
* cache or its parent has expired. <code>bundle.expire</code> is true
* upon return if the bundle in the cache has expired.
*/
- private static final ResourceBundle findBundleInCache(CacheKey cacheKey,
- Control control) {
+ private static ResourceBundle findBundleInCache(CacheKey cacheKey,
+ Control control) {
BundleReference bundleRef = cacheList.get(cacheKey);
if (bundleRef == null) {
return null;
@@ -1620,9 +1620,9 @@
* the bundle before this call, the one found in the cache is
* returned.
*/
- private static final ResourceBundle putBundleInCache(CacheKey cacheKey,
- ResourceBundle bundle,
- Control control) {
+ private static ResourceBundle putBundleInCache(CacheKey cacheKey,
+ ResourceBundle bundle,
+ Control control) {
setExpirationTime(cacheKey, control);
if (cacheKey.expirationTime != Control.TTL_DONT_CACHE) {
CacheKey key = (CacheKey) cacheKey.clone();
@@ -1653,7 +1653,7 @@
return bundle;
}
- private static final void setExpirationTime(CacheKey cacheKey, Control control) {
+ private static void setExpirationTime(CacheKey cacheKey, Control control) {
long ttl = control.getTimeToLive(cacheKey.getName(),
cacheKey.getLocale());
if (ttl >= 0) {
@@ -2350,18 +2350,27 @@
if (script.length() == 0 && region.length() > 0) {
// Supply script for users who want to use zh_Hans/zh_Hant
// as bundle names (recommended for Java7+)
- if (region.equals("TW") || region.equals("HK") || region.equals("MO")) {
+ switch (region) {
+ case "TW":
+ case "HK":
+ case "MO":
script = "Hant";
- } else if (region.equals("CN") || region.equals("SG")) {
+ break;
+ case "CN":
+ case "SG":
script = "Hans";
+ break;
}
} else if (script.length() > 0 && region.length() == 0) {
// Supply region(country) for users who still package Chinese
// bundles using old convension.
- if (script.equals("Hans")) {
+ switch (script) {
+ case "Hans":
region = "CN";
- } else if (script.equals("Hant")) {
+ break;
+ case "Hant":
region = "TW";
+ break;
}
}
}
@@ -2562,6 +2571,7 @@
ResourceBundle bundle = null;
if (format.equals("java.class")) {
try {
+ @SuppressWarnings("unchecked")
Class<? extends ResourceBundle> bundleClass
= (Class<? extends ResourceBundle>)loader.loadClass(bundleName);
--- a/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
package sun.util.calendar;
-import java.util.Locale;
import java.util.TimeZone;
/**
@@ -203,7 +202,7 @@
return false;
}
int dow = bdate.getDayOfWeek();
- if (dow != bdate.FIELD_UNDEFINED && dow != getDayOfWeek(bdate)) {
+ if (dow != Date.FIELD_UNDEFINED && dow != getDayOfWeek(bdate)) {
return false;
}
@@ -329,7 +328,7 @@
}
// accepts 0 (December in the previous year) to 12.
- private final int getMonthLength(int year, int month) {
+ private int getMonthLength(int year, int month) {
int days = DAYS_IN_MONTH[month];
if (month == FEBRUARY && isLeapYear(year)) {
days++;
--- a/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,6 @@
package sun.util.calendar;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -99,7 +92,7 @@
};
private static void initNames() {
- ConcurrentMap<String,String> nameMap = new ConcurrentHashMap<String,String>();
+ ConcurrentMap<String,String> nameMap = new ConcurrentHashMap<>();
// Associate a calendar name with its class name and the
// calendar class name with its date class name.
@@ -112,7 +105,7 @@
synchronized (CalendarSystem.class) {
if (!initialized) {
names = nameMap;
- calendars = new ConcurrentHashMap<String,CalendarSystem>();
+ calendars = new ConcurrentHashMap<>();
initialized = true;
}
}
@@ -164,10 +157,10 @@
cal = LocalGregorianCalendar.getLocalGregorianCalendar(calendarName);
} else {
try {
- Class cl = Class.forName(className);
+ Class<?> cl = Class.forName(className);
cal = (CalendarSystem) cl.newInstance();
} catch (Exception e) {
- throw new RuntimeException("internal error", e);
+ throw new InternalError(e);
}
}
if (cal == null) {
--- a/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java Sat Dec 03 10:58:19 2011 +0900
@@ -29,7 +29,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
@@ -124,8 +123,8 @@
new sun.security.action.GetPropertyAction("java.home"));
final String fname = homeDir + File.separator + "lib" + File.separator
+ "calendars.properties";
- calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
+ calendarProps = AccessController.doPrivileged(new PrivilegedExceptionAction<Properties>() {
+ public Properties run() throws IOException {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(fname)) {
props.load(fis);
@@ -142,7 +141,7 @@
if (props == null) {
return null;
}
- List<Era> eras = new ArrayList<Era>();
+ List<Era> eras = new ArrayList<>();
StringTokenizer eraTokens = new StringTokenizer(props, ";");
while (eraTokens.hasMoreTokens()) {
String items = eraTokens.nextToken().trim();
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Sat Dec 03 10:58:19 2011 +0900
@@ -31,7 +31,6 @@
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -318,7 +317,7 @@
return offset;
}
- private final int getTransitionIndex(long date, int type) {
+ private int getTransitionIndex(long date, int type) {
int low = 0;
int high = transitions.length - 1;
@@ -572,7 +571,7 @@
List<String> excluded = ZoneInfoFile.getExcludedZones();
if (excluded != null) {
// List all zones from the idList and excluded lists
- List<String> list = new ArrayList<String>(idList.size() + excluded.size());
+ List<String> list = new ArrayList<>(idList.size() + excluded.size());
list.addAll(idList);
list.addAll(excluded);
idList = list;
@@ -592,7 +591,7 @@
*/
public static String[] getAvailableIDs(int rawOffset) {
String[] result;
- List<String> matched = new ArrayList<String>();
+ List<String> matched = new ArrayList<>();
List<String> IDs = ZoneInfoFile.getZoneIDs();
int[] rawOffsets = ZoneInfoFile.getRawOffsets();
@@ -807,7 +806,7 @@
return (checksum == ((ZoneInfo)other).checksum);
}
- private static SoftReference<Map> aliasTable;
+ private static SoftReference<Map<String, String>> aliasTable;
/**
* Returns a Map from alias time zone IDs to their standard
@@ -820,7 +819,7 @@
public synchronized static Map<String, String> getAliasTable() {
Map<String, String> aliases = null;
- SoftReference<Map> cache = aliasTable;
+ SoftReference<Map<String, String>> cache = aliasTable;
if (cache != null) {
aliases = cache.get();
if (aliases != null) {
@@ -830,7 +829,7 @@
aliases = ZoneInfoFile.getZoneAliases();
if (aliases != null) {
- aliasTable = new SoftReference<Map>(aliases);
+ aliasTable = new SoftReference<>(aliases);
}
return aliases;
}
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -573,7 +573,7 @@
synchronized static ZoneInfo addToCache(String id, ZoneInfo zi) {
if (zoneInfoObjects == null) {
- zoneInfoObjects = new HashMap<String, ZoneInfo>();
+ zoneInfoObjects = new HashMap<>();
} else {
ZoneInfo zone = zoneInfoObjects.get(id);
if (zone != null) {
@@ -758,7 +758,7 @@
case TAG_ZoneIDs:
{
int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
- ids = new ArrayList<String>(n);
+ ids = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
byte m = buf[index++];
@@ -777,7 +777,7 @@
System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
}
- zoneIDs = new SoftReference<List<String>>(ids);
+ zoneIDs = new SoftReference<>(ids);
return ids;
}
@@ -802,7 +802,7 @@
case TAG_ZoneAliases:
{
int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
- aliases = new HashMap<String, String>(n);
+ aliases = new HashMap<>(n);
for (int i = 0; i < n; i++) {
byte m = buf[index++];
String name = new String(buf, index, m, "UTF-8");
@@ -865,7 +865,7 @@
case TAG_ExcludedZones:
{
int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
- excludeList = new ArrayList<String>();
+ excludeList = new ArrayList<>();
for (int i = 0; i < n; i++) {
byte m = buf[index++];
String name = new String(buf, index, m, "UTF-8");
@@ -886,7 +886,7 @@
}
if (excludeList != null) {
- excludedIDs = new SoftReference<List<String>>(excludeList);
+ excludedIDs = new SoftReference<>(excludeList);
} else {
hasNoExcludeList = true;
}
@@ -935,7 +935,7 @@
System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
}
- rawOffsetIndices = new SoftReference<byte[]>(indices);
+ rawOffsetIndices = new SoftReference<>(indices);
return indices;
}
@@ -986,7 +986,7 @@
System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
}
- rawOffsets = new SoftReference<int[]>(offsets);
+ rawOffsets = new SoftReference<>(offsets);
return offsets;
}
@@ -1022,7 +1022,7 @@
return null;
}
- zoneInfoMappings = new SoftReference<byte[]>(data);
+ zoneInfoMappings = new SoftReference<>(data);
return data;
}
@@ -1034,8 +1034,8 @@
byte[] buffer = null;
try {
- buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
+ buffer = AccessController.doPrivileged(new PrivilegedExceptionAction<byte[]>() {
+ public byte[] run() throws IOException {
File file = new File(ziDir, fileName);
if (!file.exists() || !file.isFile()) {
return null;
@@ -1068,4 +1068,7 @@
}
return buffer;
}
+
+ private ZoneInfoFile() {
+ }
}
--- a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java Sat Dec 03 10:58:19 2011 +0900
@@ -119,11 +119,12 @@
* loading.
*/
private synchronized void loadLookup() {
- if (lookup != null)
+ if (lookup != null) {
return;
+ }
Object[][] contents = getContents();
- Map temp = createMap(contents.length);
+ Map<String, Object> temp = createMap(contents.length);
for (int i = 0; i < contents.length; ++i) {
// key must be non-null String, value must be non-null
String key = (String) contents[i][0];
@@ -140,9 +141,9 @@
* Lets subclasses provide specialized Map implementations.
* Default uses HashMap.
*/
- protected Map createMap(int size) {
- return new HashMap(size);
+ protected Map<String, Object> createMap(int size) {
+ return new HashMap<>(size);
}
- private Map lookup = null;
+ private Map<String, Object> lookup = null;
}
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java Fri Dec 02 19:33:54 2011 -0500
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java Sat Dec 03 10:58:19 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -80,17 +80,16 @@
int clen = contents.length;
String[] tmpobj = new String[clen+1];
tmpobj[0] = key;
- for (int i = 0; i < clen; i++) {
- tmpobj[i+1] = contents[i];
- }
+ System.arraycopy(contents, 0, tmpobj, 1, clen);
return tmpobj;
}
/**
* Use LinkedHashMap to preserve order of bundle entries.
*/
- protected Map createMap(int size) {
- return new LinkedHashMap(size);
+ @Override
+ protected Map<String, Object> createMap(int size) {
+ return new LinkedHashMap<>(size);
}
/**