[lworld] RFR: 8281073: [lworld] Update MethodHandles::zero, empty, constant APIs for primitive classes

Alex Menkov amenkov at openjdk.java.net
Thu Feb 10 15:09:48 UTC 2022


On Wed, 9 Feb 2022 20:24:07 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> The `MethodHandles::zero` and `MethodHandles::empty` APIs are updated to return a primitive object with the default value if the given type is a primitive value type. These methods return null if the given type is a value class and a primitive reference type.
> 
> The MethodHandles::constant method will throw `NullPointerException` if the given type is a primitive value type and the given value is null.   That's the same behavior as the `int` type but such case is missing in the spec.

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 5116:

> 5114:      * and returns a suitable default depending on the return type.
> 5115:      * If the requested type is a primitive type or {@code void}, it returns
> 5116:      * a zero primitive value or {@ocde void}.

{@ocde void} -> {@code void}

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

PR: https://git.openjdk.java.net/valhalla/pull/644


More information about the valhalla-dev mailing list