type-annotations on lambda expressions, not sure what to expect
Werner Dietl
wdietl at gmail.com
Fri Jan 25 22:42:37 PST 2013
Hi Steve,
type annotations in and on lambda expressions were first specified in
the JSR 308 spec sent out by Mike on Wednesday.
I will try to implement that spec ASAP; I will have a better
understanding early next week.
cu, WMD.
On Fri, Jan 25, 2013 at 6:07 PM, Steve Sides <steve.sides at oracle.com> wrote:
> Hi,
> I'm looking at type-annotations on lambda expressions. This little sample
> below compiles, but there are no type-annotations in the class file, and I'm
> not really sure what to expect.
> Any answers yet?
>
> -steve
>
> import java.lang.annotation.*;
> import static java.lang.annotation.RetentionPolicy.*;
> import static java.lang.annotation.ElementType.*;
>
> public class test {
> // type-annotations do not appear in class files.
> IntOperation dubble = (@A Integer I) -> I * 2;
> PrintString PS = (@A String msg) -> System.out.println(msg);
> PrintString Debug = (@A String msg) -> { @A @A String dbg="DEBUG:";
> dbg=dbg.concat(msg);
> System.out.println(dbg); };
> }
> // SAM interfaces
> interface IntOperation { Integer operate(Integer i); }
> interface PrintString { void print(String s); }
> interface IntOperations { intOps getIntOps( ); }
>
> @Retention(RUNTIME)
> @Target({TYPE_USE})
> @Repeatable( AC.class)
> @interface A {}
>
> @Retention(RUNTIME)
> @Target({TYPE_USE})
> @interface AC { A[] value(); }
> }
>
>
>
>
--
http://www.google.com/profiles/wdietl
More information about the type-annotations-dev
mailing list