On Mon, 21 Sep 2026 07:44:01 GMT, Marc Chevalier <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/runtime/ValueObjectMethods.java line >> 176: >> >>> 174: // to enable caching. The identity hash of the value class >>> distinguishes >>> 175: // different value classes and is easy for the compiler to >>> fetch. >>> 176: return (result & U.hashCodeMask()) == 0 ? typeHash : result; >> >> Should this comment be updated: >>> Use an alternative non-zero value when the computed hash is zero, >> >> It contradicts the check, since we aren't comparing the computed hash code >> `result` with `0`: >> >>> (result & U.hashCodeMask()) == 0 > > I don't think think it is really wrong, but I attempted to make the comment > clearer. Is that better? As far as I can see, there isn't a precedence of mentioning caching or mark word in this part of the code, so it raises additional questions about the VM side code that isn't easily visible here. So I think keeping it as simple as something like the following might be OK: > // Return an alternate hash code value if the computed hash code is 0 when > masked with the hashCodeMask() Now that I read this comment, I've a related question - is it guaranteed that if the alternate hash code is returned, then `typeHash & U.hashCodeMask()` will not be `0`? Sorry if that was already implied/answered, but I couldn't spot that detail. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32660#discussion_r4060304299
