8008161: Regression: j.u.TimeZone.getAvailableIDs(rawOffset) returns non-sorted list

To return a sorted list

Reviewed-by: lancea, naoto
This commit is contained in:
Xueming Shen 2013-02-13 11:49:34 -08:00
parent 8f58ebc261
commit 48a592be5a
2 changed files with 26 additions and 2 deletions
jdk
src/share/classes/sun/util/calendar
test/sun/util/calendar/zi

@ -92,7 +92,13 @@ public final class ZoneInfoFile {
ids.add(id);
}
}
return ids.toArray(new String[ids.size()]);
// It appears the "zi" implementation returns the
// sorted list, though the specification does not
// specify it. Keep the same behavior for better
// compatibility.
String[] list = ids.toArray(new String[ids.size()]);
Arrays.sort(list);
return list;
}
public static ZoneInfo getZoneInfo(String zoneId) {

@ -23,7 +23,7 @@
/*
*@test
*@bug 8007572
*@bug 8007572 8008161
*@summary Test whether the TimeZone generated from JSR310 tzdb is the same
*as the one from the tz data from javazic
*/
@ -156,6 +156,24 @@ public class TestZoneInfo310 {
sun.util.calendar.ZoneInfoFile.getVersion(), ver);
throw new RuntimeException("Version test failed");
}
// test getAvailableIDs(raw);
zids_new = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
//Arrays.sort(zids_new);
zids_old = ZoneInfoOld.getAvailableIDs(-8 * 60 * 60 * 1000);
if (!Arrays.equals(zids_new, zids_old)) {
System.out.println("------------------------");
System.out.println("NEW.getAvailableIDs(-8:00)");
for (String zid : zids_new) {
System.out.println(zid);
}
System.out.println("------------------------");
System.out.println("OLD.getAvailableIDs(-8:00)");
for (String zid : zids_old) {
System.out.println(zid);
}
throw new RuntimeException(" FAILED: availableIds(offset) don't match");
}
}
private static void delete(File f) {