Are annotations on parameter types supported in lambda expressions?
Dieter Kleinrath
dieter.kleinrath at gmail.com
Tue Mar 18 10:50:30 UTC 2014
Hello Alex,
thank you very much for your explanation.
> You speak of "type parameters of lambda expressions" but lambda
> expressions are not generic so they cannot declare type parameters. As to
> the types of formal parameters of lambda expressions, it has been legal to
> annotate them for some time [1]. See JLS8 9.6.4.1, 9.7.4, and 4.11.
>
> [1] http://mail.openjdk.java.net/pipermail/type-annotations-
> spec-experts/2012-December/000044.html
>
>
Sorry, but I expressed myself incorrectly: of course I didn't mean the
annotations of "type parameters of lambda expressions" (as in generics),
instead I meant annotations of the type of a formal parameter.
But with the help of your answer I was indeed able to find the type
annotations on formal parameters of lambda expressions in the Runtime
VisibleTypeAnnotations attribute of the class file when compiling with
javac. It turned out I messed my own tests up a bit and the bug is only
relevant for the Eclipse compiler. The reason I'm not able to receive the
type annotation using reflection is certainly related to
https://bugs.openjdk.java.net/browse/JDK-8027181.
Thanks again,
Dieter
More information about the type-annotations-spec-comments
mailing list