Field and Method Literals
Collin Fagan
collin.fagan at gmail.com
Sun Apr 17 18:59:17 PDT 2011
I'm not on the experts group .. probably for good reason, but has the three
forms of method references changed?
As of at least one of the prototypes you could:
Class Person{
String getName(){ ... }
static defaultName() { ... }
}
interface StringProvider{
public String value();
}
// bound reference to the instance of tom's getName method
Person tom = new Person();
StringProvider name = tom#getName;
// assign a static method, using the class name
StringProvider name = Person#defaultName;
interface StringFromPersonProvider{
public String value(Person p);
}
// unbound reference to an interface that takes Person as it's parameter.
// this is like Method.invoke()
StringFromPersonProvider fromPersonName = Person#getName;
The last one is the one I'm most excited about, but it also seems to be the
one I can't find in my email. I was sure someone told me unbound non-static
was on the table ...
Collin
On Sun, Apr 17, 2011 at 7:47 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> On 04/17/2011 10:04 PM, Alessio Stalla wrote:
>
>> On Sun, Apr 17, 2011 at 8:14 PM, Collin Fagan<collin.fagan at gmail.com>
>> wrote:
>>
>>> *Adding or removing formal parameters of that method will break the
>>> compatibility.*
>>>
>>> Isn't this almost always the case? I'm having a hard time understanding
>>> why
>>> it's any worse to break an annotation then any other line of code.
>>>
>> A agree. Also, he's talking about Spring, where annotations are used
>> for the configuration of a graph of objects and are necessarily tied
>> to the implementation (intended as method signatures in this case).
>>
>
> I found a nice post from Gavin King that explains why
> depending on interceptor implementation is not a good idea:
> http://relation.to/Bloggers/OnCDIInterceptorBindings
>
> I think you can easily apply this principle to constant method handle
> in annotations.
>
>
> But more to the point what is Chris actually asking for? Is it just to be
>>> able to use static method references with annotations?
>>>
>> I believe he's asking for non-static method references without a
>> receiver object, usable in annotations.
>>
>> Alessio
>>
>
> Rémi
>
>
More information about the lambda-dev
mailing list