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

Mandy Chung mchung at openjdk.org
Tue Mar 19 00:08:31 UTC 2024


On Thu, 7 Mar 2024 21:56:05 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Correct substitutability comparison of float and double using the raw-bits as indicated in JEP 401.

src/java.base/share/classes/java/lang/runtime/ValueObjectMethods.java line 107:

> 105:                 throw new RuntimeException(e);
> 106:             }
> 107:         }

Suggestion:

        static {
            primitiveSubstitutable.putAll(primitiveEquals); // adopt all the primitive eq methods
            primitiveSubstitutable.put(float.class,
                    findStatic("eqValue", methodType(boolean.class, float.class, float.class)));
            primitiveSubstitutable.put(double.class,
                    findStatic("eqValue", methodType(boolean.class, double.class, double.class)));
        }


Suggest to use existing helper methods and use `MethodType::methodType` for simplicty (avoid `doPrivileged` and loader).

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1039#discussion_r1518246901



More information about the valhalla-dev mailing list