Annotating lambda expressions
Ron Pressler
ron at paralleluniverse.co
Fri Jul 10 21:33:55 UTC 2015
Allowing annotations on lambda expressions but not on method references
seems very reasonable to me. Manual expansion of the method reference into
an expression is always possible.
Ron Pressler
paralleluniverse.co
@puniverseco <https://twitter.com/puniverseco> on Twitter
On Fri, Jul 10, 2015 at 12:31 PM, Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:
>
>
> On 10/07/15 09:43, Ron Pressler wrote:
>
>> (Related to
>> http://mail.openjdk.java.net/pipermail/compiler-dev/2015-January/009220.html)
>>
>>
>> It is useful to add an annotation to a lambda expression -- as in
>> foo(@Special () -> { ...}) -- which will be applied to the static method
>> implementing the lambda (not to the interface the lambda implements). This
>> would allow instrumentation tools operating on method implementations to
>> handle lambdas. So far, AFAICT, this is not possible (or am I wrong?).
>>
> This is not possible, currently - as Remi said; you have annotations on
> declarations (i.e. variable, classes, methods) - you have annotation on
> types (i.e. type of a cast, type argument, etc.) - but you don't have
> annotations on _expressions_.
> I take it that, under the current translation scheme, there seems to be a
> plausible description for what should happen when the lambda is annotated;
> but what if the lambda is turned into a method reference (by some IDE
> refactoring, or human intervention) ? In that case it is not guaranteed
> that there would still be a physical place where to put the annotation
> (unless we tell the compiler to 'expand' all annotated method references).
>
> So, while I don't question the genuine nature of the use case you put
> forward, I'm not seeing a 100% straightforward path to get there w/o adding
> non trivial complexity to both implementation and the spec.
>
> Maurizio
>
>>
>> Opinions?
>>
>> Ron
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150711/4ee82ec9/attachment.html>
More information about the compiler-dev
mailing list