Method references in annotations?

Brian Goetz brian.goetz at oracle.com
Mon Aug 1 09:18:48 PDT 2011


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.)



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