type-annotations on lambda expressions, not sure what to expect
Steve Sides
steve.sides at oracle.com
Fri Jan 25 18:07:51 PST 2013
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(); }
}
More information about the type-annotations-dev
mailing list