Are annotations on parameter types supported in lambda expressions?

Dieter Kleinrath dieter.kleinrath at gmail.com
Sat Mar 15 11:57:29 UTC 2014


Hello!

I'm not sure, if this is the right place to ask this question, or if it
would be better to ask the developers of JSR 335 (Project Lambda).

The JSR 308 Specification is not very specific about whether Type
Annotations should also be allowed on the type parameters of lambda
expressions or not. But if I read it correctly, I guess code like the
following should be ok (where MyTypeAnnotation is an Annotation
with ElementType#TYPE_USE):

Consumer<String> c = (@MyTypeAnnotation String p) -> System.out.println(p);

But the current JDK 8 (b132) javac compiler does not store the information
of parameter type annotations in the generated class files (the same is
true for the current Eclipse JDT compiler). I tested this by trying to get
the Annotation at runtime with Method#getAnnotatedParameterTypes() and by
reading the class file with the latest ASM build (that already supports
Type Annotations).

So I wanted to ask if you can confirm, that parameter Type Annotations
should/will be supported for lambda expressions? Also, do you think, that
this feature has not yet been implemented but is on the TODO list, or if
this should already be reported as a bug to the Lambda developers?

Thanks for your help,
Dieter

PS.: On a side note: parameter names of lambda expressions are currently
also not stored in the class files, if one compiles with javac
-parameters...


More information about the type-annotations-spec-comments mailing list