Type Annotations and Lambda
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Feb 5 14:52:16 PST 2013
On 05/02/13 22:19, Werner Dietl wrote:
> Dear all,
>
> I implemented method and constructor reference type arguments
> (METHOD_REFERENCE_TYPE_ARGUMENT and
> CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT) in this changeset:
>
> http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/257b779bc4c7
>
> This resolves the crash noticed by Steve and implements correct
> bytecode storage.
> More extensive tests would be great. I no longer manage to crash the
> compiler with any type annotation uses in lambda.
>
> I am waiting on a specification clarification from Mike and/or Alex
> about METHOD_REFERENCE_RECEIVER and CONSTRUCTOR_REFERENCE_RECEIVER.
> To me these don't look like type uses, but instead only like scoping
> mechanisms, for which we don't support type annotations.
> It would be great to see a few examples of type uses for these and
> what the interpretation of type annotations should be.
There are several kinds of method references - the so-called unbound
kind has a type as a qualifier - i.e.
Person::getName
Constructor references also have a type as a qualifier:
ArrayList::new
I don't have specific ideas on what type annotations on such elements
would be - but perhaps, if an annotation is put i.e. on the type of a
qualifier of a method reference it could be used by a checker as a way
to 'filter' the set of valid types that can be used as a target for this
expression?
>
> Finally, the spec says that type annotations in the signature or body
> of a lambda expression should appear in the method that results from
> translation.
> I was hoping that this would work without any special effort. However,
> no type annotations appear in a translated method.
> Could somebody point me to the location in the code that translates a
> lambda expression into a method?
This is the place:
http://hg.openjdk.java.net/jdk8/jdk8/langtools/file/tip/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
>
> Thanks,
> cu, WMD.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130205/6871befc/attachment.html
More information about the type-annotations-dev
mailing list