On Mon, 6 Oct 2025 21:49:31 GMT, Naoto Sato <[email protected]> wrote:
>> Fixing the equals/hashCode contract in the SimpleTimeZone class. The current
>> implementation includes DST rule fields in hash code computation even for
>> zones that do not observe DST, while equals() always considers them. Also
>> correcting the example code in the class description, where it used
>> 20-year-old obsolete "America/Los_Angeles" rule.
>
> Naoto Sato has updated the pull request incrementally with one additional
> commit since the last revision:
>
> fixed typo
LGTM
src/java.base/share/classes/java/util/SimpleTimeZone.java line 871:
> 869: public int hashCode()
> 870: {
> 871: int hash = 31 * getID().hashCode() + rawOffset;
int hash = Objects.hash(getID(), rawOffset, useDaylight);
return !useDaylight ? hash : 31 * hash + Objects.hash(
startMonth, startDay, startDayOfWeek, startTime, endMonth, endDay,
endDayOfWeek, endTime);
Seems reasonable to use `Objects.hash` here. Could save some lines if wanted?
test/jdk/java/util/TimeZone/SimpleTimeZoneHashCodeTest.java line 1:
> 1: /*
Include _equals_ in the test name as well? Perhaps _HashCodeEqualsTest_ or
something along those lines.
-------------
Marked as reviewed by jlu (Committer).
PR Review: https://git.openjdk.org/jdk/pull/27660#pullrequestreview-3311435895
PR Review Comment: https://git.openjdk.org/jdk/pull/27660#discussion_r2411594933
PR Review Comment: https://git.openjdk.org/jdk/pull/27660#discussion_r2411564566