Method reference conversion
Brian Goetz
brian.goetz at oracle.com
Thu Dec 15 18:08:00 PST 2011
Slight correction -- in this particular case (where the method reference is a bound instance reference), it seems quite unlikely that these references would be ==. However, for static references and unbound instance references, it is quite likely that they will be ==. In any case, it is unlikely the spec will make promises that are potentially expensive to keep.
On Dec 15, 2011, at 4:10 PM, Brian Goetz wrote:
> Most likely outcome: no guarantees (such guarantees come with a cost) but it is "highly likely" that method1 == method2.
>
> When we finish the implementation of functional interface conversion we'll have a update.
>
> On Dec 15, 2011, at 3:35 PM, Uther wrote:
>
>> Hello. I have been reading this mailing list from long time but didn't
>> post anything right now since I'm not a Java expert, but I was
>> wonderning about Method references.
>>
>> Will every reference to a same method be converted to the same object?
>> Will the language specification tell something about it?
>>
>> For exemple:
>> Runnable method1 = this::myMethod;
>> Runnable method2 = this::myMethod;
>> System.out.println(method1 == method2); //returns true
>>
>> I'm not sure it is technicaly possible, but it would be very nice that
>> specification garantee that, it may allow to do interesting things like
>> a removeListener(this::myListener) after a addListener(this::myListener);
>>
>
>
More information about the lambda-dev
mailing list