Method reference conversion
uther.ii at gmail.com
Thu Dec 15 23:28:50 PST 2011
> 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.
So Method reference are not really suited to Liseners. I think it's a
shame since it was a really good use case of method reference.
On 16/12/11 07:00, Howard Lovatt wrote :
> It would be nice if they were equal() even if !=
> On 16 December 2011 13:08, Brian Goetz<brian.goetz at oracle.com> wrote:
Since the behaviour of equals is redefined in every class, I don't think
it is possible.
It may be possible to have a special attribute .methodReference (like
".length" or ".class", I don't know the official name) returning a
Method object if the reference was set by reference conversion, null
Methods like "removeListener" would not work out of the box, but It
might be updated to support method references.
Runnable method1 = this::myMethod;
Runnable method2 = this::myMethod;
System.out.println(method1.methodReference.equals(method2.methodReference); //returns true
More information about the lambda-dev