[lworld] RFR: 8378375: [lworld] System.identityHashCode for value objects should vary by its class

Roger Riggs rriggs at openjdk.org
Fri Feb 27 16:16:27 UTC 2026


On Wed, 25 Feb 2026 18:10:40 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> System.identityHashCode for value instance should include a salt value that varies by class.
> This improves the distribution of hashcodes for value classes with similar primitive fields.
> The class hashCode is a decent salt value and is readily available.

The simple test `test/jdk/valhalla/valuetypes/ValueObjectMethodsTest.java` should be expanded and run in multiple modes. It will probably need to fall back to a golden file or a very intimate test that knows exactly how the hashCode is computed.

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

PR Comment: https://git.openjdk.org/valhalla/pull/2169#issuecomment-3962874783


More information about the valhalla-dev mailing list