Re: Making enum hashcodes consistent across JVM's

2022-03-17 Thread dfranken . jdk
Hi, Our use case is that we have different instances of an application running in a cloud environment and a precomputed hash code is used downstream to see if object instances generated in different application instances are the same or not. An enum was later added to our model which caused the

Re: Making enum hashcodes consistent across JVM's

2022-03-17 Thread Raffaello Giulietti
Hi, specifying a fixed hashCode() algorithm has the important drawback that it prevents evolution. For example, as you note, String has a strictly specified algorithm [1] that was perhaps a good one in the early days of Java (around 1995) but has shown its deficiencies over the years. In

Re: Making enum hashcodes consistent across JVM's

2022-03-17 Thread Remi Forax
- Original Message - > From: "dfranken jdk" > To: "core-libs-dev" > Sent: Thursday, March 17, 2022 1:49:08 PM > Subject: Making enum hashcodes consistent across JVM's > Dear all, > > Currently enums do not have a well-defined hashCode() implemen

Making enum hashcodes consistent across JVM's

2022-03-17 Thread dfranken . jdk
Dear all, Currently enums do not have a well-defined hashCode() implementation so they defer to Object.hashCode() which just uses an internal mechanism to determine the hashcode, likely based on the object's place in the heap. This may confuse a lot of developers as other classes such as String