[lworld] RFR: 8298659: [lworld] ValueObject isSubstutitable comparison of float/double should use raw bits

Mandy Chung mchung at openjdk.org
Wed Feb 7 22:35:05 UTC 2024


On Wed, 7 Feb 2024 19:22:32 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Update the substitutability implementation to match the new JLS for JEP 401.
> Float and double values should be compared for equality using the raw bits.

src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 183:

> 181:     private static boolean eq(long a, long b) { return a == b; }
> 182:     private static boolean eq(float a, float b) {
> 183:         return Float.floatToRawIntBits(a) == Float.floatToRawIntBits(b);

`ObjectMethods` are used for records as well and so these methods should not be modified.  Instead I suggest to add new methods in `ValueObjectMethods` class for value object substutitability comparison of float/double.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/998#discussion_r1482176440



More information about the valhalla-dev mailing list