RFR: 8311170: Simplify and modernize equals and hashCode in security area [v12]

Pavel Rappo prappo at openjdk.org
Fri Aug 4 22:03:37 UTC 2023


On Fri, 4 Aug 2023 21:40:37 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

> Why changing the ordering?

The order was changed to be parallel with that of `equals`.

> I was wondering if you'd change this to Objects.hash(...) with all the fields as arguments.

Sure, we could use a convenience method, but because `eData` is an array, it should be `Arrays.deepHashCode(..., eData, ...)` or this construct:

    Objects.hash(..., Arrays.hashCode(eData), ...)

Bottom line: as long as we include all eData elements in the computation, we should be fine. If we fail to do that, we'll violate the equals-hashCode contract.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14738#discussion_r1284876142



More information about the security-dev mailing list