RFR: 8172720: Collections.SingletonList::hashCode not spec-compliant
Chris Hegarty
chris.hegarty at oracle.com
Thu Jan 12 16:03:30 UTC 2017
> 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/java/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