RFR: 8172720: Collections.SingletonList::hashCode not spec-compliant
Martin Buchholz
martinrb at google.com
Thu Jan 12 19:34:30 UTC 2017
Grumpy here would like to point out that in his preferred never-ever broken
world, this would have quietly been fixed with only Claes and his friendly
neighborhood release engineer (who might be a bot) noticiing.
On Thu, Jan 12, 2017 at 11:28 AM, Stuart Marks <stuart.marks at oracle.com>
wrote:
> Whoops, we all missed this one. Thanks for the quick fix.
>
> On 1/12/17 8:07 AM, Claes Redestad wrote:
>
>> Thanks Chris!
>>
>> /Claes
>>
>> On 2017-01-12 17:03, Chris Hegarty wrote:
>>
>>>
>>> On 12 Jan 2017, at 15:42, Claes Redestad <claes.redestad at oracle.com>
>>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> there was an issue with my patch for JDK-8037325 where the
>>>> hashCode implemented for Collections.SingletonList was not
>>>> compliant with specification, which breaks certain tests.
>>>>
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8172720
>>>>
>>>> Trivial fix:
>>>>
>>>> diff -r 59e5101730c8 src/java.base/share/classes/ja
>>>> va/util/Collections.java
>>>> --- a/src/java.base/share/classes/java/util/Collections.java Thu
>>>> Jan 12
>>>> 13:38:27 2017 +0100
>>>> +++ b/src/java.base/share/classes/java/util/Collections.java Thu
>>>> Jan 12
>>>> 16:39:44 2017 +0100
>>>> @@ -4859,7 +4859,7 @@
>>>> }
>>>> @Override
>>>> public int hashCode() {
>>>> - return Objects.hashCode(element);
>>>> + return 31 + Objects.hashCode(element);
>>>> }
>>>> }
>>>>
>>>>
>>> Looks fine.
>>>
>>> -Chris.
>>>
>>>
More information about the core-libs-dev
mailing list