Will lambda expressions become primitive objects?
Brian Goetz
brian.goetz at oracle.com
Wed Oct 6 16:23:07 UTC 2021
Yes, these are reasonable candidates for losing their identity. In fact, if you read the JLS, you’ll see that we make no guarantees on the identity of the lambda object. That was a deliberately planted stake in the ground ….
Sent from my iPad
> On Oct 6, 2021, at 11:46 AM, Glavo <zjx001202 at gmail.com> wrote:
>
> Objects created by lambda expressions seem to meet the limitations of
> primitive objects. At present, the object created by lambda expression
> still seems to be identity object, making them primitive objects may
> reduce the creation of unnecessary objects in the absence of inlining.
> So I'm curious if you have such plans?
>
> I don't know if a lot of code depends on the object identity of lambda
> expressions, If the object identity of a lambda expression cannot be
> removed for compatibility, can you consider supporting such a simple
> way to create a lambda expression that is a primitive object:
>
> var runnable = (Runnable & PrimitiveObject) () -> {};
More information about the valhalla-dev
mailing list