Method references in annotations?

Rémi Forax forax at
Mon Aug 1 10:51:38 PDT 2011

On 08/01/2011 06:18 PM, Brian Goetz wrote:
> Annotation parameters need to be constants; from the perspective of the
> classfile, method references are not constant.  So this would not be as
> trivial as it sounds, but not impossible if it were a priority (which it
> is not currently.)

The major problem is that introducing a new constant as an annotation
requires to change the format of the corresponding attributes in the 
class file.
This format is not versioned so it will break a lot of tools with weird 


> On 8/1/2011 11:30 AM, Paul Benedict wrote:
>> Project Lambda is introducing method references. That's a feature I
>> desire because one of my gripes with JPA (or any annotations that
>> relate to properties) is the necessity to spell-out the property
>> names.
>> Example:
>> @OneToMany(cascade=ALL, mappedBy="customer")
>> Would something like this now be possible (provided the annotation was
>> refactored)?
>> @OneToMany(cascade=ALL, mappedBy=#SomeClass.getCustomer)
>> Paul

More information about the lambda-dev mailing list