On Mon, 17 Jul 2023 18:13:38 GMT, Pavel Rappo <pra...@openjdk.org> wrote:
>> Thanks for noticing this difference! >> >> Yes, the initial value would've been exponentiated (^ or ** in your >> notation). However, I note that the original code computed this: >> >> if nameValue.length > 0 >> >> (37^nameValue.length) * oid.hashCode() + 37 + Arrays.hashCode(nameValue) >> >> otherwise >> >> 37 + oid.hashCode() >> >> Well, it would've computed that, had the multiplier constant been 37 in >> Arrays.hashCode, which it is not; it's 31. >> >> Since we cannot achieve absolute fidelity with the old code, I suggest we do >> this instead, what do you think? >> >> public int hashCode() { >> if (myhash == -1) { >> myhash = Arrays.deepHashCode(new Object[]{oid, nameValue}); >> } >> return myhash; > > Correction. If the multiplier were 31, then it would've been this: > > return ( 30 + oid.hashCode() ) * 31**nameValue.length + > Arrays.hashCode(nameValue); > ^ ^ > > @djelinski, do you think we should use this instead? > > return Arrays.deepHashCode(new Object[]{oid, nameValue}); I think `oid.hashCode() + Arrays.hashCode(nameValue)` would have been good enough, but deepHashCode is also acceptable. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14738#discussion_r1265763292